diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index a6b906408..c326770a8 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -956,6 +956,11 @@ struct CBDT if (unlikely (!get_extents (font, glyph, &pixel_extents, false))) return false; + funcs->push_clip_rectangle (data, + extents.x_bearing, extents.y_bearing, + extents.x_bearing + extents.width, + extents.y_bearing + extents.height); + funcs->image (data, blob, pixel_extents.width, -pixel_extents.height, @@ -963,6 +968,8 @@ struct CBDT font->slant_xy, &extents); + funcs->pop_clip (data); + hb_blob_destroy (blob); return true; } diff --git a/util/hb-cairo-utils.c b/util/hb-cairo-utils.c index 3613e09b6..27dda47e5 100644 --- a/util/hb-cairo-utils.c +++ b/util/hb-cairo-utils.c @@ -180,6 +180,15 @@ hb_cairo_paint_glyph_image (cairo_t *cr, if (!surface) return; + cairo_save (cr); + /* this clip is here to work around recording surface limitations */ + cairo_rectangle (cr, + extents->x_bearing, + extents->y_bearing, + extents->width, + extents->height); + cairo_clip (cr); + cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); @@ -200,6 +209,8 @@ hb_cairo_paint_glyph_image (cairo_t *cr, cairo_pattern_destroy (pattern); cairo_surface_destroy (surface); + + cairo_restore (cr); } static void