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

+2 -3
View File
@@ -255,10 +255,9 @@ fn paragraph_breaks_match_pdftex_at_150pt() {
compare_fixture(WORDS, 150);
}
/// P1 work: matching pdfTeX's emergency line breaking needs TeX's tolerance
/// and demerit model, so this fixture currently records the divergence.
/// The same text at a wider measure; TeX produces four lines here (7, 8, 9
/// and 1 words), which exercises the pass-1 solution rather than the fallback.
#[test]
#[ignore = "P1: TeX tolerance and demerits"]
fn paragraph_breaks_match_pdftex_at_180pt() {
compare_fixture(WORDS, 180);
}