Files

8.9 KiB

Route-D native math — C/D acceptance

Updated 2026-10-31. C/D passes for the current native core atom slice. The previous +7.131bp absolute-page failure is resolved: fraction rule center 179.252bp vs TeX 179.1484375bp, error +0.1035625bp. Entire formula ink bounds at 144dpi are identical. No v1 dispatch or new template rendering rule was added. This is not complete LaTeX/XeTeX compatibility.

Production pipeline

  • math_engine_tex::layout creates TFM-backed geometry in TeX scaled points.
  • math::prepare_math prepares display/Text-style inline math once. It converts dimensions to Route-D's PDF-bp page coordinates at the boundary, including the incoming tagged measure. The conversion is 800/803, not a fitted factor.
  • VerticalItem::Math.geometry and HorizontalBox::math_geometry retain the measured result. PDF/SVG painting consumes these items without laying out the atom again. Geometry remains part of serialization and page hashing.
  • DisplayItem::MathGlyph retains raw slot, optical font identity, Unicode, position and painted size. math_font.rs supplies the same CMR/CMMI/CMSY 10/7/5pt and CMEX10 programs to PDF and SVG. CMEX slot 88 is the large sum; slot 80 is the text-size sum. Both can coexist with correct ToUnicode maps.
  • PDF embeds the real Type1 masters. SVG uses paths extracted from those same programs, with per-page definitions reused by glyph instances. It needs no installed browser math font or runtime conversion utility.

The native slice covers symbols, rows, absolute/mu spaces, explicit classes, styles, scripts, operator limits, fractions, simple upright text/operator names and fixed-measure tags. The parser now retains scoped style declarations, tfrac/dfrac style, explicit limits policies, mu units and italic uppercase Greek variants. The new oracle exercises these distinctions.

Unported forms such as radicals, extensible delimiters, accents and matrices still retain their existing Route-D implementation as a whole formula. prepare_math(...).geometry == None makes that boundary explicit. No subtree inside native geometry falls back, and no part of this choice invokes v1. Those forms must not be counted as native math compatibility. Text ligatures, kerning and arbitrary alphabet/font selection also need further coverage.

General vertical-state fixes

  • Actual line baseline height/depth reach both measured and painted lists. The existing Paragraph API's block budget is explicit glue, not line height plus a second depth. A display finalizes the preceding paragraph at its last baseline + depth, also across discardable material. Interline glue selects baselineskip/lineskip from pending depth; display depth reaches resumed text.
  • PageBuilder consumes pending depth once. Painted lists retain topskip and signed glue. Page setting reserves insertion material and class separator skip, matching breakpoint selection. Losing that skip had incorrectly stretched the footnote page and lowered the formula.
  • Glue cannot bypass a no-break penalty. Terminal fill/forced-break semantics prevent a negative section penalty from creating an extra final page or stretching ordinary final-page body glue.
  • Standard NFSS \@setfontsize and \@startsection parameters enter typed layout state, including letter-@ controls. ex comes from TFM fontdimen5. Negative afterskip produces run-in headings through native styled text and fixed kern nodes, without injecting LaTeX strings. Heading metadata retains actual UnitId after footnote insertion.
  • Removed Times-only 11.5pt baselines, 7pt/0pt display defaults, consecutive/ after-display/section-3 heading adjustments and the earlier 17pt fraction insertion. Text family alone no longer selects these layout rules.
  • Per-unit measured hashes track preceding-paragraph dependencies. Structural display edits replay changed preceding material. A suffix with later insertions uses the native insertion assembler. Earlier held insertions still require a full Route-D paged rebuild; this never invokes v1.

Verification

python3 scripts/math-tex-oracle.py
cargo test -p texrra-tex-core --offline math_engine_tex::tests -- --nocapture
cargo test -p texrra-tex-core --offline --test math_native -- --nocapture
cargo test --workspace --offline
cargo fmt --all -- --check
git diff --check
./scripts/compile-tex-reference.sh fixtures/arxiv-template /tmp/texrra-math-d/reference
python3 scripts/check-arxiv-math.py --reference /tmp/texrra-math-d/reference/template.pdf --candidate /tmp/texrra-math-d/arxiv-final.pdf --json /tmp/texrra-math-d/absolute-final.json

