Bug 63922 - FcFreeTypeQueryFace fails on postscripts fonts loaded from memory

Workaround to not failing even when the hash is unable to generate from fonts.
This change also contains to ignore the case if the hash isn't in either both
patterns.
This commit is contained in:
Akira TAGOH 2013-05-10 20:26:11 +09:00
parent 0f9aa8759d
commit 1cad82cde2
3 changed files with 31 additions and 17 deletions

View File

@ -1671,10 +1671,10 @@ FcFreeTypeQueryFace (const FT_Face face,
alen = (len + 63) & ~63;
fontdata = malloc (alen);
if (!fontdata)
goto bail1;
goto bail3;
err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)fontdata, &len);
if (err != FT_Err_Ok)
goto bail1;
goto bail3;
memset (&fontdata[len], 0, alen - len);
hashstr = FcHashGetSHA256DigestFromMemory (fontdata, len);
}
@ -1687,12 +1687,14 @@ FcFreeTypeQueryFace (const FT_Face face,
}
else
{
goto bail1;
goto bail3;
}
if (!hashstr)
goto bail1;
if (!FcPatternAddString (pat, FC_HASH, hashstr))
goto bail1;
if (hashstr)
{
if (!FcPatternAddString (pat, FC_HASH, hashstr))
goto bail1;
}
bail3:
/*
* Compute the unicode coverage for the font

View File

@ -191,15 +191,26 @@ FcCompareSize (FcValue *value1, FcValue *value2)
static double
FcCompareFilename (FcValue *v1, FcValue *v2)
{
const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
if (FcStrCmp (s1, s2) == 0)
return 0.0;
else if (FcStrCmpIgnoreCase (s1, s2) == 0)
return 1.0;
else if (FcStrGlobMatch (s1, s2))
return 2.0;
else
return 3.0;
const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
if (FcStrCmp (s1, s2) == 0)
return 0.0;
else if (FcStrCmpIgnoreCase (s1, s2) == 0)
return 1.0;
else if (FcStrGlobMatch (s1, s2))
return 2.0;
else
return 3.0;
}
static double
FcCompareHash (FcValue *v1, FcValue *v2)
{
const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
/* Do not match an empty string */
if (!s1 || !s2 || !s1[0] || !s2[0])
return 1.0;
return FcCompareString (v1, v2);
}
#define PRI_NULL(n) \
@ -215,6 +226,7 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
#define PRI_FcCompareCharSet(n) PRI1(n)
#define PRI_FcCompareLang(n) PRI1(n)
#define PRI_FcComparePostScript(n) PRI1(n)
#define PRI_FcCompareHash(n) PRI1(n)
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)

View File

@ -43,6 +43,6 @@ FC_OBJECT (LCD_FILTER, FcTypeInteger, NULL)
FC_OBJECT (NAMELANG, FcTypeString, NULL)
FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
FC_OBJECT (PRGNAME, FcTypeString, NULL)
FC_OBJECT (HASH, FcTypeString, FcCompareString)
FC_OBJECT (HASH, FcTypeString, FcCompareHash)
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
/* ^-------------- Add new objects here. */