提交 755b44cc 编写于 作者: B Behdad Esfahbod

[ft] Round metrics instead of truncate

Lohit-Punjabi has a upem of 769!  We were losing one unit in our
code, and FreeType is losing another one...  Test with U+0A06.
Has an advance of 854 in the font.  We were producing 852.
Now we do 853, which is what FreeType is telling us.
上级 9a49351c
...@@ -94,7 +94,7 @@ hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, ...@@ -94,7 +94,7 @@ hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v))) if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v)))
return 0; return 0;
return v >> 10; return (v + (1<<9)) >> 10;
} }
static hb_position_t static hb_position_t
...@@ -112,7 +112,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED, ...@@ -112,7 +112,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
* have a Y growing upward. Hence the extra negation. */ * have a Y growing upward. Hence the extra negation. */
return -v >> 10; return (-v + (1<<9)) >> 10;
} }
static hb_bool_t static hb_bool_t
...@@ -418,8 +418,8 @@ hb_ft_font_create (FT_Face ft_face, ...@@ -418,8 +418,8 @@ hb_ft_font_create (FT_Face ft_face,
_hb_ft_get_font_funcs (), _hb_ft_get_font_funcs (),
ft_face, (hb_destroy_func_t) _do_nothing); ft_face, (hb_destroy_func_t) _do_nothing);
hb_font_set_scale (font, hb_font_set_scale (font,
((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM) >> 16, ((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16,
((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM) >> 16); ((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16);
hb_font_set_ppem (font, hb_font_set_ppem (font,
ft_face->size->metrics.x_ppem, ft_face->size->metrics.x_ppem,
ft_face->size->metrics.y_ppem); ft_face->size->metrics.y_ppem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册