[cairo] UserFontFace vs FtFontFace management (cairomm)
Ian Britten
britten at caris.com
Thu Dec 4 05:09:47 PST 2008
Jonathon Jongsma wrote:
> So, I think that we can redesign the UserFontFace interface to let you
> do this without *too* much ugliness, but I'm now realizing that this
> does not solve your initial issue at all -- regardless of whether the
> callbacks are done by stored functor objects or class virtual methods,
> they both require that the wrapper object stay alive as long as the
> callbacks are needed.
Bummer. I wonder if it's worth bothering with a redesign then, if
it doesn't offer enough benefit? I'd hate to see you spend a lot of
time on something that is probably pretty rarely used, when the
current version generally works (Albeit with caveats, but so would
your redesigned version, from the sounds of it).
> For example, consider the following case:
[ snip ]
Ya, that's basically how I ran into it. The simple examples/tests/etc
all work fine, since they just do everything in one scope. Once you
ramp up into a more extensive/complex usage, you quickly hit this...
> I've been racking my brain trying to figure
> out a way to make this work, but I'm afraid I don't have any good ideas
> so far.
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...
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...
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.
As always, keep up the great work!
Ian
More information about the cairo
mailing list