<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-forward-container"><font size="+1">In our
application, we allow multiple documents to be open at the same
time, and user can open/close many documents during one run of
the application.<br>
<br>
I set up each document to use one </font><font size="+1"><font
size="+1">FT_Library object</font>, one Cairo surface and one
cairo_t object. The reason is that FT requires each thread
should have its own FT_Library object, and I want each document
to have its own thread.<br>
<br>
Then we discovered an issue with Cairo Font Cache and usage of
Cairo+FT in general. We have two </font><font size="+1">documents
that have different fonts that draw text at the same location
and with the same scaling. When user closes one doc and open
another one, the text may display incorrectly. I found that in
</font><font size="+1"><font size="+1"><font size="+1">those cases</font></font>
the 2 FT_Face objects in the two documents have the same pointer
address. It can happen because when a doc is closed, I released
its </font><font size="+1"><font size="+1">FT_Face objects.</font>
</font><font size="+1"><font size="+1">After tracing into the
Cairo code, I suspect </font> Cairo font cache failed to
distinguish fonts by using their hash values. With other
information </font><font size="+1"><font size="+1">(ctm,
options)</font> being the same , the hash calculation relies
heavily on the </font><font size="+1">font pointer addresses.<br>
<br>
Question-1:<br>
Is it true that I can not determine the life time of a </font><font
size="+1">FT_Face object when using Cairo? In my case</font><font
size="+1"><font size="+1">, even though I de-ref the
cairo_font_face_t and cairo_scaled_font_t carefully</font>,
when a document is closed</font>, the reference counts on the
font objects are not zero. Although my following
FT_Done_Face(face) calls does not cause a crash, the Cairo's font
cache is already in bad state. I don't see a way around this.<br>
<br>
<font size="+1">Question-2:</font><br>
Is it possible that Cairo add an interface function that allow
user to tell the font cache to remove font objects in a future
release? <br>
<br>
The interface may look like:<br>
unsigned int cairo_cache_release_font
(cairo_font_face_t *font_face);<br>
unsigned int cairo_cache_release_scaled_font (<font size="+1"><font
size="+1">cairo_scaled_font_t</font></font>
*font_face);<br>
Both functions return the reference count on the font after the
release.<br>
<br>
Thanks,<br>
<br>
Jian Ye<br>
<br>
<br>
</div>
<br>
</body>
</html>