diff --git a/src/hb-font.cc b/src/hb-font.cc index 7a430237c..b6b668dd8 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -103,7 +103,7 @@ hb_font_get_nominal_glyph_default (hb_font_t *font, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - if (font->has_nominal_glyphs_func ()) + if (font->has_nominal_glyphs_func_set ()) { return font->get_nominal_glyphs (1, &unicode, 0, glyph, 0); } @@ -121,7 +121,7 @@ hb_font_get_nominal_glyphs_default (hb_font_t *font, unsigned int glyph_stride, void *user_data HB_UNUSED) { - if (font->has_nominal_glyph_func ()) + if (font->has_nominal_glyph_func_set ()) { for (unsigned int i = 0; i < count; i++) { @@ -176,7 +176,7 @@ hb_font_get_glyph_h_advance_default (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - if (font->has_glyph_h_advances_func ()) + if (font->has_glyph_h_advances_func_set ()) { hb_position_t ret; font->get_glyph_h_advances (1, &glyph, 0, &ret, 0); @@ -200,7 +200,7 @@ hb_font_get_glyph_v_advance_default (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - if (font->has_glyph_v_advances_func ()) + if (font->has_glyph_v_advances_func_set ()) { hb_position_t ret; font->get_glyph_v_advances (1, &glyph, 0, &ret, 0); @@ -220,7 +220,7 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font, unsigned int advance_stride, void *user_data HB_UNUSED) { - if (font->has_glyph_h_advance_func ()) + if (font->has_glyph_h_advance_func_set ()) { for (unsigned int i = 0; i < count; i++) { @@ -252,7 +252,7 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font, unsigned int advance_stride, void *user_data HB_UNUSED) { - if (font->has_glyph_v_advance_func ()) + if (font->has_glyph_v_advance_func_set ()) { for (unsigned int i = 0; i < count; i++) { @@ -687,10 +687,16 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT +bool +hb_font_t::has_func_set (unsigned int i) +{ + return this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]; +} + bool hb_font_t::has_func (unsigned int i) { - return (this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]) || + return has_func_set (i) || (parent && parent != &_hb_Null_hb_font_t && parent->has_func (i)); } diff --git a/src/hb-font.hh b/src/hb-font.hh index e10d56745..2df5e42ee 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -171,6 +171,7 @@ struct hb_font_t /* Public getters */ HB_INTERNAL bool has_func (unsigned int i); + HB_INTERNAL bool has_func_set (unsigned int i); /* has_* ... */ #define HB_FONT_FUNC_IMPLEMENT(name) \ @@ -180,6 +181,13 @@ struct hb_font_t hb_font_funcs_t *funcs = this->klass; \ unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \ return has_func (i); \ + } \ + bool \ + has_##name##_func_set (void) \ + { \ + hb_font_funcs_t *funcs = this->klass; \ + unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \ + return has_func_set (i); \ } HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT