Repository navigation
math-layout: math fonts at every LaTeX text size, amsmath cmex designs, \prime, \epsilon/\varepsilon (size oracle 37/37) - #172
Merged
Conversation
…s, \prime, \epsilon/\varepsilon, one-character groups
- cm: `declare_math_sizes` (fontmath.ltx \DeclareMathSizes, latex.ltx
\calculate@math@sizes), `design_for` (ot1cmr/omlcmm/omscmsy and the
lmodern .fd ranges), `CmMathMetrics::for_text_size` and `with_extension`,
`tfm_by_name`; `ExtensionSizing::Designs` for amsmath/amsfonts' sized
OMX/cmex (cmex7/8/9/10 at the math size).
- Embedded TFMs gain cmr9, cmr17, cmmi9, cmsy9, cmex7, cmex8, cmex9
(appended to ALL_FONTS, existing font ids unchanged).
- symbol_slot: \prime U+2032 = cmsy "30; U+03B5 (\varepsilon) = cmmi "22,
U+03F5 (\epsilon) stays "0F.
- layout: TeX §1186 unpacks a one-Ord group (`{x}^2`, `\mathop{x}`), and
`Nucleus::TextChar` sets one upright fam0 character (`\mathrm{K}`) as a
math character for Rule 18a and make_op.
- tests/size_oracle: 37 pdflatex fixtures (10/11/12pt classes, 8-24.88pt
text sizes, with and without amsmath): all glyph identities match and
every glyph/rule is within 0.5bp (33 within 0.005bp; \bmod/\pmod 0.26-0.32bp
from the cmr o-d kern math-layout's Text does not apply).
Implementation-Agent: Claude Opus 5 (subagent kabir-claude math font metrics, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 13, 2026
This was referenced Sep 14, 2026
GoKubar
pushed a commit
that referenced
this pull request
Sep 15, 2026
…prime (#278) (#528) What changed: - The prime's box geometry already matched pdflatex (compiler #174 and math-layout #172): script size, sup shift, one superscript for f'', f'^2 joining it, f_1'/x'_a sub+sup. What was wrong was the painted glyph. The pipeline drew cmsy "30 with Latin Modern Math's cmap glyph for U+2032 (`minute`, ink 430..748/1000 em). That glyph is pre-raised for unscripted Unicode use, so at the superscript position it sat 2.7-3.1bp too high at the bottom and 1.3-1.5bp at the top. - mathfont.rs reads the face's GSUB `ssty` lookups (AlternateSubst, plus Single and Extension). mathtex.rs paints cmsy "30 with the first ssty alternate, `minute.st` (ink 96..549, cmsy's unraised design; lmsy7 is 41..559). - tests/math_primes.rs pins the pdflatex \showbox oracle (10pt and 12pt, inline and display, f'(x) f'' f''' f^{\prime} f'^2 f_1' x'_a) for placement, and lmsy7/lmsy8 AFM ink for the prime, at 0.5bp. What was run: - cargo test --test math_primes (before fix): test result: FAILED. 1 passed; 1 failed - cargo test --test math_primes (after): test result: ok. 2 passed; 0 failed - render-pipeline full suite: every failure (letter_class_geometry 5, uline 2, underline_sout 4, xcolor_oracle 1) panics at src/adapter.rs:1261, the par-leading debug_assert that open PR #517 fixes; no other failures - math-layout and compiler: see PR Next step: re-check the Mac app rendering of f'(x) once this lands. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.
Math font metric gaps reported by the siunitx (#163/#168), footnotes (#154), headings/TOC (#141/#151), algorithmic (#159/#162) and HW residuals (#171) lanes. Additive API only. Existing constructors (
latex_10pt,latex_12pt) andALL_FONTSids are unchanged. Basemain.Changes
Sizes and designs (
cm.rs)declare_math_sizes(text_pt)gives the\DeclareMathSizestable from fontmath.ltx 75-86. Undeclared sizes use\calculate@math@sizes(.7/.5, TeX multiplication).design_for(family, size)picks the design from the ot1cmr/omlcmm/omscmsy.fdfiles. It uses the lmodern ranges, which select the same designs at every declared size.CmMathMetrics::for_text_size(pt)andwith_extension(..)build the metrics for any text size.tfm_by_namelooks up an embedded TFM.\fontname\textfont0..3for every size command in 10/11/12pt articles.Family 3 (
ExtensionSizing::Designs)OMX/cmexis notsfixed.\textfont3is cmex10 at 10.95pt,\scriptfont3cmex8,\scriptscriptfont3cmex7 at 6pt. HW1/HW2 are such documents. lmodern keepslmex10fixed (Fixed).New embedded TFMs (generator extended)
\smallin 10pt,\LARGE+).Symbols
\primeU+2032 is cmsy "30. It used to fall back to Latin Modern Math's advance.\varepsilonU+03B5 is cmmi "22 (was "0F, 0.64pt too narrow).\epsilonU+03F5 stays "0F. The compiler side is in a separate PR.Layout
{x}^2places its scripts likex^2, and\mathop{x}is centred.Nucleus::TextChar(char)sets one upright fam0 character (\mathrm{K}) as a math character. The siunitxK^{-1}exponent sat 0.78bp high because it was treated as a box.ml::Nucleusexhaustively, so the new variant needs no pipeline arm.Oracle
tools/size_oracle.py(MacTeX 2026 pdflatex, oracle only) writestests/size_oracle/expected.txt.tests/size_oracle.rslays out the same 37 formulas and checks glyph font, code and size, plus positions within 0.5bp. It covers:\mathrm{K}^{-1},\mathrm{m}^2\,\mathrm{s}^{-1},\mathrm{d}x,f',f'',\epsilon/\varepsilon;\bmod/\pmodand the kernel\pmod;\dotsas dotsc, dotsb and before),\cdots, the kernel\ldots;\sin^2,\lim_{},\frac,\sum,\sqrtat note/heading/\hugesizes, and digits and letters with scripts.37/37 pass. 33 are within 0.005bp.
\bmod/\pmodare off by 0.26-0.32bp because math-layout's multi-characterTextdoes not apply cmr's o-d kern (pre-existing; the pipeline's text sink kerns).cargo test(math-layout): all green (lib 10, golden 28, size_oracle 2).Conflicts / follow-ups
TexMathMetrics::for_text_size) and render-pipeline: footnotes with floats, \thanks notes, footnote-size math (includes #140) #154 (at_text_size) each carry a local size table limited to the old embedded designs (no 9pt, no cmr17). After this merges they can callCmMathMetrics::for_text_size. The render-pipeline and compiler companions follow as separate draft PRs.layout.rs.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu