Report TeX outputpenalty for glue breaks
This commit is contained in:
1 parent
94559ee431
commit
8007fd1b6c
5 files changed
+31
-8
No files matched your search
@@ -1933,7 +1933,7 @@ impl Engine {
|
||||
page.insertions = insertions.into_values().collect();
|
||||
page.seal_in_place();
|
||||
pages.push(page);
|
||||
page_penalties.push(0);
|
||||
page_penalties.push(10_000);
|
||||
page_depths.push(0);
|
||||
page_stretches.push(0);
|
||||
page_fil_stretches.push(0);
|
||||
@@ -1971,7 +1971,7 @@ impl Engine {
|
||||
vsize: document.page_goal,
|
||||
top_skip: document.top_skip,
|
||||
max_depth: document.max_depth,
|
||||
output_penalty: page_penalties.get(index).copied().unwrap_or(0),
|
||||
output_penalty: page_penalties.get(index).copied().unwrap_or(10_000),
|
||||
insertion_counts,
|
||||
insertion_dimens,
|
||||
insertion_skips,
|
||||
|
||||
@@ -990,6 +990,17 @@ mod tests {
|
||||
assert_eq!(program.shipout_count(&mut forced).unwrap(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifnum_recognises_glue_break_penalties() {
|
||||
let program =
|
||||
OutputProgram::parse(r"\ifnum\outputpenalty=10000\shipout\box255\fi").unwrap();
|
||||
let mut context = context(0);
|
||||
context.output_penalty = 10_000;
|
||||
assert_eq!(program.shipout_count(&mut context).unwrap(), 1);
|
||||
context.output_penalty = 150;
|
||||
assert_eq!(program.shipout_count(&mut context).unwrap(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifodd_ships_even_page_numbers_only() {
|
||||
let program = OutputProgram::parse(r"\ifodd\pageno\shipout\box255\else\relax\fi").unwrap();
|
||||
|
||||
@@ -95,8 +95,9 @@ pub struct PageFragment {
|
||||
pub end: usize,
|
||||
/// TeX's page cost for the breakpoint: badness plus penalty.
|
||||
pub cost: i64,
|
||||
/// Penalty that produced this break: a forced penalty value, the chosen
|
||||
/// candidate's penalty, or zero for the final page.
|
||||
/// TeX `\outputpenalty` for this break: the penalty value when the page
|
||||
/// broke at a penalty, otherwise 10000 (glue break, goal overflow or the
|
||||
/// final page, exactly as TeX reports it).
|
||||
pub penalty: i64,
|
||||
/// Badness of the page height against the page goal.
|
||||
pub badness: i64,
|
||||
@@ -656,6 +657,7 @@ impl PageBuilder {
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let penalty = if penalty == 0 { 10_000 } else { penalty };
|
||||
PageFragment {
|
||||
start,
|
||||
end,
|
||||
@@ -736,7 +738,17 @@ mod tests {
|
||||
let pages = builder.build(&nodes);
|
||||
assert_eq!(pages.len(), 2);
|
||||
assert_eq!(pages[0].penalty, -10_000);
|
||||
assert_eq!(pages[1].penalty, 0);
|
||||
assert_eq!(pages[1].penalty, 10_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glue_breaks_report_a_ten_thousand_penalty() {
|
||||
let builder = PageBuilder::new(100);
|
||||
let nodes = vec![box_(80, 0), glue(0, 0, 0), box_(80, 0)];
|
||||
let pages = builder.build(&nodes);
|
||||
assert_eq!(pages.len(), 2);
|
||||
assert_eq!(pages[0].penalty, 10_000);
|
||||
assert_eq!(pages[1].penalty, 10_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user