Work around cairo limitations
If we just draw an image, cairos recording surface complains that it is unbounded. Its not true of course. To make things work, clip to the extents.
This commit is contained in:
parent
9b9d7c7b8e
commit
4816be9ab5
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue