[util/gpu] demo-font: tolerate NULL paint encode

hb_gpu_paint_encode returns NULL when the glyph uses unsupported
paint features (e.g. COLRv1 gradients/transforms) or emits zero
ops.  Treat that as an empty glyph instead of die()-ing the whole
app, so fonts mixing supported and unsupported paint still render
their supported parts.

Zero-init hb_ext so the empty-glyph extents are well-defined, and
skip recycle_blob when blob is NULL.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-13 18:12:23 -06:00
1 parent b616298d73
commit 736d59bf72
1 file changed
+4 -6
+4 -6
View File
@@ -104,12 +104,9 @@ _demo_font_upload_glyph (demo_font_t *font,
hb_gpu_paint_clear (font->p);
hb_gpu_paint_glyph (font->p, font->font, glyph_index);
hb_glyph_extents_t hb_ext;
hb_glyph_extents_t hb_ext = {};
hb_blob_t *blob = hb_gpu_paint_encode (font->p, &hb_ext);
if (!blob)
die ("Failed encoding glyph");
unsigned int len = hb_blob_get_length (blob);
unsigned int len = blob ? hb_blob_get_length (blob) : 0;
glyph_info->extents.min_x = hb_ext.x_bearing;
glyph_info->extents.max_x = hb_ext.x_bearing + hb_ext.width;
@@ -129,7 +126,8 @@ _demo_font_upload_glyph (demo_font_t *font,
font->num_glyphs++;
font->sum_bytes += len;
hb_gpu_paint_recycle_blob (font->p, blob);
if (blob)
hb_gpu_paint_recycle_blob (font->p, blob);
}
void