提交 4e478131 编写于 作者: B Behdad Esfahbod

[ft] Add hb_ft_font_changed()

When the font size or variations settings on underlying FT_Face change,
one can call hb_ft_font_changed() and continue using hb_font created using
hb_ft_font_create().

Fixes https://github.com/behdad/harfbuzz/issues/559

New API:
hb_ft_font_changed()
上级 94b3cafc
......@@ -291,6 +291,7 @@ hb_ft_face_create_cached
hb_ft_face_create_referenced
hb_ft_font_create
hb_ft_font_create_referenced
hb_ft_font_changed
hb_ft_font_get_face
hb_ft_font_set_load_flags
hb_ft_font_get_load_flags
......
......@@ -610,6 +610,19 @@ hb_ft_font_create (FT_Face ft_face,
font = hb_font_create (face);
hb_face_destroy (face);
_hb_ft_font_set_funcs (font, ft_face, false);
hb_ft_font_changed (font);
return font;
}
void
hb_ft_font_changed (hb_font_t *font)
{
if (font->destroy != _hb_ft_font_destroy)
return;
hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
FT_Face ft_face = ft_font->ft_face;
hb_font_set_scale (font,
(int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16),
(int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16));
......@@ -640,8 +653,6 @@ hb_ft_font_create (FT_Face ft_face,
free (mm_var);
}
#endif
return font;
}
/**
......
......@@ -116,7 +116,13 @@ hb_ft_font_set_load_flags (hb_font_t *font, int load_flags);
HB_EXTERN int
hb_ft_font_get_load_flags (hb_font_t *font);
/* Makes an hb_font_t use FreeType internally to implement font functions. */
/* Call when size or variations settings on underlying FT_Face change. */
HB_EXTERN void
hb_ft_font_changed (hb_font_t *font);
/* Makes an hb_font_t use FreeType internally to implement font functions.
* Note: this internally creates an FT_Face. Use it when you create your
* hb_face_t using hb_face_create(). */
HB_EXTERN void
hb_ft_font_set_funcs (hb_font_t *font);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册