Re: Why Doesn’t Cairo Use FT_Reference_ Face?
Behdad Esfahbod <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On 15-03-06 08:28 PM, Lawrence D'Oliveiro wrote: > There is some really peculiar behaviour in the > cairo_ft_font_face_create_for_ft_face call > <http://cairographics.org/manual/cairo-FreeType-Fonts.html#cairo-ft-font-face-create-for-ft-face>. > Cairo wants to keep a reference to the FT_Face, but it seems unable to > use the FT_Reference_Face call which is provided specifically for that > purpose > <http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Reference_Face>! > So the caller is forced to go through some weird contortions to avoid > leaking FT_Face objects, or disposing of them prematurely. Correct. That's because FT_Reference_Face didn't exist until years after the cairo API was designed. > Cairo should call FT_Reference_Face on FT_Face objects that are passed > to it, and balance these with FT_Done_Face calls when it no longer > needs these references. > > This would be backward-compatible: the user_data shenanigans documented > on the Cairo API page would not become problematic, they would simply no > longer be necessary. That's in fact not true in all situations. For example, if an app caches the cairo_font_face_t in the FT_Face's generic slot, changing the API as you suggest with create a circular loop causing leaks. But I'd be happy to ignore that. I just hate having to explain this version dependency in the docs... In HarfBuzz I added a new API called _referenced(). I would prefer that to changing the semantics of existing API. The one-line set_user_data doesn't bother me that much. Cheers, -- behdad http://behdad.org/ -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo