[cairo] UserFontFace vs FtFontFace management (cairomm)

Behdad Esfahbod behdad at behdad.org
Thu Dec 4 08:38:06 PST 2008


Ian Britten wrote:

> Nor do I, especially not knowing all the C<->C++ separation issues
> you need to maintain between cairo<->cairomm...

> Anything I would come up with would lean towards trying to store the
> actual C++ object in the user-data part of the C object, but I'm
> assuming you've been down that road...

Yes, that's how it's supposed to be done.

> I also assume there's a reason that the C++ Context doesn't simply
> maintain a reference to the faces that are set on it...

Because that would be redundant and the font face on the context can be
changed from other languages.


> As a general note (Not directed at anyone in particular), I'm finding
> that the further I get into the text handling in Cairo, the more and
> more I have to cache myself, adding to my overall complexity.
> - I have to cache+share the FT_Face objects that I'm using to make
>    the Cairo faces.
> - It seems I'll have to cache+share the Cairo faces too (To prevent
>    needless duplicate fonts in my PDF output).
> - I've had to cache my UserFont objects, to address this issue.
> - I also have to cache my custom user-data structures, containing
>    the attributes needed to render my UserFonts (One per font).
> In the end, it seems to be working, but it just feels ... clunky :(
> Please don't take this as negative criticism - I'm probably doing
> more advanced text rendering than most Cairo users, and I'm only
> mentioning it to provide 'food for thought' for any future
> changes/improvements that may be planned.

I don't want to be defensive, but I think some of this is expected, some
there's really nothing to do about (You *have* to cache your user font.
There's no way for cairo to ever know if two different user fonts are the
same.) and some is imposed by the way you have designed/organized your system.
 Pango has to do, I'm sure, more complex text stuff, and while we do lots of
caching, everything is for reason and flows nicely together.

I think the cairo API right now is at a good level between convenience and
getting out of the way.  If there's been issues, it mostly has been that the
caching in cairo has been troublesome, not the other way around.

behdad

> As always, keep up the great work!
> Ian



More information about the cairo mailing list