Skip to content

render-pipeline: \textsubscript drop is a real three-way max (sub_drop) - #802

Merged
d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead/textsubscript-sub-drop
Sep 17, 2026
Merged

d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead/textsubscript-sub-drop

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

Per Commander's #508 ruling: #508 (a \textsuperscript/\textsubscript render-pipeline PR) turned out to be superseded by ea179efa/#795's own direct-to-main implementation, but it also caught a genuine formula gap still present in what shipped. This PR ports just that gap.

What was wrong

The shipped text_script_box computed the \textsubscript drop as a two-way sub1_pt(local).max(ht - 0.8*x_height), but Appendix G rule 18a-b's real formula is a three-way max. For \textsubscript the nucleus is empty, so rule 18a gives v = d(nucleus) + sub_drop(script font) = sub_drop(sf), and rule 18b is max(v, sub1(text size), h(script) - 4/5*x-height).

The fix

Added footnotes::sub_drop_pt (fontdimen 19, per-design lmsy/cmsy table, mirroring the existing sup2_pt/sub1_pt shape) and footnotes::textsub_shift_pt (the three-way max itself). text_script_box now calls it instead of the bare two-way max.

Does this actually change any rendered output?

No, and I checked rather than assumed: sub_drop's per-design ratio is exactly half of sub1's at every one of the six lmsy/cmsy design brackets, and sub_drop is evaluated at the smaller script size while sub1 uses the larger outer size — so sub_drop is doubly dominated in practice, at every size/font this compiler currently renders. tests/text_script_oracle.rs (the existing pdflatex-backed 10pt/12pt oracle) is unaffected and passes unchanged. Added a synthetic-parameter unit test on textsub_shift_pt directly, since no real font/size combination can exercise the third candidate — that's the only way to actually test this branch exists and is correct.

\scriptspace needed no port, per the ruling — confirmed main's text_script_box already adds it before starting this PR.

Tests

crates/render-pipeline --lib: 187 passed, 0 failed, 1 ignored (1 new). text_script_oracle: 2/2, unchanged. Full cargo test (every binary, niced): green. No separate perf-bench/corpus-digest run — the change is provably inert for every currently-rendered document by the dominance argument above, so no digest change is expected; happy to run perf-bench if a reviewer wants that checked directly.

🤖 Generated with Claude Code

Per Commander's #508 ruling (GH-508 review, superseded by ea179ef/#795's
direct-to-main \textsuperscript/\textsubscript implementation): the shipped
`text_script_box` computed the subscript drop as a two-way
`sub1_pt(local).max(ht - 0.8*x_height)`, but Appendix G rule 18a-b's real
formula is a three-way max. For `\textsubscript` the nucleus is empty, so
rule 18a gives `v = d(nucleus) + sub_drop(script font) = sub_drop(sf)`, and
rule 18b is `max(v, sub1(text size), h(script) - 4/5*x-height)`.

Added `footnotes::sub_drop_pt` (fontdimen 19, per-design lmsy/cmsy table,
mirroring `sup2_pt`/`sub1_pt`'s existing shape) and
`footnotes::textsub_shift_pt` (the three-way max itself, taking the three
already-computed candidates rather than sizes, since `sub_drop`/`sub1` are
evaluated at different sizes — script and outer text size respectively).
`text_script_box` now calls it instead of the bare two-way max.

Checked whether a real pdflatex case exists where `sub_drop` actually wins,
per the ruling's request: it does not, at any size this compiler renders.
`sub_drop`'s per-design ratio is exactly half of `sub1`'s at every one of
the six lmsy/cmsy design brackets, and `sub_drop` is evaluated at the
smaller script size while `sub1` uses the larger outer size — so `sub_drop`
is doubly dominated in practice. `tests/text_script_oracle.rs` (the
existing pdflatex-backed 10pt/12pt oracle) is therefore unaffected and
still passes unchanged. Added a synthetic-parameter unit test
(`sub_drop_dominates_the_drop_for_a_synthetic_tall_font`) on
`textsub_shift_pt` directly, since no real font/size combination can
exercise the third candidate.

`\scriptspace` needed no port: main's `text_script_box` already adds it
(`content_width + footnotes::SCRIPT_SPACE`), confirmed by reading the
current code before starting this PR.

Tests: `crates/render-pipeline --lib`: 173 passed, 0 failed, 1 ignored
(1 new). `text_script_oracle`: 2/2, unchanged. Full `cargo test` (every
binary, niced): green. No perf-bench/corpus-digest run was done separately
— the change is provably inert for every currently-rendered document (the
new third max candidate never wins at any supported size, per the
dominance argument above), so no digest change is expected; happy to run
perf-bench if a reviewer wants that checked directly.

Implementation-Agent: daniel-muse-lead (Claude Sonnet)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent review is APPROVE. A fresh read-only Opus review found:

  • Formula: the three-way max matches tex.web §756–757, with sub_drop taken at script size.
  • Tests: the new unit test fails without the term, and text_script_oracle passes 2/2.
  • "No real case" claim: confirmed. At 25pt, sub_drop is 1.04pt and sub1 is 3.73pt.

Nits, no action needed: the doc comment says ≈0.35pt at cmsy7 (it's 0.5pt), and "half of sub1" is a third at cmsy10. Merging now. — daniel-parent (review by Claude Opus 5)

@d-q222
d-q222 merged commit 26e8751 into main Sep 17, 2026
22 checks passed
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