diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index 5d6705a6c..644b064ce 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -335,21 +335,13 @@ struct glyf_accelerator_t bool paint_glyph (hb_font_t *font, hb_codepoint_t gid, hb_paint_funcs_t *funcs, void *data) const { - int xscale, yscale; - unsigned int upem; - - hb_font_get_scale (font, &xscale, &yscale); - upem = hb_face_get_upem (hb_font_get_face (font)); - - funcs->push_transform (data, xscale/(float)upem, 0, - 0, yscale/(float)upem, - 0, 0); + funcs->push_root_transform (data, font); funcs->push_clip_glyph (data, gid); funcs->color (data, 0xffff, 1.); funcs->pop_clip (data); - funcs->pop_transform (data); + funcs->pop_root_transform (data); return false; } diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index 65bf6d739..76a66f0c9 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -555,21 +555,13 @@ bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoin bool OT::cff1::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const { - int xscale, yscale; - unsigned int upem; - - hb_font_get_scale (font, &xscale, &yscale); - upem = hb_face_get_upem (hb_font_get_face (font)); - - funcs->push_transform (data, xscale/(float)upem, 0, - 0, yscale/(float)upem, - 0, 0); + funcs->push_root_transform (data, font); funcs->push_clip_glyph (data, glyph); funcs->color (data, 0xffff, 1.); funcs->pop_clip (data); - funcs->pop_transform (data); + funcs->pop_root_transform (data); return false; } diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc index a6bdfac8a..983305c22 100644 --- a/src/hb-ot-cff2-table.cc +++ b/src/hb-ot-cff2-table.cc @@ -145,21 +145,13 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, bool OT::cff2::accelerator_t::paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data) const { - int xscale, yscale; - unsigned int upem; - - hb_font_get_scale (font, &xscale, &yscale); - upem = hb_face_get_upem (hb_font_get_face (font)); - - funcs->push_transform (data, xscale/(float)upem, 0, - 0, yscale/(float)upem, - 0, 0); + funcs->push_root_transform (data, font); funcs->push_clip_glyph (data, glyph); funcs->color (data, 0xffff, 1.); funcs->pop_clip (data); - funcs->pop_transform (data); + funcs->pop_root_transform (data); return false; } diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 4fd1e2baf..815b11549 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -1929,24 +1929,15 @@ struct COLR hb_paint_context_t c (this, funcs, data, instancer); - int xscale, yscale; - unsigned int upem; - - hb_font_get_scale (font, &xscale, &yscale); - upem = hb_face_get_upem (hb_font_get_face (font)); - const Paint *paint = get_base_glyph_paint (glyph); if (paint) { // COLRv1 glyph - // FIXME handle slant - funcs->push_transform (data, xscale/(float)upem, 0, - 0, yscale/(float)upem, - 0, 0); + c.funcs->push_root_transform (data, font); c.recurse (*paint); - c.funcs->pop_transform (c.data); + c.funcs->pop_root_transform (c.data); return true; } @@ -1955,10 +1946,7 @@ struct COLR if (record && ((hb_codepoint_t) record->glyphId == glyph)) { // COLRv0 glyph - // FIXME handle slant - funcs->push_transform (data, xscale/(float)upem, 0, - 0, yscale/(float)upem, - 0, 0); + funcs->push_root_transform (data, font); for (const auto &r : (this+layersZ).as_array (numLayers) .sub_array (record->firstLayerIdx, record->numLayers)) @@ -1968,7 +1956,7 @@ struct COLR c.funcs->pop_clip (c.data); } - c.funcs->pop_transform (c.data); + c.funcs->pop_root_transform (c.data); return true; } diff --git a/src/hb-paint.hh b/src/hb-paint.hh index c177e9c62..e97072e4c 100644 --- a/src/hb-paint.hh +++ b/src/hb-paint.hh @@ -132,6 +132,18 @@ struct hb_paint_funcs_t mode, !user_data ? nullptr : user_data->pop_group); } + void push_root_transform (void *paint_data, + hb_font_t *font) + { + int xscale, yscale; + float upem; + hb_font_get_scale (font, &xscale, &yscale); + upem = hb_face_get_upem (hb_font_get_face (font)); + func.push_transform (this, paint_data, xscale/upem, 0, 0, yscale/upem, 0, 0, + !user_data ? nullptr : user_data->push_transform); } + void pop_root_transform (void *paint_data) + { func.pop_transform (this, paint_data, + !user_data ? nullptr : user_data->pop_transform); } }; DECLARE_NULL_INSTANCE (hb_paint_funcs_t);