Render XeLaTeX shared page resources and scoped graphics
This commit is contained in:
1 parent
e20acc3eb9
commit
009fde04f7
13 files changed
+445
-12
No files matched your search
@@ -20,6 +20,7 @@ pub(super) struct PdfProjection {
|
||||
stack: Vec<GraphicsState>,
|
||||
units: DisplayUnits,
|
||||
xdv_origin: Option<[i64; 2]>,
|
||||
xdv_content_scopes: Vec<(DeviceOrigin, [i64; 2])>,
|
||||
height: i64,
|
||||
digits: u8,
|
||||
units_per_bp: f64,
|
||||
@@ -53,6 +54,7 @@ impl PdfProjection {
|
||||
stack: vec![graphics], // The page writer begins with q.
|
||||
units: page.units,
|
||||
xdv_origin,
|
||||
xdv_content_scopes: Vec::new(),
|
||||
height: page.height,
|
||||
digits: page.pdf.as_ref().map_or(3, |page| page.file.decimal_digits),
|
||||
units_per_bp: 1.0 / page.units.bp(1),
|
||||
@@ -141,10 +143,31 @@ impl PdfProjection {
|
||||
self.text_active = false;
|
||||
}
|
||||
let previous_origin = self.origin;
|
||||
match mode {
|
||||
PdfLiteralMode::XdvBeginContent => {
|
||||
self.save();
|
||||
self.xdv_content_scopes.push((previous_origin, [x, y]));
|
||||
self.move_origin([x, y]);
|
||||
return None;
|
||||
}
|
||||
PdfLiteralMode::XdvEndContent => {
|
||||
self.restore();
|
||||
if let Some((origin, _)) = self.xdv_content_scopes.pop() {
|
||||
self.origin = origin;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if *mode == PdfLiteralMode::XdvContent {
|
||||
self.save();
|
||||
}
|
||||
let special_origin = mode.xdv_origin([x, y], self.xdv_origin.unwrap_or([0, 0]));
|
||||
let page_origin = self.xdv_origin.unwrap_or([0, 0]);
|
||||
let special_origin = if *mode == PdfLiteralMode::XdvCode {
|
||||
Some(self.xdv_content_scopes.last().map_or(page_origin, |&(_, point)| point))
|
||||
} else {
|
||||
mode.xdv_origin([x, y], page_origin)
|
||||
};
|
||||
if *mode == PdfLiteralMode::Origin {
|
||||
self.move_origin([x, y]);
|
||||
} else if let Some(point) = special_origin {
|
||||
|
||||
Reference in new issue
Block a user