Apply TeX sentence spacing to interword glue

This commit is contained in:
gloamxun committed 2026-10-23 01:26:04 +08:00
1 parent bd109d03c5
commit 295c934438
8 files changed
+137 -23

No files matched your search

+16 -15
View File
@@ -125,16 +125,17 @@ and justification.
tolerance bounds, break penalties and flagged demerits are modelled,
`\hyphenation` exceptions are inserted into the pattern trie, and
`\hangindent`/`\hangafter`/`\parshape` change each line's measure and left
offset. Remaining gaps are `\looseness`, spacefactor/`\sfcode`,
generic `fil`/`fill` glue orders outside `\parfillskip`, and the
offset, and `\parfillskip` (with or without `fil`) decides whether the last
line is justified. Sentence spacing follows TeX's default `\sfcode` values:
interword glue stretch is multiplied by the space factor, shrink is divided
by it, `\fontdimen7` is added from factor 2000, and `\frenchspacing`
disables the effect. Remaining gaps are `\looseness`, custom `\sfcode`
overrides, generic `fil`/`fill` glue orders outside `\parfillskip`, and the
vertical-list skips (`\baselineskip`, `\lineskip`, `\parskip`).
The pdfLaTeX oracle pins six measures (100-240pt) and all match; no oracle
fixture is ignored.
The pdfLaTeX oracle currently pins two measures (150pt and 180pt). The earlier
multi-width table was produced by the old single-cost breaker and is no longer
evidence of divergence; 120pt and 200pt should be added as fixtures next.
The pdfLaTeX oracle pins the 100-240pt measure matrix plus `\hangindent`,
`\parfillskip` and sentence-spacing fixtures; all match and no oracle fixture
is ignored.
- `\middle|` inside `\left...\right` is accepted as a delimiter symbol (not yet stretched).
- `\sqrt[n]{x}` carries an optional degree atom; `\left.` is an empty
@@ -261,7 +262,7 @@ for a later overlaid slash.
| Milestone | State | Notes |
| --- | --- | --- |
| M0 checkpoint engine | done | page list, page hashes, snapshot/restore, edit replay |
| M1 horizontal/paragraphs | partial | boxes/glue/penalties, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, pdfTeX oracle matrix 100-240pt |
| M1 horizontal/paragraphs | partial | boxes/glue/penalties, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing (`\sfcode`/`\frenchspacing`), pdfTeX oracle matrix 100-240pt plus three register fixtures |
| M2 vertical/page builder | partial | vsize, topskip, insertions, marks, Rust output hook, top/bottom floats, float-page/text fractions, rules, vskip, penalties; interpreted `\output` absent |
| M3 halign | partial | natural columns, spans, omit, hline rows, templates, noalign skip, rules; no PDF painter |
| M4 math | partial | atoms, scripts, fractions, roots, delimiters, accents, operators, classes, braces, boxed, negated; no math painter/shrink wrapping |
@@ -299,7 +300,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 186 unit tests plus six route-D integration tests and seven oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 296 tests (186 route-D unit, 6 route-D integration, 7 oracle, 71 v1 integration, 19 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
The crate currently has 188 unit tests plus six route-D integration tests and eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 299 tests (188 route-D unit, 6 route-D integration, 8 oracle, 71 v1 integration, 19 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
### M0 incremental demo
@@ -327,11 +328,11 @@ The staged program that closes these milestones is described in
Route D currently covers M0-M4/M6 as a working subset. The remaining milestones are
deliberately open rather than approximated:
- **M1**: `\looseness`, spacefactor/`\sfcode`, generic `fil`/`fill` glue
orders and the vertical-list skips are still open; the tolerance, penalty and
demerit registers, `\hyphenation` exceptions,
`\hangindent`/`\parshape`, and `\parfillskip` with or without `fil` are
modelled.
- **M1**: `\looseness`, custom `\sfcode` overrides, generic `fil`/`fill`
glue orders and the vertical-list skips are still open; the tolerance, penalty
and demerit registers, `\hyphenation` exceptions,
`\hangindent`/`\parshape`, `\parfillskip` with or without `fil`, and the
default `\sfcode`/`\frenchspacing` sentence spacing are modelled.
- **M5**: `cmr10.tfm` is parsed at runtime with widths, glyph heights/depths and kern pairs. only used text faces embed Liberation Serif/Mono as Type0/Identity-H; each face is subset to the glyphs actually used (composite components included, glyph IDs retained); FontFile2 and ToUnicode streams use Flate compression; the ToUnicode CMap follows the used characters; ff/fi/fl/ffi/ffl ligatures come from TFM, and CMR10 italic corrections are applied at line ends; full NFSS family switching is not implemented.
- **M6**: `\output`, `\insert`, mark/float output policies, class-file execution and
math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, and insertion material is stacked by class from the page bottom; `\output` is still Rust code rather than interpreted tokens.