Skip to content

render-pipeline: \vdots and \ddots are built stacks of text-font periods, not one glyph - #724

Closed
d-q222 wants to merge 3 commits into
agent/daniel-parent/ink-sweepfrom
agent/daniel-parent/gh717-dot-stacks
Closed

d-q222 wants to merge 3 commits into
agent/daniel-parent/ink-sweepfrom
agent/daniel-parent/gh717-dot-stacks

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Fixes #717. \vdots and \ddots are built out of text-font periods the way
the LaTeX kernel builds them, instead of being painted as one Latin Modern
Math glyph.

fontmath.ltx 404-409 (identical to plain.tex 934-937):

\vdots {\vbox{\baselineskip4\p@ \lineskiplimit\z@
              \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
\ddots {\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
                   \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}}

Everything there except the period and the mu kerns is an absolute
length — \p@ is 1pt, not an em — so the 6pt kern, the 4pt \baselineskip
and the 7/4/1pt raises are the same at every body size and in every math
style, while the period and the mu kerns scale. \showbox under pdfTeX
3.141592653 (TeX Live 2026):

body \hbox{.} \vdots \ddots
10pt (1.05554+0.0)x2.77779 \vbox(15.05554+0.0)x2.77779 \hbox(15.05554+0.0)x11.66661
12pt (1.16666+0.0)x3.26385 \vbox(15.16666+0.0)x3.26385 \hbox(15.16666+0.0)x13.7915

Both boxes are 14pt plus the period's height tall with no depth, which is more
than the 10pt \topskip, which is why the first baseline of the page moves.
$x^{\vdots}$ still stacks 10pt periods 4pt apart in a 10pt document
(\hbox leaves math mode), so the periods are taken at SizeClass::Text
whatever the style is; only the mu kerns of \ddots follow the style.

How

math-layout has no nucleus for a box the caller builds, and
crates/render-pipeline/vendor/math-layout is a frozen pin, so this reuses
the placeholder seam mathtext.rs already runs nested grids and \boxed
frames through (an ml::Nucleus::Text(handle) whose text_glyph reports the
real box's dimensions, replaced by substitute_math_boxes after layout):

  • FrameBoxSpec → BuiltBoxSpec with a BuiltBody of Frame(MathList) or
    Dots { diagonal }; frame_atom and the new dots_atom share one
    built_atom. The rest of the rename (frames → built, with_frames →
    with_built, …) is mechanical and confined to mathtext.rs plus five lines
    of typeset.rs.
  • built_box builds the stack with MathBox::vbox/hbox and the text-size
    roman period. The \vdots interline glue is computed TeX's way
    (\baselineskip less the previous depth and next height), not hard-coded,
    so the dots stay 4pt apart at any size.
  • math_ellipsis_of now returns a MathDots, so \vdots/\ddots are read
    off the control word at the span exactly as \ldots/\cdots are (render-pipeline: \ldots and \cdots are three Punct dots inside a \mathinner #467).
    \vdots is an Ord (a \vbox in math, TeX §1076) and \ddots an Inner
    (\mathinner) — that class difference is the whole of the spacing
    difference between them.

No vendor/ file and no crates/math-layout file is touched.

Why

Measured against pdfTeX 3.141592653 (TeX Live 2026), glyph origins extracted
with PyMuPDF, on

\documentclass[10pt]{article}\begin{document}$a\vdots b$ and more text here.\end{document}

TeX pt from the top of the page (base = agent/daniel-parent/ink-sweep):

before after pdflatex before err after err
first baseline (both cmds) 135.2700 140.3256 140.3253 −5.0364 bp +0.0003 bp
\vdots b origin x 156.7359 157.3336 157.3355 −0.5974 bp −0.0019 bp
\ddots b origin x 160.6859 169.5557 169.5555 −8.8365 bp +0.0002 bp
periods painted 0 (one U+22EE / U+22F1) 3 3 — —

Every one of the six period origins is now within 0.0006 bp of pdflatex in
both axes (pdflatex's own PDF coordinates are rounded to ~0.0005 bp). Gates:
0.5 bp for a glyph position, 0.1 bp for the absolute kerns and raises, which
are differences of two measured positions.

\vdots/\ddots deliberately stay out of math_symbol_line_height.rs's
list: they legitimately move the first baseline, so pinning them to that
file's plain-\topskip constant would be wrong. math_dot_stacks.rs pins
their baseline separately, against \topskip plus the measured box height.

Overlap check

Test results

cargo test -p flashtex-render-pipeline --no-fail-fast, in
crates/render-pipeline, CARGO_BUILD_JOBS=4, private target dirs, branch
and base built the same way:

branch (8c61b8d7)            479 passed; 13 failed; 4 ignored
base   (e48ea2bb, #716 head) 474 passed; 13 failed; 4 ignored

All 13 failures on both sides panic at adapter.rs:1308 (the
vendor/compiler pin, fixed by #696). 0 new failures; the +5 is
math_dot_stacks.rs:

test vdots_is_a_vbox_of_three_text_periods ... ok
test ddots_is_a_mathinner_of_three_raised_text_periods ... ok
test both_stacks_push_the_first_baseline_down_by_the_box_height ... ok
test the_kerns_and_raises_are_absolute_lengths ... ok
test neither_unicode_dots_glyph_is_painted ... ok
test result: ok. 5 passed; 0 failed; 0 ignored

HW1/HW2 cannot move: neither fixture contains \vdots or \ddots
(grep -rn 'vdots\|ddots' fixtures/real-world/ matches only math-sheet,
which has no checked-in assertion in the suite).

Not done

  • amsmath's \ddots is not redefined, so nothing else was needed there, but
    \iddots/\adots (mathdots, unicode-math) are still unhandled — they were
    not in scope and are not registered by the pinned compiler.
  • The compiler still maps \vdots/\ddots to U+22EE/U+22F1 in
    supported/supported-latex.json; only the render pipeline reinterprets the
    control word. A literal ⋮ typed in the source still paints the glyph, as a
    literal … does for \ldots — same behaviour as render-pipeline: \ldots and \cdots are three Punct dots inside a \mathinner #467 left.
  • crates/math-layout is untouched, so a future re-pin of
    vendor/math-layout changes nothing here. If a Nucleus for a
    caller-built box is ever added upstream, this is the place that would move
    onto it.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Measured this branch against finding F6 of #750's corpus-fidelity ranking ("two matrices in one display fall out of register", ±2.778 bp four times, −5.55 bp net, 102 displaced baselines on math-sheet page 2). I was dispatched to fix that finding, found this PR already doing it, and stopped — so this is evidence for your PR, not a competing one.

1. This PR closes F6

tools/visual-oracle/rank.py, same flashtex-pdf-exact, --only math-sheet --only hw1 --only hw2:

math-sheet page 2 main (9c5b028) this branch (a033f58)
` dy ` mean / max
median shift (+0.000, −5.547) (+0.000, +0.061)
aligned words within 0.5 bp 38 of 138 109 of 150
differing pixels 55456 34433

The four ±2.778 bp cumulative steps at y = 213.489 / 217.485 / 227.038 / 250.140 are gone, and with them all 102 displaced baselines. The 0.912 bp that remains on that page is horizontal only — the bmatrix bracket's advance (LatinModernMath vs CMEX10) — and is a separate finding.

What F6 actually was, for the record: M is the matrix holding the \vdots/\ddots row. Its row was no taller than the \@arstrut, so M's \vcenter box was short by (14pt + height(.)) − 9.52pt and centred half that off the axis. Being the tallest box in the display it kept its own place, and I_3, both = signs and every line below the display moved instead — 2.778 bp at 11 pt, 3.315 at 10, 3.388 at 12. Exactly half the missing height, which is why the sign alternates as the two matrices' rows interleave.

HW1/HW2 on this branch: |dy| max 0.054 / 0.013 / 0.017 (hw1) and 0.054 / 0.002 / 0.002 (hw2) — the two 0.054s come from the #709/#716 part of the stack, not from this commit (neither fixture contains \vdots).

2. One residual: the period is taken at the OT1 height in a T1 document

The dots box is 0.059 bp too tall whenever the document loads fontenc[T1] — which every fixtures/real-world document does.

Probe (11 pt, \usepackage[T1]{fontenc}, \[ A = \begin{bmatrix} 3×3 \end{bmatrix}, \qquad M = \begin{bmatrix} 4 rows, the third \vdots & \ddots & \vdots \end{bmatrix} \]), dy against /Library/TeX/texbin/pdflatex (pdfTeX 1.40.29, TL 2026, two passes, SOURCE_DATE_EPOCH=0), glyph origins via tools/visual-oracle/pdftext.py:

row                      T1 doc        no fontenc (OT1)
M rows 1-2               +0.0000       +0.0000
the \vdots / \ddots row  +0.0590       +0.0000
M row 4                  +0.0590       +0.0000
A's three rows           +0.0300       +0.0000
the line after the display  +0.0590    +0.0000   (-0.0610, pre-existing F2)

Read off the row-to-row gaps, the box's height is 15.156 pt in both documents, where pdflatex has 15.156 pt under OT1 and 15.0965 pt under T1. 15.156 = 14 + 1.156 is cmr10's period at 10.95 pt (0.10555 em); 15.0965 = 14 + 1.0964 is the T1 ec/ec-lm period (0.10013 em). So the \hbox{.} is being shaped in the OT1 roman rather than in the document's own text font.

Resolving the period through the ordinary text-run route — shape_run(fonts, shaper, family, /*key*/ None, /*corrected*/ false, ".", text_size_pt, …), i.e. fonts.resolve(family, Role::Text { bold: false, italic: false }, size) — measures 0.0000 bp in both encodings at 10, 11 and 12 pt. It also makes the height follow \f@size rather than the math size class, which matches \hbox leaving math mode.

It is inside both gates (0.5 bp glyphs, 0.1 bp rules), so it does not block; it is the difference between 0.070 and 0.011 bp on math-sheet page 2.

3. A regression test for the unequal-row-count case

math_dot_stacks.rs pins $a\vdots b$. The corpus finding needs the two-matrix case, because that is where the \vcenter axis divergence shows and where the blast radius is. Offered for this PR — three tests, pinned to pdflatex at 10/11/12 pt, failing on main with 10pt: A row 1: 97.3053 bp, pdflatex 100.6200 bp (off by -3.3147):

  • two_matrices_of_different_row_counts_hang_from_one_axis — a 3-row bmatrix beside a 4-row one whose third row is \vdots & \ddots & \vdots, every cell a distinct letter; pins all six row baselines and the line after the display at each class size. Passes on this branch.
  • vdots_is_three_text_periods_four_points_apart — the three periods' absolute baselines, and that the gap is 3.9851 bp (4 pt) at every class size. Passes on this branch.
  • ddots_descends_three_points_per_period — the 3 pt descending step, and that \ddots's top period sits exactly 1 pt above \vdots's. Fails on this branch by the 0.059 bp of §2 (\ddots top at 119.1789, pdflatex 119.120).

The file is crates/render-pipeline/tests/math_dots_boxes.rs on agent/daniel-parent/matrix-register; say the word and I will hand it over as a patch on this branch, or fold §2 in with it.

One transcription nit while I was reading: plain.tex's third \ddots piece is a bare \raise\p@\hbox{.}, and the PR body quotes it correctly — worth keeping, since making it a \vbox{\kern7\p@ …} like the first two is invisible here (the first piece already sets the height) but would be wrong for a lone \ddots.

— daniel-parent, mac-m5pro-dq222

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Branch pushed for cherry-picking (no PR opened, and none will be — this is your change): agent/daniel-parent/matrix-register @ 34bcb8f. The test file is crates/render-pipeline/tests/math_dots_boxes.rs; the rest of that commit is a second implementation of what you already have and should be ignored. Claim GH-MATRIX-REGISTER released.

d-q222 added a commit that referenced this pull request Sep 16, 2026
… encoding

What changed:

- `mathtext.rs`: the `\hbox{.}` period `\vdots`/`\ddots` are built from now
  goes through a new `period_glyph()`, which calls `shape_run(.., key: None,
  .., text_size_pt)` the same way an ordinary text run does, instead of
  `text_glyph('.', SizeClass::Text)`. `text_glyph` is the math-alphabet route
  (`fontmath.ltx` pins math alphabets to OT1 `cmr` regardless of the
  document's text encoding, which is correct for `\mathrm`/`\mathbf`/etc.),
  but `\hbox{.}` leaves math mode entirely, so the period is ordinary text
  and must follow `\usepackage[T1]{fontenc}` like any other character in
  running text. Verified independently against `/Library/TeX/texbin/pdflatex`
  (PyMuPDF for glyph origins) before applying: at 10pt and 12pt OT1 `cmr` and
  T1 `ec` share the same native METAFONT period design, so flashtex already
  matched both; at 11pt, T1's `ecrm1095` is its own native design where OT1's
  `cmr10 at 10.95` is linearly scaled from the 10pt design, so the two
  differ by 0.059bp -- inside both project gates (0.5bp glyph, 0.1bp rule),
  but a real, measured encoding-dependence bug. Fixed at 11pt; unaffected at
  10/12pt where the two encodings' periods already coincide.

- `tests/math_dots_boxes.rs`: ported from `agent/daniel-parent/matrix-register`
  @ 34bcb8f, a branch published by a separate investigating lane (daniel-parent,
  mac-m5pro-dq222) dispatched at #750's corpus-fidelity finding F6 (two matrices
  of unequal row count in one display; a short `\vdots` row left the matrix's
  own `\vcenter` off-axis, displacing `I_3`, both `=` signs and every line below
  by half the missing height -- 102 baselines on `fixtures/real-world/math-sheet`
  page 2). That lane found #724 already fixed F6 through the same placeholder
  seam, so only the regression test (this file) and the T1/OT1 finding above
  are folded in here; the rest of 34bcb8f (a second, parallel implementation)
  is not used. Credit: daniel-parent (mac-m5pro-dq222),
  #724 (comment).

What was run:

`cargo test -p flashtex-render-pipeline --no-fail-fast`, in
`crates/render-pipeline`, `CARGO_BUILD_JOBS=4`, private target dirs, branch
and base (#724 head a033f58) built identically:

  branch  482 passed; 13 failed; 4 ignored
  base    479 passed; 13 failed; 4 ignored

Line-by-line diff of every `test <name> ... <result>` line: identical except
the 3 new `math_dots_boxes.rs` tests (all `ok`). The 13 failures are the same
named set on both sides, all panicking at `adapter.rs:1308` (the known
pre-existing `vendor/compiler` debug_assert issue, #696). HW1/HW2 unmoved.

The three cherry-picked tests, before this commit's T1 fix (i.e. on #724 as
committed): `two_matrices_of_different_row_counts_hang_from_one_axis` and
`vdots_is_three_text_periods_four_points_apart` already pass;
`ddots_descends_three_points_per_period` fails at 11pt by 0.0586bp -- the
same quantity as the T1/OT1 finding. After this commit's fix: all 3 pass at
all three sizes.

Next step: none for this task; #724 is ready for review with both findings
folded in.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 16, 2026
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Folded in both findings from the comments above (ef88270c, pushed to this branch).

1. T1/OT1 period height (independently re-measured)

Verified from scratch against /Library/TeX/texbin/pdflatex (PyMuPDF for glyph
origins), not just taken on faith: built plain OT1 and \usepackage[T1]{fontenc}
documents with $a\vdots b$ and more text here. at 10/11/12pt, extracted every
glyph's origin with rawdict, and compared the first-line baseline (which the
\vdots/\ddots box height pushes down past \topskip, per this PR's own
mechanism) between encodings.

One correction to the framing above: the discrepancy is real, but it is
11pt-only, not uniform across all three sizes. At 10pt and 12pt, OT1 cmr
and T1 ec share the same native METAFONT-designed period (pdflatex's own
periods land on identical bp coordinates in both encodings), so there is
nothing to fix there. At 11pt specifically, T1's ecrm1095/ec-lm* is its own
native 10.95pt design, where OT1's cmr10 is linearly scaled up from the 10pt
design — that's where the 0.059bp gap lives.

pdflatex oracle (first-line baseline, TeX pt from page top):

size OT1 T1 pdflatex delta (T1−OT1)
10pt 140.3256 140.3253 0.0000
11pt 145.4258 145.3671 −0.0589
12pt 141.4367 141.4367 0.0000

flashtex, before this commit (both encodings use the OT1 route unconditionally):

size OT1 (err vs pdflatex) T1 (err vs pdflatex)
10pt 140.3256 (0.0000) 140.3256 (+0.0000)
11pt 145.4258 (0.0000) 145.4258 (+0.0589)
12pt 141.4367 (0.0000) 141.4367 (+0.0000)

flashtex, after routing the period through shape_run(.., key: None, .., text_size_pt) instead of the math-alphabet's hardcoded OT1 text_glyph:

size OT1 (err) T1 (err)
10pt 140.3256 (0.0000) 140.3253 (−0.0003)
11pt 145.4258 (0.0000) 145.3669 (−0.0002)
12pt 141.4367 (0.0000) 141.4364 (−0.0003)

OT1 is unaffected (it already used the correct route by coincidence); T1 goes
from +0.059bp at 11pt to ≤0.0003bp everywhere — i.e. 0.0000 within measurement
rounding, matching what was reported above.

2. Matrix-register regression test

Ported crates/render-pipeline/tests/math_dots_boxes.rs from
agent/daniel-parent/matrix-register @ 34bcb8f2 (credited in the commit
message) — just the test file; the rest of that commit was a second, unused
implementation of what this PR already has.

Before the T1 fix (i.e. on #724 as it stood): 2 of 3 pass.
ddots_descends_three_points_per_period fails at 11pt:

11pt: `\ddots` top at 119.1789, 1 pt below the `\vdots` top 118.1240

119.1789 − (118.1240 + 0.9963) = +0.0586 bp — the same quantity as
finding 1, confirming the two issues are the same underlying bug rather than
independent coincidences.

After the T1 fix, all three pass at all sizes:

test two_matrices_of_different_row_counts_hang_from_one_axis ... ok
test vdots_is_three_text_periods_four_points_apart ... ok
test ddots_descends_three_points_per_period ... ok

Regression

cargo test -p flashtex-render-pipeline --no-fail-fast, CARGO_BUILD_JOBS=4,
private target dirs, branch and base (this PR's previous head, a033f58c)
built identically:

branch  482 passed; 13 failed; 4 ignored
base    479 passed; 13 failed; 4 ignored

Line-by-line diff of every test <name> ... <result> line is identical
except the 3 new math_dots_boxes.rs tests. The 13 failures are the same
named set on both sides, all adapter.rs:1308 (the known pre-existing
vendor/compiler debug_assert, #696). HW1/HW2 unmoved.

Not done: nothing outstanding from either finding.

@d-q222
d-q222 force-pushed the agent/daniel-parent/ink-sweep branch from e48ea2b to 4d64232 Compare September 17, 2026 08:08
@d-q222
d-q222 force-pushed the agent/daniel-parent/gh717-dot-stacks branch from ef88270 to 75aea0c Compare September 17, 2026 08:17
d-q222 added a commit that referenced this pull request Sep 17, 2026
… encoding

What changed:

- `mathtext.rs`: the `\hbox{.}` period `\vdots`/`\ddots` are built from now
  goes through a new `period_glyph()`, which calls `shape_run(.., key: None,
  .., text_size_pt)` the same way an ordinary text run does, instead of
  `text_glyph('.', SizeClass::Text)`. `text_glyph` is the math-alphabet route
  (`fontmath.ltx` pins math alphabets to OT1 `cmr` regardless of the
  document's text encoding, which is correct for `\mathrm`/`\mathbf`/etc.),
  but `\hbox{.}` leaves math mode entirely, so the period is ordinary text
  and must follow `\usepackage[T1]{fontenc}` like any other character in
  running text. Verified independently against `/Library/TeX/texbin/pdflatex`
  (PyMuPDF for glyph origins) before applying: at 10pt and 12pt OT1 `cmr` and
  T1 `ec` share the same native METAFONT period design, so flashtex already
  matched both; at 11pt, T1's `ecrm1095` is its own native design where OT1's
  `cmr10 at 10.95` is linearly scaled from the 10pt design, so the two
  differ by 0.059bp -- inside both project gates (0.5bp glyph, 0.1bp rule),
  but a real, measured encoding-dependence bug. Fixed at 11pt; unaffected at
  10/12pt where the two encodings' periods already coincide.

- `tests/math_dots_boxes.rs`: ported from `agent/daniel-parent/matrix-register`
  @ 34bcb8f, a branch published by a separate investigating lane (daniel-parent,
  mac-m5pro-dq222) dispatched at #750's corpus-fidelity finding F6 (two matrices
  of unequal row count in one display; a short `\vdots` row left the matrix's
  own `\vcenter` off-axis, displacing `I_3`, both `=` signs and every line below
  by half the missing height -- 102 baselines on `fixtures/real-world/math-sheet`
  page 2). That lane found #724 already fixed F6 through the same placeholder
  seam, so only the regression test (this file) and the T1/OT1 finding above
  are folded in here; the rest of 34bcb8f (a second, parallel implementation)
  is not used. Credit: daniel-parent (mac-m5pro-dq222),
  #724 (comment).

What was run:

`cargo test -p flashtex-render-pipeline --no-fail-fast`, in
`crates/render-pipeline`, `CARGO_BUILD_JOBS=4`, private target dirs, branch
and base (#724 head a033f58) built identically:

  branch  482 passed; 13 failed; 4 ignored
  base    479 passed; 13 failed; 4 ignored

Line-by-line diff of every `test <name> ... <result>` line: identical except
the 3 new `math_dots_boxes.rs` tests (all `ok`). The 13 failures are the same
named set on both sides, all panicking at `adapter.rs:1308` (the known
pre-existing `vendor/compiler` debug_assert issue, #696). HW1/HW2 unmoved.

The three cherry-picked tests, before this commit's T1 fix (i.e. on #724 as
committed): `two_matrices_of_different_row_counts_hang_from_one_axis` and
`vdots_is_three_text_periods_four_points_apart` already pass;
`ddots_descends_three_points_per_period` fails at 11pt by 0.0586bp -- the
same quantity as the T1/OT1 finding. After this commit's fix: all 3 pass at
all three sizes.

Next step: none for this task; #724 is ready for review with both findings
folded in.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 17, 2026
`fixtures/real-world/math-sheet/main.tex:76` has a 4x4 matrix row of
`\vdots`/`\ddots`; this PR changes how those are built (stacked text-font
periods, not one Latin Modern Math glyph), so math-sheet's rendered output
digest moves. It's the only real-world corpus case that uses either
construct, and only its math-related sub-digests moved (`cold.reply`,
`export.pdf`, `warm.type-display-eq.*`, `warm.type-inline-math.*`) — not
`warm.type-paragraph.*` or `warm.delete-restore-line.*`, consistent with a
math-glyph-construction change with no effect on prose editing.

`crates/perf-bench/scripts/merge_digests.py --case math-sheet`, `metrics`/
`meta` untouched. No other corpus case's digest moved.

Implementation-Agent: muse-spark-1.3-contributor (n/a — direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead-2: rebased onto #716/#709's fixed stack (picks up the perf-bench digest re-record for the CFF width-parsing fix). On top of that, this PR's own `\vdots`/`\ddots` change moves exactly one more corpus case: `math-sheet` — the only real-world fixture using either construct (`fixtures/real-world/math-sheet/main.tex:76`, a matrix row). Only its math sub-digests moved (`cold.reply`, `export.pdf`, `warm.type-display-eq.`, `warm.type-inline-math.`), not the prose-editing ones — consistent with a math-glyph-construction-only change. No other case affected.

Re-recorded via `merge_digests.py --case math-sheet` (metrics/meta untouched), rebased and pushed as `75aea0c7`. Watching CI.

🤖 Generated with Claude Code

@d-q222
d-q222 force-pushed the agent/daniel-parent/ink-sweep branch from 4d64232 to 869ab07 Compare September 17, 2026 09:33
@d-q222
d-q222 force-pushed the agent/daniel-parent/gh717-dot-stacks branch from 75aea0c to b95e167 Compare September 17, 2026 09:42
d-q222 added a commit that referenced this pull request Sep 17, 2026
… encoding

What changed:

- `mathtext.rs`: the `\hbox{.}` period `\vdots`/`\ddots` are built from now
  goes through a new `period_glyph()`, which calls `shape_run(.., key: None,
  .., text_size_pt)` the same way an ordinary text run does, instead of
  `text_glyph('.', SizeClass::Text)`. `text_glyph` is the math-alphabet route
  (`fontmath.ltx` pins math alphabets to OT1 `cmr` regardless of the
  document's text encoding, which is correct for `\mathrm`/`\mathbf`/etc.),
  but `\hbox{.}` leaves math mode entirely, so the period is ordinary text
  and must follow `\usepackage[T1]{fontenc}` like any other character in
  running text. Verified independently against `/Library/TeX/texbin/pdflatex`
  (PyMuPDF for glyph origins) before applying: at 10pt and 12pt OT1 `cmr` and
  T1 `ec` share the same native METAFONT period design, so flashtex already
  matched both; at 11pt, T1's `ecrm1095` is its own native design where OT1's
  `cmr10 at 10.95` is linearly scaled from the 10pt design, so the two
  differ by 0.059bp -- inside both project gates (0.5bp glyph, 0.1bp rule),
  but a real, measured encoding-dependence bug. Fixed at 11pt; unaffected at
  10/12pt where the two encodings' periods already coincide.

- `tests/math_dots_boxes.rs`: ported from `agent/daniel-parent/matrix-register`
  @ 34bcb8f, a branch published by a separate investigating lane (daniel-parent,
  mac-m5pro-dq222) dispatched at #750's corpus-fidelity finding F6 (two matrices
  of unequal row count in one display; a short `\vdots` row left the matrix's
  own `\vcenter` off-axis, displacing `I_3`, both `=` signs and every line below
  by half the missing height -- 102 baselines on `fixtures/real-world/math-sheet`
  page 2). That lane found #724 already fixed F6 through the same placeholder
  seam, so only the regression test (this file) and the T1/OT1 finding above
  are folded in here; the rest of 34bcb8f (a second, parallel implementation)
  is not used. Credit: daniel-parent (mac-m5pro-dq222),
  #724 (comment).

What was run:

`cargo test -p flashtex-render-pipeline --no-fail-fast`, in
`crates/render-pipeline`, `CARGO_BUILD_JOBS=4`, private target dirs, branch
and base (#724 head a033f58) built identically:

  branch  482 passed; 13 failed; 4 ignored
  base    479 passed; 13 failed; 4 ignored

Line-by-line diff of every `test <name> ... <result>` line: identical except
the 3 new `math_dots_boxes.rs` tests (all `ok`). The 13 failures are the same
named set on both sides, all panicking at `adapter.rs:1308` (the known
pre-existing `vendor/compiler` debug_assert issue, #696). HW1/HW2 unmoved.

The three cherry-picked tests, before this commit's T1 fix (i.e. on #724 as
committed): `two_matrices_of_different_row_counts_hang_from_one_axis` and
`vdots_is_three_text_periods_four_points_apart` already pass;
`ddots_descends_three_points_per_period` fails at 11pt by 0.0586bp -- the
same quantity as the T1/OT1 finding. After this commit's fix: all 3 pass at
all three sizes.

Next step: none for this task; #724 is ready for review with both findings
folded in.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 17, 2026
…sed (#724)

Re-derived fresh against this branch's own already-fixed baseline
(inherited from #709/#716's rebase) rather than reusing the pre-rebase
commit, which conflicted on the same JSON line.

Same single case as before: math-sheet (fixtures/real-world/math-sheet/
main.tex:76, the only real-world fixture using \vdots/\ddots), only its
math sub-digests moved. merge_digests.py --case math-sheet; metrics/meta
untouched.

Also observed tikz-heavy.export.pdf gaining a digest where none existed
before (main previously couldn't export tikz-heavy to PDF at all) --
unrelated to this PR's own \vdots/\ddots change, not re-recorded here;
flagging separately on #2.

Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
@d-q222
d-q222 force-pushed the agent/daniel-parent/ink-sweep branch from 869ab07 to 73288e9 Compare September 17, 2026 10:55
…ot a glyph

What changed:
The LaTeX kernel gives neither command a character. Both are boxes built out
of `\hbox{.}` of the *text* font (`fontmath.ltx` 404-409, identical to
`plain.tex` 934-937):

    \vdots {\vbox{\baselineskip4\p@ \lineskiplimit\z@
                  \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
    \ddots {\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
                       \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}}

Everything there except the period and the `mu` kerns is an absolute length,
so the 6pt kern, the 4pt `\baselineskip` and the 7/4/1pt raises do not move
with the body size, and `\hbox` leaves math mode so the periods do not shrink
in a script. Both boxes come out 14pt plus the period's height tall with no
depth -- 15.05554pt at 10pt -- which is more than `\topskip`, so they push the
first baseline of the page down.

flashtex mapped both to one Latin Modern Math codepoint (U+22EE, U+22F1),
advance 2.18pt and 6.13pt, ink box 5.06pt too short (issue #717).

math-layout has no nucleus for a box the caller builds, and
`crates/render-pipeline/vendor/math-layout` is a frozen pin, so the stacks go
through the placeholder seam `mathtext.rs` already runs nested grids and
`\boxed` frames through: `FrameBoxSpec` is generalised to `BuiltBoxSpec` with
a `BuiltBody` of `Frame(MathList)` or `Dots { diagonal }`, and `built_box`
builds the dot stack out of `MathBox::vbox`/`hbox` with the text-size roman
period. `math_ellipsis_of` returns a `MathDots` so `\vdots`/`\ddots` are read
off the control word the same way `\ldots`/`\cdots` are (#467).

Measured against pdfTeX 3.141592653 (TeX Live 2026), glyph origins by PyMuPDF,
`\documentclass[10pt]{article}` `$a\vdots b$ and more text here.`, TeX pt:

                        before     after    pdflatex
    first baseline     135.2700  140.3256   140.3253
    \vdots `b` origin  156.7359  157.3336   157.3355
    \ddots `b` origin  160.6859  169.5557   169.5555

i.e. the first baseline was 5.0364 bp out and `\ddots` 8.8365 bp wide of
pdflatex; the largest residual now is 0.0019 bp. The three periods of each
stack now land within 0.0006 bp of pdflatex in both axes.

What was run:
    cargo test -p flashtex-render-pipeline --no-fail-fast   (crates/render-pipeline)
    branch: 479 passed; 13 failed
    base  : 474 passed; 13 failed        (e48ea2b, built the same way)
    all 13 failures on both sides panic at adapter.rs:1308 (the vendor/compiler
    pin, fixed by #696); 0 new failures, 5 new tests.

Next step:
None; `\vdots`/`\ddots` stay out of `math_symbol_line_height.rs`'s list on
purpose -- they legitimately move the first baseline, which
`math_dot_stacks.rs` pins separately.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
… encoding

What changed:

- `mathtext.rs`: the `\hbox{.}` period `\vdots`/`\ddots` are built from now
  goes through a new `period_glyph()`, which calls `shape_run(.., key: None,
  .., text_size_pt)` the same way an ordinary text run does, instead of
  `text_glyph('.', SizeClass::Text)`. `text_glyph` is the math-alphabet route
  (`fontmath.ltx` pins math alphabets to OT1 `cmr` regardless of the
  document's text encoding, which is correct for `\mathrm`/`\mathbf`/etc.),
  but `\hbox{.}` leaves math mode entirely, so the period is ordinary text
  and must follow `\usepackage[T1]{fontenc}` like any other character in
  running text. Verified independently against `/Library/TeX/texbin/pdflatex`
  (PyMuPDF for glyph origins) before applying: at 10pt and 12pt OT1 `cmr` and
  T1 `ec` share the same native METAFONT period design, so flashtex already
  matched both; at 11pt, T1's `ecrm1095` is its own native design where OT1's
  `cmr10 at 10.95` is linearly scaled from the 10pt design, so the two
  differ by 0.059bp -- inside both project gates (0.5bp glyph, 0.1bp rule),
  but a real, measured encoding-dependence bug. Fixed at 11pt; unaffected at
  10/12pt where the two encodings' periods already coincide.

- `tests/math_dots_boxes.rs`: ported from `agent/daniel-parent/matrix-register`
  @ 34bcb8f, a branch published by a separate investigating lane (daniel-parent,
  mac-m5pro-dq222) dispatched at #750's corpus-fidelity finding F6 (two matrices
  of unequal row count in one display; a short `\vdots` row left the matrix's
  own `\vcenter` off-axis, displacing `I_3`, both `=` signs and every line below
  by half the missing height -- 102 baselines on `fixtures/real-world/math-sheet`
  page 2). That lane found #724 already fixed F6 through the same placeholder
  seam, so only the regression test (this file) and the T1/OT1 finding above
  are folded in here; the rest of 34bcb8f (a second, parallel implementation)
  is not used. Credit: daniel-parent (mac-m5pro-dq222),
  #724 (comment).

What was run:

`cargo test -p flashtex-render-pipeline --no-fail-fast`, in
`crates/render-pipeline`, `CARGO_BUILD_JOBS=4`, private target dirs, branch
and base (#724 head a033f58) built identically:

  branch  482 passed; 13 failed; 4 ignored
  base    479 passed; 13 failed; 4 ignored

Line-by-line diff of every `test <name> ... <result>` line: identical except
the 3 new `math_dots_boxes.rs` tests (all `ok`). The 13 failures are the same
named set on both sides, all panicking at `adapter.rs:1308` (the known
pre-existing `vendor/compiler` debug_assert issue, #696). HW1/HW2 unmoved.

The three cherry-picked tests, before this commit's T1 fix (i.e. on #724 as
committed): `two_matrices_of_different_row_counts_hang_from_one_axis` and
`vdots_is_three_text_periods_four_points_apart` already pass;
`ddots_descends_three_points_per_period` fails at 11pt by 0.0586bp -- the
same quantity as the T1/OT1 finding. After this commit's fix: all 3 pass at
all three sizes.

Next step: none for this task; #724 is ready for review with both findings
folded in.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Re-derived again after re-rebasing onto the re-rebased #709/#716
(current main, post batch-I). Only math-sheet named -- twelvept-plain
also moved in this recording, but that's Commander's separate #741
baseline cleanup in progress, not touched here.

merge_digests.py --case math-sheet; metrics/meta untouched.

Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
@d-q222
d-q222 force-pushed the agent/daniel-parent/gh717-dot-stacks branch from b95e167 to 4be9718 Compare September 17, 2026 11:05
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent review returned APPROVE. It was a fresh read-only Opus review at the current head, with its own test binaries run and #724's dot stacks checked against pdflatex \showbox. The stack (#709, then #716, then #724) merges into main a0da8d4 without conflicts, and the digest changes are confined to each PR's own cases. It is queued for the current merge batch. — daniel-parent (review by Claude Opus 5)

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Merged to main as part of batch K (49d03bb): 4be9718 is an ancestor of main, and GitHub didn't auto-detect the merge. — daniel-parent (Claude Opus 5)

@d-q222 d-q222 closed this Sep 17, 2026
d-q222 added a commit that referenced this pull request Sep 17, 2026
…-0 fix (#754 review)

The perf-bench baseline conflicted with current main (169+ commits ahead of
this PR's merge base, several digest re-records since: #709's CFF
width-parsing fix, #724's math-sheet change, twelvept-plain/tikz-heavy, the
vendor compiler re-pin). Merged origin/main, rebuilt --release, ran the full
corpus, and used merge_digests.py to splice in only the 19 cases this PR's
own fix (family 0 is cmr, not rm-lmr, without lmodern) actually changes --
every case that uses math, matching the review's own note that this is
exactly what the fix should touch. metrics/meta are untouched (portable
digests only, per merge_digests.py's own design).

Also fixed the misplaced doc-comment block the review flagged: a new
`math_roman_lm` doc paragraph had been inserted in the middle of
`cmex_designs`'s own doc comment with no blank line, so rustdoc attached
all of it (both functions' explanations) to `math_roman_lm`, leaving
`cmex_designs` with no doc at all. Reordered so each function keeps its own
comment. Also updated mathtex.rs's stale module doc, which still said
family 0 is unconditionally `rm-lmr*`.

Verified: cargo build --release --locked clean; cargo test --release
--locked for flashtex-render-pipeline: 125 test result lines, all ok,
including display_placement (47-50 confirmed on the merged tree),
math_roman_family (7/7) and math_text (7/7) specifically named in the
review. merge_digests.py's own self-check confirmed only the 19 named
cases' digests changed; python3 gen_fixtures.py and oracle.py refs still
byte-identical (reproducibility unaffected by the merge).

Note on local perf-bench --check: run on this machine (not the pinned
linux-x86_64-ryzen7-7800x3d host, without --require-same-host), it reports
2 timing "regressions". merge_digests.py only ever touches digests, never
metrics/meta, and its own self-check would have refused otherwise -- timing
comparisons across mismatched hosts are exactly what --require-same-host
exists to gate; the real check runs on the pinned host in CI.

Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
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