Repository navigation
render-pipeline: lay out T1 cmr documents with EC metrics (HW1 breaks = pdflatex) - #111
Merged
Merged
Conversation
Documents with \usepackage[T1]{fontenc} and no lmodern get LaTeX's
default t1cmr.fd fonts in pdflatex: the EC metrics (ecrm1095 for 11pt
body text), not the ec-lm* metrics lmodern selects. ec-lmr10 scaled to
10.95pt is about 0.57% wider (ecrm1095 quad 0.994328 of the size), which
moved line breaks in every real-world fixture (all nine are T1 without
lmodern).
- Family::ComputerModern: EC metrics with the Latin Modern outlines,
selected by Stylesheet::family_for (T1 fontenc, no lmodern).
- ec_tfm_file: t1cmr.fd's declared sizes (5..35.83) and shapes
(ecrm/ecbx/ecti/ecbi/ecsl), nearest declared size.
- FontSet::otf_with_tfm: a separate face entry per metric file (same
program and wire font_id, own shape_key so the shaper cache does not
mix LM and EC runs); a missing EC file falls back to the ec-lm TFM
with an ec_metrics_unavailable warning.
- TFM discovery appends <texmf>/fonts/tfm/jknappen/ec after every
Latin Modern candidate (order of existing entries unchanged).
- Tfm::parse reads only the header's lf words, as TeX (tex.web 575) and
tftopl do: the jknappen/ec files are zero-padded to 3584 bytes and the
shared font-resources reader rejected them ("file/table length
mismatch").
HW1 line breaks now match pdflatex on all pages (3 -> 0 differing
hunks); HW2 3 -> 1 (p3 line 1, an inline-math width delta). Real-world
corpus 31 -> 25 break hunks, no fixture worse, overfull counts equal.
Implementation-Agent: Claude Opus 5 (subagent kabir-claude HW text widths, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Member
|
Merged to main via integration/2026-09-13h (Commander). |
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.
Why HW1/HW2 line breaks differed
All nine
fixtures/real-worlddocuments use\usepackage[T1]{fontenc}withoutlmodern. So pdflatex sets them in LaTeX's defaultt1cmr.fdfonts, which use the EC metrics (ecrm1095for 11pt body text,ecbx1200, ...). The pipeline laid them out withec-lm*metrics (ec-lmr10scaled to 10.95pt) instead.ec-lmr10@10.95 vsecrm1095widths\hsize/\parindent/\parshapeA blocker sat under the metrics: the shared font-resources TFM reader rejected every
jknappen/ecfile withTFM file/table length mismatch. Those files are zero-padded to 3584 bytes, but TeX (tex.web §575) reads onlylfwords, and tftopl says "extra junk at the end ... proceed as if it weren't there".Change (render-pipeline only, no vendor edits)
Family::ComputerModern: EC metrics with Latin Modern outlines. Chosen byStylesheet::family_forfor T1 fontenc withoutlmodern. OT1 andlmoderndocuments are unchanged.ec_tfm_file: the declared sizes and shapes fromt1cmr.fd, picking the nearest declared size.FontSet::otf_with_tfm: one face entry per metric file. It keeps the same program and wirefont_idbut gets its ownshape_key, so the shaper cache never mixes LM and EC runs. If the EC file is missing, theec-lmTFM is used and anec_metrics_unavailablewarning is emitted.<texmf>/fonts/tfm/jknappen/ecafter all existing candidates, so existing order is unchanged.Tfm::parsereads the header'slfwords only.Gates
Line breaks vs MacTeX pdflatex (differing hunks per page;
\mathbbextraction artifacts ignored):Real-world corpus: 31 → 25 hunks; no fixture worse (letter 3→2, other six unchanged); page counts equal.
Overfull: counts identical on all 9 fixtures (HW1 0, HW2 1, article-twocolumn 1, lecture-notes 2).
Tests:
cargo test --releasein render-pipeline is green, including 7 new tests: padded TFM,ecrm1095load,t1cmr.fdtable, CM vs LM faces, EC fallback, discovery order,family_for/t1_encoding.FT-065
perf_bench --steps 20: HW1/HW2 keystroke p50 within ±0.1ms of main (for example HW1 type-paragraph 1.12→1.04ms, HW2 1.12→1.15ms). The 500KB document's digests are byte-identical, since it is OT1. HW1/HW2 digests change as intended.Follow-ups (not in this PR)
jknappen/ecTFMs next toec-lm*. Until then the app warnsec_metrics_unavailableand keeps today's LM metrics.bytes.len() != lf*4to<intfm.rsupstream, then drop the render-pipeline trim at the next re-pin.crates/microtype).\mathbbℝ advance, taken from latinmodern-math rather than the msbm10 TFM: 0.91pt short per ℝ, 3 on the line. Every other chunk on that line matches pdflatex to within 0.005pt.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu