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:
parent
0f9aa8759d
commit
1cad82cde2
|
@ -1671,10 +1671,10 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
alen = (len + 63) & ~63;
|
alen = (len + 63) & ~63;
|
||||||
fontdata = malloc (alen);
|
fontdata = malloc (alen);
|
||||||
if (!fontdata)
|
if (!fontdata)
|
||||||
goto bail1;
|
goto bail3;
|
||||||
err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)fontdata, &len);
|
err = FT_Load_Sfnt_Table (face, 0, 0, (FT_Byte *)fontdata, &len);
|
||||||
if (err != FT_Err_Ok)
|
if (err != FT_Err_Ok)
|
||||||
goto bail1;
|
goto bail3;
|
||||||
memset (&fontdata[len], 0, alen - len);
|
memset (&fontdata[len], 0, alen - len);
|
||||||
hashstr = FcHashGetSHA256DigestFromMemory (fontdata, len);
|
hashstr = FcHashGetSHA256DigestFromMemory (fontdata, len);
|
||||||
}
|
}
|
||||||
|
@ -1687,12 +1687,14 @@ FcFreeTypeQueryFace (const FT_Face face,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goto bail1;
|
goto bail3;
|
||||||
}
|
}
|
||||||
if (!hashstr)
|
if (hashstr)
|
||||||
goto bail1;
|
{
|
||||||
if (!FcPatternAddString (pat, FC_HASH, hashstr))
|
if (!FcPatternAddString (pat, FC_HASH, hashstr))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
}
|
||||||
|
bail3:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the unicode coverage for the font
|
* Compute the unicode coverage for the font
|
||||||
|
|
|
@ -202,6 +202,17 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
|
||||||
return 3.0;
|
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) \
|
#define PRI_NULL(n) \
|
||||||
PRI_ ## n ## _STRONG = -1, \
|
PRI_ ## n ## _STRONG = -1, \
|
||||||
PRI_ ## n ## _WEAK = -1,
|
PRI_ ## n ## _WEAK = -1,
|
||||||
|
@ -215,6 +226,7 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
|
||||||
#define PRI_FcCompareCharSet(n) PRI1(n)
|
#define PRI_FcCompareCharSet(n) PRI1(n)
|
||||||
#define PRI_FcCompareLang(n) PRI1(n)
|
#define PRI_FcCompareLang(n) PRI1(n)
|
||||||
#define PRI_FcComparePostScript(n) PRI1(n)
|
#define PRI_FcComparePostScript(n) PRI1(n)
|
||||||
|
#define PRI_FcCompareHash(n) PRI1(n)
|
||||||
|
|
||||||
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
|
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,6 @@ FC_OBJECT (LCD_FILTER, FcTypeInteger, NULL)
|
||||||
FC_OBJECT (NAMELANG, FcTypeString, NULL)
|
FC_OBJECT (NAMELANG, FcTypeString, NULL)
|
||||||
FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
|
FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
|
||||||
FC_OBJECT (PRGNAME, FcTypeString, NULL)
|
FC_OBJECT (PRGNAME, FcTypeString, NULL)
|
||||||
FC_OBJECT (HASH, FcTypeString, FcCompareString)
|
FC_OBJECT (HASH, FcTypeString, FcCompareHash)
|
||||||
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
|
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
|
||||||
/* ^-------------- Add new objects here. */
|
/* ^-------------- Add new objects here. */
|
||||||
|
|
Loading…
Reference in New Issue