+2005-11-02 Patrick Lam <plam@mit.edu>
+ * src/fcpat.c (FcPatternDestroy, FcPatternTransferFullName):
+
+ Don't zero out full names for FC_REF_CONSTANT fonts;
+ also, duplicate full names when transferring, and free
+ full names when freeing the associated font.
+ Reported by Jinghua Luo.
+
2005-11-02 Patrick Lam <plam@mit.edu>
* fc-cache/fc-cache.c (scanDirs):
* src/fcpat.c (FcValueListSerialize):
static FcPatternEltPtr
FcPatternEltPtrCreateDynamic (FcPatternElt * e);
+/* If you are trying to duplicate an FcPattern which will be used for
+ * rendering, be aware that (internally) you also have to use
+ * FcPatternTransferFullFname to transfer the associated filename. If
+ * you are copying the font (externally) using FcPatternGetString,
+ * then everything's fine; this caveat only applies if you're copying
+ * the bits individually. */
+
FcPattern *
FcPatternCreate (void)
{
{
int i;
- if (FcPatternFindFullFname (p))
- FcPatternAddFullFname (p, 0);
-
if (p->ref == FC_REF_CONSTANT || --p->ref > 0)
return;
+ if (FcPatternFindFullFname (p))
+ {
+ FcStrFree (FcPatternFindFullFname (p));
+ FcPatternAddFullFname (p, 0);
+ }
+
for (i = 0; i < p->num; i++)
FcValueListDestroy ((FcPatternEltU(p->elts)+i)->values);
{
FcChar8 * s;
FcPatternGetString (orig, FC_FILE, 0, &s);
- FcPatternAddFullFname (new, FcPatternFindFullFname(orig));
+ FcPatternAddFullFname (new, FcStrCopy (FcPatternFindFullFname(orig)));
}