From 159bb6a3864becc12acb20a7db2061631f22165f Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 20 Oct 2026 18:17:47 +0800 Subject: [PATCH] Paint insertion material in route-D display lists --- crates/texrra-tex-core/src/lib.rs | 24 ++++++++++++++++++++++++ crates/texrra-tex-core/src/render.rs | 10 +++++++++- docs/TEX_CORE.md | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index 00deace..c1f359e 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -1347,6 +1347,30 @@ mod tests { let pdf = crate::pdf::display_list_to_pdf(&list, 792 * 65_536); assert!(String::from_utf8_lossy(&pdf).contains("0.5 g 10 10 20 20 re f")); } + + #[test] + fn insertion_contents_reach_the_display_list() { + let page = Page { + items: vec![VerticalItem::Insertion(Insertion { + class: 0, + height: 20 * 65_536, + items: vec![VerticalItem::Rule { + width: 100 * 65_536, + height: 2 * 65_536, + }], + })], + insertions: Vec::new(), + marks: Vec::new(), + floats: Vec::new(), + sources: Vec::new(), + hash: 0, + }; + let list = page.display_list(); + assert!(list.items.iter().any(|item| matches!( + item, + crate::render::DisplayItem::Rule { width, .. } if *width == 100 * 65_536 + ))); + } #[test] fn link_rectangles_become_pdf_annotations() { use crate::render::DisplayList; diff --git a/crates/texrra-tex-core/src/render.rs b/crates/texrra-tex-core/src/render.rs index f075314..f6775eb 100755 --- a/crates/texrra-tex-core/src/render.rs +++ b/crates/texrra-tex-core/src/render.rs @@ -232,7 +232,15 @@ impl Page { pub fn display_list(&self) -> DisplayList { let mut list = DisplayList::default(); let mut y = 0_i64; - for item in &self.items { + let items: Vec = self + .items + .iter() + .flat_map(|item| match item { + VerticalItem::Insertion(insertion) => insertion.items.clone(), + _ => vec![item.clone()], + }) + .collect(); + for item in &items { match item { VerticalItem::Box(box_) => { y += box_.height; diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index fb7585c..cd270e3 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -257,3 +257,5 @@ PDF writer: `src/pdf.rs` emits a one-page PDF 1.4 for a `DisplayList` (Base-14 T M6 (partial): display-list Link rectangles become PDF /Annots /Subtype /Link /URI dictionaries. Raw-RGB images are PDF XObjects; /special and embedded font subsets remain. M7 (partial): DisplayList::special injects raw PDF content-stream operators; SVG previews show a comment. Driver-level \special parsing and coordinate transforms remain. + +M2 (partial): insertion material is expanded into the page display list at its reserved position, so footnote/float material is no longer dropped by the painter; page-bottom placement and rules remain to be modelled.