Carry XDV device advances through packed box scopes
This commit is contained in:
1 parent
9da75c82f5
commit
9efededf6d
14 files changed
+252
-83
No files matched your search
@@ -125,7 +125,9 @@ impl NativeShipout {
|
||||
let mut missing_graphics_step = false;
|
||||
let mut output_index = 0;
|
||||
let mut reached_boundary = false;
|
||||
self.box_node.visit_geometry(|item| {
|
||||
let xdv = page.pdf.as_ref()
|
||||
.is_some_and(|pdf| pdf.driver == crate::pdf_device::PdfDriver::Xdv);
|
||||
self.box_node.visit_device_geometry(None, xdv, |item, shift| {
|
||||
if reached_boundary {
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +141,7 @@ impl NativeShipout {
|
||||
boxes::GeometryItem::PdfColor { x, y } => {
|
||||
match color_steps.next() {
|
||||
Some(Some(color)) => {
|
||||
page.items.push(color.display_item(left + x, baseline + y))
|
||||
page.push_device_item(color.display_item(left + x + shift, baseline + y), shift)
|
||||
}
|
||||
Some(None) => {}
|
||||
None => missing_color_step = true,
|
||||
@@ -147,30 +149,30 @@ impl NativeShipout {
|
||||
return;
|
||||
}
|
||||
boxes::GeometryItem::PdfTextSpace { x, y, operation } => {
|
||||
page.items.push(DisplayItem::PdfTextSpace {
|
||||
x: self.device.horizontal_origin + x,
|
||||
page.push_device_item(DisplayItem::PdfTextSpace {
|
||||
x: self.device.horizontal_origin + x + shift,
|
||||
y: self.device.vertical_origin + self.box_node.height + y,
|
||||
operation,
|
||||
});
|
||||
}, shift);
|
||||
return;
|
||||
}
|
||||
boxes::GeometryItem::PdfGraphics { x, y } => {
|
||||
match graphics_steps.next() {
|
||||
Some((step, operation)) => {
|
||||
if let Some(operation) = operation {
|
||||
page.items.push(DisplayItem::PdfGraphics {
|
||||
x: self.device.horizontal_origin + x,
|
||||
page.push_device_item(DisplayItem::PdfGraphics {
|
||||
x: self.device.horizontal_origin + x + shift,
|
||||
y: self.device.vertical_origin + self.box_node.height + y,
|
||||
operation: operation.clone(),
|
||||
});
|
||||
}, shift);
|
||||
}
|
||||
if let Some(program) = self.xdv_color_steps.get(&step) {
|
||||
page.items.push(DisplayItem::PdfColor {
|
||||
x: left + x,
|
||||
page.push_device_item(DisplayItem::PdfColor {
|
||||
x: left + x + shift,
|
||||
y: baseline + y,
|
||||
program: program.clone(),
|
||||
mode: crate::pdf_device::PdfLiteralMode::Page,
|
||||
});
|
||||
}, shift);
|
||||
}
|
||||
if let Some((image, origin)) = self.pdf_special_images.get(&step) {
|
||||
let [left, bottom] = image.xdv.as_ref().unwrap().layout_offset;
|
||||
@@ -178,14 +180,14 @@ impl NativeShipout {
|
||||
page.items.len(),
|
||||
crate::provenance::PaintSource::token(*origin),
|
||||
);
|
||||
page.items.push(DisplayItem::PdfImage {
|
||||
x: self.device.horizontal_origin + x + left,
|
||||
page.push_device_item(DisplayItem::PdfImage {
|
||||
x: self.device.horizontal_origin + x + shift + left,
|
||||
y: self.device.vertical_origin + self.box_node.height + y
|
||||
- image.height - bottom,
|
||||
width: image.width,
|
||||
height: image.height,
|
||||
image: image.clone(),
|
||||
});
|
||||
}, shift);
|
||||
}
|
||||
}
|
||||
None => missing_graphics_step = true,
|
||||
@@ -196,18 +198,18 @@ impl NativeShipout {
|
||||
if !p.source.tokens.is_empty() {
|
||||
page.sources.insert(page.items.len(), p.source);
|
||||
}
|
||||
let x = self.device.horizontal_origin + p.x;
|
||||
let y = self.device.vertical_origin + self.box_node.height + p.y;
|
||||
let x = left + p.x + shift;
|
||||
let y = baseline + p.y;
|
||||
if let MathItem::OpenType(run) = p.item {
|
||||
run.paint(x, y, |value| value, |item, source| {
|
||||
if !matches!(item, DisplayItem::OpenTypeActualText(_) | DisplayItem::OpenTypeColor(_)) {
|
||||
page.sources.insert(page.items.len(), source);
|
||||
}
|
||||
page.items.push(item);
|
||||
page.push_device_item(item, shift);
|
||||
});
|
||||
return;
|
||||
}
|
||||
page.items.push(match p.item {
|
||||
let item = match p.item {
|
||||
MathItem::NativeGlyph {
|
||||
font,
|
||||
slot,
|
||||
@@ -245,7 +247,8 @@ impl NativeShipout {
|
||||
invalid_geometry = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
page.push_device_item(item, shift);
|
||||
})?;
|
||||
if before_output.is_some() && !reached_boundary {
|
||||
return Err("missing deferred output boundary in its packed list".into());
|
||||
|
||||
Reference in new issue
Block a user