Reproduce TeX paragraph breaking with tolerance passes and demerits

- replace the single-tolerance DP with pass 0 (pretolerance, no hyphenation),
  pass 1 (tolerance, hyphenation) and an optional emergency pass
- add emergencystretch to ParagraphStyle; the emergency pass only runs when it
  is positive, otherwise TeX's overfull fallback applies and each line fills to
  the first break at or past the measure
- compute badness and fitness classes like TeX and fold them with penalties
  into demerits, ignoring the trailing forced penalty on the final line
- keep forward order in the greedy fallback
- enable the 180pt pdfLaTeX oracle fixture and add an emergencystretch test
- give route-D extraction tests scaled body styles so fixed-cell
  ParagraphStyle defaults no longer mix raw units with TFM advances
- document the passes, oracle results and remaining P1 gaps
This commit is contained in:
gloamxun committed 2026-10-23 00:50:57 +08:00
1 parent 03aa1c5110
commit ac134b3c4e
8 files changed
+331 -164

No files matched your search

+3 -1
View File
@@ -1854,7 +1854,9 @@ mod tests {
document.units.push(Unit::paragraph(6, "f"));
let mut engine = Engine::layout(&document);
assert!(engine.pages().len() >= 2);
engine.edit(&document, 5, "edited second page");
// Keep the replacement to a single line so it cannot spill onto a
// third page; this test is about the checkpoint replay boundary.
engine.edit(&document, 5, "g");
assert_eq!(engine.recomputed_pages(), 1);
assert_eq!(engine.changed_pages(), &[1]);
}