From 47c896f0040c4fd6b6c91cdbc0f4f0fa2e9f6582 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 23 Dec 2022 16:20:44 -0700 Subject: [PATCH] [paint-extents] Hook it up, kinda --- src/hb-ft-colr.hh | 25 +++++++++++++++++++------ src/hb-ot-color-colr-table.hh | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index f87a347fa..0efd7e7d0 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -457,15 +457,29 @@ hb_ft_paint_glyph_colr (hb_font_t *font, &paint)) { FT_ClipBox clip_box; - bool has_clip; - - has_clip = FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box); - if (has_clip) + if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box)) paint_funcs->push_clip_rectangle (paint_data, clip_box.bottom_left.x - font->slant_xy * clip_box.bottom_left.y, clip_box.bottom_left.y, clip_box.top_right.x - font->slant_xy * clip_box.top_right.y, clip_box.top_right.y); + else + { + /* XXX Untested. */ + auto *extents_funcs = hb_paint_extents_get_funcs (); + hb_paint_extents_context_t extents_data; + hb_ft_paint_context_t c (ft_font, font, + extents_funcs, &extents_data, + palette, foreground); + _hb_ft_paint (&c, paint); + 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); + + hb_paint_funcs_destroy (extents_funcs); + } paint_funcs->push_root_transform (paint_data, font); @@ -475,8 +489,7 @@ hb_ft_paint_glyph_colr (hb_font_t *font, _hb_ft_paint (&c, paint); paint_funcs->pop_root_transform (paint_data); - if (has_clip) - paint_funcs->pop_clip (paint_data); + paint_funcs->pop_clip (paint_data); return true; } diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 0194e100b..c9d1f563c 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -33,6 +33,7 @@ #include "hb-ot-layout-common.hh" #include "hb-ot-var-common.hh" #include "hb-paint.hh" +#include "hb-paint-extents.hh" /* * COLR -- Color @@ -1997,6 +1998,21 @@ struct COLR return true; } +#if 0 + /* This currently goes into infinite recursion. */ + + auto *extents_funcs = hb_paint_extents_get_funcs (); + hb_paint_extents_context_t extents_data; + paint_glyph (font, glyph, extents_funcs, &extents_data, 0, HB_COLOR(0,0,0,0)); + + extents_data.groups.tail().extents.xmin, + extents_data.groups.tail().extents.ymin, + extents_data.groups.tail().extents.xmax, + extents_data.groups.tail().extents.ymax; + + hb_paint_funcs_destroy (extents_funcs); +#endif + return false; }