summaryrefslogtreecommitdiff
path: root/pango/pangofc-fontmap.c
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2019-08-04 12:26:07 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2019-08-04 12:35:00 +0200
commitd7b706d8f2a6d15b34dabbd38ab8389de5e71ff8 (patch)
treefb6a06e05b3f7c4f1ec5375587c6da7fd638f065 /pango/pangofc-fontmap.c
parent48a49b185a5511efd02326fb60d445b759679e09 (diff)
downloadpango-d7b706d8f2a6d15b34dabbd38ab8389de5e71ff8.tar.gz
fc: Ignore more unsupported font formats
FontConfig uses FreeType’s FT_Get_X11_Font_Format() to get the font format. From the list of font formats it supports, only “TrueType” and “CFF” are supported by HarfBuzz. We now check explicitly for supported formats and reject anything else: https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/include/freetype/internal/services/svfntfmt.h#n36 FreeType, however, seems to use “CFF” for both OpenType fonts with CFF table (.otf) and bare CFF fonts (.cff), but the later are not supported by HarfBuzz although they rather rare (outside of PDF files, which shouldn’t be rendered with Pango), so it should be OK.
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r--pango/pangofc-fontmap.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index bddd5410..d0a01115 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -895,6 +895,20 @@ pango_fc_fontset_get_key (PangoFcFontset *fontset)
return fontset->key;
}
+static gboolean
+pango_fc_is_supported_font_format (const char *fontformat)
+{
+ /* harfbuzz supports only SFNT fonts. */
+ /* FIXME: "CFF" is used for both CFF in OpenType and bare CFF files, but
+ * HarfBuzz does not support the later and FontConfig does not seem
+ * to have a way to tell them apart.
+ */
+ if (g_ascii_strcasecmp (fontformat, "TrueType") == 0 ||
+ g_ascii_strcasecmp (fontformat, "CFF") == 0)
+ return TRUE;
+ return FALSE;
+}
+
static PangoFont *
pango_fc_fontset_load_next_font (PangoFcFontset *fontset,
gboolean *has_more)
@@ -925,8 +939,7 @@ pango_fc_fontset_load_next_font (PangoFcFontset *fontset,
res = FcPatternGetString (font_pattern, FC_FONTFORMAT, 0, (FcChar8 **)(void*)&s);
g_assert (res == FcResultMatch);
- /* harfbuzz does not support these */
- if (strcmp (s, "Type 1") == 0 || strcmp (s, "PCF") == 0)
+ if (!pango_fc_is_supported_font_format (s))
font = NULL;
else
font = pango_fc_font_map_new_font (fontset->key->fontmap,
@@ -1394,8 +1407,8 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap,
res = FcPatternGetString (fontset->fonts[i], FC_FONTFORMAT, 0, (FcChar8 **)(void*)&s);
g_assert (res == FcResultMatch);
- if (strcmp (s, "Type 1") == 0 || strcmp (s, "PCF") == 0)
- continue; /* harfbuzz does not support these */
+ if (!pango_fc_is_supported_font_format (s))
+ continue;
res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **)(void*)&s);
g_assert (res == FcResultMatch);