From 1dc3e95a0429323b711c9c69ad6678dbc9adf85a Mon Sep 17 00:00:00 2001 From: GloamXun Date: Sat, 24 Oct 2026 00:20:32 +0800 Subject: [PATCH] Run the output routine after each paged page --- crates/texrra-tex-core/src/lib.rs | 410 ++++++++++++++++++++++-------- docs/ROUTE_D_PLAN.md | 5 +- docs/TEX_CORE.md | 4 +- 3 files changed, 304 insertions(+), 115 deletions(-) diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index ee39abc..aa43af3 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -813,14 +813,21 @@ impl Document { /// Maximum height available to one insertion class on a page. pub fn insertion_class_limit(&self, class: u8) -> i64 { + let fraction = self.insertion_fraction_limit(class); + self.insertion_classes + .iter() + .find(|entry| entry.number == class) + .and_then(|entry| entry.max_height) + .map_or(fraction, |absolute| fraction.min(absolute)) + } + + /// Percentage share of the page that insertion class `class` may occupy. + pub fn insertion_fraction_limit(&self, class: u8) -> i64 { self.insertion_classes .iter() .find(|entry| entry.number == class) .map_or(self.page_goal, |entry| { - let fraction = self.page_goal * i64::from(entry.fraction_percent) / 100; - entry - .max_height - .map_or(fraction, |absolute| fraction.min(absolute)) + self.page_goal * i64::from(entry.fraction_percent) / 100 }) } pub fn with_top_skip(mut self, top_skip: i64) -> Self { @@ -1122,17 +1129,17 @@ fn held_insertion_material( } fn take_insertion_prefix( - document: &Document, - class: u8, + _class: u8, items: Vec, capacity: i64, + multiplier: i64, ) -> (Vec, Vec, i64) { let mut accepted = Vec::new(); let mut reserved = 0_i64; let mut rest = items.into_iter(); let mut remainder = Vec::new(); while let Some(item) = rest.next() { - let reserve = document.insertion_reserve(class, item_height(&item)); + let reserve = item_height(&item).saturating_mul(multiplier) / 1000; if reserved + reserve <= capacity { accepted.push(item); reserved += reserve; @@ -1501,6 +1508,159 @@ impl OutputRoutine for NoOutput { fn shipout(&mut self, _page: &mut Page, _page_number: usize) {} } +/// State carried between interpreted output-routine runs in a paged layout. +/// +/// TeX's output registers are global: an assignment made while shipping one +/// page changes what later pages see. Keeping the state next to the page loop +/// lets a `\dimen` assignment shrink the capacity of the next page's +/// insertion class, as it does inside TeX's output routine. +struct PagedOutput { + program: output::OutputProgram, + pageno: i64, + deadcycles: i64, + counts: [i64; 256], + dimens: [i64; 256], + skips: [i64; 256], + initial_dimens: Vec<(u8, i64)>, +} + +impl PagedOutput { + fn new(document: &Document, program: output::OutputProgram) -> Self { + let mut counts = [1000_i64; 256]; + let mut dimens = [0_i64; 256]; + let mut skips = [0_i64; 256]; + let mut initial_dimens = Vec::new(); + for class in &document.insertion_classes { + let slot = class.number as usize; + counts[slot] = i64::from(class.multiplier); + dimens[slot] = class.max_height.unwrap_or(0); + skips[slot] = class.skip.unwrap_or(document.insertion_skip); + initial_dimens.push((class.number, dimens[slot])); + } + Self { + program, + pageno: 1, + deadcycles: 0, + counts, + dimens, + skips, + initial_dimens, + } + } + + #[allow(clippy::too_many_arguments)] + fn ship( + &mut self, + document: &Document, + page: &Page, + page_goal: i64, + penalty: i64, + depth: i64, + stretch: i64, + stretches: [i64; 4], + shrink: i64, + badness: i64, + insert_penalties: i64, + ) -> Option { + let page_total: i64 = page.items.iter().map(item_height).sum(); + let mut context = output::OutputContext { + page_goal, + page_total, + page_depth: depth, + page_stretch: stretch, + page_fil_stretch: stretches[1], + page_fill_stretch: stretches[2], + page_filll_stretch: stretches[3], + page_shrink: shrink, + vbadness: badness, + hsize: document.text_width, + vsize: document.page_goal, + top_skip: document.top_skip, + max_depth: document.max_depth, + output_penalty: penalty, + max_deadcycles: document.max_deadcycles, + insertion_counts: self.counts, + insertion_dimens: self.dimens, + insertion_skips: self.skips, + pageno: self.pageno, + deadcycles: self.deadcycles, + prev_graf: page_prev_graf(page), + insert_penalties, + }; + let forced = self.deadcycles >= document.max_deadcycles.max(0); + if forced { + context.deadcycles = 0; + } + let shipped_now = if forced { + 1 + } else { + self.program.shipout_count(&mut context).ok()? + }; + self.counts = context.insertion_counts; + self.dimens = context.insertion_dimens; + self.skips = context.insertion_skips; + self.pageno = context.pageno.wrapping_add(1); + self.deadcycles = context.deadcycles; + if shipped_now > 0 { + self.deadcycles = 0; + Some(true) + } else { + self.deadcycles += 1; + Some(false) + } + } +} + +/// Insertion capacity in force before the next page is assembled. +/// TeX's `\count` multiplier in force before the next page. +fn output_insertion_multiplier( + document: &Document, + class: u8, + routine: Option<&PagedOutput>, +) -> i64 { + let initial = document + .insertion_classes + .iter() + .find(|entry| entry.number == class) + .map_or(1000, |entry| i64::from(entry.multiplier)); + match routine { + Some(routine) if routine.counts[class as usize] != initial => { + routine.counts[class as usize].max(0) + } + _ => initial, + } +} + +fn output_insertion_limit(document: &Document, class: u8, routine: Option<&PagedOutput>) -> i64 { + let fraction = document.insertion_fraction_limit(class); + let absolute = match routine { + Some(routine) => { + let slot = class as usize; + let initial = routine + .initial_dimens + .iter() + .find(|(number, _)| *number == class) + .map_or(0, |(_, value)| *value); + if routine.dimens[slot] == initial { + class_backstop(document, class, fraction) + } else { + routine.dimens[slot] + } + } + None => class_backstop(document, class, fraction), + }; + fraction.min(absolute.max(0)) +} + +fn class_backstop(document: &Document, class: u8, fraction: i64) -> i64 { + document + .insertion_classes + .iter() + .find(|entry| entry.number == class) + .and_then(|entry| entry.max_height) + .unwrap_or(fraction) +} + pub struct Engine { layout: Layout, } @@ -1990,17 +2150,14 @@ impl Engine { } } let builder = Self::paged_builder(document); + let mut routine = match &document.output_routine { + Some(source) => Some(PagedOutput::new( + document, + output::OutputProgram::parse(source).ok()?, + )), + None => None, + }; let mut pages = Vec::new(); - let mut page_penalties = Vec::new(); - let mut page_depths = Vec::new(); - let mut page_stretches = Vec::new(); - let mut page_fil_stretches = Vec::new(); - let mut page_fill_stretches = Vec::new(); - let mut page_filll_stretches = Vec::new(); - let mut page_shrinks = Vec::new(); - let mut page_badnesses = Vec::new(); - let mut page_insert_penalties = Vec::new(); - let mut page_goals: Vec = Vec::new(); let mut held: BTreeMap> = BTreeMap::new(); let fragments = builder.build_with_deferred_bottom_floats(&nodes); for fragment in &fragments { @@ -2027,11 +2184,12 @@ impl Engine { let held_classes: Vec = held.keys().copied().collect(); for class in held_classes { let material = held.remove(&class).unwrap_or_default(); - let limit = document.insertion_class_limit(class); + let limit = output_insertion_limit(document, class, routine.as_ref()); let capacity = (limit - used.get(&class).copied().unwrap_or(0)).max(0); let material = held_insertion_material(document, capacity, material); + let multiplier = output_insertion_multiplier(document, class, routine.as_ref()); let (accepted, remainder, reserved) = - take_insertion_prefix(document, class, material, capacity); + take_insertion_prefix(class, material, capacity, multiplier); attach_insertion(&mut insertions, &mut used, class, accepted, reserved); if !remainder.is_empty() { held.insert(class, remainder); @@ -2048,13 +2206,15 @@ impl Engine { VerticalItem::Mark(mark) => marks.push(mark.clone()), VerticalItem::Insertion(insertion) => { let class = insertion.class; - let limit = document.insertion_class_limit(class); + let limit = output_insertion_limit(document, class, routine.as_ref()); let capacity = (limit - used.get(&class).copied().unwrap_or(0)).max(0); + let multiplier = + output_insertion_multiplier(document, class, routine.as_ref()); let (accepted, remainder, reserved) = take_insertion_prefix( - document, class, insertion.items.clone(), capacity, + multiplier, ); attach_insertion(&mut insertions, &mut used, class, accepted, reserved); if !remainder.is_empty() { @@ -2079,20 +2239,27 @@ impl Engine { page.marks = marks; page.floats = floats; let reserved: i64 = insertions.values().map(|insertion| insertion.height).sum(); - page_goals.push((document.page_goal - reserved).max(0)); page.insertions = insertions.into_values().collect(); page.sources = sources; page.seal_in_place(); - pages.push(page); - page_penalties.push(fragment.penalty); - page_depths.push(fragment.depth); - page_stretches.push(fragment.stretch); - page_fil_stretches.push(fragment.stretches[1]); - page_fill_stretches.push(fragment.stretches[2]); - page_filll_stretches.push(fragment.stretches[3]); - page_shrinks.push(fragment.shrink); - page_badnesses.push(fragment.badness); - page_insert_penalties.push(insert_penalties); + let shipped = match routine.as_mut() { + Some(routine) => routine.ship( + document, + &page, + (document.page_goal - reserved).max(0), + fragment.penalty, + fragment.depth, + fragment.stretch, + fragment.stretches, + fragment.shrink, + fragment.badness, + insert_penalties, + )?, + None => true, + }; + if shipped { + pages.push(page); + } } // Insertion material that did not fit its class limit on the page where @@ -2105,8 +2272,13 @@ impl Engine { let material = held.remove(&class).unwrap_or_default(); let limit = document.insertion_class_limit(class); let material = held_insertion_material(document, limit, material); + let multiplier = document + .insertion_classes + .iter() + .find(|entry| entry.number == class) + .map_or(1000, |entry| i64::from(entry.multiplier)); let (accepted, remainder, reserved) = - take_insertion_prefix(document, class, material, limit); + take_insertion_prefix(class, material, limit, multiplier); attach_insertion(&mut insertions, &mut used, class, accepted, reserved); if !remainder.is_empty() { held.insert(class, remainder); @@ -2114,86 +2286,26 @@ impl Engine { } let mut page = Page::empty(); let reserved: i64 = insertions.values().map(|insertion| insertion.height).sum(); - page_goals.push((document.page_goal - reserved).max(0)); page.insertions = insertions.into_values().collect(); page.seal_in_place(); - pages.push(page); - page_penalties.push(10_000); - page_depths.push(0); - page_stretches.push(0); - page_fil_stretches.push(0); - page_fill_stretches.push(0); - page_filll_stretches.push(0); - page_shrinks.push(0); - page_badnesses.push(10_000); - page_insert_penalties.push(0); - } - if let Some(source) = &document.output_routine { - let program = output::OutputProgram::parse(source).ok()?; - let mut shipped = Vec::new(); - let mut deadcycles = 0_i64; - let mut pageno = 1_i64; - // TeX's output registers are global: assignments made by the - // routine on one page stay visible on later pages. - let mut insertion_counts = [1000_i64; 256]; - let mut insertion_dimens = [0_i64; 256]; - let mut insertion_skips = [0_i64; 256]; - for class in &document.insertion_classes { - let slot = class.number as usize; - insertion_counts[slot] = i64::from(class.multiplier); - insertion_dimens[slot] = class.max_height.unwrap_or(0); - insertion_skips[slot] = class.skip.unwrap_or(document.insertion_skip); + let shipped = match routine.as_mut() { + Some(routine) => routine.ship( + document, + &page, + (document.page_goal - reserved).max(0), + 10_000, + 0, + 0, + [0; 4], + 0, + 10_000, + 0, + )?, + None => true, + }; + if shipped { + pages.push(page); } - for (index, page) in pages.into_iter().enumerate() { - let page_total: i64 = page.items.iter().map(item_height).sum(); - let mut context = output::OutputContext { - page_goal: page_goals.get(index).copied().unwrap_or(document.page_goal), - page_total, - page_depth: page_depths.get(index).copied().unwrap_or(0), - page_stretch: page_stretches.get(index).copied().unwrap_or(0), - page_fil_stretch: page_fil_stretches.get(index).copied().unwrap_or(0), - page_fill_stretch: page_fill_stretches.get(index).copied().unwrap_or(0), - page_filll_stretch: page_filll_stretches.get(index).copied().unwrap_or(0), - page_shrink: page_shrinks.get(index).copied().unwrap_or(0), - vbadness: page_badnesses.get(index).copied().unwrap_or(10_000), - hsize: document.text_width, - vsize: document.page_goal, - top_skip: document.top_skip, - max_depth: document.max_depth, - output_penalty: page_penalties.get(index).copied().unwrap_or(10_000), - max_deadcycles: document.max_deadcycles, - insertion_counts, - insertion_dimens, - insertion_skips, - pageno, - deadcycles, - prev_graf: page_prev_graf(&page), - insert_penalties: page_insert_penalties.get(index).copied().unwrap_or(0), - }; - let forced = deadcycles >= document.max_deadcycles.max(0); - if forced { - context.deadcycles = 0; - } - let shipped_now = if forced { - 1 - } else { - program.shipout_count(&mut context).ok()? - }; - insertion_counts = context.insertion_counts; - insertion_dimens = context.insertion_dimens; - insertion_skips = context.insertion_skips; - pageno = context.pageno.wrapping_add(1); - deadcycles = context.deadcycles; - if shipped_now > 0 { - shipped.push(page); - deadcycles = 0; - } else { - // TeX counts a page the output routine does not ship as a - // dead cycle; the count resets on the next shipout. - deadcycles += 1; - } - } - pages = shipped; } let paged_page_nodes = if document.output_routine.is_none() && pages.len() == fragments.len() { @@ -3615,6 +3727,84 @@ mod tests { assert_eq!(Engine::layout(&document).pages().len(), 1); } + #[test] + fn output_routine_dimen_limits_later_insertions() { + let items = || { + (0..8) + .map(|_| VerticalItem::Rule { + width: 65_536, + height: 10, + }) + .collect::>() + }; + let mut document = Document::new( + 100, + vec![ + Unit::insertion(1, 1, 80, items()), + Unit::vskip(2, 65_536), + Unit::insertion(3, 1, 80, items()), + ], + ); + document.insertion_classes = vec![InsertionClass { + number: 1, + fraction_percent: 100, + max_height: None, + skip: None, + multiplier: 1000, + }]; + + let without = Engine::layout_paged(&document).expect("paged layout"); + assert_eq!( + without.layout.pages.len(), + 2, + "both insertions should fit before any assignment" + ); + assert_eq!(without.layout.pages[0].insertions[0].height, 80); + + document.output_routine = + Some(r"\ifnum\pageno=1 \dimen1=30 \fi \shipout\box255".to_string()); + let with = Engine::layout_paged(&document).expect("paged layout"); + assert_eq!(with.layout.pages.len(), 3); + assert_eq!(with.layout.pages[0].insertions[0].height, 80); + assert_eq!(with.layout.pages[1].insertions[0].height, 30); + assert_eq!(with.layout.pages[2].insertions[0].height, 50); + } + + #[test] + fn output_routine_count_changes_later_insertion_reservations() { + let items = || { + (0..4) + .map(|_| VerticalItem::Rule { + width: 65_536, + height: 10, + }) + .collect::>() + }; + let mut document = Document::new( + 100, + vec![ + Unit::insertion(1, 1, 40, items()), + Unit::vskip(2, 65_536), + Unit::insertion(3, 1, 40, items()), + ], + ); + document.insertion_classes = vec![InsertionClass { + number: 1, + fraction_percent: 100, + max_height: None, + skip: None, + multiplier: 1000, + }]; + let without = Engine::layout_paged(&document).expect("paged layout"); + assert_eq!(without.layout.pages[0].insertions[0].height, 40); + assert_eq!(without.layout.pages[1].insertions[0].height, 40); + + document.output_routine = + Some(r"\ifnum\pageno=1 \count1=2000 \fi \shipout\box255".to_string()); + let with = Engine::layout_paged(&document).expect("paged layout"); + assert_eq!(with.layout.pages[1].insertions[0].height, 80); + } + #[test] fn insertion_class_limit_ships_the_overflow_to_the_next_page() { let rule = VerticalItem::Rule { diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 0bd7862..e77c0fb 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -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`). 469 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 471 workspace tests are green and no oracle fixture is ignored. Known gaps, in dependency order: @@ -88,8 +88,7 @@ source-level `\hyphenation{...}` exceptions and `\parshape` measures, box height and depth, and the assigned values carry over to later pages (TeX output registers are global); an assigned `\vsize` changes later page goals for documents without insertions or floats, but - insertion-register writes still do not feed back into page building, `\box255` content is not inspectable and the full - `\output` machinery is still missing; + the paged builder now runs the routine page by page, so `\dimen` and `\count` assignments change the insertion limits and reservations of later pages (a `\skip` assignment still has no effect on that path, which never applied `\skip` there), `\box255` content is not inspectable and the full `\output` machinery is still missing; 4. `\halign` handles spans/omit/templates but not the full TeX column algorithm; 5. math is a compact subset without the CM math fonts (`cmmi`, `cmsy`, `cmex`), display-math line breaking or `\mathchoice`-level styling; diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 5e4e90d..c050be6 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -129,7 +129,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`, `\parindent`, `\parshape`, `\leftskip`/`\rightskip`, `\hfil`/`\hfill` glue orders, `\prevgraf` in the output routine, and vertical-glue fixtures | -| 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` applied when pages are materialised, and TeX glue orders `\vfil`/`\vfill`/`\vfilll` honoured so only the highest order with stretch is used), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep`, a `\bottomfraction` cap and the `\topnumber`/`\bottomnumber`/`\totalnumber` limits, with `\floatpagefraction` deciding when a float-heavy page ships without body) 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, bottom floats or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable and assignable registers (`\pageno=...` carries into the next page, and an assigned `\vsize` retargets later pages when the document has no insertions or floats), `\ht255`, `\dp255` and `\wd255` expose the page box height, depth and width to the routine, and `\hsize` is readable (and assignable for the rest of the run) while `\wd255` tracks it; route-D sets `\hsize` from its 480pt text measure, insertion class registers `\count`/`\dimen`/`\skip` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`) and accept assignments for the duration of the routine, `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `\maxdeadcycles` (default 25, assignable) makes the page builder ship the page itself once that many dead cycles have accumulated, `PageFragment::penalty` carries the break penalty (`\outputpenalty`: the penalty value when the break landed on a penalty, otherwise 10000, as TeX reports for glue breaks, goal overflow and the final page), and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine; `\vbadness` reports the badness of the break that produced the page and `\insertpenalties` the number of insertion items held over from it | +| 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` applied when pages are materialised, and TeX glue orders `\vfil`/`\vfill`/`\vfilll` honoured so only the highest order with stretch is used), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep`, a `\bottomfraction` cap and the `\topnumber`/`\bottomnumber`/`\totalnumber` limits, with `\floatpagefraction` deciding when a float-heavy page ships without body) 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, bottom floats or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable and assignable registers (`\pageno=...` carries into the next page, and an assigned `\vsize` retargets later pages when the document has no insertions or floats), `\ht255`, `\dp255` and `\wd255` expose the page box height, depth and width to the routine, and `\hsize` is readable (and assignable for the rest of the run) while `\wd255` tracks it; route-D sets `\hsize` from its 480pt text measure, insertion class registers `\count`/`\dimen`/`\skip` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`) and accept assignments that outlive the routine (the paged builder runs the routine after each page, so an assigned `\dimen` or `\count` changes the insertion capacity and reservation of later pages), `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `\maxdeadcycles` (default 25, assignable) makes the page builder ship the page itself once that many dead cycles have accumulated, `PageFragment::penalty` carries the break penalty (`\outputpenalty`: the penalty value when the break landed on a penalty, otherwise 10000, as TeX reports for glue breaks, goal overflow and the final page), and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine; `\vbadness` reports the badness of the break that produced the page and `\insertpenalties` the number of insertion items held over from it | | 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 | @@ -367,7 +367,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 312 unit tests plus seven route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 469 tests (312 route-D unit, 7 route-D integration, 35 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 13 binary units), with none ignored. v1 remains the live server path. +The crate currently has 314 unit tests plus seven route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 471 tests (314 route-D unit, 7 route-D integration, 35 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