Match TeX hyphenation and justification semantics

This commit is contained in:
texrra committed 2026-10-23 01:00:45 +08:00
1 parent ac134b3c4e
commit 4fbc43f5ff
6 files changed
+5074 -56

No files matched your search

+14 -16
View File
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
PDF opt-in with `?engine=route-d`). 285 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 286 workspace tests are green and no oracle
fixture is ignored.
Known gaps, in dependency order:
@@ -154,21 +154,19 @@ Acceptance: 30 fixtures covering widths, indents, hyphenation, overfull and
underfull lines; line break positions and overfull boxes identical to
pdfLaTeX.
Status (P0 committed, P1 in progress): the oracle harness found and fixed two
real defects — the TFM lig/kern reader kept the last instruction for a shared
key instead of the first (`k` + `a` picked up `w`'s kern), and justification
squeezed overfull lines past their declared shrink. Both are fixed and the
150pt fixture now matches pdfLaTeX word for word.
Status (continued): the breaker now reproduces TeX's passes and demerits.
Pass 0 uses `\pretolerance` without hyphenation, pass 1 `\tolerance` with it,
and a third pass with `\tolerance=10000` plus `\emergencystretch` runs only when
that register is positive. With zero emergencystretch TeX gives up and fills
each line to the first break at or past the measure, which is exactly the
overfull fallback implemented here. Demerits combine line penalty, badness,
break penalties and adjacent fitness changes, and the final line keeps its
natural width. Both oracle fixtures now pass, so TeX's emergency choices are
reproduced rather than approximated.
Status (P0 committed, P1 in progress): the oracle harness found and fixed
four real defects: the TFM lig/kern reader kept the last instruction for a
shared key (`k` + `a` picked up `w`'s kern), justification squeezed overfull
lines past their declared shrink while clamping legal stretch, the vendored
plain-TeX hyphenation patterns disagreed with pdfLaTeX (`kappa`, `lambda`),
and the final-pass fallback did not model TeX's artificial demerits. The
breaker now uses TeX Live's `hyph-en-us` patterns and exceptions with
`\lefthyphenmin=2`/`\righthyphenmin=3`, stretches normal glue past its
nominal stretch while clamping shrink at the declared limit, and falls back to
the longest prefix within `\tolerance` or the first overflowing prefix. The
oracle compares 100, 120, 150, 180, 200 and 240pt and all six match pdfLaTeX
word for word within 0.05pt; the narrow measures exercise hyphenated and
overfull breaks.
Still open: explicit `\tolerance`/`\pretolerance` overrides, flagged
(hyphenated) demerits, `\parfillskip` variants, `\hangindent`/`\parshape`,