Route route-D page breaking through the paged builder

This commit is contained in:
gloamxun committed 2026-10-23 15:02:52 +08:00
1 parent 08a312be82
commit 6b3145fd09
6 files changed
+113 -26

No files matched your search

+11 -7
View File
@@ -156,10 +156,13 @@ and justification.
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
paragraph does not fit on the page, the scrolling builder splits it at line
boundaries (`Paragraph::split_at`): the fragment keeps its baseline grid on
the next page, `\parskip` is not charged inside the paragraph, and only a
single unsplittable line is allowed to overflow at the top of a page.
paragraph does not fit on the page it is split at line boundaries
(`Paragraph::split_at`): the fragment keeps its baseline grid on the next
page, `\parskip` is not charged inside the paragraph, and only a single
unsplittable line is allowed to overflow at the top of a page. The scrolling
builder splits paragraphs directly; for the paged builder each paragraph
becomes one node per line joined by zero-width interline glue, so its page
breaks also land between lines with the same overflowing-line rule.
Remaining gaps are generic `fil`/`fill` glue orders outside
`\parfillskip` and `\prevgraf`.
@@ -358,7 +361,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 297 unit tests plus seven route-D integration tests and thirty oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 449 tests (297 route-D unit, 7 route-D integration, 30 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 12 binary units), with none ignored. v1 remains the live server path.
The crate currently has 298 unit tests plus seven route-D integration tests and thirty oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 450 tests (298 route-D unit, 7 route-D integration, 30 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 13 binary units), with none ignored. v1 remains the live server path.
### M0 incremental demo
@@ -393,8 +396,9 @@ deliberately open rather than approximated:
interline glue, the default `\sfcode`/`\frenchspacing` sentence spacing,
explicit `\spaceskip`/`\xspaceskip`, stretch and shrink on the
inter-paragraph `\parskip` glue, and `\raggedright` (infinite `\rightskip` fil) are modelled.
- **M2**: the scrolling builder still drives `Document`; `page::PageBuilder`
implements TeX's candidate-breakpoint cost (badness + penalty, glue
- **M2**: `Engine::layout` keeps the scrolling builder as the non-paged
fallback, while route-D previews and PDFs run `Engine::layout_paged`;
`page::PageBuilder` implements TeX's candidate-breakpoint cost (badness + penalty, glue
stretch/shrink, `\topskip`, `\maxdepth`); a break at glue is only legal
when it follows a non-discardable item, so glue after glue is not a
breakpoint and the glue at a break is discarded and `Engine::layout_paged` runs it