[vector] Add new_path(), make _glyph_or_fail trivially thin

_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) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-18 04:14:34 -06:00
1 parent 82734f4ce5
commit bc3713f5f5
2 files changed
+10 -6

No files matched your search

+5 -6
View File
@@ -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;
+5
View File
@@ -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;