Skip to content

render-pipeline: font metric sweep for #710 (Latin Modern vs Computer Modern) - #740

Merged
jay3332 merged 2 commits into
mainfrom
agent/daniel-parent/font-metric-sweep
Sep 19, 2026
Merged

jay3332 merged 2 commits into
mainfrom
agent/daniel-parent/font-metric-sweep

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Measurement-only font metric sweep for #710. A new standalone binary,
crates/render-pipeline/src/bin/font-metric-sweep.rs, compares the shipped
10pt Latin Modern OTF metrics (as loaded by this engine's own FontSet /
LoadedFace / TexMathMetrics::otf_glyph path) against local pdfTeX
Computer Modern TFM metrics (via the existing render-pipeline::tfm::Tfm
wrapper) for every glyph in the CMR/CMMI/CMSY/CMEX math families. It writes
docs/evidence/font-metric-sweep-710.md, and ships a shared-machine-safe
wrapper at tools/font-metric-sweep/run.sh + README so it can be re-run.

No rendering or layout behavior changes. The diff is one new bin, one new
tools/ directory, one new evidence doc, and a 3-line docs/INDEX.md link.
No existing src/ file besides the new binary was touched.

Why

#710 was filed after \ell was found 0.09331pt wider in Latin Modern than in
Computer Modern, putting \sqrt{\frac{\ell}{\ell}}'s vinculum 0.0930bp off —
inside the 0.1bp rule gate by only 0.007bp. Rather than discover the next such
case one oracle at a time, this sweep measures every CM-vs-LM glyph metric at
once and flags candidates against the same tolerances the render-pipeline
oracle tests already use.

Overlap check

gh pr list --repo flash-tex/flashtex --state all --search "710" and a
search for "font-metric-sweep" turned up no other PR touching this. Claim
GH-710-FONT-METRIC-SWEEP was held by daniel-parent for this task; no other
active claim overlaps crates/render-pipeline/src/bin/font-metric-sweep.rs
or tools/font-metric-sweep/.

