src/fcfreetype.c | 16 +++++++++------- src/fcmatch.c | 30 +++++++++++++++++++++--------- src/fcobjs.h | 2 +- 3 files changed, 31 insertions(+), 17 deletions(-) New commits: commit 1cad82cde29ea488ea22541b46ed347d10952557 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri May 10 20:26:11 2013 +0900 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. diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 5e8990d..02e85cb 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -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 diff --git a/src/fcmatch.c b/src/fcmatch.c index 84c9a9a..10976d6 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -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) diff --git a/src/fcobjs.h b/src/fcobjs.h index b735401..682fe6a 100644 --- a/src/fcobjs.h +++ b/src/fcobjs.h @@ -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. */ _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig