Measure XeLaTeX graphics links from device placement
This commit is contained in:
1 parent
d875b69280
commit
d627614af8
12 files changed
+295
-149
No files matched your search
@@ -547,6 +547,7 @@ impl Executor {
|
||||
let mut pdf_objects = Vec::new();
|
||||
let mut pdf_images = Vec::new();
|
||||
let mut pdf_forms = Vec::new();
|
||||
let mut content_origins = Vec::new();
|
||||
let mut xdv_annotations = std::collections::BTreeMap::new();
|
||||
let mut reopened_images = false;
|
||||
let mut xdv_paper_specials = Vec::new();
|
||||
@@ -642,7 +643,7 @@ impl Executor {
|
||||
(special.position[0] + horizontal_origin) as f64,
|
||||
(special.position[1] + vertical_origin + b.height) as f64,
|
||||
).map(|coordinate| coordinate.round() as i64);
|
||||
xdv_navigation.push((shipout.specials.len(), graphics_step, point, *origin));
|
||||
xdv_navigation.push((shipout.specials.len(), graphics_step, point, *origin, content_origins.last().copied()));
|
||||
None
|
||||
} else if xdv && self.xdv_setup_special(&special)? {
|
||||
None
|
||||
@@ -653,6 +654,13 @@ impl Executor {
|
||||
None
|
||||
};
|
||||
use crate::pdf_device::{PdfGraphics, PdfLiteralMode};
|
||||
if let Some(PdfGraphics::Literal { mode, .. }) = &graphics {
|
||||
match mode {
|
||||
PdfLiteralMode::XdvBeginContent => content_origins.push(special.position),
|
||||
PdfLiteralMode::XdvEndContent => { content_origins.pop(); }
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
match &graphics {
|
||||
Some(PdfGraphics::Save | PdfGraphics::Literal { mode: PdfLiteralMode::XdvBeginContent, .. }) => {
|
||||
xdv_graphics_stack.push((special.span, xdv_transform, self.xdv_colors.current()));
|
||||
@@ -845,7 +853,14 @@ impl Executor {
|
||||
device.vertical_origin = offset + v_offset;
|
||||
}
|
||||
let delta = [device.horizontal_origin - horizontal_origin, device.vertical_origin - vertical_origin];
|
||||
for (index, graphics_step, [x, y], origin) in xdv_navigation {
|
||||
let [origin_x, origin_y] = crate::pdf_device::xdv_page_origin(
|
||||
crate::render::DisplayUnits::TeX, device.page_height, magnification,
|
||||
);
|
||||
let default_content_origin = [
|
||||
origin_x - device.horizontal_origin,
|
||||
device.page_height - origin_y - device.vertical_origin - shipout.box_node.height,
|
||||
];
|
||||
for (index, graphics_step, [x, y], origin, content_origin) in xdv_navigation {
|
||||
let special = &shipout.specials[index];
|
||||
let position = crate::pdf_device::xdv_object::Position {
|
||||
page: self.shipped_pages + 1,
|
||||
@@ -862,10 +877,16 @@ impl Executor {
|
||||
if let Some(raster) = raster {
|
||||
shipout.pdf_special_images.insert(graphics_step, (raster, source));
|
||||
}
|
||||
} else if let Some(operation) = self.ship_xdv_navigation(
|
||||
special, position, graphics_step, &mut shipout.pdf_links, origin, files,
|
||||
)? {
|
||||
shipout.pdf_graphics_steps[graphics_step] = Some(operation);
|
||||
} else {
|
||||
let [left, top] = content_origin.unwrap_or(default_content_origin);
|
||||
let [x, y] = special.position;
|
||||
let capture_origin = [x - left, top - y]
|
||||
.map(|coordinate| crate::render::DisplayUnits::TeX.bp(coordinate));
|
||||
if let Some(operation) = self.ship_xdv_navigation(
|
||||
special, position, graphics_step, capture_origin, &mut shipout.pdf_links, origin, files,
|
||||
)? {
|
||||
shipout.pdf_graphics_steps[graphics_step] = Some(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(navigation) = &self.state.xdv_navigation {
|
||||
|
||||
Reference in new issue
Block a user