[cairo] Possible bug in font hinting metrics?

Behdad Esfahbod behdad at behdad.org
Fri Sep 7 13:50:19 PDT 2007


On Fri, 2007-09-07 at 12:03 -0400, George Wright wrote:
> Hello,
> 
> Can someone explain to me how font hinting is supposed to work?
> 
> We are rendering text on a cairo context which can be scaled by the user. If 
> the scale factor of the context is 1.0 then the text renders fine. However, 
> if hinting is enabled and the context is scaled, then the text has awkward 
> gaps between the letters. We are getting the glyph extents through 
> cairo_scaled_font_glyph_extents and rendering a buffer of glyphs using 
> calculations based on those reported glyph extents.

Are you using the scaled font with the scale included in the CTM?  You
should.

behdad

> From the cairo API documentation at 
> http://www.cairographics.org/manual/cairo-Scaled-Fonts.html#cairo-text-extents-t 
> it says:
> 
> "If you call cairo_scale(cr, 2.0, 2.0), text will be drawn twice as big, but 
> the reported text extents will not be doubled. They will change slightly due 
> to hinting (so you can't assume that metrics are independent of the 
> transformation matrix), but otherwise will remain unchanged."
> 
> We are obviously not getting the hinted extents.
> 
> To see what I mean I've made a screenshot at 
> http://vm.gwright.org.uk/cairo_text.png - in particular, I mean things like 
> the unnaturally large gap between 'w' and 'e' in "the web".
> 
> Is there a way of getting the true (hinted) extents or is this a bug in cairo?
> 
> Regards,
> 
> George
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list