Test results

  • Row counts: 251 glyph rows compared — cmr10 42, cmmi10 94,
    cmsy10 82, cmex10 33.
  • Gate watch (rows at or above 80% of either gate, ranked by effective
    char-box delta): 69 rows — 27 position-gate (0.5bp) EXCEEDS, 2
    position approaches; 62 rule-gate (0.1bp) EXCEEDS, 7 rule
    approaches. Near-gate names include \xi, \ell, \zeta, T, V,
    \eta, y.
  • Largest raw divergence: the CMEX brace pieces (cmex10 0x7B/0x7D,
    U+23DF/U+23DE) at +15.58819 bp (relative +3.45); these are
    source-piece comparisons, not independent LM assembly glyphs.
  • \ell (cmmi10 0x60): raw advance CM 4.16670pt → LM 4.17000pt
    (+0.00330pt); italic correction CM 0.00000pt → LM 0.09000pt; effective
    math char-box delta +0.09330pt = +0.09365bp — the number that
    prompted fonts: Latin Modern \ell is 0.09331pt wider than cmmi10 — radical bar lands 0.0930bp off, just inside the 0.1bp gate #710.
  • Command run (from a clean re-run, not just the committed artefact):
    CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-metricship CARGO_BUILD_JOBS=4 \
      tools/font-metric-sweep/run.sh --output docs/evidence/font-metric-sweep-710.md
    wrote docs/evidence/font-metric-sweep-710.md (251 compared, 42 unmeasured)
    
    This reproduced the numeric content byte-for-byte against the version
    Codex measured.
  • Three rows hand-checked against tftopl dumps of the local TFMs
    (independent of the tool's own output):
    • \ell (cmmi10 O140 octal = 0x60): TFM CHARWD R 0.41667 (→4.16670pt
      at design size 10pt), no CHARIC (→0.00000pt) — matches the report's
      CM-side numbers exactly.
    • cmex10 0x7B private brace piece (O173): TFM CHARWD R 0.450005
      (→4.50005pt), CHARHT R 0.119998 (→1.19998pt) — matches exactly.
    • cmsy10 0x30 \prime (O60): TFM CHARWD R 0.275 (→2.75000pt),
      CHARHT R 0.555557 (→5.55557pt) — matches exactly.
  • 42 unmeasured/out-of-scope entries, each listed individually with a
    reason in the "Unmeasured or out-of-scope rows" section (composite/overprint
    constructs like \hbar, \not; slots with no four-family CM declaration;
    engine slot-to-glyph mappings that return no glyph, e.g. two CMEX brace
    positions and two CMEX arrow positions; \varnothing's NCM-sentinel path).
  • Fixed during verification: the "Gate watch list" section originally didn't
    say what an EXCEEDS mark means. Added a paragraph (generated by the tool
    itself, with live counts) making explicit that the 0.1bp/0.5bp thresholds
    are the same generic oracle-test tolerances reused as a screening cutoff on
    each glyph's raw metric delta in isolation — an EXCEEDS entry is not a
    claim that the glyph draws a mis-sized rule or that any test currently
    fails, only that it is a candidate worth checking against a specific
    construct. Most flagged rows (\forall, \Im, \prime, the cmex10
    arrow/brace slots) are never used to draw a rule.

Not done

Nothing further for this issue — it is scoped as measurement-only. Following
up on any individual flagged row (the way \ell will need a fix) is
out of scope here and would be its own oracle-by-oracle task.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

… vs Computer Modern)

What changed:
- New measurement-only binary crates/render-pipeline/src/bin/font-metric-sweep.rs
  that compares the shipped Latin Modern OTF metrics against local pdfTeX
  Computer Modern TFM metrics (cmr10/cmmi10/cmsy10/cmex10), reusing the
  existing FontSet/LoadedFace/TexMathMetrics and tfm::Tfm reader paths. It
  writes no layout or rendering code and changes no rendering behavior.
- tools/font-metric-sweep/run.sh + README.md: shared-machine-safe wrapper
  (CARGO_TARGET_DIR/CARGO_BUILD_JOBS) to re-run the sweep.
- docs/evidence/font-metric-sweep-710.md: the generated evidence report, plus
  an added "What EXCEEDS means here" paragraph clarifying that the 0.1 bp
  rule / 0.5 bp position thresholds are a screening cutoff reused from this
  codebase's oracle-test tolerances, not a claim that a given glyph draws a
  mis-sized rule or that any test currently fails.
- docs/INDEX.md: links the new evidence doc.

What was run:
- CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-metricship CARGO_BUILD_JOBS=4
  tools/font-metric-sweep/run.sh --output docs/evidence/font-metric-sweep-710.md
  -> "wrote docs/evidence/font-metric-sweep-710.md (251 compared, 42 unmeasured)"
- Independent hand check against tftopl dumps of the local TFMs (not the
  tool's own output) for three rows: \ell (cmmi10 0x60, CM CHARWD 0.41667 ->
  4.16670pt, no CHARIC), cmex10 0x7B private brace piece (CM CHARWD 0.450005
  -> 4.50005pt), cmsy10 0x30 \prime (CM CHARWD 0.275 -> 2.75000pt) — all match
  the report's CM-side numbers exactly.
- Re-running the sweep after the wording change reproduced byte-identical
  numeric output; only the new caveat paragraph and its dynamically computed
  counts (69 gate-watch rows; 62 rule-EXCEEDS/7 approaches; 27
  position-EXCEEDS/2 approaches) were added.

Next step: none; this is a standalone measurement artefact for #710. Follow-up
issues, if the Commander wants them, are one-oracle-at-a-time fixes for the
flagged rows (starting with \ell in \sqrt{\ell/\ell}), not part of this PR.

Implementation-Agent: gpt-5.6-luna (Codex) via daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

@d-q222 d-q222 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification — VERIFIED (one non-blocking finding)

Fetched refs/review/pr-740 = f6f04ae2, own worktree, CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-vr3-740, CARGO_BUILD_JOBS=4.

1. Re-run, and what "reproduces" actually means

I ran the binary directly rather than through tools/font-metric-sweep/run.sh, because that wrapper hard-codes CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-metricsweep and would have shared a target dir with other lanes:

$ cd crates/render-pipeline
$ CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-vr3-740 CARGO_BUILD_JOBS=4 \
    cargo run --bin font-metric-sweep -- --output /tmp/.../sweep-rerun.md
wrote /tmp/.../sweep-rerun.md (251 compared, 42 unmeasured)

Same headline line: 251 compared, 42 unmeasured. Diffed against the committed artefact:

$ diff docs/evidence/font-metric-sweep-710.md sweep-rerun.md
20c20
< Font directory supplied to `FontSet`: `/Users/dqi26/flashtex-wt/metric-sweep/crates/render-pipeline/../../apps/mac/Fonts`.
---
> Font directory supplied to `FontSet`: `/Users/dqi26/flashtex-wt/vr3-740/crates/render-pipeline/../../apps/mac/Fonts`.
24,25c24,25
< | Latin Modern CMR path | `/Users/dqi26/flashtex-wt/metric-sweep/.../lmroman10-regular.otf` | `1aa18cfe...` | ... |
< | Latin Modern math     | `/Users/dqi26/flashtex-wt/metric-sweep/.../latinmodern-math.otf` | `6075562b...` | ... |
---
> | Latin Modern CMR path | `/Users/dqi26/flashtex-wt/vr3-740/.../lmroman10-regular.otf` | `1aa18cfe...` | ... |
> | Latin Modern math     | `/Users/dqi26/flashtex-wt/vr3-740/.../latinmodern-math.otf` | `6075562b...` | ... |

Three lines differ, and all three are the checkout path. Every measured number, every SHA-256, every gate verdict is identical. So the PR's wording — "reproduced the numeric content byte-for-byte" — is precise and correct; the file as a whole is not byte-identical across checkouts, which is the finding at the bottom.

2. Counts, re-derived from the artefact rather than read off the summary

$ python3 - (count '| cm…' rows per '## ' section)
69  ## Gate watch list
251 ## Complete measured table
$ awk 'NR>526' docs/evidence/font-metric-sweep-710.md | grep -c '^| '   # minus 2 header rows
44 → 42
$ (gate-watch columns, tallied)
position gate: EXCEEDS 27, approaches 2, below 40
rule gate:     EXCEEDS 62, approaches 7

251 compared rows, 42 unmeasured entries each on its own row with a reason, 69 gate-watch rows, 27 / 2 position and 62 / 7 rule — every number in the PR body checks out against the file itself.

Headline values present as claimed: \ell (cmmi10 0x60) +0.09330 pt = +0.09365 bp, CMEX brace pieces cmex10 0x7B/0x7D at +15.52995 pt (+15.58819 bp).

3. Spot-check against tftopl, rows I picked (not the PR's three)

I deliberately chose a row the PR did not hand-check, cmsy10 0x38 (\forall), plus \ell as a cross-check of its own claim:

$ tftopl $(kpsewhich cmsy10.tfm) cmsy10.pl
(CHARACTER O 70
   (CHARWD R 0.555557)
   (CHARHT R 0.694445)
   )

Report row 453: cmsy10 0x38 … 5.55557 → 6.66000 | +1.10443 … 6.94445 → 6.96000 … 0.00000 → 0.02000. CM advance 0.555557 × 10 pt = 5.55557 pt ✓, CM height 6.94445 ✓, no CHARDP → CM depth 0.00000 ✓, no CHARIC → CM italic 0.00000 ✓.

$ tftopl $(kpsewhich cmmi10.tfm) cmmi10.pl
(CHARACTER O 140
   (CHARWD R 0.41667)
   (CHARHT R 0.694445)
   ...

Report row 379: cmmi10 0x60 … 4.16670 → 4.17000 … 6.94445 → 7.05000 … italic 0.00000 → 0.09000. 0.41667 × 10 = 4.16670 pt ✓, height 6.94445 ✓, and the absent CHARIC is why the CM italic correction is 0.00000 — which is the whole of the +0.09330 pt effective delta that prompted #710. Confirmed from the TFM, independently of the tool.

4. It changes no rendering behaviour

$ git diff --stat $(git merge-base origin/main refs/review/pr-740) refs/review/pr-740
 crates/render-pipeline/src/bin/font-metric-sweep.rs | 1135 ++++++++++++++
 docs/INDEX.md                                       |    3 +
 docs/evidence/font-metric-sweep-710.md              |  574 ++++++++
 tools/font-metric-sweep/README.md                   |   16 +
 tools/font-metric-sweep/run.sh                      |   10 +
 5 files changed, 1738 insertions(+)

All additions. The only src/ path is the new src/bin/ target — no existing layout src/ file is touched, and no library code is reachable from a changed line. The "measurement-only" framing holds.

Finding (non-blocking)

docs/evidence/font-metric-sweep-710.md:20,24,25 embed an absolute, machine-local checkout path (/Users/dqi26/flashtex-wt/metric-sweep/...), a worktree that no longer exists. Consequences:

  • The committed artefact cannot be reproduced byte-identically by anyone — including this lane — because those three lines encode where it was run, not what was measured. Anyone re-running it and diffing gets three spurious hunks and has to decide whether to trust them.
  • It would also make the doc churn on every re-run from a different worktree, which is exactly the kind of noise that erodes an evidence file's value over time.

Cheap fix, if you take it: emit the path relative to the repository root (the binary already knows it, run.sh computes ROOT), keeping the SHA-256 columns as the actual provenance — they are what pin the faces, and they already match across my run and yours. Not worth blocking a measurement-only PR over.

— independently verified by daniel-parent's review lane

What changed:
The font-metric-sweep generator baked this machine's absolute checkout
path into docs/evidence/font-metric-sweep-710.md (via env!("CARGO_MANIFEST_DIR")
and FontSet's loaded-face paths), so the document referenced a worktree
that no longer exists and could not be byte-reproduced from any other
checkout. path_for_report and the font-directory line now go through a
new relative_to_repo() helper: paths inside the repo are rendered
repo-relative; paths outside it (the system TeX Live TFMs and
fontmath.ltx) keep the absolute form since there is no relative form for
them, and each row already carries a SHA-256 of the file's contents for
identity. Regenerated the doc with tools/font-metric-sweep/run.sh; only
the three flagged lines changed (font directory, LM CMR path, LM math
path), all 251/42 row counts identical.

What was run:
- cargo build --manifest-path crates/render-pipeline/Cargo.toml --bin font-metric-sweep (CARGO_BUILD_JOBS=4): clean build, only pre-existing unrelated warnings.
- cargo run ... --bin font-metric-sweep -- --output docs/evidence/font-metric-sweep-710.md: "wrote docs/evidence/font-metric-sweep-710.md (251 compared, 42 unmeasured)", matching the prior committed counts.
- Cross-checkout reproducibility: copied the fixed generator into a second worktree at a different absolute path (/Users/dqi26/flashtex-verify-metric-sweep-740) and regenerated there; `diff` reported no differences and both outputs hashed to the same SHA-256 (75e15dee6575eb60809838f156895777e1e71ef214d7e3b60114a082953f6b25).

Next step: none; verification round item closed.

Implementation-Agent: claude-sonnet-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Verification-round fix: docs/evidence/font-metric-sweep-710.md baked this
machine's absolute worktree path (/Users/dqi26/flashtex-wt/metric-sweep/...)
into three lines (font directory, LM CMR path, LM math path), so it couldn't
be byte-reproduced from any other checkout — the whole point of the document.

Fixed in the generator (crates/render-pipeline/src/bin/font-metric-sweep.rs),
not by hand-editing the doc:

  • Added relative_to_repo(): paths inside this repo checkout are now
    rendered repo-relative (e.g. apps/mac/Fonts/lmroman10-regular.otf
    instead of the absolute worktree path). Paths outside the repo (the
    system TeX Live TFMs and fontmath.ltx) still render absolute, since
    there's no repo-relative form for them — each of those rows already
    carries a SHA-256 of the file's contents for identity, so nothing there
    loses reproducibility value.
  • path_for_report and the "Font directory supplied to FontSet" line
    both now go through this helper.

Regenerated via tools/font-metric-sweep/run.sh (cargo run --bin font-metric-sweep -- --output docs/evidence/font-metric-sweep-710.md):

wrote docs/evidence/font-metric-sweep-710.md (251 compared, 42 unmeasured)

Only the three flagged lines changed; every other line (all 251 measured
rows, the SHA-256s, the summary counts) is byte-identical to what was
committed before.

Proof the document's own claim holds — ran the fixed generator from a
second, differently-located checkout
(/Users/dqi26/flashtex-verify-metric-sweep-740, a detached worktree of
this branch, distinct from /Users/dqi26/flashtex-wt/metric-sweep) and
diffed the two outputs:

$ diff .../flashtex-wt/metric-sweep/docs/evidence/font-metric-sweep-710.md /tmp/verify-metric-sweep-out.md
(no output — files are identical)
$ shasum -a 256 .../flashtex-wt/metric-sweep/docs/evidence/font-metric-sweep-710.md /tmp/verify-metric-sweep-out.md
75e15dee6575eb60809838f156895777e1e71ef214d7e3b60114a082953f6b25  .../flashtex-wt/metric-sweep/docs/evidence/font-metric-sweep-710.md
75e15dee6575eb60809838f156895777e1e71ef214d7e3b60114a082953f6b25  /tmp/verify-metric-sweep-out.md

Byte-identical, same SHA-256, from two different absolute checkout paths.
The verification worktree was removed after the check; nothing under it
was committed.

Pushed as 53d02744 (fast-forward, f6f04ae2..53d02744).

@jay3332
jay3332 merged commit 34c6f66 into main Sep 19, 2026
21 of 22 checks passed
jay3332 added a commit that referenced this pull request Sep 19, 2026
…he integration batch + package definitions

The pin reads main again after the second integration pass (#827 cherry-picks,
#863, #950, #737/#739/#758/#732/#740/#825, visual-oracle tooling) and the
`metadata.packages` work (`crate::package_definitions`, tex-expansion's
`package_defs.rs`). `git archive` of this tree's `crates/compiler` and
`crates/tex-expansion`, PINs at the merge commit, VENDORING.md rows updated,
`scripts/check-vendor-pins.sh` both "up to date". render-pipeline 819/0 in
both profiles against the new pins; compiler 1368/0, tex-expansion 150/0
release; Mac inventory sync current; swift build clean.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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.

2 participants