Set vertical glue for ragged and flushed pages
This commit is contained in:
1 parent
448152cea4
commit
00c23a3511
6 files changed
+143
-14
No files matched your search
@@ -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`). 379 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 380 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
@@ -264,7 +264,7 @@ badness from the page goal and accumulated glue, adding the break penalty, and
|
||||
applying `\topskip` to the first box and `\maxdepth` to the page depth. Seven
|
||||
unit tests cover overfull avoidance, exact glue filling, forced penalties,
|
||||
penalty-driven earlier breaks, `\topskip`, `\maxdepth`, marks, insertion
|
||||
limits and top-float placement.
|
||||
limits, float placement and vertical glue setting.
|
||||
`Engine::layout_paged` now feeds it every document whose units are single
|
||||
vertical items (`Document::max_depth` supplies `\maxdepth`) and materialises the
|
||||
chosen fragments as hashed pages; ties go to the breakpoint closest to the page
|
||||
@@ -279,12 +279,11 @@ the source. Insertion classes are placed by the
|
||||
paged builder with their limits and held-over material, top floats are placed
|
||||
at the head of a fragment with `\textfloatsep` reserved above the body, and
|
||||
bottom floats sit at the page bottom with `\floatsep` between them and a
|
||||
`\bottomfraction` cap; in-text floats flow inline with their `\intextsep` gaps counted as body height. Paged layouts also record the
|
||||
`\bottomfraction` cap; in-text floats flow inline with their `\intextsep` gaps counted as body height. Vertical glue is set when pages are materialised: `PageBuilder::ragged_bottom` defaults to `\raggedbottom`, while `\flushbottom` stretches `VerticalItem::StretchGlue` proportionally so the page body reaches the goal (`PageFragment::set` records the signed setting amount). Paged layouts also record the
|
||||
node index starting each page, so `Engine::edit` reuses the sealed prefix and
|
||||
rebuilds only the pages from the edited unit onward; insertions and interpreted
|
||||
`\output` keep the full-rebuild fallback. Next: paper margins, then
|
||||
extend the `\output` interpreter past the
|
||||
shipout/ifdim/ifnum/ifodd/ifcase subset.
|
||||
`\output` keep the full-rebuild fallback. Next: extend the `\output`
|
||||
interpreter past the shipout/ifdim/ifnum/ifodd/ifcase subset.
|
||||
|
||||
Acceptance: 10 page fixtures (article text, footnotes, floats, forced breaks);
|
||||
page counts identical and first/last baselines within 1pt of pdfLaTeX.
|
||||
|
||||
+8
-5
@@ -116,7 +116,7 @@ and justification.
|
||||
| --- | --- | --- |
|
||||
| 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, `\spaceskip`/`\xspaceskip`, `\raggedright` (infinite `\rightskip`), `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 90-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, placing top and bottom floats (with `\floatsep` and a `\bottomfraction` cap) and insertion classes on that path, while in-text floats flow inline as body material; paged layouts replay edits from the edited unit's page and fall back to a full rebuild only when insertions or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable registers and `PageFragment::penalty` carries the break penalty |
|
||||
| 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 (with `\raggedbottom`/`\flushbottom` vertical glue setting applied when pages are materialised), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep` and a `\bottomfraction` cap) and insertion classes on that path, while in-text floats flow inline as body material; paged layouts replay edits from the edited unit's page and fall back to a full rebuild only when insertions or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable registers and `PageFragment::penalty` carries the break penalty |
|
||||
| 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 |
|
||||
| M5 | NFSS/TFM metrics, CM/Latin Modern | same line/page breaks as reference |
|
||||
@@ -342,7 +342,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 255 unit tests plus seven route-D integration tests and seventeen oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 379 tests (255 route-D unit, 7 route-D integration, 17 oracle, 71 v1 integration, 22 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 256 unit tests plus seven route-D integration tests and seventeen oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 380 tests (256 route-D unit, 7 route-D integration, 17 oracle, 71 v1 integration, 22 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
@@ -379,9 +379,12 @@ deliberately open rather than approximated:
|
||||
- **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
|
||||
for simple documents; paged edits replay from the edited page, but bottom
|
||||
and its remaining float path still needs a paged equivalent before it can become the default;
|
||||
paper margins remain open, and
|
||||
for simple documents; `PageBuilder::ragged_bottom` selects `\raggedbottom`
|
||||
(the default) or `\flushbottom`, which stretches `VerticalItem::StretchGlue`
|
||||
in proportion to its stretch so the page body reaches the goal (only shrink
|
||||
is clamped, as in TeX); paged edits replay from the edited page, insertions
|
||||
and an interpreted `\output` keep the full-rebuild fallback; paper margins
|
||||
remain open, and
|
||||
the `\output` interpreter only covers the shipout/ifdim/ifnum/ifodd/ifcase subset (explicit
|
||||
`\hoffset`/`\voffset` offsets are applied by the PDF writer).
|
||||
- **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.
|
||||
|
||||
Reference in new issue
Block a user