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.
This commit is contained in:
Patrick Lam 2005-11-02 15:29:53 +00:00
parent 303bcf9b9d
commit d7b3ac6367
2 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,11 @@
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):

View File

@ -39,6 +39,13 @@ FcPatternFindFullFname (const FcPattern *p);
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)
{
@ -297,12 +304,15 @@ FcPatternDestroy (FcPattern *p)
{
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);
@ -1993,5 +2003,5 @@ FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig)
{
FcChar8 * s;
FcPatternGetString (orig, FC_FILE, 0, &s);
FcPatternAddFullFname (new, FcPatternFindFullFname(orig));
FcPatternAddFullFname (new, FcStrCopy (FcPatternFindFullFname(orig)));
}