Include PDF graphics in the native XeTeX device

This commit is contained in:
gloamxun committed 2026-11-21 13:34:55 +08:00
1 parent facecbf790
commit 794c2f9b2c
19 files changed
+545 -37

No files matched your search

@@ -1,4 +1,4 @@
//! Graphics state produced by the pdfTeX extension whatsits.
//! Graphics state produced by PDF extension whatsits and device specials.
use crate::render::DisplayUnits;
use std::sync::Arc;
@@ -36,12 +36,22 @@ pub enum PdfGraphics {
Matrix(PdfMatrix),
Restore { shift: [i64; 2] },
Literal { mode: PdfLiteralMode, bytes: Arc<[u8]> },
SaveMatrix(PdfMatrix),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct PdfMatrix([u64; 4]);
impl PdfMatrix {
pub(crate) fn scale(x: f64, y: f64) -> Self {
Self([x, 0.0, 0.0, y].map(f64::to_bits))
}
pub(crate) fn rotation(angle: f64) -> Self {
let (s, c) = angle.to_radians().sin_cos();
Self([c, s, -s, c].map(f64::to_bits))
}
pub(crate) fn parse(text: &str) -> Result<Self, &'static str> {
let mut words = text.split_ascii_whitespace();
let mut coefficients = [0; 4];