From bc3713f5f52d2039f4f7de330620b51339abd00a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 18 Apr 2026 04:14:34 -0600 Subject: [PATCH] [vector] Add new_path(), make _glyph_or_fail trivially thin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _glyph_or_fail is now: extend extents, new_path, draw. No format switch, no flush — just accumulate. new_path() flushes any pending path and starts a fresh one, separating glyph outlines so they don't interact under fill rules. Flush also happens on foreground change and at render time, so the last pending path is always emitted. Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-vector-draw.cc | 11 +++++------ src/hb-vector-draw.hh | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/hb-vector-draw.cc b/src/hb-vector-draw.cc index be2e48399..8a41b33ce 100644 --- a/src/hb-vector-draw.cc +++ b/src/hb-vector-draw.cc @@ -508,12 +508,8 @@ hb_vector_draw_glyph_or_fail (hb_vector_draw_t *draw, } } - draw->flush_path (); - hb_font_draw_glyph (font, glyph, hb_vector_draw_get_funcs (draw), draw); - if (!draw->path.length) - return false; - draw->flush_path (); - return true; + draw->new_path (); + return hb_font_draw_glyph_or_fail (font, glyph, hb_vector_draw_get_funcs (draw), draw); } /** @@ -585,6 +581,7 @@ void hb_vector_draw_set_foreground (hb_vector_draw_t *draw, hb_color_t foreground) { + draw->flush_path (); draw->foreground = foreground; } @@ -641,6 +638,7 @@ hb_vector_draw_get_background (const hb_vector_draw_t *draw) static hb_blob_t * hb_vector_draw_render_pdf (hb_vector_draw_t *draw) { + draw->flush_path (); if (!draw->has_extents) return nullptr; @@ -755,6 +753,7 @@ hb_vector_draw_render_pdf (hb_vector_draw_t *draw) static hb_blob_t * hb_vector_draw_render_svg (hb_vector_draw_t *draw) { + draw->flush_path (); if (!draw->has_extents) return nullptr; diff --git a/src/hb-vector-draw.hh b/src/hb-vector-draw.hh index 7d5f0dda5..d2458cd89 100644 --- a/src/hb-vector-draw.hh +++ b/src/hb-vector-draw.hh @@ -39,6 +39,11 @@ struct hb_vector_draw_t unsigned get_precision () const { return path.precision; } hb_blob_t *recycled_blob = nullptr; + void new_path () + { + flush_path (); + } + void flush_path () { if (!path.length) return;