Replace the font path in FcPattern to what it is actually located.

This commit is contained in:
Akira TAGOH 2017-09-07 19:43:59 +09:00
parent 85d9de58ed
commit 6f226ad67e
2 changed files with 72 additions and 1 deletions

View File

@ -448,7 +448,46 @@ FcListAppend (FcListHashTable *table,
e = FcPatternObjectFindElt (font, FcObjectFromName (os->objects[o]));
if (e)
{
for (v = FcPatternEltValues(e), idx = 0; v;
idx = 0;
if (FcRefIsConst (&font->ref) && !strcmp (os->objects[o], FC_FILE))
{
struct stat statb;
for (v = FcPatternEltValues (e); v->value.type != FcTypeString; v = FcValueListNext (v));
if (!v)
goto bail2;
if (FcStat (FcValueString (&v->value), &statb) < 0)
{
FcChar8 *dir = FcStrDirname (FcValueString (&v->value));
const FcChar8 *alias;
if ((alias = FcDirCacheFindAliasPath (dir)))
{
FcChar8 *base = FcStrBasename (FcValueString (&v->value));
FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
FcValue vv;
FcStrFree (base);
vv.type = FcTypeString;
vv.u.s = s;
if (!FcPatternAdd (bucket->pattern,
os->objects[o],
FcValueCanonicalize (&vv),
FcTrue))
{
FcStrFree (s);
FcStrFree (dir);
goto bail2;
}
FcStrFree (s);
FcStrFree (dir);
idx++;
}
else
FcStrFree (dir);
}
}
for (v = FcPatternEltValues(e); v;
v = FcValueListNext(v), ++idx)
{
if (!FcPatternAdd (bucket->pattern,

View File

@ -643,6 +643,38 @@ FcFontRenderPrepare (FcConfig *config,
}
else
{
if (FcRefIsConst (&font->ref) && fe->object == FC_FILE_OBJECT)
{
FcValueListPtr l = FcPatternEltValues (fe);
struct stat statb;
while (l->value.type != FcTypeString)
l = FcValueListNext (l);
if (FcStat (FcValueString (&l->value), &statb) < 0)
{
FcChar8 *dir = FcStrDirname (FcValueString (&l->value));
const FcChar8 *alias;
if ((alias = FcDirCacheFindAliasPath (dir)))
{
FcChar8 *base = FcStrBasename (FcValueString (&l->value));
FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
FcValue v;
FcStrFree (base);
v.type = FcTypeString;
v.u.s = s;
FcPatternObjectAddWithBinding (new, fe->object,
FcValueCanonicalize (&v),
l->binding,
FcTrue);
FcStrFree (s);
FcStrFree (dir);
}
else
FcStrFree (dir);
}
}
FcPatternObjectListAdd (new, fe->object,
FcValueListDuplicate (FcPatternEltValues (fe)),
FcTrue);