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)))
|
if (unlikely (!get_extents (font, glyph, &pixel_extents, false)))
|
||||||
return 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,
|
funcs->image (data,
|
||||||
blob,
|
blob,
|
||||||
pixel_extents.width, -pixel_extents.height,
|
pixel_extents.width, -pixel_extents.height,
|
||||||
|
@ -963,6 +968,8 @@ struct CBDT
|
||||||
font->slant_xy,
|
font->slant_xy,
|
||||||
&extents);
|
&extents);
|
||||||
|
|
||||||
|
funcs->pop_clip (data);
|
||||||
|
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,6 +180,15 @@ hb_cairo_paint_glyph_image (cairo_t *cr,
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return;
|
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_t *pattern = cairo_pattern_create_for_surface (surface);
|
||||||
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
|
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_pattern_destroy (pattern);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue