[cairo] 1 user font or 2?

Ian Britten britten at caris.com
Thu Dec 4 10:10:21 PST 2008


Hi all,
Me again, with another text question...  (A spin-off of trying to
eliminate duplicate user fonts embedded in a PDF)

As most of you are probably getting tired of hearing by now, ;)
I've got a custom FT_Face for handling our legacy stroke fonts.
I'm wrapping these with Cairo user-fonts, so they're drawn and
emitted correctly.

Now, for the tricky bit:
Two pieces of text may draw using the same (FT) face, but with
different thicknesses.  With these fonts, the thickness is not
part of the face definition, but is a dynamic attribute of the
text using the face (Sortof the way the font size is).
[ There's actually more attributes, like cap, etc, but lets keep
the discussion simple... ]

Now, on one hand, it could be argued that because they have
different thicknesses, I should treat them as separate, and cache
a separate user font instance for each one, based on the unique
combination of FT_Face + attributes.

On the other hand, they are using the same FT_Face, which could
possibly suggest they're the same, and that maybe I only need
to cache a single user font?  (However, I guess I'd still need
separate user-data for the different attributes, but I can
probably manage that)

I'm leaning towards the second approach, mostly because I'd be
able to search/populate my cache based on a single item (the face),
rather than accounting for all the attributes too.  However, I'm
not sure what the backends would think (Mostly PDF.  Images
probably don't care one way or the other)

I guess maybe stated more simply - Can a single user-font draw
itself differently/dynamically in it's 'render' function (Keeping
in mind the face/path is the same)?  Or does 'different draw'
mean 'different user font instance' ?

Many thanks for any insight/info!
Ian


More information about the cairo mailing list