Add support for color user fonts
This fixes #389 (closed).
Poppler users cairo's user font functionality to render type3 fonts in PDFs. When those contain color, they come out black.
For that, I added a new API call cairo_user_font_face_set_color
which should be called after cairo_user_font_face_create
.
It causes glyphs to set a color surface, like is done in the freetype code.
I tested this with Poppler's pdftocairo
and this PDF file.
A few things to note:
- I think it's unavoidable to add a new function call, but not sure I picked the best approach. Should it be a font_option call instead? Should there be a
get_color
? - The new code path is only accessible after calling the new API call, so I don't think it will break any existing code.
- New glyphs set both a "surface" and a "color surface", even though only the color surface is used. This is the way it's implemented in the freetype code (search for "kludge"). I think it can be avoided by modifying
ensure_scaled_glyph
to look for a color surface if a regular surface isn't found, but I haven't tried it.