Emit native PDF literals at scan and shipout boundaries

This commit is contained in:
gloamxun committed 2026-11-21 02:03:25 +08:00
1 parent 13ab32247d
commit 432c1d2ba7
21 files changed
+264 -61

No files matched your search

@@ -1510,7 +1510,10 @@ impl Executor {
self.push(vec![
Token::new(TokenKind::Character('{', CatCode::BeginGroup), span).into(),
])?;
let expanded = self.scan_expanded_group(files)?;
let previous_writing = std::mem::replace(&mut self.writing, true);
let expanded = self.scan_expanded_group(files);
self.writing = previous_writing;
let expanded = expanded?;
if !self.required_raw(files)?.end_write {
return self.fail("unbalanced expanded native write");
}
@@ -2790,7 +2793,8 @@ impl Executor {
}
OutputOperation::PdfSave
| OutputOperation::PdfSetMatrix(_)
| OutputOperation::PdfRestore => {
| OutputOperation::PdfRestore
| OutputOperation::PdfLiteral { .. } => {
return self.fail("PDF graphics operation requires a positioned shipout");
}
OutputOperation::Open { stream, name, from } => {
@@ -2812,10 +2816,7 @@ impl Executor {
}
}
OutputOperation::Write { stream, tokens } => {
let previous_writing = std::mem::replace(&mut self.writing, true);
let expanded = self.fully_expand(tokens.clone(), files);
self.writing = previous_writing;
let expanded = expanded?;
let expanded = self.fully_expand(tokens.clone(), files)?;
let text = self.token_list_text(&expanded);
let mut text = self.external_print(&text);
if *stream == 18 {
@@ -3758,7 +3759,7 @@ impl Executor {
self.output_command(primitive, token.span, files)?
}
Pdfcolorstack => self.scan_pdf_color_action(token.span, files)?,
Pdfsave | Pdfsetmatrix | Pdfrestore => {
Pdfsave | Pdfsetmatrix | Pdfrestore | Pdfliteral => {
self.scan_pdf_graphics(primitive, token.span, files)?
}
Pdfstartlink | Pdfendlink | Pdfdest => {