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

+17 -6
View File
@@ -15,6 +15,15 @@ pub struct ShipoutDevice {
pub pdf: Option<crate::pdf_device::PdfPageData>,
}
/// A resolved device special in packed-list order. The position is in
/// unscaled TeX sp relative to the box reference point, with y increasing down.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct ShipoutSpecial {
pub span: Span,
pub position: [i64; 2],
pub bytes: Arc<[u8]>,
}
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct NativeShipout {
pub box_node: NativeBox,
@@ -30,7 +39,9 @@ pub struct NativeShipout {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(super) pdf_color_steps: Vec<Option<Arc<PdfColorProgram>>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub(super) pdf_graphics_steps: Vec<PdfGraphics>,
pub(super) pdf_graphics_steps: Vec<Option<PdfGraphics>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub specials: Vec<ShipoutSpecial>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(super) pdf_text_spaces: Option<crate::pdf_device::text_spaces::SpaceSettings>,
#[serde(default, skip_serializing_if = "pdf_resource_entries_empty")]
@@ -116,14 +127,14 @@ impl NativeShipout {
return;
}
boxes::GeometryItem::PdfGraphics { x, y } => {
if let Some(operation) = graphics_steps.next() {
page.items.push(DisplayItem::PdfGraphics {
match graphics_steps.next() {
Some(Some(operation)) => page.items.push(DisplayItem::PdfGraphics {
x: self.device.horizontal_origin + x,
y: self.device.vertical_origin + self.box_node.height + y,
operation: operation.clone(),
});
} else {
missing_graphics_step = true;
}),
Some(None) => {}
None => missing_graphics_step = true,
}
return;
}