diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-21 23:35:31 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-07-21 23:35:31 +0000 |
commit | 36343bff25bdcaabfcc4188f3a4ef78d126e2649 (patch) | |
tree | 30a3e4758e20989c474e5113216e1b04fbea96b2 /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc | |
parent | 18dfb9521bc655a3a1fcc29063fb102522769f5f (diff) |
harfbuzz 1.3.0
git-svn-id: svn://tug.org/texlive/trunk@41748 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc index 2cad8c26495..eaa1311d445 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -70,11 +70,12 @@ struct hb_ft_font_t { 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)); @@ -82,6 +83,7 @@ _hb_ft_font_create (FT_Face ft_face, bool unref) 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; @@ -90,10 +92,16 @@ _hb_ft_font_create (FT_Face ft_face, bool unref) } 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); } @@ -165,7 +173,21 @@ hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED, 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; @@ -444,9 +466,11 @@ retry: #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); } @@ -526,7 +550,7 @@ hb_face_t * 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 @@ -606,7 +630,7 @@ hb_font_t * 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); } @@ -675,7 +699,8 @@ hb_ft_font_set_funcs (hb_font_t *font) 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), |