[cairo] font lifetime
Owen Taylor
otaylor at redhat.com
Wed Jan 26 06:49:52 PST 2005
On Wed, 2005-01-26 at 14:48 +0100, Alexander Larsson wrote:
> On Wed, 2005-01-26 at 08:24 -0500, Owen Taylor wrote:
> > On Wed, 2005-01-26 at 12:47 +0100, Alexander Larsson wrote:
> > > I'm making xpdf work with the new font changes, and I have a question.
> > >
> > > If i call cairo_ft_font_create_for_ft_face with a FT_Face. How do I know
> > > how long i need to keep the FT_Face around? The cairo_font_t object is
> > > passed around internally in cairo, and can end up in all sorts of caches
> > > and stuff, complicating its lifecycle.
> >
> > 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.
>
> What is wrong with destroy notifiers? They are very useful.
I think the concern was reentrancy, especially in the presence of thread
locking. I've never found that to be the case in the past, usually you
can just avoid calling the destroy notifier until after you've cleaned
up internal state and unlocked lock.
Threading is perhaps slightly more of an issue for this particular case,
since cache elements can be forced out of the cache due to rendering
activity in other threads, and having destroy notifiers called from a
different thread when all PDF activity is confined to a single thread
could be awkward.
I don't think the glyph image cache behavior is really right for the
create_for_ft_face case... the glyph cache really should never be
keeping a the unscaled font alive, because once all other references
to the unscaled font have been dropped, there is no way to get back
to it.
So, very likely, when the last reference to the cairo_font_t is dropped,
we should either:
- Clear the FT_Face out of the unscaled font (calling a hypothetical
destroy notifier), leaving the unscaled font around as a small
empty shell until it gets completely forced out.
or:
- Purge all references to the unscaled font from the cache.
The first is a little easier, and a little less efficient.
I'm not using cairo_ft_font_create_for_ft_face() in Pango at the moment,
so I'd be interested in knowing what you need out of it for the Xpdf
backend... other than the destroy notifier issue, is it doing what
you want?
Regards,
Owen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050126/a099359f/attachment.pgp
More information about the cairo
mailing list