Skip to content

render-pipeline: paint vertical extensible delimiters from MathVariants assemblies - #227

Merged
GoKubar merged 1 commit into
mainfrom
agent/linux-math-assemblies/vertical-assemblies
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/linux-math-assemblies/vertical-assemblies

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

A \left(/\left[/\left\{/\left|/\left\lceil/\left\lfloor/\sqrt taller 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, because parse_vertical_variants read only the variant records and skipped glyphAssemblyOffset. The top piece fell through to the size-chain branch and drew one small fixed variant; every other piece drew nothing and raised a math_glyph_unmapped warning. A six-row \left[ array \right] painted an 18 pt bracket where a 72 pt one belongs.

What changed

  • One parse_variants for both axes, returning minConnectorOverlap (20 in Latin Modern Math) and a pub struct AssemblyPart with the whole GlyphPartRecord: startConnectorLength, endConnectorLength, fullAdvance and the fExtender flag (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_piece recognises a placed cmex glyph as a recipe piece and otf_gid maps it to the part with the same role (cmex's rep ↔ the flagged extender, bot/top ↔ the outermost fixed parts, mid ↔ the one between two extenders).
  • typeset::math_items paints 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)

\showbox in a 10 pt article; array6 is a six-row array. "before"/"after" are the painted ink 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. 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_DIRS at apps/mac/Fonts.

  • amsmath oracle corpus 59/59 within 0.5 bp (control 59/59).
  • amssymb oracle corpus 38/39 — same as the control; 32-braces-narrow (worst 1.012 bp) is a horizontal \overbrace case that fails identically before and after.
  • cargo test --release on crates/render-pipeline: 196 passed, 0 failed (control 191 + this change's 5 new tests; failing set empty on both).
  • HW1 3 pages / 0 errors / 6 warnings, HW2 3 pages / 0 errors / 9 warnings — diagnostics identical to the control, no overfull reported.
  • fixtures/real-world through the CLI: status, page count and error count unchanged everywhere; 9 math_glyph_unmapped warnings disappear (math-sheet 7, input-bibliography 2) and nothing new appears. Zero font diagnostics in every run.

Out of scope, found while measuring

  • \|/\Vert reaches 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 is vendor/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.
  • TexMathMetrics always builds CmMathMetrics with ExtensionSizing::Fixed, but amsmath/amsfonts redeclare OMX/cmex/m/n without sfixed. In an 11 pt article loading amsmath, pdfTeX's \textfont3 is cmex10 at 10.95pt while 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::Designs already 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

…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
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