GNU bug report logs - #21835
25.0.50; cursor height wrong when line-spacing is used

Previous Next

Package: emacs;

Reported by: David Reitter <david.reitter <at> gmail.com>

Date: Thu, 5 Nov 2015 04:22:01 UTC

Severity: minor

Found in version 25.0.50

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 21835 <at> debbugs.gnu.org
Subject: bug#21835: 25.0.50; cursor height wrong when line-spacing is used
Date: Thu, 05 Nov 2015 18:12:21 +0200
> From: David Reitter <david.reitter <at> gmail.com>
> Date: Wed, 4 Nov 2015 23:21:13 -0500
> 
> Start Emacs 25 (master branch)  (with -Q if you like)
> 
> (setq line-spacing 1.0)
> 
> (Note how the display doesn’t update, so enter C-l to force it)

It does update for me if I evaluate that with C-j at the right
parenthesis.  How did you evaluate it?

> Result: cursor is displayed with wrong (large, two-line) height when at the end of a line, and correctly when not at the end of a line.

Strange as it might sound, this is not a bug, but intended behavior.
It is a consequence of improvements in display code that avoid
extremely large lines with some fonts (in particular, math fonts) that
declare preposterously large font sizes.  Previously, the line height,
and the height of the cursor at EOL, was determined by the font-global
ascent/descent values.  We now determine the height of the line by
looking at the glyphs we actually display on that line.  See bug#20628
for more details.

The problem with displaying the cursor at the end of the line is that
there's no displayable glyph there, whose dimensions in the font we
could use to determine the cursor height.  So we set the cursor height
to the line height.

> This wasn’t the case in Emacs 24.

Yes, the changes to use the glyph metrics are new in Emacs 25.

> Also note bug#17977

That's unrelated to this issue, AFAICS.  That bug is NS specific,
whereas what you describe happens on all supported GUI frames.

> In any case, the cursor’s height should not change.

When you say "should not change", what do you have in mind?  Should
not change from what value?  If you think that the value of the cursor
height is fixed when it is displayed on other characters of the line,
then this is not so, unfortunately.

Please keep in mind that characters on a line can have different
dimensions, even if they come from the same font, let alone if they
come from different fonts (which happens quite a lot in Emacs, given
today's abundance of rare characters in plain text).  When the cursor
is displayed on a character, it gets its dimensions from that
character (you can see the effect of that if you display a line where
some characters come from a larger font).  But that doesn't work when
the cursor is at the end of a line, where there's no character to
begin with.  So we use the line's height instead.  I agree that the
result looks somewhat ugly, especially when the value of line-spacing
is large.  Suggestions for better defaults are welcome; at the time, I
tried several other ideas, but they all had worse problems.

> If it has to be this high the actual text line should be vertically
> centered.

We cannot do that without changing how line-spacing is applied.  Since
Emacs 21.1, when this feature was added, we always added the spacing
_below_ each line.  The ELisp manual documents this:

     You can specify the line spacing for all lines in a buffer via the
  buffer-local ‘line-spacing’ variable.  An integer specifies the number
  of pixels put below lines.  A floating-point number specifies the
  spacing relative to the default frame line height.

and elsewhere:

  ‘line-spacing’
       Additional space to leave below each text line, in pixels (a
       positive integer).

(Note the "below" parts in both excerpts.)

I personally never use these features, so I don't object to changing
the effect of line-spacing to have it distributes between the ascent
and descent parts somehow.  Not sure what others will say.  In any
case, doing this will require non-trivial changes to display code.

Thanks.




This bug report was last modified 9 years and 90 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.