[HarfBuzz] Inter-glyph spacing

Khaled Hosny khaledhosny at eglug.org
Sat Sep 13 03:34:53 PDT 2014


On Sat, Sep 13, 2014 at 02:22:24PM +0700, Martin Hosken wrote:
> Dear Simon,
> 
> >        if (FT_Set_Char_Size(uds->ft_face,f->pointSize * 64.0, 0, 0, 0))
> >          return 0;
> > 
> 
> > 	What also confuses me is that the result is very font-specific. SIL fonts are 
> > squashed. Times and Optima render perfectly: Pango and Harfbuzz equivalent. 
> > Adobe Garamond Pro and Caslon Pro are horrible, with some very strange 
> > inter-glyph spacing; in particular there is too much space after every letter 
> > "a", and too little after an "s".
> 
> I think I have what the problem is. I'm not sure what the best solution is.
> 
> The SIL fonts have horizontal device metrics, and you are basically getting back hinted positioning, due to it thinking you are working on a 1dpi screen or somesuch. This gives you hinted positioning that looks really funny in a pdf.
> 
> The key code inside hb-ft.cc is:
> 
>   hb_font_set_scale (font,
>                      (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16),
>                      (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16));
> 
> since it is the scale that is passed to graphite make_font as the ppem value. Off the top of my head, I'm not sure how you could set an appropriate metrics.x_scale to get the rendering you want at an appropriate ppem that gets scaled back to points for you.
> 
> I'm wondering if using the font scale rather than the font ppem is the right answer in the graphite integration code. Anyone got any thoughts?

I don't use the hb-ft in XeTeX but my own FreeType font functions so
that I can load the glyphs with FT_LOAD_NO_SCALE to avoid hinting, then
I call:

  hb_font_set_scale(m_hbFont, m_unitsPerEM, m_unitsPerEM);
  hb_font_set_ppem(m_hbFont, 0, 0);

to do away with no device adjustments since neither hinting nor device
correction make any sense at PDF generation time (IMO).

Regards,
Khaled


More information about the HarfBuzz mailing list