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
@@ -1144,11 +1144,11 @@ fn page_content(
|
||||
// to its page origin, with three decimals by default.
|
||||
let round = |value: f64| (value * 1000.0).round() / 1000.0;
|
||||
let [left, bottom] = placement.layout_offset;
|
||||
let x = round(list.units.bp(*x - left) + tx - origin_x) + round(origin_x)
|
||||
- list.units.bp(h);
|
||||
let x = round(list.units.bp(*x - left) + tx - origin_x)
|
||||
+ round(round(origin_x) - list.units.bp(h));
|
||||
let y = round(
|
||||
list.units.bp(height - *y - *image_height - bottom) + ty - origin_y,
|
||||
) + round(origin_y) - list.units.bp(v);
|
||||
) + round(round(origin_y) - list.units.bp(v));
|
||||
let [a, b, c, d, x, y] = [a, b, c, d, x, y].map(crate::pdf_image::real);
|
||||
content.push_str(&format!("q {a} {b} {c} {d} {x} {y} cm "));
|
||||
if let Some(clip) = placement.clip() {
|
||||
@@ -1298,10 +1298,16 @@ fn page_content(
|
||||
pt(coordinate).parse::<f64>().expect("formatted PDF dimension")
|
||||
})
|
||||
};
|
||||
let [a, b, c, d, e, f] = matrix
|
||||
.about(coordinates[0], coordinates[1], false)
|
||||
.0
|
||||
.map(crate::pdf_image::real);
|
||||
let mut coefficients = matrix.about(coordinates[0], coordinates[1], false).0;
|
||||
if xdv {
|
||||
// The device keeps the full transform for geometry but
|
||||
// serializes the linear and translation terms separately.
|
||||
for (index, value) in coefficients.iter_mut().enumerate() {
|
||||
let precision = if index < 4 { 100_000.0 } else { 1000.0 };
|
||||
*value = (*value * precision).round() / precision;
|
||||
}
|
||||
}
|
||||
let [a, b, c, d, e, f] = coefficients.map(crate::pdf_image::real);
|
||||
content.push_str(&format!("{a} {b} {c} {d} {e} {f} cm\n"));
|
||||
}
|
||||
PdfGraphics::Literal { .. } | PdfGraphics::TextBoundary => {
|
||||
|
||||
Reference in new issue
Block a user