Execute positioned TeX specials through native PDF devices

This commit is contained in:
gloamxun committed 2026-11-21 11:24:46 +08:00
1 parent 05e633bb14
commit ce8a780031
21 files changed
+519 -29

No files matched your search

@@ -19,6 +19,7 @@ pub(super) struct PdfProjection {
stack: Vec<GraphicsState>,
units: DisplayUnits,
height: i64,
magnification: i32,
digits: u8,
units_per_bp: f64,
text_active: bool,
@@ -48,6 +49,7 @@ impl PdfProjection {
stack: vec![graphics], // The page writer begins with q.
units: page.units,
height: page.height,
magnification: page.magnification,
digits: page.pdf.as_ref().map_or(3, |page| page.file.decimal_digits),
units_per_bp: 1.0 / page.units.bp(1),
text_active: false,
@@ -132,13 +134,20 @@ impl PdfProjection {
if *mode != PdfLiteralMode::Direct {
self.text_active = false;
}
let previous_origin = self.origin.position();
let special_origin = mode.xdv_origin([x, y], self.height, self.magnification);
if *mode == PdfLiteralMode::Origin {
self.move_origin([x, y]);
} else if let Some(point) = special_origin {
self.move_origin(point);
}
if self.apply_literal(bytes).is_none() {
self.graphics = None;
self.stack.clear();
}
if special_origin.is_some() {
self.move_origin(previous_origin);
}
return None;
}
self.text_active = false;