Subject: Re: bug#29078: 25.2; font issue with FreeType 2.8; should not use the rounded ascender and descender

From: Werner LEMBERG <[email-masked]>
Date: Tue, 31 Oct 2017 17:24:23 +0100 (CET)

>>   if (scalable)
>>     {
>>       if (use_truetype_bytecode_hinting(font))
> 
> Hmm, ok. Then it becomes a question of determining how to define
> 'use_truetype_bytecode_hinting', which is not immediately obvious to
> me.

FreeType decides at glyph loading time (i.e., while calling
`FT_Load_Glyph' and its siblings) whether native bytecode hinting gets
used.[*]

Or to say it differently: It's up to Emacs which hinting mode gets
used.  Currently, Emacs uses the FT_LOAD_DEFAULT flag almost
everywhere; this flag implies native TrueType hinting first.  Only if
the TTF doesn't contain bytecode FreeType tries auto-hinting.  So
maybe a simpler alternative is just to test whether we have a TrueType
font:

  if (scalable)
    {
      if (!strcmp(FT_Get_X11_Font_Format(ft_face), "TrueType")
          && !(ft_load_glyph_mode & FT_LOAD_NO_HINTING)
          && !(ft_load_glyph_mode & FT_LOAD_FORCE_AUTOHINT))

Note that this is true for direct FreeType access.  I don't know how
Emacs interacts with GTK, Pango, Cairo, whatever, behaves.  I also
wonder whether Emacs obeys fontconfig settings, which are normally
used to globally set the hinting mode on a GNU/Linux box...

    Werner

[*] I meanwhile consider this late selection of the hinting mode a
    design error in FreeType, which I can't change due to backward
    compatibility.