1113 tests passed / 0 failed, fmt/diff checks pass. 476 independent pdfTeX probes have maximum dimension error 1sp (tolerance 8sp). Eight integration tests include 12 real TeX vlist comparisons across Roman/Times, shallow/deep/ multiline paragraphs, small/tall displays, intervening signed glue and resumed text. These controlled vlist probes convert the TeX math box at the same public bp boundary; they do not claim full display-environment/unit compatibility. Structural display edits and suffix insertion assembly match full native rebuilds. Existing 42 pdfTeX layout oracles and required flow/tag tests pass.

Seven fixed-baseline PDF raster probes at 144dpi have identical bboxes. Six simple probes have zero binary ink differences; full arXiv math differs by 19/1948 pixels (0.98%), below the 2% limit.

Final release acceptance

The reference was rebuilt from the fixture with the existing documented cleveref/language workarounds. This is a layout oracle, not full package execution. No everydisplay diagnostic was inserted; that former probe changed layout and must not be used as an absolute-position reference.

Gate Result
pages 3 vs 3
words / sequence ratio reference 1243, native 1259; 0.924860 (C: 0.920064)
2.1 / 3.3 / final URL six lines / Tables page 2 / URL page 2
rule x, native / reference 305.094 / 305.093750bp
rule width, native / reference 173.052 / 173.050781bp
rule center y, native / reference 179.252 / 179.1484375bp
absolute y error +0.1035625bp — PASS (1bp limit)
formula ink bbox at 144dpi both [265,330,1079,388]
cold preview HTTP, one sample 364.245ms
five warm previews HTTP 35.123 / 37.186 / 49.836 / 42.003 / 39.105ms
five formula edits HTTP 81.102 / 108.579 / 159.064 / 240.549 / 102.997ms
same edits, engine-reported 48.865 / 68.827 / 110.054 / 171.527 / 67.267ms

Edits used buffer=1&patch=1 with distinct numerator subscripts. Three pages remained; changedPages=[1], recomputedPages=3 because an earlier insertion queue cannot yet be restored. Source files remained unchanged. These local samples are slower than the C snapshot and are not p95 guarantees or a latency improvement claim. The first run under concurrent test load is preserved.

Both CMR figure/table samples remain two pages; the top figure image matrix remains [132,48,174,744]. General baseline/topskip/heading fixes intentionally move text, so C's old non-math whole-page hash is superseded, not claimed identical. New first-page hash: d97456b415cf286d595e8a756147265b3bf9fa880bab446dafb02d802c65d7d0. Table/float regressions and independent layout oracles pass. The historical article-basic source is unavailable and was not revalidated.

Remaining native milestones

Continue native token/state/primitive execution and pinned real-format boot; extend radicals, extensible delimiters, accents, matrices and arbitrary text/ font semantics with TeX oracles. General predisplaysize/short-display decisions, text/page TeX-pt/PDF-bp conventions, ordinary paragraph block budgets, and remaining font-dependent float/microtype rules are still migration debt. Audit edit latency/cancellation and retaining insertion queues. C/D completion applies to the current atom slice, not the whole product replacement.

The historical 223.2pt ink-derived fraction width is incorrect; the independent vector reference is approximately 173.051bp. Never stretch to it or subtract a fixture error in a painter. Source-parameter support is a typed subset, not a claim that the entire LaTeX class/format is already executed natively.

Artifacts

Current temporary review directory: /tmp/texrra-math-d/:

  • comparison.pdf: three full-page TeX/native pairs plus seven fixed-baseline probe pairs; comparison-page2.png is the visual preview.
  • arxiv-final.pdf, reference/template.pdf, probe-native.pdf, probe-reference.pdf.
  • absolute-final.json, fidelity-final.json, metrics-final.json, metrics-under-test-load.json, raster/dimension verification logs, CMR PDFs.
  • acceptance.py records the unsaved-edit timing procedure.

Workspace log: /tmp/texrra-d-workspace-deliver.log; final release log: /tmp/texrra-d-release-deliver.log. Outlines regenerate with python3 scripts/build-math-outlines.py (fontTools only for generation). Runtime uses the bundled outlines and the same Type1 programs as PDF.