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

@@ -69,12 +69,14 @@ impl Executor {
return Ok(());
}
self.reads.insert(Dependency::PdfCatalogState);
let warnings = if matches!(kind, b"docview" | b"outline") {
let warnings = if matches!(kind, b"docview" | b"outline" | b"pageresources") {
let navigation = Arc::make_mut(self.state.xdv_navigation.get_or_insert_with(Default::default));
if kind == b"docview" {
navigation.merge_catalog(operands, position, self.limits.tokens)
} else {
} else if kind == b"outline" {
navigation.add_outline(operands, position, (position.page, graphics_step, 1), self.limits.tokens)
} else {
navigation.set_page_resources(operands, position, self.limits.tokens)
}
} else {
use crate::pdf_device::xdv_navigation::ObjectCommand;
@@ -176,6 +178,21 @@ impl Executor {
return Ok(Some(graphics));
}
let body = data.strip_prefix(b"pdf:").map(xdv_skip_white);
if let Some(body) = body {
for (command, mode) in [
(b"bcontent".as_slice(), PdfLiteralMode::XdvBeginContent),
(b"econtent", PdfLiteralMode::XdvEndContent),
(b"code", PdfLiteralMode::XdvCode),
] {
if let Some(operands) = xdv_operand(body, command) {
let bytes = xdv_skip_white(operands);
if mode != PdfLiteralMode::XdvCode && !bytes.is_empty() {
return self.fail("unexpected operands to XDV content boundary");
}
return Ok(Some(PdfGraphics::Literal { mode, bytes: Arc::from(bytes) }));
}
}
}
if let Some(content) = body.and_then(|body| xdv_operand(body, b"content")) {
let bytes = xdv_skip_white(content);
return Ok((!bytes.is_empty()).then(|| PdfGraphics::Literal {
@@ -339,7 +356,7 @@ pub(super) fn xdv_navigation_operand(data: &[u8]) -> Option<(&'static [u8], &[u8
(b"dest".as_slice(), b"dest".as_slice()), (b"destination", b"dest"),
(b"docview", b"docview"), (b"outline", b"outline"), (b"out", b"outline"),
(b"obj", b"obj"), (b"object", b"obj"), (b"put", b"put"), (b"close", b"close"),
(b"stream", b"stream"), (b"fstream", b"fstream"),
(b"stream", b"stream"), (b"fstream", b"fstream"), (b"pageresources", b"pageresources"),
] {
if let Some(operands) = xdv_operand(body, name) {
return Some((kind, operands));