diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index c315c550f..0672033ea 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -2695,6 +2695,7 @@ struct COLR { // COLRv1 glyph + bool is_bounded = true; if (clip) { hb_glyph_extents_t extents; @@ -2709,12 +2710,30 @@ struct COLR extents.y_bearing); } else + { clip = false; + is_bounded = false; + } + + if (!is_bounded) + { + auto *bounded_funcs = hb_paint_bounded_get_funcs (); + scratch.paint_bounded.clear (); + + paint_glyph (font, glyph, + bounded_funcs, &scratch.paint_bounded, + palette_index, foreground, + false, + scratch); + + is_bounded = scratch.paint_bounded.is_bounded (); + } } c.funcs->push_font_transform (c.data, font); - c.recurse (*paint); + if (is_bounded) + c.recurse (*paint); c.funcs->pop_transform (c.data); diff --git a/src/hb-font.hh b/src/hb-font.hh index acb0a2eda..5e23bd040 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -35,7 +35,6 @@ #include "hb-atomic.hh" #include "hb-shaper.hh" #include "hb-outline.hh" -#include "hb-paint-bounded.hh" /* @@ -525,19 +524,6 @@ struct hb_font_t unsigned int palette, hb_color_t foreground) { - /* COLRv1 spec says a glyph must not be painted if the paint graph - * draws unbounded. Implement this here such that all font-funcs - * benefit, since we have the code. */ - auto *bounded_funcs = hb_paint_bounded_get_funcs (); - hb_paint_bounded_context_t bounded_data; - klass->get.f.paint_glyph (this, user_data, - glyph, - bounded_funcs, &bounded_data, - palette, foreground, - !klass->user_data ? nullptr : klass->user_data->paint_glyph); - if (!bounded_data.is_bounded ()) - return; - klass->get.f.paint_glyph (this, user_data, glyph, paint_funcs, paint_data, diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 45cf81c13..051201bd9 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -28,6 +28,7 @@ #include "hb.hh" #include "hb-decycler.hh" +#include "hb-paint-bounded.hh" #include FT_COLOR_H @@ -512,6 +513,7 @@ hb_ft_paint_glyph_colr (hb_font_t *font, node.visit (gid); bool clip = false; + bool is_bounded = false; FT_ClipBox clip_box; if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box)) { @@ -525,11 +527,25 @@ hb_ft_paint_glyph_colr (hb_font_t *font, font->slant_xy * clip_box.top_right.y)), clip_box.top_right.y); clip = true; + is_bounded = true; + } + if (!is_bounded) + { + auto *bounded_funcs = hb_paint_bounded_get_funcs (); + hb_paint_bounded_context_t bounded_data; + hb_ft_paint_context_t ce (ft_font, font, + bounded_funcs, &bounded_data, + palette_array, palette_index, foreground); + hb_decycler_node_t node2 (ce.glyphs_decycler); + node2.visit (gid); + ce.recurse (paint); + is_bounded = bounded_data.is_bounded (); } c.funcs->push_font_transform (c.data, font); - c.recurse (paint); + if (is_bounded) + c.recurse (paint); c.funcs->pop_transform (c.data);