Reference counting of cairo free type face

Julian Viereck <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hi there,

I try to add font support to the node-canvas [1] library, which uses 
cairo for rendering. I use the freetype2 library to load a font face and 
then use it in cairo. The font rendering is working, but I got stuck on 
memory management of the cairo font face. In particular, the cairo font 
face's reference counter is not reset to 1 at the point I expect it to be.

Here's what I'm doing. I concentrate on the essential parts only. Let 
"ref(cr_face)" be "cairo_font_face_get_reference_count(cr_face)" to get 
the internal reference counter for the cairo font face.

     // Create a free type font face from a font file.
     FT_New_Face(library, *filePath, faceIdx, &ft_face);
     // Create a cairo font face.
     cr_face = cairo_ft_font_face_create_for_ft_face(ft_face, 0);

     // At this point ref(cr_face) == 1.

     // Set the cairo font face on a cairo rendering context.
     cairo_set_font_face(ctx, cr_face);

     // At this point ref(cr_face) == 2. I guess that's okay, as the 
font is requird for rendering.

     cairo_text_path(ctx, str);

     // At this point ref(cr_face) == 4.

     cairo_destroy(ctx);

     // At this point ref(cr_face) == 3.

Shouldn't the reference count after the "cairo_destory" be 1 again and 
the cairo font face deleted? Do I need to perform some manually cleanup 
first?

Hope someone can help me out here and very best,

Julian

PS: I use cairo 1.12.8 and the freetype 2.4.10 library.

---

[1]: https://github.com/LearnBoost/node-canvas


-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.