Add a TeX page builder over vertical lists

This commit is contained in:
gloamxun committed 2026-10-23 01:41:06 +08:00
1 parent 49bd9b63e6
commit d4a9c6b4fd
6 files changed
+397 -7

No files matched your search

+15 -2
View File
@@ -61,8 +61,11 @@ Known gaps, in dependency order:
`\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`;
2. the page builder used by `Document` is still the scrolling builder with
fraction policies; `page::PageBuilder` now implements the candidate-breakpoint
cost model (badness + penalty, glue setting, `\topskip`, `\maxdepth`) with
unit tests, but it is not yet wired into `Document` and an interpreted
`\output` is absent;
3. `\insert` classes are data structures, not TeX registers and an output
routine;
4. `\halign` handles spans/omit/templates but not the full TeX column algorithm;
@@ -231,6 +234,16 @@ Scope:
- floats: TeX-compatible policy module used by the default output routine
(top/bottom fractions and counts already exist).
The foundation is in `crates/texrra-tex-core/src/page.rs`: `PageBuilder` takes a
`VerticalNode` list (box height/depth, glue width/stretch/shrink, penalties,
marks) and chooses each page at the cheapest feasible breakpoint, scoring
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` and marks. Wiring this
builder into `Document` and replacing the scrolling path is the next step,
followed by `\voffset`, insertion registers and the interpreted `\output`.
Acceptance: 10 page fixtures (article text, footnotes, floats, forced breaks);
page counts identical and first/last baselines within 1pt of pdfLaTeX.