[cairo] Problem with freeing font faces
k at ailis.de
Sun Aug 10 09:00:02 PDT 2014
I'm trying to use freetype fonts in cairo and have some problems getting
them released when they are no longer used. I'm note sure if this is a
bug or if I'm doing something wrong (Tried with Cairo 1.12.14 and with
current Git HEAD).
The first thing I do is creating the font face from a freetype font:
cairo_font_face_t* font =
Now the reference counter of this font face is 1 as expected. Now I set
this font in the current cairo context:
The reference counter is now 2. I guess this is correct because now
there is one reference in the current cairo context and I still have my
own reference. So I destroy my own reference to get back to reference
Now I draw some text using this font:
cairo_show_text(cr, "Hello World");
After this line of code the reference counter is suddenly at 3. I think
this is pretty strange and it looks like a bug to me.
Finally I remove the font from the cairo context with this line:
The reference counter drops from 3 to 2. Now there should be no
reference to the font anymore but the font (and its userdata) is not
freed because there are two unknown references left.
When I remove the "cairo_show_text" call from my code, then it works
correctly. The reference counter drops to 0 and the destroy callbacks of
registered userdata is called.
The full C++ source code of my test program can be downloaded here:
So what's going on there? Something wrong in my code or a Cairo bug?
Klaus Reimer <http://www.ailis.de/~k/>
[2FC4 CCA0 C03B 1E5F 1ACC 94D6 6461 426C E734 75A1]
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the cairo