From 432afa9dffd17df382b17c473e5c4d8199cdf8a4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 7 Jan 2023 16:25:30 -0700 Subject: [PATCH] [paint] Fix paint_extents usage It was broken all this time :(. The two backends do this slightly differently... --- src/OT/Color/COLR/COLR.hh | 13 +++---------- src/hb-ft-colr.hh | 3 +++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 41d57ae93..408ed5060 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -2045,7 +2045,6 @@ struct COLR hb_array (font->coords, font->num_coords)); bool is_bounded = true; - bool pop_clip_first = true; if (clip) { hb_glyph_extents_t extents; @@ -2063,6 +2062,8 @@ struct COLR } else { + c.funcs->push_root_transform (c.data, font); + auto *extents_funcs = hb_paint_extents_get_funcs (); hb_paint_extents_context_t extents_data; @@ -2078,24 +2079,16 @@ struct COLR extents.ymin, extents.xmax, extents.ymax); - - c.funcs->push_root_transform (c.data, font); - - pop_clip_first = false; } } if (is_bounded) c.recurse (*paint); - if (clip && pop_clip_first) - c.funcs->pop_clip (c.data); + c.funcs->pop_clip (c.data); c.funcs->pop_transform (c.data); - if (clip && !pop_clip_first) - c.funcs->pop_clip (c.data); - return true; } } diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index e1f234f8f..642897fd9 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -454,12 +454,15 @@ hb_ft_paint_glyph_colr (hb_font_t *font, } else { + auto *extents_funcs = hb_paint_extents_get_funcs (); hb_paint_extents_context_t extents_data; hb_ft_paint_context_t ce (ft_font, font, extents_funcs, &extents_data, palette, foreground); + ce.funcs->push_root_transform (ce.data, font); ce.recurse (paint); + ce.funcs->pop_transform (ce.data); hb_extents_t extents = extents_data.get_extents (); is_bounded = extents_data.is_bounded ();