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

+22
View File
@@ -13,8 +13,23 @@ pub struct PdfFileOptions {
pub decimal_digits: u8,
pub pk_resolution: u32,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum PdfDriver {
#[default]
PdfTeX,
Xdv,
}
impl PdfDriver {
fn is_pdftex(&self) -> bool {
*self == Self::PdfTeX
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct PdfPageData {
#[serde(default, skip_serializing_if = "PdfDriver::is_pdftex")]
pub driver: PdfDriver,
pub file: PdfFileOptions,
pub stream_compression: u8,
}
@@ -28,6 +43,13 @@ pub fn magnify(value: i64, mag: i32) -> i64 {
((n + 500) / 1000) as i64
}
}
/// Convert a physical dimension to the logical coordinates of a magnified page.
pub(crate) fn unmagnify(value: i64, mag: i32) -> i64 {
let mag = i64::from(mag);
let n = value * 1000;
n.signum() * ((n.abs() + mag / 2) / mag)
}
pub fn divide_scaled(value: i64, denominator: i64, digits: u8) -> (i64, i64) {
let scale = 10i128.pow(u32::from(digits));
let n = i128::from(value).abs();