[cairo] cairo-created PDFs are too large

Ian Britten britten at caris.com
Thu Dec 4 05:41:04 PST 2008

Adrian Johnson wrote:

>> As such, I'm "creating a new font face" for each glyph to be drawn.
>> However, I'm always creating a Cairo face from a FT_Face, and the
>> actual FT_Face is cached/shared amongst all the Cairo faces that
>> use it.  As such, the number of unique FT_Faces used is relatively
>> low, compared to the number of Cairo faces I 'create' (ie: Allocate).

> Each time you create and use a font face with
> cairo_ft_font_face_create_for_ft_face() you will get a new font embedded 
> in the PDF.

Hmmm...  I've been looking closer at this, and I think I need some
- I already cache each unique FT_Face, and reuse that unique instance
   when constructing each Cairo font face.
- I construct/set/delete a Cairo font face for each glyph I render,
   using that FT_Face.
- I'm using cairomm, in case that makes a difference:
        Cairo::FtFontFace::create(ftFace, load_flags);
- Also note that each FT_Face may be either a stock TT face, or a
   custom (stroke, user) face, since I've written my own FT_Driver
   (Again, just in case that's relevant).
- I'm using cairo v1.8.4 and cairomm v1.7.0

Now, I'm seeing a difference between stock (TT) fonts, and my user
- If I render text using TT fonts, I seem to automatically only get
   the unique faces written to my PDF (As reported by evince), with
   no additional caching on my part.  This seems to contradict what
   you wrote.
- If I render text using my User fonts, I get one face written to
   my PDF for each glyph, seemingly to agree with what you wrote

This observation seem to seems to imply a qualification to your
statement:  Namely, I'll only get redundant fonts embedded if
they're user fonts.  This suggest to me that I only need to look
at caching my user fonts, and not necessarily the regular TT fonts.


More information about the cairo mailing list