fontconfig/bugzilla-179457-fix-font-file-names-for-wine.patch

99 lines
2.4 KiB
Diff

diff -ru fontconfig-2.3.94.orig/src/fcpat.c fontconfig-2.3.94/src/fcpat.c
--- fontconfig-2.3.94.orig/src/fcpat.c 2006-03-10 16:00:36.000000000 +0100
+++ fontconfig-2.3.94/src/fcpat.c 2006-06-02 13:27:57.000000000 +0200
@@ -1098,6 +1112,39 @@
return FcPatternAdd (p, object, v, FcTrue);
}
+static FcResult
+FcPatternGetFile (const FcPattern *p, const char *object, int id, FcChar8 ** s)
+{
+ const char *fn, *fpath;
+ FcChar8 *fname;
+ int size;
+
+ fn = FcPatternFindFullFname(p);
+ if (fn)
+ {
+ *s = (FcChar8 *) fn;
+ return FcResultMatch;
+ }
+
+ if (!p->bank)
+ return FcResultMatch;
+
+ fpath = FcCacheFindBankDir (p->bank);
+ size = strlen((char *)fpath) + 1 + strlen ((char *)*s) + 1;
+ fname = malloc (size);
+ if (!fname)
+ return FcResultOutOfMemory;
+
+ FcMemAlloc (FC_MEM_STRING, size);
+ strcpy ((char *)fname, (char *)fpath);
+ strcat ((char *)fname, "/");
+ strcat ((char *)fname, (char *)*s);
+
+ FcPatternAddFullFname (p, (const char *)fname);
+ *s = (FcChar8 *)fname;
+ return FcResultMatch;
+}
+
FcResult
FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v)
{
@@ -1112,6 +1159,12 @@
if (!id)
{
*v = FcValueCanonicalize(&FcValueListPtrU(l)->value);
+
+ /* Pull the FC_FILE trick here too. */
+ if (v->type == FcTypeString &&
+ FcObjectToPtr(object) == FcObjectToPtr(FC_FILE))
+ return FcPatternGetFile (p, object, id, (FcChar8 **)&(v->u.s));
+
return FcResultMatch;
}
id--;
@@ -1175,41 +1228,6 @@
if (v.type != FcTypeString)
return FcResultTypeMismatch;
- if (FcObjectToPtr(object) == FcObjectToPtr(FC_FILE))
- {
- const char *fn, *fpath;
- FcChar8 *fname;
- int size;
-
- fn = FcPatternFindFullFname(p);
- if (fn)
- {
- *s = (FcChar8 *) fn;
- return FcResultMatch;
- }
-
- if (!p->bank)
- {
- *s = (FcChar8 *) v.u.s;
- return FcResultMatch;
- }
-
- fpath = FcCacheFindBankDir (p->bank);
- size = strlen((char*)fpath) + 1 + strlen ((char *)v.u.s) + 1;
- fname = malloc (size);
- if (!fname)
- return FcResultOutOfMemory;
-
- FcMemAlloc (FC_MEM_STRING, size);
- strcpy ((char *)fname, (char *)fpath);
- strcat ((char *)fname, "/");
- strcat ((char *)fname, (char *)v.u.s);
-
- FcPatternAddFullFname (p, (const char *)fname);
- *s = (FcChar8 *)fname;
- return FcResultMatch;
- }
-
*s = (FcChar8 *) v.u.s;
return FcResultMatch;
}