From 3e411b58d63bbcc745df9f51b86dcdc8dc6d0c03 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 13 Apr 2026 01:59:18 -0600 Subject: [PATCH] [api] Return hb_bool_t from hb_raster_draw_glyph and hb_gpu_draw_glyph Both were declared void, diverging from their sibling APIs (hb_vector_{draw,paint}_glyph, hb_raster_paint_glyph) which all return hb_bool_t, and from the font-level hb_font_draw_glyph_or_fail() pattern. Switch both to return hb_bool_t and route the internal call through hb_font_draw_glyph_or_fail() instead of hb_font_draw_glyph(). Returns false when the font has no outlines for the given glyph; true otherwise. Libraries are new/experimental; the ABI break is acceptable. Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-gpu-draw.cc | 9 ++++++--- src/hb-gpu.h | 2 +- src/hb-raster-draw.cc | 9 +++++++-- src/hb-raster.h | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/hb-gpu-draw.cc b/src/hb-gpu-draw.cc index c42ffe289..36df1b947 100644 --- a/src/hb-gpu-draw.cc +++ b/src/hb-gpu-draw.cc @@ -1044,9 +1044,12 @@ hb_gpu_draw_get_scale (const hb_gpu_draw_t *draw, * encoder using hb_font_draw_glyph(). Also sets the font scale * on the encoder. * + * Return value: `true` if the glyph was drawn, `false` if the font + * has no outlines for @codepoint. + * * Since: 14.0.0 **/ -void +hb_bool_t hb_gpu_draw_glyph (hb_gpu_draw_t *draw, hb_font_t *font, hb_codepoint_t codepoint) @@ -1055,8 +1058,8 @@ hb_gpu_draw_glyph (hb_gpu_draw_t *draw, hb_font_get_scale (font, &x_scale, &y_scale); hb_gpu_draw_set_scale (draw, x_scale, y_scale); - hb_font_draw_glyph (font, codepoint, - hb_gpu_draw_get_funcs (), + return hb_font_draw_glyph_or_fail (font, codepoint, + hb_gpu_draw_get_funcs (), draw); } diff --git a/src/hb-gpu.h b/src/hb-gpu.h index 744eed63a..1ce9469b9 100644 --- a/src/hb-gpu.h +++ b/src/hb-gpu.h @@ -106,7 +106,7 @@ hb_gpu_draw_get_scale (const hb_gpu_draw_t *draw, HB_EXTERN hb_draw_funcs_t * hb_gpu_draw_get_funcs (void); -HB_EXTERN void +HB_EXTERN hb_bool_t hb_gpu_draw_glyph (hb_gpu_draw_t *draw, hb_font_t *font, hb_codepoint_t codepoint); diff --git a/src/hb-raster-draw.cc b/src/hb-raster-draw.cc index 49b8d8296..18192bc66 100644 --- a/src/hb-raster-draw.cc +++ b/src/hb-raster-draw.cc @@ -963,9 +963,12 @@ hb_raster_draw_get_funcs (void) * rasterizer's current transform. The pen coordinates are applied before * minification and are transformed by the current affine transform. * + * Return value: `true` if the glyph was drawn, `false` if the font has + * no outlines for @glyph. + * * Since: 13.0.0 **/ -void +hb_bool_t hb_raster_draw_glyph (hb_raster_draw_t *draw, hb_font_t *font, hb_codepoint_t glyph, @@ -983,8 +986,10 @@ hb_raster_draw_glyph (hb_raster_draw_t *draw, xx, yx, xy, yy, dx + xx * pen_x + xy * pen_y, dy + yx * pen_x + yy * pen_y); - hb_font_draw_glyph (font, glyph, hb_raster_draw_get_funcs (), draw); + hb_bool_t ret = hb_font_draw_glyph_or_fail (font, glyph, + hb_raster_draw_get_funcs (), draw); hb_raster_draw_set_transform (draw, xx, yx, xy, yy, dx, dy); + return ret; } diff --git a/src/hb-raster.h b/src/hb-raster.h index d06fb7140..2702dfa4b 100644 --- a/src/hb-raster.h +++ b/src/hb-raster.h @@ -195,7 +195,7 @@ hb_raster_draw_set_glyph_extents (hb_raster_draw_t *draw, HB_EXTERN hb_draw_funcs_t * hb_raster_draw_get_funcs (void); -HB_EXTERN void +HB_EXTERN hb_bool_t hb_raster_draw_glyph (hb_raster_draw_t *draw, hb_font_t *font, hb_codepoint_t glyph,