Model TeX interline glue and parskip
This commit is contained in:
1 parent
8cb09ea5a8
commit
49bd9b63e6
8 files changed
+200
-32
No files matched your search
+15
-6
@@ -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`). 305 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 301 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
@@ -57,9 +57,10 @@ Known gaps, in dependency order:
|
||||
`\adjdemerits`, `\doublehyphendemerits`, `\finalhyphendemerits`,
|
||||
`\hyphenpenalty`, `\exhyphenpenalty`, `\hyphenation` exceptions,
|
||||
`\hangindent`/`\hangafter`/`\parshape` line geometry, `\parfillskip`
|
||||
with or without `fil`, default `\sfcode` sentence spacing and
|
||||
`\looseness`), but not yet custom `\sfcode` overrides or generic
|
||||
`fil`/`fill` glue orders;
|
||||
with or without `fil`, default `\sfcode` sentence spacing,
|
||||
`\looseness`, and `\baselineskip`/`\lineskip`/`\parskip` interline
|
||||
glue), but not yet custom `\sfcode` overrides, generic `fil`/`fill` glue
|
||||
orders or `\prevgraf`;
|
||||
2. the page builder is a scrolling builder with fraction policies, not a TeX
|
||||
page builder with badness and an interpreted `\output`;
|
||||
3. `\insert` classes are data structures, not TeX registers and an output
|
||||
@@ -200,9 +201,17 @@ oracle fixture matches pdfLaTeX's line breaks and word positions.
|
||||
reverted when no feasible layout exists; 120pt and 200pt fixtures require one
|
||||
extra line and match pdfLaTeX exactly.
|
||||
|
||||
Interline spacing follows TeX: the first baseline sits at the paragraph's
|
||||
ascent, each later baseline advances by `\baselineskip` when the resulting gap
|
||||
clears `\lineskiplimit`, otherwise by `\lineskip`, and `\parskip` (default
|
||||
`0pt`) separates paragraph units in the vertical list. Page-level `\topskip`
|
||||
placement remains part of P2, and a paragraph still reserves a whole number of
|
||||
line boxes for pagination.
|
||||
|
||||
Still open: generic `fil`/`fill` glue orders, custom `\sfcode` overrides,
|
||||
vertical-list skips (`\baselineskip`, `\lineskip`, `\parskip`), double/final
|
||||
hyphen demerit oracle fixtures, and more width fixtures.
|
||||
`\prevgraf`, explicit `\vskip` classes (`\smallskip` and friends), page-level
|
||||
`\topskip` placement, double/final hyphen demerit oracle fixtures, and more
|
||||
width fixtures.
|
||||
|
||||
### P2 — Vertical list, page builder, `\output` (L2)
|
||||
|
||||
|
||||
+14
-9
@@ -109,7 +109,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`, pdfLaTeX oracle matrix 100-240pt plus four register fixtures; custom `\sfcode`, generic fil and vertical skips 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, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 100-240pt plus register, geometry and vertical-glue fixtures; custom `\sfcode`, 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; interpreted `\output`, float pages 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 |
|
||||
@@ -132,9 +132,13 @@ and justification.
|
||||
disables the effect. `\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
|
||||
the resulting gap clears `\lineskiplimit`, otherwise by `\lineskip`;
|
||||
`\parskip` is appended between paragraph units in the vertical list. A
|
||||
paragraph still reserves a whole number of line boxes, so page budgeting is
|
||||
unchanged (page-level `\topskip` placement belongs to M2).
|
||||
Remaining gaps are custom `\sfcode` overrides, generic `fil`/`fill` glue
|
||||
orders outside `\parfillskip`, and the vertical-list skips
|
||||
(`\baselineskip`, `\lineskip`, `\parskip`).
|
||||
orders outside `\parfillskip`, and `\prevgraf`.
|
||||
|
||||
The pdfLaTeX oracle pins the 100-240pt measure matrix plus `\hangindent`,
|
||||
`\parfillskip`, sentence-spacing and `\looseness` fixtures; all match and no
|
||||
@@ -265,7 +269,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 (`\sfcode`/`\frenchspacing`), pdfTeX oracle matrix 100-240pt plus three register 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 (`\sfcode`/`\frenchspacing`), `\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; 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 |
|
||||
@@ -303,7 +307,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 192 unit tests plus six route-D integration tests and ten oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 305 tests (192 route-D unit, 6 route-D integration, 10 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 190 unit tests plus six route-D integration tests and eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 301 tests (190 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
|
||||
|
||||
@@ -332,10 +336,11 @@ Route D currently covers M0-M4/M6 as a working subset. The remaining milestones
|
||||
deliberately open rather than approximated:
|
||||
|
||||
- **M1**: 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`, `\looseness`, and the default
|
||||
`\sfcode`/`\frenchspacing` sentence spacing are modelled.
|
||||
`\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.
|
||||
- **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.
|
||||
|
||||
Reference in new issue
Block a user