[cairo] font face lifetime

Vojtech Fried vfried at opentext.com
Wed Feb 2 09:55:16 PST 2011


Hi,

I use freetype fonts in cairo. I have read in the docs that cairo may cache cairo font faces and that's why I should use FT_Done_Face as a cairo_destroy_func_t set in cairo_font_face_set_user_data.
That probably also means that I should
1. not call FT_Done_FreeType at all
or 2. call it at exit
or 3. use one freetype library object per one freetype font used in cairo and call FT_Done_FreeType at the same time as FT_Done_Face
or 4. perhaps use some reference counting for the freetype library object.

But how does it work for multiple threads?
Can it happen that thread A needs the font faces created by another thread B long after thread A ends? I guess it can. In my case in one scenario I use freetype to load a font from memory. I create some kind of memory stream and freetype is happy to use it. But the data are only valid as long as the thread that created them is alive. Can anything wrong happen when the data are no longer valid but the cairo font face is still cached somewhere? E.g. could cairo try to read this "zombie" font?
Is there any way to clear cairo caches from font faces (and perhaps other objects) created by a specific thread? (I think there is no such way.)

Vojtech
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110202/2fce50c9/attachment.htm>


More information about the cairo mailing list