Carry XDV device advances through packed box scopes

This commit is contained in:
gloamxun committed 2026-11-29 03:42:11 +08:00
1 parent 9da75c82f5
commit 9efededf6d
14 files changed
+252 -83

No files matched your search

+18
View File
@@ -285,6 +285,9 @@ pub struct DisplayList {
pub prepared_virtual_glyphs: Option<std::collections::BTreeMap<usize, std::sync::Arc<Vec<crate::math_engine_tex::PositionedItem>>>>,
/// Paint-order indices into `items`; absent entries have unknown origin.
pub sources: std::collections::BTreeMap<usize, crate::provenance::PaintSource>,
/// Nonzero XDV device shifts from the packed TeX coordinates, in paint order.
#[doc(hidden)]
pub xdv_horizontal_offsets: Vec<(usize, i64)>,
pub images: Vec<PdfImage>,
/// A common physical transform for preview/PDF, without altering fonts or
/// logical TeX geometry. 1000 is unit magnification.
@@ -308,6 +311,7 @@ impl Default for DisplayList {
forms: Vec::new(),
prepared_virtual_glyphs: None,
sources: Default::default(),
xdv_horizontal_offsets: Vec::new(),
images: Vec::new(),
magnification: 1000,
units: DisplayUnits::PostScript,
@@ -414,6 +418,20 @@ impl DisplayList {
&& right.next().is_none()
}
#[doc(hidden)]
pub fn xdv_horizontal_offset(&self, index: usize) -> i64 {
self.xdv_horizontal_offsets
.binary_search_by_key(&index, |&(index, _)| index)
.map_or(0, |position| self.xdv_horizontal_offsets[position].1)
}
pub(crate) fn push_device_item(&mut self, item: DisplayItem, offset: i64) {
if offset != 0 {
self.xdv_horizontal_offsets.push((self.items.len(), offset));
}
self.items.push(item);
}
pub fn push(&mut self, item: DisplayItem) {
self.items.push(item);
}