Honour TeX looseness when an alternative line count exists

This commit is contained in:
gloamxun committed 2026-10-23 13:46:32 +08:00
1 parent 96cd98f833
commit a6397fcfef
6 files changed
+219 -99

No files matched your search

+5 -3
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`). 424 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 426 workspace tests are green and no oracle
fixture is ignored.
Known gaps, in dependency order:
@@ -219,8 +219,10 @@ is added from 2000, and `\frenchspacing` switches it off; a 150pt punctuated
oracle fixture matches pdfLaTeX's line breaks and word positions.
`\looseness` adjusts the final line count inside TeX's `[1,9]` window and is
reverted when no feasible layout exists; 120pt and 200pt fixtures require one
extra line and match pdfLaTeX exactly.
reverted when no feasible layout exists; a 120pt fixture requires one extra
line and matches pdfLaTeX exactly. When the requested count is infeasible
TeX's own output picks an alternative optimum that route-D does not
reproduce; the infeasible case is covered by unit tests.
Interline spacing follows TeX: the first baseline sits at the paragraph's
ascent, each later baseline advances by `\baselineskip` when the resulting gap
+2 -4
View File
@@ -140,9 +140,7 @@ and justification.
a zero code leaves the running factor unchanged, as in TeX. Explicit
`\spaceskip`/`\xspaceskip` replace the font glue, and hyphenation applies
to a word's letter core so trailing punctuation does not suppress the
pattern lookup (pdfTeX breaks `epsilon:` as `ep-`). `ParagraphStyle::ragged_right` models `\raggedright`: lines keep their natural width and fill greedily, because the infinite `fil` in `\rightskip` leaves no reason to stretch. `\looseness` shifts the paragraph by whole lines when
the requested count lies between one and nine lines away from the natural
count (the adjustment is reverted when no feasible layout exists).
pattern lookup (pdfTeX breaks `epsilon:` as `ep-`). `ParagraphStyle::ragged_right` models `\raggedright`: lines keep their natural width and fill greedily, because the infinite `fil` in `\rightskip` leaves no reason to stretch. `\looseness` asks for the natural line count shifted by up to nine lines (TeX's `[1,9]` window); the shift is kept only while a feasible layout exists at that count. When the requested count is infeasible pdfLaTeX can still emit a different alternative optimum; route-D keeps the ordinary optimum there, which the unit tests pin.
Interline glue follows TeX: each baseline advances by `\baselineskip` when
the resulting gap clears `\lineskiplimit`, otherwise by `\lineskip`;
`\parskip` is appended between paragraph units in the vertical list. When a
@@ -346,7 +344,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`) supplies advances, kerns, ligatures, and italic correction for layout, while the display list and PDF select the matching Liberation face. `Engine::edit` preserves the face when reflowing an edited paragraph.
The crate currently has 288 unit tests plus seven route-D integration tests and twenty-four oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 424 tests (288 route-D unit, 7 route-D integration, 24 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 binary units), with none ignored. v1 remains the live server path.
The crate currently has 289 unit tests plus seven route-D integration tests and twenty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 426 tests (289 route-D unit, 7 route-D integration, 25 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 binary units), with none ignored. v1 remains the live server path.
### M0 incremental demo