Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: third_party/harfbuzz-ng/src/hb-ft.cc

Issue 2163983005: Roll HarfBuzz to 1.3.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font-private.hh ('k') | third_party/harfbuzz-ng/src/hb-gobject-structs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/harfbuzz-ng/src/hb-ft.cc
diff --git a/third_party/harfbuzz-ng/src/hb-ft.cc b/third_party/harfbuzz-ng/src/hb-ft.cc
index 2cad8c2649572c64c460ceca9158dead2656dc1c..eaa1311d445fb2d033267efbe2800d0395d9f4d6 100644
--- a/third_party/harfbuzz-ng/src/hb-ft.cc
+++ b/third_party/harfbuzz-ng/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),
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font-private.hh ('k') | third_party/harfbuzz-ng/src/hb-gobject-structs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698