freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Re: Reference count in FreeType2


From: Behdad Esfahbod
Subject: [ft-devel] Re: Reference count in FreeType2
Date: Tue, 23 Mar 2010 13:57:13 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Thunderbird/3.0.3

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
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]