{
FT_Face ft_face;
int load_flags;
+ bool symbol; /* Whether selected cmap is symbol cmap. */
bool unref; /* Whether to destroy ft_face when done. */
};
static hb_ft_font_t *
-_hb_ft_font_create (FT_Face ft_face, bool unref)
+_hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
{
hb_ft_font_t *ft_font = (hb_ft_font_t *) calloc (1, sizeof (hb_ft_font_t));
return NULL;
ft_font->ft_face = ft_face;
+ ft_font->symbol = symbol;
ft_font->unref = unref;
ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
}
static void
+_hb_ft_face_destroy (FT_Face ft_face)
+{
+ FT_Done_Face (ft_face);
+}
+
+static void
_hb_ft_font_destroy (hb_ft_font_t *ft_font)
{
if (ft_font->unref)
- FT_Done_Face (ft_font->ft_face);
+ _hb_ft_face_destroy (ft_font->ft_face);
free (ft_font);
}
unsigned int g = FT_Get_Char_Index (ft_font->ft_face, unicode);
if (unlikely (!g))
- return false;
+ {
+ if (unlikely (ft_font->symbol) && unicode <= 0x00FFu)
+ {
+ /* 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". */
+ g = FT_Get_Char_Index (ft_font->ft_face, 0xF000u + unicode);
+ if (!g)
+ return false;
+ }
+ else
+ return false;
+ }
*glyph = g;
return true;
#endif
};
+ bool symbol = ft_face->charmap && ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
+
hb_font_set_funcs (font,
funcs,
- _hb_ft_font_create (ft_face, unref),
+ _hb_ft_font_create (ft_face, symbol, unref),
(hb_destroy_func_t) _hb_ft_font_destroy);
}
hb_ft_face_create_referenced (FT_Face ft_face)
{
FT_Reference_Face (ft_face);
- return hb_ft_face_create (ft_face, (hb_destroy_func_t) FT_Done_Face);
+ return hb_ft_face_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
}
static void
hb_ft_font_create_referenced (FT_Face ft_face)
{
FT_Reference_Face (ft_face);
- return hb_ft_font_create (ft_face, (hb_destroy_func_t) FT_Done_Face);
+ return hb_ft_font_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
}
return;
}
- FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE);
+ if (FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE))
+ FT_Select_Charmap (ft_face, FT_ENCODING_MS_SYMBOL);
FT_Set_Char_Size (ft_face,
abs (font->x_scale), abs (font->y_scale),