unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Werner LEMBERG <wl@gnu.org>
Cc: clement.pitclaudel@live.com, ohwoeowho@gmail.com, 20628@debbugs.gnu.org
Subject: bug#20628: 25.0.50; Incorrect line height for some fonts
Date: Wed, 03 Jun 2015 17:53:18 +0300	[thread overview]
Message-ID: <83y4k0rggx.fsf@gnu.org> (raw)
In-Reply-To: <20150603.114417.268457608.wl@gnu.org>

> 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 <wl@gnu.org>
> 
> > 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.





  reply	other threads:[~2015-06-03 14:53 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22  3:02 bug#20628: 25.0.50; Incorrect line height for some fonts Clément Pit--Claudel
2015-05-22  7:32 ` Eli Zaretskii
2015-05-22 10:11   ` Oleh Krehel
2015-05-22 12:26     ` Eli Zaretskii
2015-05-22 12:49       ` Oleh Krehel
2015-05-22 13:13         ` Eli Zaretskii
2015-05-22 13:18         ` Eli Zaretskii
2015-05-22 13:03       ` Eli Zaretskii
2015-05-22 13:15         ` Oleh Krehel
2015-05-22 13:55           ` Eli Zaretskii
2015-05-22 13:54             ` Oleh Krehel
2015-05-22 14:07               ` Eli Zaretskii
2015-05-22 14:20                 ` Oleh Krehel
2015-05-22 14:49                   ` Eli Zaretskii
2015-05-22 15:03                     ` Oleh Krehel
2015-05-22 15:39                       ` Eli Zaretskii
2015-05-22 16:05                         ` Oleh Krehel
2015-05-22 16:14                           ` Eli Zaretskii
2015-05-22 16:15                             ` Oleh Krehel
2015-05-22 16:32                               ` Eli Zaretskii
2015-05-22 16:33                                 ` Oleh Krehel
2015-05-22 16:54                                   ` Oleh Krehel
2015-05-22 17:15                                     ` Andreas Schwab
2015-05-22 17:40                                       ` Oleh Krehel
2015-05-22 18:18                                     ` Eli Zaretskii
2015-05-22 18:18                                       ` Oleh Krehel
2015-05-22 18:43                                         ` Eli Zaretskii
2015-05-22 18:53                                           ` Oleh Krehel
2015-05-22 19:05                                             ` Clément Pit--Claudel
2015-05-22 19:27                                             ` Eli Zaretskii
2015-05-22 19:09                                           ` Clément Pit--Claudel
2015-05-22 19:37                                             ` Eli Zaretskii
2015-05-22 20:08                                       ` Oleh Krehel
2015-05-22 22:43                                         ` Stefan Monnier
2015-05-22 23:55                                           ` Clément Pit--Claudel
2015-05-23  7:24                                             ` Eli Zaretskii
2015-05-24  8:20                                               ` Clément Pit--Claudel
2015-05-24  9:36                                                 ` Eli Zaretskii
2015-05-23  7:20                                           ` Eli Zaretskii
2015-05-23 13:27                                             ` Stefan Monnier
2015-05-23 13:54                                               ` Eli Zaretskii
2015-05-23  7:10                                         ` Eli Zaretskii
2015-05-23  7:47                                           ` YAMAMOTO Mitsuharu
2015-05-23  8:26                                             ` Eli Zaretskii
2015-05-23  9:56                                               ` Oleh Krehel
2015-05-23 10:21                                                 ` Eli Zaretskii
2015-05-23 10:56                                                   ` Oleh Krehel
2015-05-25 10:32                                             ` Rasmus
2015-05-25 13:24                                               ` Drew Adams
2015-05-25 14:39                                                 ` Eli Zaretskii
2015-05-22 18:15                                   ` Eli Zaretskii
2015-05-22 18:57                                     ` Clément Pit--Claudel
2015-05-22 19:15                                       ` Eli Zaretskii
2015-05-22 21:49                                         ` Werner LEMBERG
2015-05-23  6:52                                           ` Eli Zaretskii
2015-05-23  9:50                                             ` Werner LEMBERG
2015-05-23  9:57                                               ` Werner LEMBERG
2015-05-23 10:31                                               ` Eli Zaretskii
2015-05-23 11:45                                                 ` Werner LEMBERG
2015-05-24  8:20                                           ` Clément Pit--Claudel
2015-05-24  9:29                                             ` Eli Zaretskii
2015-05-24  9:32                                               ` Werner LEMBERG
2015-05-24  9:48                                                 ` Eli Zaretskii
2015-05-24 10:06                                                   ` Eli Zaretskii
2015-05-24 10:29                                                     ` Eli Zaretskii
2015-05-27 15:20                                                     ` Eli Zaretskii
2015-05-29  8:20                                                       ` Eli Zaretskii
2015-05-29  8:35                                                         ` Clément Pit--Claudel
2015-05-29  9:30                                                           ` Oleh Krehel
2015-05-29 10:23                                                             ` Eli Zaretskii
2015-05-29 10:38                                                               ` Oleh Krehel
2015-05-29 14:49                                                                 ` Stefan Monnier
2015-05-29 14:49                                                                   ` Oleh Krehel
2015-05-29 18:17                                                                     ` Eli Zaretskii
2015-05-29 13:15                                                             ` Eli Zaretskii
2015-05-29 13:16                                                               ` Oleh Krehel
2015-05-29 18:18                                                                 ` Eli Zaretskii
2015-05-30  9:40                                                                 ` Eli Zaretskii
2015-05-30  5:21                                                               ` Clément Pit--Claudel
2015-05-30  9:42                                                                 ` Eli Zaretskii
2015-05-30 13:00                                                                   ` Oleh Krehel
2015-05-30 14:20                                                                     ` Eli Zaretskii
2015-05-30 14:32                                                                       ` Oleh Krehel
2015-05-30 16:28                                                                         ` Eli Zaretskii
2015-05-30 16:59                                                                           ` Oleh Krehel
2015-05-30 18:35                                                                             ` Eli Zaretskii
2015-05-30 18:57                                                                               ` Oleh Krehel
2015-05-30 19:23                                                                                 ` Eli Zaretskii
2015-05-30 19:26                                                                                   ` Oleh Krehel
2015-05-30 19:52                                                                                     ` Eli Zaretskii
2015-05-31 14:48                                                                                       ` Eli Zaretskii
2015-06-01 10:54                                                                                         ` Oleh Krehel
2015-06-01 14:49                                                                                           ` Eli Zaretskii
2015-06-06 13:14                                                                                             ` Eli Zaretskii
2015-05-30 18:58                                                                   ` Clément Pit--Claudel
2015-05-30 19:25                                                                     ` Eli Zaretskii
2015-06-03  9:44                                                     ` Werner LEMBERG
2015-06-03 14:53                                                       ` Eli Zaretskii [this message]
2015-05-22 19:03                                     ` Clément Pit--Claudel
2015-05-22 19:35                                       ` Eli Zaretskii
2015-05-22 20:25                                         ` Clément Pit--Claudel
2015-05-23  7:12                                           ` Eli Zaretskii
2015-05-24  8:20                                             ` Clément Pit--Claudel
2015-05-24  9:31                                               ` Eli Zaretskii
2015-05-23  8:19                                           ` Eli Zaretskii
2015-05-22 15:41                       ` Andreas Schwab
2015-05-22 15:05                     ` Eli Zaretskii
2015-05-22 15:27                     ` Stefan Monnier
2015-05-22 15:42                       ` Eli Zaretskii
2015-05-22 13:21         ` Andreas Schwab
2015-05-24  8:20   ` Clément Pit--Claudel
2015-05-24  9:32     ` Eli Zaretskii
2015-05-22 15:16 ` Rasmus
     [not found] <<555E9C2E.8040008@live.com>
     [not found] ` <<83wq004x2w.fsf@gnu.org>
     [not found]   ` <<83twv44vd3.fsf@gnu.org>
     [not found]     ` <<87egm87ny6.fsf@gmail.com>
     [not found]       ` <<83oalc4syu.fsf@gnu.org>
     [not found]         ` <<87617k7m5u.fsf@gmail.com>
     [not found]           ` <<83mw0w4seb.fsf@gnu.org>
     [not found]             ` <<87zj4w66ds.fsf@gmail.com>
     [not found]               ` <<83lhgg4qhf.fsf@gnu.org>
     [not found]                 ` <<87iobk64e6.fsf@gmail.com>
     [not found]                   ` <<83h9r44o63.fsf@gnu.org>
     [not found]                     ` <<87pp5sy4vu.fsf@gmail.com>
     [not found]                       ` <<83egm84mj3.fsf@gnu.org>
     [not found]                         ` <<87617k6127.fsf@gmail.com>
     [not found]                           ` <<83d21s4lpx.fsf@gnu.org>
     [not found]                             ` <<87twv44lnc.fsf@gmail.com>
     [not found]                               ` <<87egm84kp2.fsf@gmail.com>
     [not found]                                 ` <<83a8ww4grx.fsf@gnu.org>
     [not found]                                   ` <<87382oml31.fsf@gmail.com>
     [not found]                                     ` <<83k2vz3h2p.fsf@gnu.org>
     [not found]                                       ` <<wlpp5rivkj.wl%mituharu@math.s.chiba-u.ac.jp>
     [not found]                                         ` <<87oal954mc.fsf@gmx.us>
     [not found]                                           ` <<b054a996-dd2e-4436-80f2-93cc5b2d1cb9@default>
     [not found]                                             ` <<83oal8zpp8.fsf@gnu.org>
2015-05-25 15:39                                               ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83y4k0rggx.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=20628@debbugs.gnu.org \
    --cc=clement.pitclaudel@live.com \
    --cc=ohwoeowho@gmail.com \
    --cc=wl@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).