Is font face reference counting broken?

Uli Schlachter psychon at znc.in
Wed May 15 19:08:07 UTC 2024


Hi,

Am 15.05.24 um 19:39 schrieb Andreas Falkenhahn:
> On 15.05.2024 at 16:34 Uli Schlachter wrote:
[...]
>> You can use cairo_font_face_set_user_data() to register a callback for
>> when the font face is destroyed. Then, in that callback you can delete
>> the temporary file.
> 
> This sounds like a good idea but I don't think it will work in my case.
> I've tried it and the destroy callback does NOT get called at all. Ironically,
> the destroy callback IS called when using cairo_debug_reset_static_data()
> first but of course if I have to cairo_debug_reset_static_data() anyway
> where's the point in using cairo_font_face_set_user_data() on top of it?

Ah, okay. I was thinking about a long-running program. There, newer 
fonts would eventually cause the old, stale ones to be evicted from the 
cache. At that point, the callback would be called.

In such a situation, using cairo_debug_reset_static_data() could be 
problematic, because "something else" could still be having cairo 
objects alive.

[...]>> Also, I am not an expert in font stuff, but why do you need a 
temporary
>> file? Where is the font file coming from and is there perhaps a way to
>> load it directly from memory?
> 
> I'm using MicroTeX and MicroTeX's Cairo backend doesn't support loading
> fonts from memory buffers. That's pretty much my reason for using files...

...however, you seem to be working with a short-running program where 
there are no newer fonts to replace the old, stale entries in the cache. 
In that case, cairo_debug_reset_static_data() seems to be the way to go.

Cheers,
Uli
-- 
Homophobia - The fear that another man will treat you the way you treat 
women.



More information about the cairo mailing list