Ok, so some people (wine!) use FcPatternGet to fetch FC_FILE. Make that
work. Reported by Bernhard Rosenkraenzer.
This commit is contained in:
parent
dc70c15aba
commit
618adbaf7b
|
@ -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:
|
||||||
|
|
||||||
|
|
73
src/fcpat.c
73
src/fcpat.c
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue