[cairo] Drawing text with different glyph widths

Baz brian.ewins at gmail.com
Tue Sep 11 18:55:23 PDT 2007


On 12/09/2007, Jeff Muizelaar <jeff at infidigm.net> wrote:
> PDF documents often do not embed fonts, however they do include the
> glyph widths for the missing fonts. Currently, the poppler cairo backend
> ignores these widths and draws the text with the glyph widths of the
> substituted font. This often causes some very ugly rendering:
> https://bugs.freedesktop.org/show_bug.cgi?id=12304
> https://bugs.freedesktop.org/show_bug.cgi?id=11864
>
> To fix these we need to draw using the glyph widths specified in the pdf
> file. Does anyone have any suggestions for how to achieve this with
> cairo?

Tricky. I looked to see if there was any way on the mac side you could
get something like a multiple master font fallback (where each glyph
is adjusted individually) and it's just not there. At a guess, there
isn't high level api for this in the other systems either. So the
solution would have to be something at a per-face level, like
adjusting the font matrix.

Do you have the equivalent of 'cairo_font_extents_t' in the embedded
metrics? That would be enough info to perform a quick & dirty
adjustment to the height & width of the substitute font, via the
font-matrix. If you only have per-glyph measurements, cairo can give
you the equivalent measurements for the substitute font, and you can
get the font matrix by taking the average scaling for all glyphs, or
just pick a sample.

Hope this helps,
Baz


More information about the cairo mailing list