diff --git a/src/hb-paint-extents.hh b/src/hb-paint-extents.hh index b80d8e26c..bc5762562 100644 --- a/src/hb-paint-extents.hh +++ b/src/hb-paint-extents.hh @@ -438,7 +438,7 @@ hb_paint_extents_pop_group (hb_paint_funcs_t *funcs HB_UNUSED, c->pop_group (mode); } -static void +static hb_bool_t hb_paint_extents_paint_image (hb_paint_funcs_t *funcs HB_UNUSED, void *paint_data, hb_blob_t *blob HB_UNUSED, @@ -458,6 +458,8 @@ hb_paint_extents_paint_image (hb_paint_funcs_t *funcs HB_UNUSED, c->push_clip (extents); c->paint (); c->pop_clip (); + + return true; } static void diff --git a/src/hb-paint.cc b/src/hb-paint.cc index 9ae01a235..6e20a6024 100644 --- a/src/hb-paint.cc +++ b/src/hb-paint.cc @@ -75,7 +75,7 @@ hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_color_t color, void *user_data) {} -static void +static hb_bool_t hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_blob_t *image, unsigned int width, @@ -83,7 +83,7 @@ hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data, hb_tag_t format, float slant_xy, hb_glyph_extents_t *extents, - void *user_data) {} + void *user_data) { return false; } static void hb_paint_linear_gradient_nil (hb_paint_funcs_t *funcs, void *paint_data, diff --git a/src/hb-paint.h b/src/hb-paint.h index a76d5392b..7bd88124d 100644 --- a/src/hb-paint.h +++ b/src/hb-paint.h @@ -270,17 +270,19 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs, * The image dimensions and glyph extents are provided if available, * and should be used to size and position the image. * + * Return value: Whether the operation was successful. + * * Since: REPLACEME */ -typedef void (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs, - void *paint_data, - hb_blob_t *image, - unsigned int width, - unsigned int height, - hb_tag_t format, - float slant, - hb_glyph_extents_t *extents, - void *user_data); +typedef hb_bool_t (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs, + void *paint_data, + hb_blob_t *image, + unsigned int width, + unsigned int height, + hb_tag_t format, + float slant, + hb_glyph_extents_t *extents, + void *user_data); /** * hb_color_stop_t: diff --git a/test/api/test-paint.c b/test/api/test-paint.c index e1331ca0d..acbdeedf1 100644 --- a/test/api/test-paint.c +++ b/test/api/test-paint.c @@ -40,7 +40,9 @@ typedef struct { GString *string; } paint_data_t; -static void +static void print (paint_data_t *data, const char *format, ...) __attribute__((format (printf, 2, 3))); + +void print (paint_data_t *data, const char *format, ...) @@ -133,7 +135,7 @@ paint_color (hb_paint_funcs_t *funcs, hb_color_get_alpha (color)); } -static void +static hb_bool_t paint_image (hb_paint_funcs_t *funcs, void *paint_data, hb_blob_t *blob, @@ -151,6 +153,8 @@ paint_image (hb_paint_funcs_t *funcs, print (data, "image type %s size %u %u slant %f extents %d %d %d %d\n", buf, width, height, slant, extents->x_bearing, extents->y_bearing, extents->width, extents->height); + + return TRUE; } static void diff --git a/util/hb-cairo-utils.c b/util/hb-cairo-utils.c index 27dda47e5..59ae87319 100644 --- a/util/hb-cairo-utils.c +++ b/util/hb-cairo-utils.c @@ -106,7 +106,7 @@ _hb_cairo_destroy_blob (void *p) hb_blob_destroy ((hb_blob_t *) p); } -void +hb_bool_t hb_cairo_paint_glyph_image (cairo_t *cr, hb_blob_t *blob, unsigned width, @@ -116,7 +116,7 @@ hb_cairo_paint_glyph_image (cairo_t *cr, hb_glyph_extents_t *extents) { if (!extents) /* SVG currently. */ - return; + return FALSE; cairo_surface_t *surface = NULL; @@ -140,7 +140,7 @@ hb_cairo_paint_glyph_image (cairo_t *cr, /* Byte-endian conversion. */ unsigned data_size = hb_blob_get_length (blob); if (data_size < width * height * 4) - return; + return FALSE; unsigned char *data; #ifdef __BYTE_ORDER @@ -148,7 +148,7 @@ hb_cairo_paint_glyph_image (cairo_t *cr, { data = (unsigned char *) hb_blob_get_data_writable (blob, NULL); if (!data) - return; + return FALSE; unsigned count = width * height * 4; for (unsigned i = 0; i < count; i += 4) @@ -178,7 +178,7 @@ hb_cairo_paint_glyph_image (cairo_t *cr, } if (!surface) - return; + return FALSE; cairo_save (cr); /* this clip is here to work around recording surface limitations */ @@ -211,6 +211,8 @@ hb_cairo_paint_glyph_image (cairo_t *cr, cairo_surface_destroy (surface); cairo_restore (cr); + + return TRUE; } static void diff --git a/util/hb-cairo-utils.h b/util/hb-cairo-utils.h index fdf7c01af..9309e10dc 100644 --- a/util/hb-cairo-utils.h +++ b/util/hb-cairo-utils.h @@ -70,13 +70,13 @@ hb_paint_composite_mode_to_cairo (hb_paint_composite_mode_t mode) return CAIRO_OPERATOR_SOURCE; } -void hb_cairo_paint_glyph_image (cairo_t *cr, - hb_blob_t *blob, - unsigned width, - unsigned height, - hb_tag_t format, - float slant, - hb_glyph_extents_t *extents); +hb_bool_t hb_cairo_paint_glyph_image (cairo_t *cr, + hb_blob_t *blob, + unsigned width, + unsigned height, + hb_tag_t format, + float slant, + hb_glyph_extents_t *extents); void hb_cairo_paint_linear_gradient (cairo_t *cr, hb_color_line_t *color_line, diff --git a/util/helper-cairo-user.hh b/util/helper-cairo-user.hh index 3c54036bc..97ce2161c 100644 --- a/util/helper-cairo-user.hh +++ b/util/helper-cairo-user.hh @@ -282,7 +282,7 @@ paint_color (hb_paint_funcs_t *funcs, cairo_paint (cr); } -static void +static hb_bool_t paint_image (hb_paint_funcs_t *funcs, void *paint_data, hb_blob_t *blob, @@ -302,7 +302,7 @@ paint_image (hb_paint_funcs_t *funcs, buf, width, height, (double) slant, extents->x_bearing, extents->y_bearing, extents->width, extents->height); - hb_cairo_paint_glyph_image (cr, blob, width, height, format, slant, extents); + return hb_cairo_paint_glyph_image (cr, blob, width, height, format, slant, extents); } static void