Expose per-order page stretch to the output routine
This commit is contained in:
1 parent
52e3e0647c
commit
a4388942f0
6 files changed
+117
-5
No files matched your search
@@ -1727,6 +1727,9 @@ impl Engine {
|
||||
let mut page_penalties = Vec::new();
|
||||
let mut page_depths = Vec::new();
|
||||
let mut page_stretches = Vec::new();
|
||||
let mut page_fil_stretches = Vec::new();
|
||||
let mut page_fill_stretches = Vec::new();
|
||||
let mut page_filll_stretches = Vec::new();
|
||||
let mut page_shrinks = Vec::new();
|
||||
let mut held: BTreeMap<u8, Vec<VerticalItem>> = BTreeMap::new();
|
||||
let fragments = builder.build(&nodes);
|
||||
@@ -1798,6 +1801,9 @@ impl Engine {
|
||||
page_penalties.push(fragment.penalty);
|
||||
page_depths.push(fragment.depth);
|
||||
page_stretches.push(fragment.stretch);
|
||||
page_fil_stretches.push(fragment.stretches[1]);
|
||||
page_fill_stretches.push(fragment.stretches[2]);
|
||||
page_filll_stretches.push(fragment.stretches[3]);
|
||||
page_shrinks.push(fragment.shrink);
|
||||
}
|
||||
|
||||
@@ -1824,6 +1830,9 @@ impl Engine {
|
||||
page_penalties.push(0);
|
||||
page_depths.push(0);
|
||||
page_stretches.push(0);
|
||||
page_fil_stretches.push(0);
|
||||
page_fill_stretches.push(0);
|
||||
page_filll_stretches.push(0);
|
||||
page_shrinks.push(0);
|
||||
}
|
||||
if let Some(source) = &document.output_routine {
|
||||
@@ -1836,6 +1845,9 @@ impl Engine {
|
||||
page_total,
|
||||
page_depth: page_depths.get(index).copied().unwrap_or(0),
|
||||
page_stretch: page_stretches.get(index).copied().unwrap_or(0),
|
||||
page_fil_stretch: page_fil_stretches.get(index).copied().unwrap_or(0),
|
||||
page_fill_stretch: page_fill_stretches.get(index).copied().unwrap_or(0),
|
||||
page_filll_stretch: page_filll_stretches.get(index).copied().unwrap_or(0),
|
||||
page_shrink: page_shrinks.get(index).copied().unwrap_or(0),
|
||||
vsize: document.page_goal,
|
||||
top_skip: document.top_skip,
|
||||
@@ -5216,6 +5228,34 @@ mod tests {
|
||||
assert_eq!(widths, vec![20, 80], "only the fil glue stretches");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_routine_sees_fill_stretch_orders() {
|
||||
let mut document = Document::new(200, Vec::new());
|
||||
document.units = vec![
|
||||
Unit::rule(0, 10, 40),
|
||||
Unit::vertical(
|
||||
1,
|
||||
vec![VerticalItem::StretchGlue(VerticalGlue::with_order(
|
||||
20,
|
||||
4 * 65_536,
|
||||
0,
|
||||
2,
|
||||
))],
|
||||
),
|
||||
Unit::penalty(2, -10_000),
|
||||
Unit::rule(3, 10, 40),
|
||||
];
|
||||
document.output_routine = Some(r"\ifdim\pagefillstretch>3pt\shipout\box255\fi".to_owned());
|
||||
let engine = Engine::layout_paged(&document).expect("paged");
|
||||
assert_eq!(engine.pages().len(), 1);
|
||||
assert!(
|
||||
engine.pages()[0]
|
||||
.items
|
||||
.iter()
|
||||
.any(|item| matches!(item, VerticalItem::Rule { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interpreted_output_sees_the_break_penalty() {
|
||||
let mut document = Document::new(100, Vec::new());
|
||||
|
||||
Reference in new issue
Block a user