Skip to content

render-pipeline: centre \vec paint on cmmi arrow ink (#892) - #910

Merged
jay3332 merged 3 commits into
mainfrom
muse/vec-accent
Sep 19, 2026
Merged

jay3332 merged 3 commits into
mainfrom
muse/vec-accent

Conversation

@d-q222

@d-q222 d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

\vec's arrow drew a glyph-width left of the letter: layout is already exact (agrees with pdflatex \showbox to 0.00001bp), but the paint uses Latin Modern Math's uni20D7 — a Unicode zero-advance combining mark whose ink spans [-472, -56]/1000em — for what TeX treats as a spacing accent (cmmi10 char 0x7E, ink [182, 625]/1000em). Same pen origin, different ink origin, arrow lands ~2/3em too far left.

Fix: one new match arm shifts only \vec's painted outline by 0.6675 * size to centre the combining-mark ink where the spacing-accent ink would be. Pen position, TFM advance, and hit-testing rects are untouched — paint only. Every other math accent's arm is byte-identical.

Verified against two independent oracles: pdflatex \showbox (pen shift), and LuaTeX fontloader glyph bboxes (ink extents for both uni20D7 and cmmi10 char 126). \hat/\bar/\tilde/\dot/\ddot/\acute/\grave/\widehat/\widetilde/\overline all confirmed unchanged and already correct.

Test plan

  • New crates/render-pipeline/tests/math_vec_accent.rs (3 tests): \vec gid-1817 pin at the corrected 0.6675em paint shift (matching the pdflatex pen), and all 9 other accents pinned unchanged at their TeX origin
  • Pre-fix probe (fix stashed): the new pin test fails, the other-accents test passes — proves the fix, not just the harness
  • Full crates/render-pipeline suite, independently re-run on the exact pushed tree: cargo test --locked and cargo test --release --locked, both 0 failures
  • Corpus regression check: re-rendered the same corpus slice from the investigation phase (ross set7/set0, 3 real-world documents) before/after — diagnostic and error/warning counts identical everywhere; set7's 4 \vec occurrences now paint at the corrected offset (spot-checked numerically)

Produced by a supervised Muse Contributor lane (vec-accent), across 2 slices — slice 1 was pure root-cause investigation (no code, exceptionally rigorous), slice 2 implemented the fix I approved after reviewing slice 1's proposal. Reviewed (full diff read, independently re-tested debug+release) by me.

🤖 Generated with Claude Code

math_items painted the \vec accent (U+20D7, a zero-width combining mark
whose LM Math ink sits left of its origin) at the TeX box origin, landing
the arrow ~2/3em too far left. Shift paint_x by 0.6675em so the combining
ink centre (-264/1000em) lands on the cmmi10 arrow ink centre
(403.5/1000em). Layout pen, advance and hit-testing untouched.

Add tests/math_vec_accent.rs: vec paint shift + showbox pen pins, and
unchanged-pins for hat/bar/tilde/dot/ddot/acute/grave/widehat/widetilde/
overline.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor
d-q222 and others added 2 commits September 18, 2026 08:33
…892)

The `engine performance` gate failed on output digests, which is correct:
this PR deliberately changes where `\vec`'s arrow is painted, so the
rendered bytes of any case containing a `\vec` change.

`twelvept-plain` is the only affected case, and all ten of its digest keys
moved -- cold.reply, export.pdf, and both v1/v2 variants of the four warm
scenarios -- matching exactly the ten CI reported. Re-recorded with
merge_digests.py --case twelvept-plain from a --release build; `git diff
--stat` confirms the baseline file is the only file touched, and the other
25 cases are byte-identical.

Justification for the change: before this PR the arrow was placed as a
zero-width combining mark, which put its ink a glyph-width left of the
letter it accents. The new output centres the arrow over the cmmi arrow
ink, which is what pdflatex produces. The new digests are therefore the
correct rendering, not merely a different one.

Implementation-Agent: daniel-parent
Commit-Executor: daniel-parent
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@jay3332
jay3332 merged commit 002b78e into main Sep 19, 2026
20 checks passed
jay3332 added a commit that referenced this pull request Sep 19, 2026
… centred on the cmmi arrow ink)

Taken textually from CI's subset run on main 4087be5 (run 35437054671);
the other 13 gated cases are unchanged.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
GoKubar added a commit that referenced this pull request Sep 21, 2026
#910 (`002b78e68`) already moved the painted arrow over its letter: Latin
Modern Math has no spacing vector accent, so the pipeline paints
`uni20D7` (U+20D7, zero advance, ink left of its origin) shifted so its
ink centre lands on cmmi10 `vector`'s. Its tests pin the shift and the
layout pen relative to the base letter. `tests/math_vec_892.rs` pins the
outcome end to end on the issue's repro against pdfTeX 1.40.29 (TeX Live
2026):

* the three arrows (`\vec{v}`, `\vec{A}`, `\vec{F}`): painted ink box --
  origin plus the Latin Modern Math outline's CFF bounding box -- against
  pdfTeX's -- origin plus `cmmi10.afm`'s `vector` box `182 516 625 714` --
  within 0.5 bp on every side. Measured: 0.139, 0.135 and 0.135 bp at
  worst; a 2400 dpi raster of both PDFs agrees (pdfTeX [160.92, 165.36] x
  [127.77, 129.75], FlashTeX [161.04, 165.18] x [127.80, 129.69]).
* the other 47 glyphs (letters, the nine other accents' own spacing
  glyphs, the cmex wide accents in x only): identity and origin within
  0.5 bp.

Glyph identity for the arrow differs by construction (another font
program; U+20D7 is Latin Modern's drawing of the same arrow), so the
arrow is pinned by ink, not origin.

Visual oracle (tools/visual-oracle/rank.py, the issue's repro, main at
ae2d5a2, no product change here): max |dx| / |dy| 0.01 / 0.00 bp over 30
aligned words, 1277 differing pixels at 144 dpi, all from Latin Modern
vs Computer Modern outline design (the accents' ink sits within 0.2 bp).

Verified: `cargo test` and `cargo test --release` in
crates/render-pipeline (--no-fail-fast): 880 passed, 0 failed each (with
the #895 test of the next commit present). perf-bench: no output change
(tests only).

Implementation-Agent: Claude Opus 5 (kabir-claude GH892-895, mac-m5pro-kabir)
Commit-Executor: Claude Opus 5 via Claude Code (direct git)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants