From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#20628: 25.0.50; Incorrect line height for some fonts Date: Wed, 03 Jun 2015 17:53:18 +0300 Message-ID: <83y4k0rggx.fsf@gnu.org> References: <20150524.113203.250674550.wl@gnu.org> <83617i1f29.fsf@gnu.org> <834mn21e7y.fsf@gnu.org> <20150603.114417.268457608.wl@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1433343275 9685 80.91.229.3 (3 Jun 2015 14:54:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Jun 2015 14:54:35 +0000 (UTC) Cc: clement.pitclaudel@live.com, ohwoeowho@gmail.com, 20628@debbugs.gnu.org To: Werner LEMBERG Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 03 16:54:24 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z0A3V-0008U3-QA for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Jun 2015 16:54:10 +0200 Original-Received: from localhost ([::1]:36052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0A3V-0005sx-A6 for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Jun 2015 10:54:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0A3S-0005si-3X for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2015 10:54:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0A3O-0008L8-Ry for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2015 10:54:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0A3O-0008Ks-Nw for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2015 10:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z0A3O-0003It-4D for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2015 10:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Jun 2015 14:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20628 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20628-submit@debbugs.gnu.org id=B20628.143334321712663 (code B ref 20628); Wed, 03 Jun 2015 14:54:02 +0000 Original-Received: (at 20628) by debbugs.gnu.org; 3 Jun 2015 14:53:37 +0000 Original-Received: from localhost ([127.0.0.1]:39149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0A2y-0003IA-Dc for submit@debbugs.gnu.org; Wed, 03 Jun 2015 10:53:36 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:51724) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0A2v-0003Hw-Rl for 20628@debbugs.gnu.org; Wed, 03 Jun 2015 10:53:34 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NPD00900IKFXY00@a-mtaout22.012.net.il> for 20628@debbugs.gnu.org; Wed, 03 Jun 2015 17:53:27 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NPD00959IP2JRB0@a-mtaout22.012.net.il>; Wed, 03 Jun 2015 17:53:27 +0300 (IDT) In-reply-to: <20150603.114417.268457608.wl@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103539 Archived-At: > Date: Wed, 03 Jun 2015 11:44:17 +0200 (CEST) > Cc: clement.pitclaudel@live.com, ohwoeowho@gmail.com, 20628@debbugs.gnu.org > From: Werner LEMBERG > > > The relevant place in the display engine where these factors are > > taken into consideration is around line 26388 in xdisp.c, [...] > > I'm completely lost in this huuuge file. Which is why I mentioned the line number explicitly... > > The change we look for should: > > > > . set the initial values for it->ascent and it->descent using some > > heuristics based on pixel_size of the default face's font; > > Where are the initial values set? They are not set anywhere in the original display engine, because it was not needed. The values were set to the ascent and descent of each produced glyph in x_produce_glyphs and its subroutines. For character glyphs, these were taken from the font-global values, since the assumption was that those global values are reasonable. But I was somewhat wrong in the above description: the important values are not it->ascent and it->descent, but rather it->max_ascent and it->max_descent. These accumulate the maximum values seen while producing a single screen line, and when the screen line ends, they determine the line's height (see compute_line_metrics): row->height = it->max_ascent + it->max_descent; > > . update it->ascent and it->descent based on ascent/descent values > > returned by get_per_char_metric in the per-character metrics > > data > I think this already happens, right? At least the line height > increases on my GNU/Linux version of Emacs if I use a font with larger > ascent/descent values... So no additional action is needed for this, > it seems. Actually, since I wrote the message to which you respond, I think I already solved the problem, you can see the solution in the scratch/large-fonts branch of the Emacs Git repository. If you have time, I'd appreciate your opinion about the heuristics I use there. Specifically, the following macro is used to detect fonts that claim preposterously large ascent/descent values: #define FONT_TOO_HIGH(ft) ((ft)->ascent + (ft)->descent > 3*(ft)->pixel_size) The pixel_size member of the struct font object is the pixel size with which we opened the font, see the 'open' method of the font drivers (e.g., 'xftfont_open' in xftfont.c). The number 3 above is the heuristics. The other part of the heuristics is in how I compute "reasonable" values of ascent and descent to be used instead of font's global values. The code is in the function 'normal_char_ascent_descent' defined in xdisp.c. This is necessary because, as I expected, the font's global values are used all over the place in display-related code, and so just computing line height from character metrics was not enough to countermand all the negative effects of such preposterously large font height values. As just 2 examples, the font height was used to allocate pixel screen estate for the mode line, and for calculating line height when a 'display' property or a line-height property specifies height as a fraction of the "normal" text height. Thanks.