<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Verdana, sans-serif" size="2">
<div style="padding-left: 70pt; ">I'm trying to understand Cairo's font mechanism…</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">I create a face using Freetype and then create a Cairo font face.</div>
<div style="padding-left: 70pt; "> </div>
<div style="padding-left: 70pt; ">fface = cairo_ft_font_face_create_for_ft_face (ft_face, load_flags);</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">when I am finished.. I destroy the fface, destroy the Freetype font and destroy the freetype library instance..</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">I don't use the font after I've chosen to destroy it.. </div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">What I have found is that the reference count does up when I set it into a drawing context.. Up again</div>
<div style="padding-left: 70pt; ">when I apply a matrix--- backend does a scaled font and increases the reference count.</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Even if I do a set font to NULL in my drawing context: cairo_set_font_face(cairo, NULL)</div>
<div style="padding-left: 70pt; ">it seems that the reference count is still UP. Internally it seems that the scaled font is still waiting…</div>
<div style="padding-left: 70pt; ">Only when the drawing context is destroyed does it go down.. But even at that time the font still is</div>
<div style="padding-left: 70pt; ">in Cairo's own cache.</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Again if I don't use the font.. why does it matter?</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">I would assume that this should not bother me since if I don't reference the font there is nothing to go</div>
<div style="padding-left: 70pt; ">wrong.. right? Well I've found that after running for a while new fonts don't get correctly added and</div>
<div style="padding-left: 70pt; ">we see zombies.. Fonts with characters that seem to pointing to the wrong glyphs!</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Create a surface. Make a drawing context. Create a Freetype face, create a Cairo face on the Freetype face..</div>
<div style="padding-left: 70pt; ">set a matrix.. use in a context.. draw a glyph… destroy Cairo face, FT_Done_Face on freetype face.. destroy</div>
<div style="padding-left: 70pt; ">drawing context… destroy surface..</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Yes when we've free'd the Freetype buffers there was stiff a reference count on the Cairo face.. But no more</div>
<div style="padding-left: 70pt; ">references.. </div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Same things repeated over an over.. After a number of cycles a font can show a few wrong glyphs… No memory</div>
<div style="padding-left: 70pt; ">faults.. Just wrong paths!</div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">In the source and documentation it suggests that one install a callback via</div>
<div style="padding-left: 70pt; ">cairo_font_face_set_user_data to destroy things..</div>
<div style="padding-left: 70pt; "> </div>
<div style="padding-left: 70pt; ">1) I've found that the cairo_destroy_func_t does not get called at the end after I've destroyed everything.. </div>
<div style="padding-left: 70pt; ">2) If I've destroyed the freetype object myself when I was done with it, roughly at the time when the</div>
<div style="padding-left: 70pt; ">callback would be called that zombies "can" appear. In a font its not all the characters that are wrong… we've</div>
<div style="padding-left: 70pt; ">never seem this.. Only some seemingly random ones in a font.. The data is pointing to font paths since its </div>
<div style="padding-left: 70pt; ">drawing.. just not the right paths… </div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; ">Anyway to force the Cairo cache to sync itself? Why if I don't use any references to a Cairo font can't I</div>
<div style="padding-left: 70pt; ">destroy the Freetype face behind it without having it mess up a different Cairo face? </div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="padding-left: 70pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2" color="#210058"> </font></div>
<div><font color="#210058">_________________________________________________________________</font></div>
<div><font color="#210058">Edward C. Zimmermann</font></div>
<div><font color="#210058">Softwareentwicklung</font></div>
<div><font color="#210058"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
</body>
</html>