Apply XDV color state and page backgrounds at shipout

This commit is contained in:
gloamxun committed 2026-11-25 20:09:15 +08:00
1 parent cc147e93d8
commit 8be7867b37
10 files changed
+590 -19

No files matched your search

+9
View File
@@ -267,6 +267,7 @@ pub struct DisplayList {
#[doc(hidden)]
pub pdf_font_bindings: Option<std::sync::Arc<crate::native_font::PdfFontBindings>>,
pub pdf_links: crate::pdf_device::links::PageLinks,
pub pdf_background: Option<std::sync::Arc<crate::pdf_device::PdfColorProgram>>,
pub pdf_text_spaces: Option<crate::pdf_device::text_spaces::SpaceSettings>,
pub pdf_space_plan: Option<crate::pdf_device::text_spaces::SpacePlan>,
pub pdf_resources: crate::pdf_device::page_resources::PageResources,
@@ -285,6 +286,7 @@ impl Default for DisplayList {
pdf: None,
pdf_font_bindings: None,
pdf_links: Default::default(),
pdf_background: None,
pdf_text_spaces: None,
pdf_space_plan: None,
pdf_resources: Default::default(),
@@ -354,6 +356,7 @@ impl DisplayList {
&& self.units == other.units
&& self.magnification == other.magnification
&& self.images == other.images
&& self.pdf_background == other.pdf_background
&& self.pdf_resources.opacity == other.pdf_resources.opacity
&& self.pdf_resources.viewport == other.pdf_resources.viewport
&& self.pdf_resources.needs_pdf_for_preview == other.pdf_resources.needs_pdf_for_preview
@@ -482,6 +485,12 @@ impl DisplayList {
if self.magnification != 1000 || self.units == DisplayUnits::TeX {
out.push_str(&format!("<g transform=\"scale({mag:.12})\">\n"));
}
if let Some(color) = self.pdf_background.as_ref().and_then(|color| color.fill) {
let [r, g, b] = color;
out.push_str(&format!(
"<rect width=\"{width:.6}\" height=\"{height:.6}\" fill=\"#{r:02x}{g:02x}{b:02x}\"/>\n"
));
}
let glyphs: std::collections::BTreeSet<_> = self
.items
.iter()