Repository navigation
render-pipeline: paint vertical extensible delimiters from MathVariants assemblies - #227
Merged
Merged
Conversation
…ts assemblies
`parse_vertical_variants` skipped `glyphAssemblyOffset` (it read the variant
records only), so Latin Modern Math's vertical glyph assemblies were never
loaded. A `\left(`/`\left[`/`\left\{`/`\left|`/`\left\lceil`/`\left\lfloor`/
`\sqrt` taller than every fixed cmex size is stacked by TeX from the
extensible recipe's top/middle/bottom/repeat pieces (tex.web §713), and those
cmex slots had no glyph mapping: `otf_gid` fell through to the size-chain
branch, so the top piece drew one small fixed variant and the rest drew
nothing at all, one `math_glyph_unmapped` warning each. A six-row
`\left[ array \right]` painted an 18 pt bracket where a 72 pt one belongs;
`\left|` painted twelve 12.02 pt bars stacked 6 pt apart.
Reading them:
* `parse_vertical_variants`/`parse_horizontal_constructions` become one
`parse_variants`, returning `minConnectorOverlap` (20 in Latin Modern Math)
and both axes' constructions with the same value type. Assembly parts are
a new `pub struct AssemblyPart` carrying the whole `GlyphPartRecord` —
`startConnectorLength`, `endConnectorLength`, `fullAdvance` and the
`fExtender` flag — which the horizontal path had been discarding.
* `MathFonts::vertical_assembly(ch, span, size)` builds the assembly for an
exact span: non-extender parts once, every extender repeated the same
number of times, one uniform overlap at every joint, at least
`minConnectorOverlap` and at most each joint's own
`min(end of the lower part, start of the upper)`; the repeat count is the
smallest that covers the span. Every Latin Modern Math vertical part draws
from its origin up to exactly its `fullAdvance`, so the result has ink from
0 to `span` and no seam.
* `TexMathMetrics::extensible_piece` recognises a placed cmex glyph as a
piece of the recipe ending that character's size chain (TeX never sets the
extensible character itself as a delimiter: `var_delimiter` switches to the
recipe as soon as it reaches an `ext_tag` character), and `otf_gid` maps it
to the part with the same role. The roles line up because both describe the
same delimiter: cmex's `rep` is the flagged extender, `bot`/`top` are the
outermost fixed parts, `mid` is the one between two extenders, and a
delimiter cmex builds without an end piece has none there either
(`\lceil`: extender then top; `\lfloor`: bottom then extender).
* `typeset::math_items` paints a whole stacked run as one assembly and one
cluster instead of piece by piece. Per-piece painting cannot work: the
font's parts are a different design from cmex's, so the extender's own
length (0.498 em for `(`, 1.202 em for `|`) is not cmex's 0.6 em repeat,
and the parts are held together by overlapping connectors rather than by
abutting boxes. The layout is untouched — the run's box is still exactly
the one TeX's `stack_extensible` produced.
Measured against pdfTeX 3.141592653 (TeX Live 2025) `\showbox`, 10 pt
`article`, `$\displaystyle\left<d> array6 \right<d>$` and friends, where
`array6` is a six-row `array`. The layout box was already pdfTeX's; what
changes is the ink that covers it ("before"/"after" are the painted extent,
from the v2 display list):
fixture pdfTeX box after (parts) before (painted ink)
\left( frac^3 \right) 36.00036 pt 36.00034 (4) 17.92 pt, 1 variant
\left( array6 \right) 72.00072 72.00070 (11) 17.92 pt, 1 variant
\left[ array6 \right] 72.00072 72.00070 (7) 18.00 pt, 1 variant
\left\{ array6 \right\} 72.00072 72.00073 (9) 11.00 pt, 1 variant
\left| array6 \right| 72.00072 72.00073 (7) 78.02 pt, 12 bars
\left\lceil array6 72.00072 72.00072 (7) 11.00 pt, 1 variant
\left\lfloor array6 72.00072 72.00072 (7) 18.00 pt, 1 variant
\sqrt{array6} 78.00077 78.00078 (11) 18.00 pt, 1 variant
\left( array10 \right) 120.00120 120.00119 (21) 17.92 pt, 1 variant
\Bigg\| 30.00030 30.00031 (3) 36.02 pt, 5 bars
The 2e-5 pt residual is the display list's 2^-20 bp tick quantisation. The
part counts are the font's, not cmex's, for the reason above. The ink spans
the box exactly in each case: the bottom part's baseline is the box's bottom
edge and the top part's ink top is the box's top edge (asserted in the new
`tests/extensible_delimiters.rs`).
Gates (FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRS at apps/mac/Fonts), each compared
against a control build of this same base:
* amsmath oracle corpus: 59/59 within 0.5 bp (control 59/59).
* amssymb oracle corpus: 38/39 (control 38/39; `32-braces-narrow`, worst
1.012 bp, is a horizontal `\overbrace` case and fails identically before
and after).
* `cargo test --release` on `crates/render-pipeline`: 196 passed, 0 failed
(control on this base: 191; the 5 new tests are this change's. The
failing set is empty on both.)
* HW1: 3 pages, 0 errors, 6 warnings, no overfull diagnostic — byte-for-byte
the same diagnostics as the control. HW2: 3 pages, 0 errors, 9 warnings,
likewise unchanged.
* `fixtures/real-world` through the CLI: every fixture's status, page count
and error count unchanged; 9 `math_glyph_unmapped` warnings disappear
(`math-sheet` 7, `input-bibliography` 2) and nothing new appears. No font
diagnostic in any run.
Implementation-Agent: Claude Opus 5 (engine-engineer subagent, vertical extensible assemblies lane, linux-primary)
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 14, 2026
GoKubar
marked this pull request as ready for review
September 14, 2026 01:35
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.
A
\left(/\left[/\left\{/\left|/\left\lceil/\left\lfloor/\sqrttaller than every fixed cmex size is stacked by TeX from an extensible recipe (tex.web §713). Those cmex slots had no Latin Modern Math mapping, becauseparse_vertical_variantsread only the variant records and skippedglyphAssemblyOffset. The top piece fell through to the size-chain branch and drew one small fixed variant; every other piece drew nothing and raised amath_glyph_unmappedwarning. A six-row\left[ array \right]painted an 18 pt bracket where a 72 pt one belongs.What changed
parse_variantsfor both axes, returningminConnectorOverlap(20 in Latin Modern Math) and apub struct AssemblyPartwith the wholeGlyphPartRecord:startConnectorLength,endConnectorLength,fullAdvanceand thefExtenderflag (the horizontal path had been discarding all four).MathFonts::vertical_assembly(ch, span, size)builds an assembly for an exact span — fixed parts once, every extender repeated the same number of times, one uniform overlap per joint within the font's limits, the smallest repeat count that covers the span.TexMathMetrics::extensible_piecerecognises a placed cmex glyph as a recipe piece andotf_gidmaps it to the part with the same role (cmex'srep↔ the flagged extender,bot/top↔ the outermost fixed parts,mid↔ the one between two extenders).typeset::math_itemspaints a stacked run as one assembly and one cluster. Per-piece painting cannot work: Latin Modern Math's extender is 0.498 em for(and 1.202 em for|, not cmex's 0.6 em repeat, and the parts join by overlapping connectors, not by abutting boxes.The layout is untouched. Box heights and piece counts still come from math-layout's
stack_extensible; only the painting changes.Measured against pdflatex (TeX Live 2025)
\showboxin a 10 ptarticle;array6is a six-rowarray. "before"/"after" are the painted ink extent, from the v2 display list.\left( frac^3 \right)\left( array6 \right)\left[ array6 \right]\left\{ array6 \right\}\left| array6 \right|\left\lceil array6\left\lfloor array6\sqrt{array6}\left( array10 \right)\Bigg|The 2e-5 pt residual is the display list's 2^-20 bp tick quantisation. Part counts are the font's, not cmex's, for the reason above. The ink spans the box exactly: the bottom part's baseline is the box's bottom edge and the top part's ink top is the box's top edge (asserted in
tests/extensible_delimiters.rs).Gates
Each compared against a control build of this same base,
FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRSatapps/mac/Fonts.32-braces-narrow(worst 1.012 bp) is a horizontal\overbracecase that fails identically before and after.cargo test --releaseoncrates/render-pipeline: 196 passed, 0 failed (control 191 + this change's 5 new tests; failing set empty on both).fixtures/real-worldthrough the CLI: status, page count and error count unchanged everywhere; 9math_glyph_unmappedwarnings disappear (math-sheet7,input-bibliography2) and nothing new appears. Zero font diagnostics in every run.Out of scope, found while measuring
\|/\Vertreaches the pipeline as U+2223 (\mid), not U+2016, so a tall\|is built from cmex"0C(3.33334 pt wide) where pdfTeX uses"0D(5.55557 pt). The mapping isvendor/compiler's (math.rs: "Symbol has no double bar U+2016: two real verticalbar glyphs"), a Core-14 workaround that the OpenType math face does not need. The assembly machinery here does the right thing with whatever character it is handed.TexMathMetricsalways buildsCmMathMetricswithExtensionSizing::Fixed, but amsmath/amsfonts redeclareOMX/cmex/m/nwithoutsfixed. In an 11 pt article loading amsmath, pdfTeX's\textfont3iscmex10 at 10.95ptwhile FlashTeX uses cmex10 at 10 pt, so stacked delimiters land on a different piece count (fixtures/real-world/math-sheet:\left[39.42 pt in pdfTeX, 42.00 pt here).cm::ExtensionSizing::Designsalready models this; nothing selects it.Draft: not for merge until a reviewer has looked at the assembly algorithm.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu