From 793154ed8d4b2d832f81a893273c6504bac3f0b3 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Tue, 1 Nov 2005 06:57:25 +0000 Subject: [PATCH] Copy the full pathname whenever duplicating an FcPattern; otherwise, applications continue breaking. --- ChangeLog | 10 ++++++++++ src/fcint.h | 4 ++-- src/fclist.c | 6 +----- src/fcmatch.c | 4 ++++ src/fcpat.c | 25 ++++++++++++++++++++++++- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 783603c..a69de9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-10-31 Patrick Lam + * src/fcint.h: + * src/fclist.c (FcListAppend): + * src/fcmatch.c (FcFontRenderPrepare): + * src/fcpat.c (FcPatternTransferFullFname, FcPatternDuplicate, + FcPatternFreeze, FcPatternBaseFreeze): + + Copy the full pathname whenever duplicating an FcPattern; otherwise, + applications continue breaking. + 2005-10-31 Patrick Lam * fc-cat/fc-cat.c (FcCacheFileRead, main): * src/fcfreetype.c (FcFreeTypeQuery): diff --git a/src/fcint.h b/src/fcint.h index fccb941..d13bba6 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -808,8 +808,8 @@ FcPatternAppend (FcPattern *p, FcPattern *s); void FcPatternAddFullFname (const FcPattern *p, const char *fname); -const char * -FcPatternFindFullFname (const FcPattern *p); +void +FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig); const FcChar8 * FcStrStaticName (const FcChar8 *name); diff --git a/src/fclist.c b/src/fclist.c index fa567a0..38c20e0 100644 --- a/src/fclist.c +++ b/src/fclist.c @@ -424,11 +424,7 @@ FcListAppend (FcListHashTable *table, /* Also, copy over the full path info. */ if (!strcmp (os->objects[o], FC_FILE)) - { - FcChar8 * s; - FcPatternGetString (font, FC_FILE, 0, &s); - FcPatternAddFullFname (bucket->pattern, FcPatternFindFullFname(font)); - } + FcPatternTransferFullFname (bucket->pattern, font); e = FcPatternFindElt (font, os->objects[o]); if (e) diff --git a/src/fcmatch.c b/src/fcmatch.c index a359a8b..38d083e 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -489,6 +489,10 @@ FcFontRenderPrepare (FcConfig *config, FcPatternAdd (new, FcObjectPtrU(pe->object), FcValueCanonicalize(&FcValueListPtrU(pe->values)->value), FcTrue); } + + if (FcPatternFindElt (font, FC_FILE)) + FcPatternTransferFullFname (new, font); + FcConfigSubstituteWithPat (config, new, pat, FcMatchFont); return new; } diff --git a/src/fcpat.c b/src/fcpat.c index 6d8f357..b7f5279 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -34,6 +34,8 @@ static int fcpatternelt_ptr, fcpatternelt_count; static FcValueList ** fcvaluelists = 0; static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count; +static const char * +FcPatternFindFullFname (const FcPattern *p); static FcPatternEltPtr FcPatternEltPtrCreateDynamic (FcPatternElt * e); @@ -580,6 +582,9 @@ FcPatternBaseFreeze (FcPattern *b) (FcPatternEltU(b->elts)+i)->object; } + if (FcPatternFindElt (b, FC_FILE)) + FcPatternTransferFullFname (ep, b); + ent->hash = hash; ent->next = *bucket; *bucket = ent; @@ -647,6 +652,10 @@ FcPatternFreeze (FcPattern *p) if (!FcValueListPtrU((FcPatternEltU(p->elts)+i)->values)) goto bail; } + + if (FcPatternFindElt (p, FC_FILE)) + FcPatternTransferFullFname (b, p); + /* * Freeze base */ @@ -1257,6 +1266,13 @@ FcPatternDuplicate (const FcPattern *orig) FcValueCanonicalize(&FcValueListPtrU(l)->value), FcTrue)) goto bail1; + + if (!strcmp ((char *)FcObjectPtrU((e + i)->object), FC_FILE)) + { + FcChar8 * s; + FcPatternGetString (orig, FC_FILE, 0, &s); + FcPatternAddFullFname (new, FcPatternFindFullFname(orig)); + } } return new; @@ -1957,7 +1973,7 @@ FcPatternAddFullFname (const FcPattern *p, const char *fname) pb->next->m.fname = fname; } -const char * +static const char * FcPatternFindFullFname (const FcPattern *p) { struct patternDirBucket *pb; @@ -1971,3 +1987,10 @@ FcPatternFindFullFname (const FcPattern *p) return 0; } +void +FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig) +{ + FcChar8 * s; + FcPatternGetString (orig, FC_FILE, 0, &s); + FcPatternAddFullFname (new, FcPatternFindFullFname(orig)); +} -- 2.39.5