diff --git a/src/hb-font.hh b/src/hb-font.hh index b53134fa0..8d7bb2703 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -719,7 +719,13 @@ struct hb_font_t // Slant before embolden; produces nicer results. if (slanted) + { + hb_position_t xo = 0, yo = 0; + get_glyph_h_origin (glyph, &xo, &yo, false); + outline.translate (-xo, -yo); outline.slant (slant_xy); + outline.translate (xo, yo); + } if (embolden) { diff --git a/src/hb-outline.cc b/src/hb-outline.cc index d180e7c4f..75ee3041a 100644 --- a/src/hb-outline.cc +++ b/src/hb-outline.cc @@ -84,6 +84,15 @@ void hb_outline_t::replay (hb_draw_funcs_t *pen, void *pen_data) const } } +void hb_outline_t::translate (float dx, float dy) +{ + for (auto &p : points) + { + p.x += dx; + p.y += dy; + } +} + void hb_outline_t::slant (float slant_xy) { for (auto &p : points) diff --git a/src/hb-outline.hh b/src/hb-outline.hh index 060ad775f..ed1057b8a 100644 --- a/src/hb-outline.hh +++ b/src/hb-outline.hh @@ -69,6 +69,7 @@ struct hb_outline_t HB_INTERNAL void replay (hb_draw_funcs_t *pen, void *pen_data) const; HB_INTERNAL float control_area () const; + HB_INTERNAL void translate (float dx, float dy); HB_INTERNAL void slant (float slant_xy); HB_INTERNAL void embolden (float x_strength, float y_strength, float x_shift, float y_shift);