GNU bug report logs - #29078
25.2; font issue with FreeType 2.8; should not use the rounded ascender and descender

Previous Next

Package: emacs;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Tue, 31 Oct 2017 10:14:01 UTC

Severity: normal

Found in version 25.2

Full log


Message #8 received at 29078 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Vincent Lefevre <vincent <at> vinc17.net>
Cc: 29078 <at> debbugs.gnu.org
Subject: Re: bug#29078: 25.2; font issue with FreeType 2.8;
 should not use the rounded ascender and descender
Date: Tue, 31 Oct 2017 11:53:20 +0100
Vincent Lefevre <vincent <at> vinc17.net> writes:

> For TrueType fonts, FreeType 2.8 uses different rounding rules for
> values in the FT_Size_Metrics structure, which is apparently used
> by Emacs (since there are visible changes). In particular, one can
> now have ascender + descender > height. The consequences are:
>
> 1. Tables look a bit ugly.
>
> 2. Windows (with the same number of text lines) are unnecessarily
>    higher than before.
>
> 3. This can break existing configurations, where Emacs would be
>    opened at start up, with an expected window size.
>
> I could notice changes at least with the default Mono font, which
> appears to be DejaVu Sans Mono.
>
> Upstream now recommends to use the values from the FT_Face structure
> and scale them manually:
>

I don't have FreeType2.8 to test, but you're saying we need to do this?

diff --git a/src/ftfont.c b/src/ftfont.c
index 35f5923376..d16bf09a1e 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1153,18 +1153,9 @@ ftfont_open2 (struct frame *f,
   upEM = ft_face->units_per_EM;
   scalable = (INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX))
 	      && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0);
-  if (scalable)
-    {
-      font->ascent = ft_face->ascender * size / upEM + 0.5;
-      font->descent = - ft_face->descender * size / upEM + 0.5;
-      font->height = ft_face->height * size / upEM + 0.5;
-    }
-  else
-    {
-      font->ascent = ft_face->size->metrics.ascender >> 6;
-      font->descent = - ft_face->size->metrics.descender >> 6;
-      font->height = ft_face->size->metrics.height >> 6;
-    }
+  font->ascent = ft_face->ascender * size / upEM + 0.5;
+  font->descent = - ft_face->descender * size / upEM + 0.5;
+  font->height = ft_face->height * size / upEM + 0.5;
   if (INTEGERP (AREF (entity, FONT_SPACING_INDEX)))
     spacing = XINT (AREF (entity, FONT_SPACING_INDEX));
   else




This bug report was last modified 5 years and 269 days ago.

Previous Next


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