Replace font glue with explicit spaceskip and xspaceskip

This commit is contained in:
gloamxun committed 2026-10-23 02:38:12 +08:00
1 parent 4acccaee86
commit 4be0ff5787
7 files changed
+161 -25

No files matched your search

+13 -6
View File
@@ -90,7 +90,11 @@ inhibits it, leaving the overfull first-fit lines TeX produces. A 120pt
fixture with `\hangindent=20pt \hangafter=1` checks every line origin
against pdfLaTeX as well as the word positions inside each line, and a
`\parfillskip=0pt` fixture checks that a final line without `fil` glue is
justified like any other line (the default `0pt plus 1fil` leaves it short). `route_d_multiline_bands_track_pdftex` rasterizes the same
justified like any other line (the default `0pt plus 1fil` leaves it short).
Two 150pt fixtures pin explicit interword glue: `\spaceskip` replaces the
font glue (width kept, stretch/shrink following the space factor) and
`\xspaceskip` is used verbatim once the factor reaches 2000; neither adds
`\fontdimen7`. `route_d_multiline_bands_track_pdftex` rasterizes the same
paragraph in both engines and compares ink bands, covering baseline placement
and justification.
@@ -109,7 +113,7 @@ and justification.
| Milestone | Content | Acceptance |
| --- | --- | --- |
| M0 | vertical list, page builder, checkpoint, page hash, edit demo | edit on page 2 rebuilds only page 2 |
| M1 | TeX box/glue/penalty + paragraph builder (`\par`, `\hsize`, `\parindent`) | **partial**: item stream, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 100-240pt plus register, geometry, `\sfcode` and vertical-glue fixtures; generic fil glue and `\prevgraf` next |
| M1 | TeX box/glue/penalty + paragraph builder (`\par`, `\hsize`, `\parindent`) | **partial**: item stream, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing, `\spaceskip`/`\xspaceskip`, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 100-240pt plus register, geometry, `\sfcode` and vertical-glue fixtures; generic fil glue and `\prevgraf` next |
| M2 | page builder + `\output`, `\vsize`, `\topskip`, footnotes, floats | **partial**: `\vsize` page goal, `\topskip`, forced penalties, `Insertion` reserve, running `Mark`s, `OutputRoutine` hook, top/bottom `Float` placement; `page::PageBuilder` scores candidate breakpoints with TeX page badness, glue setting, `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, while the scrolling builder remains the default; interpreted `\output` next |
| M3 | `\halign`, `\omit`, `\span`, `\multispan`, booktabs/longtable | **partial**: source parsing, natural column widths, spans, rule rows, 10pt display-list painting and row-level page splitting; no booktabs/longtable parity yet |
| M4 | math lists, scripts, fractions, radicals, accents, delimiters | **partial**: token parser, atom boxes with CMR10 metrics, delimiter scaling, accents and a display-list painter; no CMEX size variants or TeX math spacing classes yet |
@@ -131,7 +135,10 @@ and justification.
by it, `\fontdimen7` is added from factor 2000, and `\frenchspacing`
disables the effect. `ParagraphStyle::space_factor_codes` carries explicit
`\sfcode` assignments, which replace the built-in table for that character;
a zero code leaves the running factor unchanged, as in TeX. `\looseness` shifts the paragraph by whole lines when
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-`). `\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).
Interline glue follows TeX: each baseline advances by `\baselineskip` when
@@ -282,7 +289,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, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing with default and custom `\sfcode`/`\frenchspacing`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfTeX oracle matrix 100-240pt plus register, geometry and vertical-glue fixtures |
| M1 horizontal/paragraphs | partial | boxes/glue/penalties, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing with default and custom `\sfcode`/`\frenchspacing`, explicit `\spaceskip`/`\xspaceskip`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfTeX oracle matrix 100-240pt plus register, geometry and vertical-glue fixtures |
| M2 vertical/page builder | partial | vsize, topskip, insertions, marks, Rust output hook, top/bottom floats, float-page/text fractions, rules, vskip, penalties; `page::PageBuilder` scores breakpoints with page badness and penalties and models `\topskip`/`\maxdepth`; `Engine::layout_paged` builds pages through it for single-item documents, while floats, insertions and incremental replay still use the scrolling path; 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 |
@@ -352,8 +359,8 @@ deliberately open rather than approximated:
`\prevgraf` are still open; the tolerance, penalty and demerit registers,
`\hyphenation` exceptions, `\hangindent`/`\parshape`, `\parfillskip` with
or without `fil`, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip`
interline glue, and the default `\sfcode`/`\frenchspacing` sentence spacing
are modelled.
interline glue, the default `\sfcode`/`\frenchspacing` sentence spacing,
and explicit `\spaceskip`/`\xspaceskip` are modelled.
- **M2**: the scrolling builder still drives `Document`; `page::PageBuilder`
implements TeX's candidate-breakpoint cost (badness + penalty, glue
stretch/shrink, `\topskip`, `\maxdepth`) and `Engine::layout_paged` runs it