From 8fc1d1bfd13ec21341606ec2421cb3904f79f0d0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 12 Mar 2026 01:46:46 -0300 Subject: [PATCH] [vector] Allow duplicate SVG refs during subsetting Some SVG glyph documents reuse the same referenced element multiple times. The vector subsetter treated a duplicate ref as a hard failure, which made hb-vector drop glyphs like U+270D from the handwriting picosvg test fonts entirely. Treat duplicate and empty refs as non-fatal while still uniquing the collected ids. Add regressions for the handwriting picosvg and picosvgz fonts, reusing a shared expected output for the pair. Fixes: https://github.com/harfbuzz/harfbuzz/issues/5829 Assisted-by: OpenAI Codex --- src/hb-vector-svg-subset.cc | 4 ++-- .../expected/basic/handwriting-picosvg.svg | 21 +++++++++++++++++++ test/vector/data/tests/basic.tests | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/vector/data/expected/basic/handwriting-picosvg.svg diff --git a/src/hb-vector-svg-subset.cc b/src/hb-vector-svg-subset.cc index 36db8ca70..54c25e24c 100644 --- a/src/hb-vector-svg-subset.cc +++ b/src/hb-vector-svg-subset.cc @@ -199,10 +199,10 @@ hb_svg_add_unique_id (hb_vector_t *v, const char *p, unsigned n) { - if (!n) return false; + if (!n) return true; OT::SVG::svg_id_span_t key = {p, n}; if (seen_ids->has (key)) - return false; + return true; if (unlikely (!seen_ids->set (key, true))) return false; auto *slot = v->push (); diff --git a/test/vector/data/expected/basic/handwriting-picosvg.svg b/test/vector/data/expected/basic/handwriting-picosvg.svg new file mode 100644 index 000000000..0853e02fd --- /dev/null +++ b/test/vector/data/expected/basic/handwriting-picosvg.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/vector/data/tests/basic.tests b/test/vector/data/tests/basic.tests index 32394776a..42712bf00 100644 --- a/test/vector/data/tests/basic.tests +++ b/test/vector/data/tests/basic.tests @@ -15,3 +15,5 @@ ../fonts/2db082c6c462d5056544e56e7ea13bf58c33a832.ttf;--logical;U+0646,U+0633,U+062A,U+0639,U+0644,U+06CC,U+0642;../expected/basic/iran-nastaliq-y-offsets.svg ../../../fuzzing/fonts/noto_handwriting-untouchedsvg.ttf;;U+270D;../expected/basic/handwriting-svg.svg ../../../fuzzing/fonts/noto_handwriting-untouchedsvgz.ttf;;U+270D;../expected/basic/handwriting-svg.svg +../../../fuzzing/fonts/noto_handwriting-picosvg.ttf;;U+270D;../expected/basic/handwriting-picosvg.svg +../../../fuzzing/fonts/noto_handwriting-picosvgz.ttf;;U+270D;../expected/basic/handwriting-picosvg.svg