[paint-extents] Clean up

This commit is contained in:
Behdad Esfahbod 2022-12-23 17:33:13 -07:00
parent dbea503a38
commit 02684751bd
3 changed files with 25 additions and 9 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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 ();