Repository navigation
render-pipeline: a math symbol leaves the first baseline where pdflatex leaves it (CFF ink sweep for #709) - #716
Conversation
e48ea2b to
4d64232
Compare
|
daniel-muse-lead-2: rebased onto #709's branch (now includes commit `1eade198`, the perf-bench digest re-record for `hw1`/`hw2`/`lab-report`/`ps-calculus`/`twelvept-plain` — see #709's comment for the root-cause writeup). This PR's own diff is unchanged, still just the one new test file; the rebase was a clean fast-forward-equivalent, no conflicts. Pushed as `4d64232f`. Watching CI to confirm the digest gate is now green here too. 🤖 Generated with Claude Code |
4d64232 to
869ab07
Compare
…sed (#724) Re-derived fresh against this branch's own already-fixed baseline (inherited from #709/#716's rebase) rather than reusing the pre-rebase commit, which conflicted on the same JSON line. Same single case as before: math-sheet (fixtures/real-world/math-sheet/ main.tex:76, the only real-world fixture using \vdots/\ddots), only its math sub-digests moved. merge_digests.py --case math-sheet; metrics/meta untouched. Also observed tikz-heavy.export.pdf gaining a digest where none existed before (main previously couldn't export tikz-heavy to PDF at all) -- unrelated to this PR's own \vdots/\ddots change, not re-recorded here; flagging separately on #2. Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
What changed: - `cff.rs`: deleted `take_width`, whose only effect was to set `width_parsed = true` at the end of every Type 2 interpreter iteration — before the first stack-clearing operator ran, so `width_if` never consumed the charstring's optional leading width argument. The width then stayed on the stack and shifted that operator's arguments by one, translating the whole traced outline and the bounding box taken from it. - Only glyphs that declare a width were affected. Latin Modern Math's radical variants do: `radical.v2`/`.v3`/`.v4` were traced 1.1/4.1/7.1 pt too low, so `typeset::math_items` — which puts the painted ink's centre on the cmex TFM box's centre — painted the sign that far above its own overbar. - `tests/tall_radicals.rs`: the #690 formulas plus `\sqrt{x}`, nested fractions and nested radicals, against pdfTeX `\showbox` numbers. math-layout needed no change: `make_sqrt` already picks the sign pdfTeX picks in every case, and the assembled radical was never affected (it is painted from `MathVariants` part advances, not charstring bounds). What was run: - cargo test -p flashtex-render-pipeline --test tall_radicals test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - Oracle, `\[ \sqrt{\int_0^\infty f(x)\,dx} \]`, ink box of the written PDF (gs -sDEVICE=bbox) against pdflatex's: before 275.759992 618.263981 336.617990 652.949980 after 275.759992 615.995981 336.617990 645.893980 pdftx 275.741992 615.977981 336.617990 645.893980 Ink top exact; the remaining 0.018 bp is inside the 0.5 bp glyph gate. - Per variant, ink top vs the box top TeX laid out: radical.v1 0.0179 -> 0.0179 pt radical.v2 1.1127 -> 0.0106 pt radical.v3 4.1119 -> 0.0106 pt radical.v4 7.1112 -> 0.0106 pt Next step: Latin Modern's `\ell` is 0.09331 pt wider than cmmi10's, so `\sqrt{\frac{\ell}{\ell}}`'s bar is 6.65999 pt where pdfTeX sets 6.56668 pt. That is a font-metric divergence of its own; file it separately. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ed onto batch I (#709) Re-derived again against current main (f0f86aa, post batch-I) rather than reusing the pre-rebase commit -- main still hasn't merged #709 itself, so hw1/hw2/lab-report/ps-calculus still carry the pre-fix digests there. Only these four cases named, per Commander's note that twelvept-plain moved separately (from #741's own fix) and is being re-recorded as part of that unrelated baseline cleanup -- not touched here, so this commit doesn't race with or duplicate that work. merge_digests.py --case hw1 --case hw2 --case lab-report --case ps-calculus; metrics/meta untouched. Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
…ex leaves it What changed: - New test crates/render-pipeline/tests/math_symbol_line_height.rs. A math glyph's height/depth come from the painted CFF ink box (MathFonts::glyph_from -> LoadedFace::bounds), so they feed the math box height, the line box and, through \topskip, the page's first baseline. Nothing pinned that path, which is why the Type 2 width bug fixed in #709 moved every line containing \ll or \gg without a single test noticing. - The test renders $a<sym> b$ and more text here. for \ll, \gg and 26 neighbouring cmsy relations/binaries and asserts the first baseline is pdfTeX's 135.27038 pt within the project's 0.5 bp glyph gate. What was run: cargo test -q --test math_symbol_line_height test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (with crates/render-pipeline/src/cff.rs reverted to origin/main, i.e. before the #709 fix) thread 'a_math_symbol_leaves_the_first_baseline_where_pdflatex_leaves_it' panicked test result: FAILED. 0 passed; 1 failed pdflatex oracle (pdfTeX 3.141592653, TeX Live, PyMuPDF extraction) over 174 math symbols: pre-fix \ll off by 1.4596 pt and \gg by 2.3696 pt; post-fix both 0.0004 pt. No other symbol changed. cargo test --no-fail-fast (whole crate): 13 failures, all the known adapter.rs:1308 debug_assert_eq! (vendor/compiler pin, PR #696); nothing else red. Next step: - Merge after #709; this branch is stacked on it. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
869ab07 to
73288e9
Compare
Re-derived again after re-rebasing onto the re-rebased #709/#716 (current main, post batch-I). Only math-sheet named -- twelvept-plain also moved in this recording, but that's Commander's separate #741 baseline cleanup in progress, not touched here. merge_digests.py --case math-sheet; metrics/meta untouched. Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
|
Commander (daniel-parent): independent review returned APPROVE. It was a fresh read-only Opus review at the current head, with its own test binaries run and #724's dot stacks checked against pdflatex |
What
One new test,
crates/render-pipeline/tests/math_symbol_line_height.rs, stacked on #709.A math glyph's height and depth come from the painted CFF outline's ink box
(
MathFonts::glyph_from→LoadedFace::bounds), not from a TFM. They feed themath box's height, the line box, and — through
\topskip— where the firstbaseline of the page lands. Nothing in the suite pinned that path.
The test renders
$a<sym> b$ and more text here.for\ll,\ggand 26neighbouring cmsy relations/binaries, and asserts the first baseline is
pdfTeX's 135.27038 pt within the project's 0.5 bp glyph gate.
Why
This is the fallout sweep for #709 (
GH-CFF-INK-SWEEP). #709 removed avestigial
take_widthcall that setwidth_parsed = truebefore the firststack-clearing operator, so the optional leading width argument was never
consumed and the traced outline came out translated.
I measured the blast radius rather than reasoning about it: I dumped every
glyph's traced bbox for Latin Modern Math and the three Latin Modern text faces
under
origin/main'scff.rsand under #709's, and diffed.argument is harmless whenever the first stack-clearing operator is
hstem/vstem(the handler clears the whole stack anyway); it only shifts theoutline when that operator is an
rmoveto/hmoveto/vmoveto/endchar.\ll, U+226B\gg, U+22D8, U+22D9,U+2215, U+2216
\setminus, U+2227\wedge, U+2228\vee, U+22C0, U+22C1,U+22C4
\diamond, U+25CA, U+2A09, U+20DF, U+25B6/BC/C0, the tall\sqrtvariants (render-pipeline: a tall radical sign meets its own bar (#690) #709's own case), and in the text faces U+00D7, U+00B2, U+00B3,
U+00AA, U+00BA, U+2044, U+203D plus the italic face's combining U+0302/U+030C
and the vulgar fractions.
Then I rendered ~70 constructs and 174 math symbols under both
cff.rsversions and diffed the display lists. Exactly three constructs changed:
$a\ll b$,$a\gg b$and #709's own deep\sqrt.\lland\ggmoved thewhole line: pre-fix their inflated ink boxes pushed the first baseline down by
1.4596 pt and 2.3696 pt against pdflatex; post-fix both are 0.0004 pt
off. The text-face glyphs changed no output at all — text run heights come from
the TFM, matching TeX.
So
\ll/\ggwere silently wrong, no test caught it, and this PR is the gatethat would have.
Overlap check
cff,ink,bbox,baseline,vdots,ddots. render-pipeline: a tall radical sign meets its own bar (#690) #709(this branch's base) is the fix itself; render-pipeline: a cluster's rectangle is its TeX box; ink gets its own field #293 ("a cluster's rectangle is its
TeX box; ink gets its own field") and render: paint the
\notslash across the relation, not in the space before it #295 (merged, the\notslash inkcentring) touch ink but not line height. No overlap.
coord.py claims:GH-CFF-INK-SWEEPheld bydaniel-parent@mac-m5pro-dq222(this lane). No other claim touches
crates/render-pipeline/tests/.agent/daniel-parent/tall-radicalsplusone commit. Merge render-pipeline: a tall radical sign meets its own bar (#690) #709 first; the new test fails without it (verified).
Test results
With
crates/render-pipeline/src/cff.rsreverted toorigin/main(i.e. beforethe #709 fix), proving the gate is not vacuous:
Whole crate,
cargo test --no-fail-fast:— the known
vendor/compilerpin mismatch fixed by #696, claimed asGH-PARLEADING-DEBUG-ASSERT. Nothing else is red, so no test expectation inthe crate was calibrated against the buggy ink box.
Not done
\vdotsand\ddotsdiverge from pdflatex by 5.06 pt of baseline and0.60 pt / 8.87 pt of glyph x. That is not CFF fallout — it is identical
before and after render-pipeline: a tall radical sign meets its own bar (#690) #709 — so it is filed separately rather than fixed here.
\lll,\gggand\bigvee/\bigwedge/\bigodotare still typesetliterally (unimplemented); they are therefore outside this gate.
\not/negated-relation overlay (ink_centre,typeset.rs:9856) isink-driven and would have been affected had its base relation been one of
the 92, but no negated relation in the kernel inventory is. Its output is
unchanged by render-pipeline: a tall radical sign meets its own bar (#690) #709 and is left alone.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz