Render XeLaTeX shared page resources and scoped graphics

This commit is contained in:
gloamxun committed 2026-11-28 18:58:49 +08:00
1 parent e20acc3eb9
commit 009fde04f7
13 files changed
+445 -12

No files matched your search

@@ -663,9 +663,9 @@ impl Executor {
} else {
None
};
use crate::pdf_device::PdfGraphics;
use crate::pdf_device::{PdfGraphics, PdfLiteralMode};
match &graphics {
Some(PdfGraphics::Save) => {
Some(PdfGraphics::Save | PdfGraphics::Literal { mode: PdfLiteralMode::XdvBeginContent, .. }) => {
xdv_graphics_stack.push((special.span, xdv_transform, self.xdv_colors.current()));
}
Some(operation @ (PdfGraphics::SaveMatrix(matrix) | PdfGraphics::Matrix(matrix))) => {
@@ -680,7 +680,7 @@ impl Executor {
);
xdv_transform = xdv_transform.concatenate(pivot);
}
Some(PdfGraphics::Restore { .. }) => {
Some(PdfGraphics::Restore { .. } | PdfGraphics::Literal { mode: PdfLiteralMode::XdvEndContent, .. }) => {
let Some((_, previous, color_at_save)) = xdv_graphics_stack.pop() else {
return Err(self.error("unmatched XDV graphics restore", special.span));
};
@@ -869,6 +869,17 @@ impl Executor {
)?;
}
}
if xdv && let Some(navigation) = &mut self.state.xdv_navigation
&& navigation.has_pending_page_resources()
{
self.reads.insert(Dependency::PdfCatalogState);
let messages = Arc::make_mut(navigation).finish_page_resources(self.shipped_pages + 1)
.map_err(|message| self.error(message, current))?;
for message in messages {
files.observe_diagnostic(WriteDestination::TerminalAndLog, &message)
.map_err(|message| self.error(message, current))?;
}
}
if xdv && (!xdv_annotations.is_empty() || self.xdv_annotations.is_active()) {
shipout.pdf_links.xdv_annotations = self.ship_xdv_annotations(&shipout, &xdv_annotations, files)?;
}