diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index a54ee0dcc..3fb40e109 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -456,6 +456,7 @@ hb_ft_paint_glyph_colr (hb_font_t *font, FT_COLOR_NO_ROOT_TRANSFORM, &paint)) { + bool is_bounded = true; FT_ClipBox clip_box; if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box)) paint_funcs->push_clip_rectangle (paint_data, @@ -471,11 +472,13 @@ hb_ft_paint_glyph_colr (hb_font_t *font, extents_funcs, &extents_data, palette, foreground); _hb_ft_paint (&c, paint); + hb_extents_t extents = extents_data.get_extents (); + is_bounded = extents_data.is_bounded (); paint_funcs->push_clip_rectangle (paint_data, - extents_data.groups.tail().extents.xmin, - extents_data.groups.tail().extents.ymin, - extents_data.groups.tail().extents.xmax, - extents_data.groups.tail().extents.ymax); + extents.xmin, + extents.ymin, + extents.xmax, + extents.ymax); hb_paint_funcs_destroy (extents_funcs); } @@ -485,7 +488,9 @@ hb_ft_paint_glyph_colr (hb_font_t *font, hb_ft_paint_context_t c (ft_font, font, paint_funcs, paint_data, palette, foreground); - _hb_ft_paint (&c, paint); + + if (is_bounded) + _hb_ft_paint (&c, paint); paint_funcs->pop_root_transform (paint_data); paint_funcs->pop_clip (paint_data); diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 6f1b23d30..1cdde5adb 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -2002,10 +2002,11 @@ struct COLR hb_paint_extents_context_t extents_data; paint_glyph (font, glyph, extents_funcs, &extents_data, 0, HB_COLOR(0,0,0,0)); - extents->x_bearing = extents_data.groups.tail().extents.xmin; - extents->y_bearing = extents_data.groups.tail().extents.ymax; - extents->width = extents_data.groups.tail().extents.xmax - extents_data.groups.tail().extents.xmin, - extents->height = extents_data.groups.tail().extents.ymin - extents_data.groups.tail().extents.ymax; + hb_extents_t e = extents_data.get_extents (); + extents->x_bearing = e.xmin; + extents->y_bearing = e.ymax; + extents->width = e.xmax - e.xmin, + extents->height = e.ymin - e.ymax; hb_paint_funcs_destroy (extents_funcs); diff --git a/src/hb-paint-extents.hh b/src/hb-paint-extents.hh index 69484d97e..01f91d243 100644 --- a/src/hb-paint-extents.hh +++ b/src/hb-paint-extents.hh @@ -138,6 +138,16 @@ struct hb_paint_extents_context_t { transforms.push (hb_transform_t{}); } + hb_extents_t get_extents () + { + return groups.tail().extents; + } + + bool is_bounded () + { + return groups.tail().status != hb_bounds_t::status_t::UNBOUNDED; + } + void push_transform (const hb_transform_t &trans) { hb_transform_t r = transforms.tail ();