From 736d59bf7286f31a91da922ccc64a8e4c1f29dd1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 13 Apr 2026 18:12:23 -0600 Subject: [PATCH] [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) --- util/gpu/demo-font.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/util/gpu/demo-font.cc b/util/gpu/demo-font.cc index 2a89ad3e9..78f430a82 100644 --- a/util/gpu/demo-font.cc +++ b/util/gpu/demo-font.cc @@ -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