Repository navigation
render-pipeline: \textsubscript drop is a real three-way max (sub_drop) - #802
Merged
Merged
Conversation
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)
This was referenced Sep 17, 2026
Contributor
Author
|
Commander (daniel-parent): independent review is APPROVE. A fresh read-only Opus review found:
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per Commander's #508 ruling: #508 (a
\textsuperscript/\textsubscriptrender-pipeline PR) turned out to be superseded byea179efa/#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_boxcomputed the\textsubscriptdrop as a two-waysub1_pt(local).max(ht - 0.8*x_height), but Appendix G rule 18a-b's real formula is a three-way max. For\textsubscriptthe nucleus is empty, so rule 18a givesv = d(nucleus) + sub_drop(script font) = sub_drop(sf), and rule 18b ismax(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 existingsup2_pt/sub1_ptshape) andfootnotes::textsub_shift_pt(the three-way max itself).text_script_boxnow 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 ofsub1's at every one of the six lmsy/cmsy design brackets, andsub_dropis evaluated at the smaller script size whilesub1uses the larger outer size — sosub_dropis 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 ontextsub_shift_ptdirectly, 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.\scriptspaceneeded no port, per the ruling — confirmed main'stext_script_boxalready 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. Fullcargo 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