Include PDF graphics in the native XeTeX device

This commit is contained in:
gloamxun committed 2026-11-21 13:34:55 +08:00
1 parent facecbf790
commit 794c2f9b2c
19 files changed
+545 -37

No files matched your search

@@ -352,6 +352,7 @@ impl Executor {
let b = &shipout.box_node;
let device = &shipout.device;
let mut graphics_stack = Vec::new();
let mut xdv_graphics_stack = Vec::new();
let (mut outputs, has_leaders) = b.output_nodes();
let leader_effects = if has_leaders {
let limit = self
@@ -440,6 +441,16 @@ impl Executor {
} else {
None
};
use crate::pdf_device::PdfGraphics;
match &graphics {
Some(PdfGraphics::Save | PdfGraphics::SaveMatrix(_)) => {
xdv_graphics_stack.push(special.span);
}
Some(PdfGraphics::Restore { .. }) if xdv_graphics_stack.pop().is_none() => {
return Err(self.error("unmatched XDV graphics restore", special.span));
}
_ => {}
}
shipout.specials.push(special);
shipout.pdf_graphics_steps.push(graphics);
} else if output.is_pdf_graphics() {
@@ -512,6 +523,9 @@ impl Executor {
if output_positions.next().is_some() {
return self.fail("unexpected positioned native output node");
}
if let Some(&span) = xdv_graphics_stack.last() {
return Err(self.error("unclosed XDV graphics save at page shipout", span));
}
if let Some((_, span)) = graphics_stack.last() {
return Err(self.error(
format!(