Ok, so some people (wine!) use FcPatternGet to fetch FC_FILE. Make that

work. Reported by Bernhard Rosenkraenzer.
This commit is contained in:
Patrick Lam 2006-03-05 06:05:50 +00:00
parent dc70c15aba
commit 618adbaf7b
2 changed files with 46 additions and 33 deletions

View File

@ -1,3 +1,9 @@
2006-03-05 Patrick Lam <plam@mit.edu>
* src/fcpat.c (FcPatternGetString, FcPatternGet):
Ok, so some people (wine!) use FcPatternGet to fetch FC_FILE.
Make that work. Reported by Bernhard Rosenkraenzer.
2006-03-03 Patrick Lam <plam@mit.edu> 2006-03-03 Patrick Lam <plam@mit.edu>
* src/fcint.h: * src/fcint.h:

View File

@ -1098,6 +1098,39 @@ FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls)
return FcPatternAdd (p, object, v, FcTrue); 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 FcResult
FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v) FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v)
{ {
@ -1112,6 +1145,12 @@ FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v)
if (!id) if (!id)
{ {
*v = FcValueCanonicalize(&FcValueListPtrU(l)->value); *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; return FcResultMatch;
} }
id--; id--;
@ -1176,39 +1215,7 @@ FcPatternGetString (const FcPattern *p, const char *object, int id, FcChar8 ** s
return FcResultTypeMismatch; return FcResultTypeMismatch;
if (FcObjectToPtr(object) == FcObjectToPtr(FC_FILE)) if (FcObjectToPtr(object) == FcObjectToPtr(FC_FILE))
{ return FcPatternGetFile (p, object, id, s);
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; *s = (FcChar8 *) v.u.s;
return FcResultMatch; return FcResultMatch;