Include PDF graphics in the native XeTeX device
This commit is contained in:
1 parent
facecbf790
commit
794c2f9b2c
19 files changed
+545
-37
No files matched your search
@@ -1,7 +1,7 @@
|
||||
//! Project TeX paint through the PDF device and any literal graphics state.
|
||||
use crate::{
|
||||
pdf_device::{
|
||||
Affine, DeviceOrigin, PdfGraphics, PdfLiteralMode, page_resources::check_pdf_nesting,
|
||||
Affine, DeviceOrigin, PdfDriver, PdfGraphics, PdfLiteralMode, page_resources::check_pdf_nesting,
|
||||
},
|
||||
render::{DisplayItem, DisplayList, DisplayUnits},
|
||||
};
|
||||
@@ -18,6 +18,7 @@ pub(super) struct PdfProjection {
|
||||
graphics: Option<GraphicsState>,
|
||||
stack: Vec<GraphicsState>,
|
||||
units: DisplayUnits,
|
||||
xdv: bool,
|
||||
height: i64,
|
||||
magnification: i32,
|
||||
digits: u8,
|
||||
@@ -48,6 +49,7 @@ impl PdfProjection {
|
||||
graphics: Some(graphics),
|
||||
stack: vec![graphics], // The page writer begins with q.
|
||||
units: page.units,
|
||||
xdv: page.pdf.as_ref().is_some_and(|pdf| pdf.driver == PdfDriver::Xdv),
|
||||
height: page.height,
|
||||
magnification: page.magnification,
|
||||
digits: page.pdf.as_ref().map_or(3, |page| page.file.decimal_digits),
|
||||
@@ -151,9 +153,11 @@ impl PdfProjection {
|
||||
return None;
|
||||
}
|
||||
self.text_active = false;
|
||||
let native = self.units == DisplayUnits::TeX;
|
||||
let native = self.units == DisplayUnits::TeX && !self.xdv;
|
||||
if native {
|
||||
self.move_origin([x, y]);
|
||||
} else if self.xdv {
|
||||
self.move_origin([0, 0]);
|
||||
}
|
||||
match operation {
|
||||
PdfGraphics::Save => self.save(),
|
||||
@@ -163,7 +167,10 @@ impl PdfProjection {
|
||||
self.concatenate(Affine::translation(*dx as f64, -*dy as f64));
|
||||
}
|
||||
}
|
||||
PdfGraphics::Matrix(matrix) => {
|
||||
PdfGraphics::Matrix(matrix) | PdfGraphics::SaveMatrix(matrix) => {
|
||||
if matches!(operation, PdfGraphics::SaveMatrix(_)) {
|
||||
self.save();
|
||||
}
|
||||
let [x, y] = if native { [0, 0] } else { [x, y] };
|
||||
self.concatenate(matrix.about(x as f64, y as f64, false));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user