[cairo] Don't Use CAIRO_FT_SYNTHESIZE_OBLIQUE!

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Tue Mar 15 00:50:02 UTC 2016


Cairo has options to synthesize bold and oblique versions of a font
with cairo_ft_font_face_set_synthesize(). CAIRO_FT_SYNTHESIZE_BOLD
seems to work reasonably well, but CAIRO_FT_SYNTHESIZE_OBLIQUE does
not. The text metrics (specifically the text width) returned for the
synthetic font do not take the obliquing into account, and you will
even get clipping of glyphs with certain fonts, when combined with
CAIRO_FT_SYNTHESIZE_BOLD.

The workaround is simple: apply your own font skew matrix with skew_x =
-0.213, skew_y = 0. This is equivalent to what FreeType does to
synthesize the obliquing in the first place, except that Cairo works
properly, returning the right metrics and avoiding the strange clipping.

By the way, the description in include/ftsynth.h in the FreeType source
makes it clear that its synthetic emboldening and obliquing functions
are not considered of good enough quality for the public API, they are
supposed to be used only as example code. Yet Cairo has gone ahead and
made use of them in its public API...


More information about the cairo mailing list