summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-05-18 15:26:03 -0700
committerBehdad Esfahbod <behdad@behdad.org>2015-05-18 15:26:03 -0700
commitbcfe167e3d60402c1f999359ca8531c6fae01a2b (patch)
treefd9b7154e3d7cd2b7062b73e7e4fbfc0e5f7140f /src
parentead7275e05966eca19f530712f8e5c738a61cf4f (diff)
Add su[pport for symbol fonts
Adds FC_SYMBOL. This affects fonts having a cmap with platform 3 encoding 0. We now map their glyphs from the PUA area to the Latin1 area. See thread "Webdings and other MS symbol fonts don't display" on the mailing list. Test before/after with: $ pango-view --markup --text='<span fallback="false">&#xd7;&#xf0d7;</span>' --font=Wingdings
Diffstat (limited to 'src')
-rw-r--r--src/fcdefault.c1
-rw-r--r--src/fcfreetype.c57
-rw-r--r--src/fcmatch.c1
-rw-r--r--src/fcobjs.h1
4 files changed, 57 insertions, 3 deletions
diff --git a/src/fcdefault.c b/src/fcdefault.c
index 7c16f48..4643e46 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -38,6 +38,7 @@ static const struct {
{ FC_GLOBAL_ADVANCE_OBJECT, FcTrue }, /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
{ FC_EMBEDDED_BITMAP_OBJECT, FcTrue }, /* !FC_LOAD_NO_BITMAP */
{ FC_DECORATIVE_OBJECT, FcFalse },
+ { FC_SYMBOL_OBJECT, FcFalse },
};
#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index afbd9ac..617b6b9 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1201,6 +1201,8 @@ FcFreeTypeQueryFace (const FT_Face face,
FcRange *r = NULL;
double lower_size = 0.0L, upper_size = DBL_MAX;
+ FcBool symbol = FcFalse;
+
FcInitDebug (); /* We might be called with no initizalization whatsoever. */
pat = FcPatternCreate ();
@@ -1803,6 +1805,11 @@ FcFreeTypeQueryFace (const FT_Face face,
if (!cs)
goto bail1;
+ /* The FcFreeTypeCharSetAndSpacing() chose the encoding; test it for symbol. */
+ symbol = face->charmap && face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
+ if (!FcPatternAddBool (pat, FC_SYMBOL, symbol))
+ goto bail1;
+
#if HAVE_FT_GET_BDF_PROPERTY
/* For PCF fonts, override the computed spacing with the one from
the property */
@@ -1835,9 +1842,18 @@ FcFreeTypeQueryFace (const FT_Face face,
if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
goto bail2;
- ls = FcFreeTypeLangSet (cs, exclusiveLang);
- if (!ls)
- goto bail2;
+ if (!symbol)
+ {
+ ls = FcFreeTypeLangSet (cs, exclusiveLang);
+ if (!ls)
+ goto bail2;
+ }
+ else
+ {
+ /* Symbol fonts don't cover any language, even though they
+ * claim to support Latin1 range. */
+ ls = FcLangSetCreate ();
+ }
if (!FcPatternAddLangSet (pat, FC_LANG, ls))
{
@@ -2093,6 +2109,22 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4);
if (glyphindex)
return glyphindex;
+ if (ucs4 < 0x100 && face->charmap &&
+ face->charmap->encoding == FT_ENCODING_MS_SYMBOL)
+ {
+ /* For symbol-encoded OpenType fonts, we duplicate the
+ * U+F000..F0FF range at U+0000..U+00FF. That's what
+ * Windows seems to do, and that's hinted about at:
+ * http://www.microsoft.com/typography/otspec/recom.htm
+ * under "Non-Standard (Symbol) Fonts".
+ *
+ * See thread with subject "Webdings and other MS symbol
+ * fonts don't display" on mailing list from May 2015.
+ */
+ glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4 + 0xF000);
+ if (glyphindex)
+ return glyphindex;
+ }
}
#if HAVE_FT_HAS_PS_GLYPH_NAMES
/*
@@ -2253,6 +2285,23 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
}
ucs4 = FT_Get_Next_Char (face, ucs4, &glyph);
}
+ if (fcFontEncodings[o] == FT_ENCODING_MS_SYMBOL)
+ {
+ /* For symbol-encoded OpenType fonts, we duplicate the
+ * U+F000..F0FF range at U+0000..U+00FF. That's what
+ * Windows seems to do, and that's hinted about at:
+ * http://www.microsoft.com/typography/otspec/recom.htm
+ * under "Non-Standard (Symbol) Fonts".
+ *
+ * See thread with subject "Webdings and other MS symbol
+ * fonts don't display" on mailing list from May 2015.
+ */
+ for (ucs4 = 0xF000; ucs4 < 0xF100; ucs4++)
+ {
+ if (FcCharSetHasChar (fcs, ucs4))
+ FcCharSetAddChar (fcs, ucs4 - 0xF000);
+ }
+ }
#ifdef CHECK
for (ucs4 = 0; ucs4 < 0x10000; ucs4++)
{
@@ -2267,6 +2316,8 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing
}
#endif
}
+
+ break;
}
#if HAVE_FT_HAS_PS_GLYPH_NAMES
/*
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 46d08bc..623d4aa 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -292,6 +292,7 @@ typedef enum _FcMatcherPriority {
PRI1(LANG),
PRI_FAMILY_WEAK,
PRI_POSTSCRIPT_NAME_WEAK,
+ PRI1(SYMBOL),
PRI1(SPACING),
PRI1(SIZE),
PRI1(PIXEL_SIZE),
diff --git a/src/fcobjs.h b/src/fcobjs.h
index 573fa61..1fc4f65 100644
--- a/src/fcobjs.h
+++ b/src/fcobjs.h
@@ -69,4 +69,5 @@ FC_OBJECT (PRGNAME, FcTypeString, NULL)
FC_OBJECT (HASH, FcTypeString, NULL) /* deprecated */
FC_OBJECT (POSTSCRIPT_NAME, FcTypeString, FcComparePostScript)
FC_OBJECT (COLOR, FcTypeBool, FcCompareBool)
+FC_OBJECT (SYMBOL, FcTypeBool, FcCompareBool)
/* ^-------------- Add new objects here. */