[cairo] font lifetime

Alexander Larsson alexl at redhat.com
Thu Jan 27 00:28:03 PST 2005


On Wed, 2005-01-26 at 07:02 -0800, Keith Packard wrote:
> Around 8 o'clock on Jan 26, Owen Taylor wrote:
> 
> > One of the outstanding issues ... see my last long mail on fonts. I want
> > to add a destroy notifier, but am getting resistance on the subject.
> 
> The alternative I've proposed is a function which you can call when you 
> are "done" with the cairo_font_t object which guarantees that the FT_face 
> will not be referenced again but doesn't destroy the cairo_font_t object.
> 
> I prefer this method both because it fits neatly into how I envision automatic 
> memory management environments and also because it avoids callbacks from 
> cairo with indeterminant threading liabilities.
> 
> It's clear that either will work for C usage.   It's also clear we could 
> do both, but I'm sure most would agree that a single method would be 
> preferred.

So, in my case I have a pdf object representing the font. This object
owns the FT_Face, and i have a cache of them. During page rendering a
bunch of cairo_font_t objects were created from the FT_Face of the font.
Eventually the pdf font drops from the cache and i unref it. In your
model I would now call the "make invalid" function on all the
cario_font_t:s. However, this means I need to keep a list of all the
fonts created, with a reference even thus unnecessarily extending their
lifetime.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's an unconventional crooked firefighter possessed of the uncanny powers of 
an insect. She's a ditzy mutant hooker with a song in her heart and a spring 
in her step. They fight crime! 




More information about the cairo mailing list