On 03/16/2010 02:05 AM, Werner LEMBERG wrote:
>> Use case is very simple: with the FreeType stack, all of hb_face_t,
>> PangoFont, and cairo_scaled_font_t all can use keeping a pointer to
>> an FT_Face.  But alas, one cannot do that safely since you never
>> know when the face is going away.
> 
> Again: What would you like as an interface?  Something like a function
> `FT_Face_IsAlive', returning a boolean?

Nope.  FT_Reference_Face().  That increments the refcount.  Then
FT_Done_Face() should decrement the refcount and only destroy if it drops to
zero.  Refcount is initialized to 1 when face is constructed.  And of course
these should be done using atomic operators.

Same about FT_Library and any other object worth keeping around.  But those
two are the major ones.

>> If there was refcounts in FreeType, harfbuzz could increment the
>> refcount on the FT_Face it keeps a pointer to.
> 
> Since my knowledge is quite poor here, can you point me to a library
> which implements something along this?

Any of HarfBuzz, cairo, glib, fontconfig.  But I think the description above
should be enough to implement it.

Of course that doesn't make FreeType threadsafe, but it does immensely
simplify life-cycle management.

behdad



> 
>     Werner
> 


_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to