Emit native PDF literals at scan and shipout boundaries
This commit is contained in:
1 parent
13ab32247d
commit
432c1d2ba7
21 files changed
+264
-61
No files matched your search
@@ -788,7 +788,7 @@ impl Executor {
|
||||
| Scriptscriptfont | Endlinechar | Newlinechar | Escapechar | Globaldefs | Time
|
||||
| Day | Month | Year | BeginGroup | EndGroup | Relax | Message | Errmessage
|
||||
| Endinput | Showbox | Show | Showthe | Discretionary | DiscretionaryHyphen
|
||||
| Parshape | Partokenname => {
|
||||
| Parshape | Partokenname | Pdfliteral => {
|
||||
return Ok(false);
|
||||
}
|
||||
_ => return self.fail(format!("unsupported native math primitive: {p:?}")),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::pdf_device::{PdfGraphics, PdfMatrix};
|
||||
use crate::pdf_device::{PdfGraphics, PdfLiteralMode, PdfMatrix};
|
||||
|
||||
impl Executor {
|
||||
pub(super) fn scan_pdf_graphics(
|
||||
@@ -14,6 +14,26 @@ impl Executor {
|
||||
let operation = match command {
|
||||
Primitive::Pdfsave => OutputOperation::PdfSave,
|
||||
Primitive::Pdfrestore => OutputOperation::PdfRestore,
|
||||
Primitive::Pdfliteral => {
|
||||
let shipout = self.keyword("shipout", files)?;
|
||||
let mode = if self.keyword("direct", files)? {
|
||||
PdfLiteralMode::Direct
|
||||
} else if self.keyword("page", files)? {
|
||||
PdfLiteralMode::Page
|
||||
} else {
|
||||
PdfLiteralMode::Origin
|
||||
};
|
||||
let tokens = if shipout {
|
||||
self.scan_group(files)?
|
||||
} else {
|
||||
self.scan_expanded_group(files)?
|
||||
};
|
||||
OutputOperation::PdfLiteral {
|
||||
mode,
|
||||
shipout,
|
||||
tokens,
|
||||
}
|
||||
}
|
||||
Primitive::Pdfsetmatrix => {
|
||||
let tokens = self.with_scanner(ScannerStatus::Absorbing, |scanner| {
|
||||
scanner.scan_expanded_group_mode(files, false)
|
||||
@@ -45,6 +65,19 @@ impl Executor {
|
||||
.map_err(|error| self.error(format!("\\pdfsetmatrix: {error}"), node.span))?;
|
||||
Ok(PdfGraphics::Matrix(matrix))
|
||||
}
|
||||
OutputOperation::PdfLiteral { mode, shipout, tokens } => {
|
||||
let expanded;
|
||||
let tokens = if *shipout {
|
||||
expanded = self.fully_expand(tokens.clone(), files)?;
|
||||
&expanded
|
||||
} else {
|
||||
tokens
|
||||
};
|
||||
Ok(PdfGraphics::Literal {
|
||||
mode: *mode,
|
||||
bytes: self.pdf_token_bytes(tokens)?.into(),
|
||||
})
|
||||
}
|
||||
OutputOperation::PdfRestore => {
|
||||
let (shift, warning) = match saved.pop() {
|
||||
Some((previous, _)) if previous == point => ([0, 0], None),
|
||||
|
||||
@@ -231,6 +231,7 @@ impl Executor {
|
||||
previous.1 || *dx != 0 || *dy != 0);
|
||||
}
|
||||
}
|
||||
Some(PdfGraphics::Literal { .. }) => {}
|
||||
None => failure = Some(self.error("missing PDF transform at link shipout", self.current)),
|
||||
},
|
||||
BoxPaint::RowStart(row) => {
|
||||
|
||||
Reference in new issue
Block a user