From: Werner LEMBERG <wl@gnu.org>
To: rpluim@gmail.com
Cc: vincent@vinc17.net, 29078@debbugs.gnu.org
Subject: bug#29078: 25.2; font issue with FreeType 2.8; should not use the rounded ascender and descender
Date: Tue, 31 Oct 2017 12:22:14 +0100 (CET) [thread overview]
Message-ID: <20171031.122214.1272044855799157335.wl@gnu.org> (raw)
In-Reply-To: <874lqfmvvj.fsf@gmail.com>
>> 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
No. The `scalable' branch must make a distinction between TrueType
and non-TrueType fonts if the font gets fully hinted (i.e., if the
TrueType bytecode gets interpreted), something like
if (scalable)
{
if (use_truetype_bytecode_hinting(font))
{
/* use TrueType rules for rounding */
font->ascent = ROUND(ft_face->ascender * size / upEM)
font->descent = ROUND(-ft_face->descender * size / upEM);
font->height = font->ascent + font->descent;
}
else
{
font->ascent = CEIL(ft_face->ascender * size / upEM);
font->descent = FLOOR(-ft_face->descender * size / upEM);
font->height = ROUND(ft_face->height * size / upEM);
}
}
...
Werner
next prev parent reply other threads:[~2017-10-31 11:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 10:12 bug#29078: 25.2; font issue with FreeType 2.8; should not use the rounded ascender and descender Vincent Lefevre
2017-10-31 10:53 ` Robert Pluim
2017-10-31 11:22 ` Werner LEMBERG [this message]
2017-10-31 13:43 ` Vincent Lefevre
2017-10-31 15:45 ` Werner LEMBERG
2017-10-31 14:00 ` Robert Pluim
2017-10-31 16:24 ` Werner LEMBERG
2019-11-17 8:02 ` Lars Ingebrigtsen
2019-11-18 7:47 ` Vincent Lefevre
2019-11-18 8:30 ` Lars Ingebrigtsen
2019-11-18 16:05 ` Eli Zaretskii
2019-11-19 10:07 ` Robert Pluim
2019-11-19 11:34 ` Vincent Lefevre
2019-11-19 16:41 ` Stefan Kangas
2019-11-19 17:33 ` Eli Zaretskii
2019-11-18 15:36 ` Eli Zaretskii
2019-11-18 16:04 ` Vincent Lefevre
2019-11-18 17:09 ` Eli Zaretskii
2019-11-18 17:23 ` Vincent Lefevre
2019-11-18 17:50 ` Eli Zaretskii
2019-11-18 17:58 ` Eli Zaretskii
2019-11-18 18:20 ` Vincent Lefevre
2019-11-18 18:31 ` Eli Zaretskii
2019-11-18 18:15 ` Vincent Lefevre
2019-11-18 18:32 ` Lars Ingebrigtsen
2019-11-18 20:26 ` Vincent Lefevre
2019-11-18 20:31 ` Lars Ingebrigtsen
2019-11-19 15:55 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171031.122214.1272044855799157335.wl@gnu.org \
--to=wl@gnu.org \
--cc=29078@debbugs.gnu.org \
--cc=rpluim@gmail.com \
--cc=vincent@vinc17.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.