diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index e25609a66..da1ce5513 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -374,14 +374,14 @@ _hb_ft_paint (hb_ft_paint_context_t *c, { float dx = paint.u.skew.center_x / 65536.f; float dy = paint.u.skew.center_y / 65536.f; - float x = +tanf (paint.u.skew.x_skew_angle / 65536.f * (float) M_PI); - float y = -tanf (paint.u.skew.y_skew_angle / 65536.f * (float) M_PI); + float sx = paint.u.skew.x_skew_angle / 65536.f; + float sy = paint.u.skew.y_skew_angle / 65536.f; c->funcs->push_translate (c->data, +dx, +dy); - c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.); + c->funcs->push_skew (c->data, sx, sy); c->funcs->push_translate (c->data, -dx, -dy); c->recurse (paint.u.skew.paint); c->funcs->pop_translate (c->data, -dx, -dy); - c->funcs->pop_transform (c->data); + c->funcs->pop_skew (c->data, sx, sy); c->funcs->pop_translate (c->data, +dx, +dy); } break; diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index c37e710e4..cabbb9642 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -1153,11 +1153,11 @@ struct PaintSkew void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - float x = +tanf (xSkewAngle.to_float(c->instancer (varIdxBase, 0)) * (float) M_PI); - float y = -tanf (ySkewAngle.to_float(c->instancer (varIdxBase, 1)) * (float) M_PI); - c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.); + float sx = xSkewAngle.to_float(c->instancer (varIdxBase, 0)); + float sy = ySkewAngle.to_float(c->instancer (varIdxBase, 1)); + c->funcs->push_skew (c->data, sx, sy); c->recurse (this+src); - c->funcs->pop_transform (c->data); + c->funcs->pop_skew (c->data, sx, sy); } HBUINT8 format; /* format = 28(noVar) or 29 (Var) */ @@ -1189,16 +1189,16 @@ struct PaintSkewAroundCenter void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - float x = +tanf (xSkewAngle.to_float(c->instancer (varIdxBase, 0)) * (float) M_PI); - float y = -tanf (ySkewAngle.to_float(c->instancer (varIdxBase, 1)) * (float) M_PI); + float sx = xSkewAngle.to_float(c->instancer (varIdxBase, 0)); + float sy = ySkewAngle.to_float(c->instancer (varIdxBase, 1)); float tCenterX = centerX + c->instancer (varIdxBase, 2); float tCenterY = centerY + c->instancer (varIdxBase, 3); c->funcs->push_translate (c->data, +tCenterX, +tCenterY); - c->funcs->push_transform (c->data, 1., y, x, 1., 0., 0.); + c->funcs->push_skew (c->data, sx, sy); c->funcs->push_translate (c->data, -tCenterX, -tCenterY); c->recurse (this+src); c->funcs->pop_translate (c->data, -tCenterX, -tCenterY); - c->funcs->pop_transform (c->data); + c->funcs->pop_skew (c->data, sx, sy); c->funcs->pop_translate (c->data, +tCenterX, +tCenterY); } diff --git a/src/hb-paint.hh b/src/hb-paint.hh index 05fcaa923..55c85b431 100644 --- a/src/hb-paint.hh +++ b/src/hb-paint.hh @@ -218,6 +218,23 @@ struct hb_paint_funcs_t if (a) pop_transform (paint_data); } + + void push_skew (void *paint_data, + float sx, float sy) + { + if (sx || sy) + { + float x = +tanf (sx * (float) M_PI); + float y = -tanf (sy * (float) M_PI); + push_transform (paint_data, 1.f, y, x, 1.f, 0.f, 0.f); + } + } + void pop_skew (void *paint_data, + float sx, float sy) + { + if (sx || sy) + pop_transform (paint_data); + } }; DECLARE_NULL_INSTANCE (hb_paint_funcs_t);