From 3c0e2b42d510843ba5d2f3c1df11ffb05dbce12a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Oct 2026 19:29:29 -0600 Subject: [PATCH] [vector] Keep SVG path clips in the body's coordinate space (#6471) The SVG body is flipped from font coordinates once at render time. The path-clip callback still emitted its own vertical flip from the older renderer, mirroring the clip relative to the drawing. Remove that transform, matching rectangle and glyph clips. Add a paint/show-extents vector regression and generate its expected SVG with hb-vector. It fails on the old code. The full Meson suite passes (293 tests). Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-BZKWFGVZ. Assisted-by: OpenAI Codex --- src/hb-vector-paint-svg.cc | 13 +++++----- .../expected/basic/paint-show-extents.svg | 26 +++++++++++++++++++ test/vector/data/tests/basic.tests | 1 + 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 test/vector/data/expected/basic/paint-show-extents.svg diff --git a/src/hb-vector-paint-svg.cc b/src/hb-vector-paint-svg.cc index 07eecf62a..01cab0a5e 100644 --- a/src/hb-vector-paint-svg.cc +++ b/src/hb-vector-paint-svg.cc @@ -576,17 +576,16 @@ hb_vector_paint_push_clip_path_end (hb_paint_funcs_t *, unsigned pfx_len = paint->id_prefix_length; unsigned clip_id = paint->clip_path_counter++; - /* The accumulated path is in font Y-up coords (the - * convention used inside per-glyph - * wrappers); this clip is emitted at base body level - * (free-form between glyphs), so flip its geometry inside - * the clipPath via the path's own transform attribute, - * keeping the body's at body Y-down. */ + /* The accumulated path is in font Y-up coords, the same + * space as the body's that references it: + * the whole body is wrapped in a single scale(1,-1) at + * render time, so no per-clip flip here (matches the + * glyph and rectangle clips above). */ paint->defs.append_str ("defs.append_len (pfx, pfx_len); paint->defs.append_str ("cp"); paint->defs.append_unsigned (clip_id); - paint->defs.append_str ("\">defs.append_str ("\">defs.append_len (paint->path.arrayZ, paint->path.length); paint->defs.append_str ("\"/>\n"); diff --git a/test/vector/data/expected/basic/paint-show-extents.svg b/test/vector/data/expected/basic/paint-show-extents.svg new file mode 100644 index 000000000..249cbee06 --- /dev/null +++ b/test/vector/data/expected/basic/paint-show-extents.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/vector/data/tests/basic.tests b/test/vector/data/tests/basic.tests index 0c7c6eec9..376910f0a 100644 --- a/test/vector/data/tests/basic.tests +++ b/test/vector/data/tests/basic.tests @@ -16,3 +16,4 @@ ../../../api/fonts/Roboto-Regular.abc.ttf;--font-size=65536;U+0061,U+0062,U+0063;../expected/basic/glyf-quadratics.pdf ../../../api/fonts/TwemojiMozilla.subset.default.32,3299.ttf;--font-size=65536;U+3299;../expected/basic/colrv0-large-scale.svg ../../../api/fonts/TwemojiMozilla.subset.default.32,3299.ttf;--font-size=65536;U+3299;../expected/basic/colrv0-large-scale.pdf +../../../api/fonts/Roboto-Regular.abc.ttf;--paint --show-extents;U+0061,U+0062,U+0063;../expected/basic/paint-show-extents.svg