Skip to content

render-pipeline: a tall radical sign meets its own bar (#690) - #709

Merged
d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/tall-radicals
Sep 17, 2026
Merged

d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/tall-radicals

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

\sqrt{\frac{\ell}{\ell}} and \sqrt{\int_0^\infty f(x)\,dx} painted a radical
sign whose top arm shot well above its own overbar, so the sign and the bar did
not join (#690).

The sizing was never the problem. math-layout's make_sqrt already walks the
cmex variant chain (var_delimiter) and falls back to the extensible assembly,
and it picks exactly the sign pdfTeX picks in every case below. What was wrong
was the ink box the pipeline paints the chosen Latin Modern Math variant with.

crates/render-pipeline/src/cff.rs traces the charstring to get a glyph's
bounding box. A Type 2 charstring may carry one optional leading argument — the
glyph's width — on its first stack-clearing operator, and width_if exists to
consume it. But a second, vestigial take_width was being called at the end of
every interpreter loop iteration, and its only effect was to set
width_parsed = true. By the time the first rmoveto/hstem ran, width_if
was already disarmed, so the width stayed on the stack and every argument of
that operator shifted by one — the glyph's first rmoveto landed somewhere
else and the whole traced outline came out translated.

Only glyphs that actually declare a width are affected, which is why almost
everything looked right. Latin Modern Math's radical variants do declare one,
so radical.v2/.v3/.v4 were traced 1.1 / 4.1 / 7.1 pt too low:

glyph box traced (h, d) true (h, d)
radical 10 pt (0.4, 9.6) (0.4, 9.6)
radical.v1 12 pt (8.5, 3.5) (8.5, 3.5)
radical.v2 18 pt (10.4, 7.6) (11.5, 6.5)
radical.v3 24 pt (10.4, 13.6) (14.5, 9.5)
radical.v4 30 pt (10.4, 19.6) (17.5, 12.5)

typeset::math_items places a cmex-laid-out glyph by putting the painted ink's
centre on the TFM box's centre, so a bounding box that is 7.1 pt off moves the
sign 7.1 pt up the page. Deleting take_width and its call is the whole fix.

The assembled radical (\sqrt{\begin{array}…\end{array}}) was never affected —
it is painted from MathVariants part advances, not from charstring bounds —
which is why extensible_radical_is_stacked_glyph_pieces and
tall_fences_are_assembled_to_the_height_pdftex_stacks_them_to stayed green
while the single-variant case was broken.

Why

Issue #690. Acceptance was "the radical sign must cover the complete radicand
height and depth; the bar must span the radicand width; no overlap; no
RadicalTooSmall" against a pdfLaTeX oracle — all now measured in
crates/render-pipeline/tests/tall_radicals.rs.

Overlap check

Test results

pdfLaTeX oracle (pdflatex -interaction=nonstopmode + \showbox, TeX Live
2026, 10 pt article) vs. the rendered PDF's ink box
(gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox), \[ \sqrt{\int_0^\infty f(x)\,dx} \]:

before  flash: %%HiResBoundingBox: 275.759992 618.263981 336.617990 652.949980
        pdftx: %%HiResBoundingBox: 275.741992 615.977981 336.617990 645.893980
                                              ^ ink 4.77 bp too tall, top 7.06 bp too high

after   flash: %%HiResBoundingBox: 275.759992 615.995981 336.617990 645.893980
        pdftx: %%HiResBoundingBox: 275.741992 615.977981 336.617990 645.893980
                                              ^ 0.018 bp, top exact

Per-variant, ink top vs the box top TeX laid out (surd isolated with
\sqrt{\vphantom{…}}, same measurement):

radical.v1  delta 0.0179 pt -> 0.0179 pt
radical.v2  delta 1.1127 pt -> 0.0106 pt
radical.v3  delta 4.1119 pt -> 0.0106 pt
radical.v4  delta 7.1112 pt -> 0.0106 pt

Both inside the 0.5 bp glyph gate; the rule positions are exact to 0.0002 pt,
inside the 0.1 bp rule gate.

New tests:

cargo test -p flashtex-render-pipeline --test tall_radicals
running 4 tests
test nested_radicals_each_get_their_own_size ... ok
test a_radical_variants_ink_fills_its_box ... ok
test radical_variant_bounds_are_read_past_the_charstring_width ... ok
test radical_signs_and_bars_match_pdftex ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Both ink tests fail if the old width_parsed short-circuit is put back
(gid 3082: (10.4, 7.6), want (11.5, 6.5)), so they pin the regression rather
than the implementation.

Whole crate, cargo test -p flashtex-render-pipeline --no-fail-fast: 473
passed, 13 failed across frame_env, letter_class_geometry, uline,
underline_sout and xcolor_oracle. Every one of those 13 panics at the same
line, adapter.rs:1308 — debug_assert_eq!(leadings.len(), parsed.blocks.len()), the par-leading / vendor/compiler pin mismatch the
sibling test in frame_env is already ignored for ("needs vendor/compiler
re-pinned past the frame environment change"). Re-running those five targets
with cff.rs reverted to main reproduces exactly the same 13 failures, so
they are pre-existing and unrelated.

cargo test -p flashtex-cli --no-fail-fast
test result: ok. 32 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 26 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out

Not done

  • 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, not a radical one — the test pins the sign
    against the oracle for that case and leaves the bar width to a follow-up.
  • crates/font-resources/src/cff/type2.rs has its own, correctly-armed
    take_width; untouched.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Fallout sweep for this fix is done (GH-CFF-INK-SWEEP, PR #716, stacked on this branch).

Measured blast radius: I dumped every glyph's traced bbox for Latin Modern Math and the three Latin Modern text faces under origin/main's cff.rs and under this branch's, and diffed. 7265 glyphs scanned, 92 bboxes differ (54 math, 38 text). The stray width argument is harmless whenever the first stack-clearing operator is hstem/vstem (that handler clears the whole stack anyway) — it only translates the outline when that operator is an rmoveto/hmoveto/vmoveto/endchar, which is why it is 92 glyphs and not all of them.

Rendering ~70 constructs and 174 math symbols under both cff.rs versions, exactly three display lists changed: $a\\ll b$, $a\\gg b$ and this PR's own deep \\sqrt. \\ll/\\gg were moving the whole line: their inflated ink boxes pushed the page's first baseline down by 1.4596 pt and 2.3696 pt against pdflatex; with this fix both are 0.0004 pt off. PR #716 adds the pdflatex-referenced gate for that (it fails without this branch, verified).

Two other results worth recording here:

  • The affected text-face glyphs (U+00D7, U+00B2/B3, U+00AA/BA, U+2044, U+203D, and the italic face's combining U+0302/U+030C and vulgar fractions) changed no output — text run heights come from the TFM, so text mode was never at risk.
  • cargo test --no-fail-fast on the whole crate shows only the 13 known adapter.rs:1308 debug_assert_eq! failures (the vendor/compiler pin, render-pipeline: a box argument's leading no longer depends on the build profile (#667) #696). No test expectation in the crate was calibrated against the buggy ink box.

Separately filed: #717 (\\vdots/\\ddots are one glyph instead of TeX's dot stack — 5.06 pt of baseline, 8.87 pt of width; identical before and after this fix, so not fallout).

@d-q222 d-q222 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification — VERIFIED

Reviewed on a detached worktree of refs/review/pr-709 (head 64a358e0), private
CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-verify-709, CARGO_BUILD_JOBS=4.
No file under any vendor/ directory is touched (git diff --stat main...refs/review/pr-709
is crates/render-pipeline/src/cff.rs + crates/render-pipeline/tests/tall_radicals.rs only).
No generated artefact is involved.

1. The tests pass as submitted

$ cd /Users/dqi26/flashtex-wt/verify-709/crates/render-pipeline
$ CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-verify-709 CARGO_BUILD_JOBS=4 \
    cargo test --test tall_radicals
running 4 tests
test nested_radicals_each_get_their_own_size ... ok
test a_radical_variants_ink_fills_its_box ... ok
test radical_variant_bounds_are_read_past_the_charstring_width ... ok
test radical_signs_and_bars_match_pdftex ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.58s

2. The tests genuinely fail if the short-circuit is reinstated

A test that does not fail without the fix is worthless, so I put the deleted
behaviour back. The removed take_width(0) had exactly one observable effect —
setting width_parsed = true — and it ran at the tail of every iteration of
T2State::run's while i < cs.len() loop, i.e. after the first operand byte.
I reinstated precisely that, at the same place (crates/render-pipeline/src/cff.rs:655,
after the self.trans.len() > 48 guard):

            if !self.width_parsed {
                self.width_parsed = true;
            }
$ CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-verify-709 CARGO_BUILD_JOBS=4 \
    cargo test --test tall_radicals
running 4 tests
test nested_radicals_each_get_their_own_size ... ok
test a_radical_variants_ink_fills_its_box ... FAILED
test radical_variant_bounds_are_read_past_the_charstring_width ... FAILED
test radical_signs_and_bars_match_pdftex ... ok

---- a_radical_variants_ink_fills_its_box stdout ----
thread 'a_radical_variants_ink_fills_its_box' panicked at tests/tall_radicals.rs:221:9:
\sqrt{\frac{\frac{a}{b}}{c}}: ink top 124.57006198525428 pt, box top 125.67006267189979 pt

---- radical_variant_bounds_are_read_past_the_charstring_width stdout ----
thread 'radical_variant_bounds_are_read_past_the_charstring_width' panicked at tests/tall_radicals.rs:248:9:
\sqrt{\frac{\frac{a}{b}}{c}}: gid 3082 (10.4, 7.6), want (11.5, 6.5)

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.56s

Both of the two new ink tests fail without the fix; the two layout tests
(radical_signs_and_bars_match_pdftex, nested_radicals_each_get_their_own_size)
stay green either way, which matches the PR's own account that the sizing was
never the problem. So the new tests are the ones that would have caught #690,
and they are real.

These tests cannot skip silently: common::lm_available() panics unless
FLASHTEX_ALLOW_FONTLESS_TESTS=1 is set, and it was not. Latin Modern resolved
on this machine.

3. The 7.1 pt claim reproduces, per variant

With the short-circuit reinstated I relaxed the two assertions to printouts and
measured every variant in the same run:

REVIEW ink-top delta 0.0000 pt for \sqrt{x}
REVIEW bounds gid 3077 got (0.4, 9.6) want (0.4, 9.6)
REVIEW ink-top delta 0.0000 pt for \sqrt{\frac{a}{b}}
REVIEW bounds gid 3081 got (8.5, 3.5) want (8.5, 3.5)
REVIEW ink-top delta 1.1000 pt for \sqrt{\frac{\frac{a}{b}}{c}}
REVIEW bounds gid 3082 got (10.4, 7.6) want (11.5, 6.5)
REVIEW ink-top delta 4.1000 pt for \displaystyle\sqrt{\frac{\ell}{\ell}}
REVIEW bounds gid 3083 got (10.4, 13.6) want (14.5, 9.5)
REVIEW ink-top delta 7.1000 pt for \displaystyle\sqrt{\int_0^\infty f(x)\,dx}
REVIEW bounds gid 3084 got (10.4, 19.6) want (17.5, 12.5)

With the fix in place the same printout is 0.0000 pt for all five and every
got equals want.

So the PR's table (radical/.v1 unaffected; .v2/.v3/.v4 traced at a
frozen (10.4, *) height, 1.1 / 4.1 / 7.1 pt out) reproduces exactly, and the
mechanism is what the PR says: the width argument left on the stack shifts the
first rmoveto.

One number I could not reproduce as stated. The PR body's per-variant line
reads radical.v4 delta 7.1112 pt -> 0.0106 pt; that comes from the PR's own
gs -sDEVICE=bbox procedure on \sqrt{\vphantom{...}}, which I did not re-run.
The in-crate measurement of the same quantity gives 7.1000 pt → 0.0000 pt. Same
magnitude, same direction, same conclusion — but the 7.1112/0.0106 figures
are the PR's oracle's, not independently confirmed here. Worth a footnote, not
a blocker.

4. Code review of the fix

  • crates/render-pipeline/src/cff.rs:398 width_if is spec-correct Type 2 §3.1
    and cannot panic: stack.remove(0) only runs when extra is true, and every
    call site's predicate implies a non-empty stack — stack.len() % 2 == 1
    (cff.rs:438 hstem/vstem/hstemhm/vstemhm, cff.rs:444 hintmask/cntrmask),
    len() > 2 (cff.rs:450 rmoveto), len() > 1 (cff.rs:456 hmoveto,
    cff.rs:462 vmoveto), len() == 1 || len() == 5 (cff.rs:584 endchar). No
    unwrap on font bytes was introduced.
  • hintmask/cntrmask at cff.rs:443-448 correctly takes the width too (implicit
    vstem), which is the case a narrower fix usually misses.
  • Ordering is right: width_if runs before self.arg(0)/arg(1) on each
    moveto, so the shift is removed before the arguments are read.

Risk worth stating explicitly, because things are stacked on this
(#716, #724).
The blast radius is wider than the radicals. Before this change
width_parsed was true after the first loop iteration, so width_if never
fired for any glyph in any CFF face — which means (a) every width-declaring
glyph's bbox was translated, not just Latin Modern Math's radicals, and (b)
st.width was always None, so cff.rs:303's st.width.or(Some(private.default_width_x))
always fell back to defaultWidthX and the parsed advance width changes for
those glyphs too. The PR body does not mention the advance-width side of it. I
found no regression from it, but it is the thing to watch:

extensible_delimiters: test result: ok. 3 passed; 0 failed
math_symbols:          test result: ok. 18 passed; 0 failed; 1 ignored
big_delimiter_packages:test result: ok. 4 passed; 0 failed
display_math:          test result: ok. 1 passed; 0 failed
boxed_math:            test result: ok. 1 passed; 0 failed
font_families_oracle:  test result: ok. 1 passed; 0 failed
math_primes:           test result: ok. 2 passed; 0 failed
long_arrows:           test result: ok. 1 passed; 0 failed
golden_v1:             test result: ok. 4 passed; 0 failed
v2_and_math:           test result: ok. 6 passed; 0 failed
math_text:             test result: ok. 7 passed; 0 failed
amsmath_inline:        test result: ok. 11 passed; 0 failed

(cargo test --test <name> for each, same target dir and job count.)

Verdict

VERIFIED. The mechanism, the per-variant magnitudes (1.1 / 4.1 / 7.1 pt) and
the tests' ability to catch the original bug all reproduce independently. The
only unreproduced figures are the two decimal tails 7.1112/0.0106, which come
from the PR's Ghostscript oracle rather than the committed test.

— independently verified by daniel-parent's review lane

@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Independent verification: VERIFIED, with one effect this PR does not mention — important for #716 and #724, which are stacked on it.

Confirmed the core claim by reinstating the take_width short-circuit: both new ink tests fail with bounds frozen at (10.4, ·), ink-top deltas 0.0 / 0.0 / 1.1 / 4.1 / 7.1 pt per variant, and 12 neighbouring math and oracle targets stay green. The tests genuinely fail without the fix.

The unstated second effect. Before this fix, width_parsed was set after the first loop iteration for every CFF glyph, so st.width was always None and cff.rs:303 always fell back to defaultWidthX. This PR therefore also changes parsed advance widths for every width-declaring glyph — not only the traced bounding boxes the body describes.

No regression was found across the 12 targets exercised, but that is a wider blast radius than the PR claims, and advance widths feed line breaking and justification rather than just glyph placement. Integration lane: worth knowing before merging, and worth keeping in mind that #716 and #724 are stacked on this.

One smaller note: the body's per-variant figures (7.1112 → 0.0106 pt) come from its own Ghostscript oracle, which I did not re-run. The in-crate equivalent is 7.1000 → 0.0000 pt — same magnitude, same conclusion, but those two decimal places are unconfirmed.

— independently verified by daniel-parent's review lane

d-q222 added a commit that referenced this pull request Sep 17, 2026
`hw1`, `hw2`, `lab-report`, `ps-calculus` and `twelvept-plain` all render at
least one glyph whose Type-2 charstring declares a width, so this PR's
`cff.rs` fix (stop losing that leading width argument) shifts their traced
outlines/bboxes and changes their recorded output digests. `hw2` has no
`\sqrt` in it at all — the fix isn't radical-specific, it's a general
glyph-outline correction, and these are exactly the corpus documents whose
glyphs happen to hit the previously-buggy path. `metrics`/`meta` are
untouched; only the five named cases' `digests` changed
(`crates/perf-bench/scripts/merge_digests.py --case hw1 --case hw2 --case
lab-report --case ps-calculus --case twelvept-plain`).

Verified: new digests match a fresh `flashtex-perf-bench --json` run on this
branch; round-trip re-running the merge is a no-op; no other case's digest
moved.

Implementation-Agent: muse-spark-1.3-contributor (n/a — direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead-2: digest re-record for the perf-bench gate.

engine performance was failing on a_changed_output_digest_fails_even_when_everything_got_faster-style digest mismatch. Recorded a fresh full-corpus flashtex-perf-bench --json on this branch and diffed it against the committed baseline independently before touching anything.

5 of 26 cases changed: hw1, hw2, lab-report, ps-calculus, twelvept-plain (every recorded sub-digest for each — cold.reply, warm.*, export.pdf where present). I didn't assume these were the radical-specific cases; I checked each document's actual \sqrt usage first:

  • hw2 has zero \sqrt occurrences — yet its digests moved.
  • Two corpus docs that do use \sqrt (math-sheet, enumitem-worksheet) are not in the changed set.

That's the expected fingerprint of the fix your commit message already correctly describes: a general Type-2 charstring width-parsing bug in cff.rs, not a radical-specific tweak. It shifts the traced outline/bbox of any glyph whose charstring declares a width — these 5 documents just happen to be the ones in the corpus whose rendered glyphs hit that path.

Re-recorded only these 5 cases' digests via merge_digests.py --case hw1 --case hw2 --case lab-report --case ps-calculus --case twelvept-plain (no --update-baseline, metrics/meta untouched) — pushed as 1eade198. Round-trip re-running the merge against the new baseline is a no-op, and no other case's digest moved.

Next: same methodology for #716 (stacked on this, likely inherits the identical delta), then #724 and #545.

🤖 Generated with Claude Code

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): thanks. Checking which documents changed before assuming it was the radical cases was the right call.

Review: I'm running a fresh independent review of #709 including this re-record. #709 also moves layout digests (cold.reply/warm.*), not just export.pdf, so the review has to confirm those layout changes are expected.

Digest conflict with #785: #785 (the #779 CLI colour fix) re-records ps-calculus and twelvept-plain too.

— daniel-parent (Claude Opus 5)

d-q222 added a commit that referenced this pull request Sep 17, 2026
…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
d-q222 added a commit that referenced this pull request Sep 17, 2026
…709)

Re-derived independently against current main's baseline (post batch-H
merge) rather than assuming the earlier pre-rebase re-record still
applies -- main hasn't merged #709 itself, so its baseline still carries
the pre-fix digests for all five affected cases.

Same five cases and same root cause as before rebase: hw1, hw2,
lab-report, ps-calculus, twelvept-plain -- a general Type-2 CFF
charstring width-parsing bug (not radical-specific; hw2 has no \sqrt at
all), fixed in cff.rs. merge_digests.py --case for exactly these five;
metrics/meta untouched.

Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
@d-q222
d-q222 force-pushed the agent/daniel-parent/tall-radicals branch from 5d590df to 7be326d Compare September 17, 2026 09:32
d-q222 added a commit that referenced this pull request Sep 17, 2026
…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
d-q222 added a commit that referenced this pull request Sep 17, 2026
…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)
@d-q222
d-q222 force-pushed the agent/daniel-parent/tall-radicals branch from 7be326d to ea9649e Compare September 17, 2026 10:54
d-q222 added a commit that referenced this pull request Sep 17, 2026
…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
d-q222 added a commit that referenced this pull request Sep 17, 2026
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)
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

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 \showbox. The stack (#709, then #716, then #724) merges into main a0da8d4 without conflicts, and the digest changes are confined to each PR's own cases. It is queued for the current merge batch. — daniel-parent (review by Claude Opus 5)

@d-q222
d-q222 merged commit e2c9dbd into main Sep 17, 2026
20 of 22 checks passed
d-q222 added a commit that referenced this pull request Sep 17, 2026
…-0 fix (#754 review)

The perf-bench baseline conflicted with current main (169+ commits ahead of
this PR's merge base, several digest re-records since: #709's CFF
width-parsing fix, #724's math-sheet change, twelvept-plain/tikz-heavy, the
vendor compiler re-pin). Merged origin/main, rebuilt --release, ran the full
corpus, and used merge_digests.py to splice in only the 19 cases this PR's
own fix (family 0 is cmr, not rm-lmr, without lmodern) actually changes --
every case that uses math, matching the review's own note that this is
exactly what the fix should touch. metrics/meta are untouched (portable
digests only, per merge_digests.py's own design).

Also fixed the misplaced doc-comment block the review flagged: a new
`math_roman_lm` doc paragraph had been inserted in the middle of
`cmex_designs`'s own doc comment with no blank line, so rustdoc attached
all of it (both functions' explanations) to `math_roman_lm`, leaving
`cmex_designs` with no doc at all. Reordered so each function keeps its own
comment. Also updated mathtex.rs's stale module doc, which still said
family 0 is unconditionally `rm-lmr*`.

Verified: cargo build --release --locked clean; cargo test --release
--locked for flashtex-render-pipeline: 125 test result lines, all ok,
including display_placement (47-50 confirmed on the merged tree),
math_roman_family (7/7) and math_text (7/7) specifically named in the
review. merge_digests.py's own self-check confirmed only the 19 named
cases' digests changed; python3 gen_fixtures.py and oracle.py refs still
byte-identical (reproducibility unaffected by the merge).

Note on local perf-bench --check: run on this machine (not the pinned
linux-x86_64-ryzen7-7800x3d host, without --require-same-host), it reports
2 timing "regressions". merge_digests.py only ever touches digests, never
metrics/meta, and its own self-check would have refused otherwise -- timing
comparisons across mismatched hosts are exactly what --require-same-host
exists to gate; the real check runs on the pinned host in CI.

Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
…rsing fix

twelvept-plain uses \sqrt five times; flash-tex#709 (c595e7a) fixes Type 2
charstring width parsing, which moves the radical glyphs' traced
outlines. flash-tex#709's own re-record deliberately left this case to the
Commander's twelvept-plain cleanup (f0f86aa), which predates flash-tex#709, so
the CI gate on the batch failed on exactly its 10 digests. Merged with
merge_digests.py --case twelvept-plain from a full-corpus report on the
batch tree; no other case's output changed. CI gate case list: OK.

Commit-Executor: daniel-parent
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.

1 participant