Merge native paragraph break candidates at the TeX line boundary
This commit is contained in:
1 parent
509f229a52
commit
a864c6c5ca
3 files changed
+66
-9
No files matched your search
@@ -925,15 +925,20 @@ fn break_lines(
|
||||
cost: 0,
|
||||
path: Vec::new(),
|
||||
}];
|
||||
let special = if get(Parameter::Looseness) != 0 {
|
||||
usize::MAX
|
||||
} else if !shape.is_empty() {
|
||||
(shape.len() - 1).saturating_sub(previous_lines)
|
||||
let last_special_line = if !shape.is_empty() {
|
||||
shape.len() - 1
|
||||
} else if get(Parameter::Hangindent) == 0 {
|
||||
0
|
||||
} else {
|
||||
get(Parameter::Hangafter).unsigned_abs() as usize
|
||||
};
|
||||
let merged_class = if get(Parameter::Looseness) == 0 {
|
||||
// TeX defers flushing easy_line's minima until after all later lines.
|
||||
// Its active line numbers start at prev_graf + 1, unlike Active::line.
|
||||
last_special_line.saturating_sub(previous_lines.saturating_add(1))
|
||||
} else {
|
||||
usize::MAX
|
||||
};
|
||||
let threshold = if pass == 0 {
|
||||
get(Parameter::Pretolerance)
|
||||
} else {
|
||||
@@ -1098,7 +1103,7 @@ fn break_lines(
|
||||
cost: a.cost.saturating_add(demerits),
|
||||
path,
|
||||
};
|
||||
let key = (a.line.min(special), 3 - fitness, b.hyphen);
|
||||
let key = (a.line.min(merged_class), 3 - fitness, b.hyphen);
|
||||
// TeX initializes each minimum to awful_bad (2^30-1).
|
||||
// Costs beyond that bound are not feasible active nodes; this
|
||||
// matters when the final pass must force an overfull line.
|
||||
@@ -1148,7 +1153,7 @@ fn break_lines(
|
||||
groups.entry(key.0).or_default().push(a);
|
||||
}
|
||||
for (class, group) in groups {
|
||||
if class < special {
|
||||
if class < merged_class {
|
||||
let at = next
|
||||
.iter()
|
||||
.position(|a| a.line >= group[0].line)
|
||||
|
||||
@@ -127,6 +127,26 @@ fn real_passes_feasible_edges_passive_nodes_and_short_lists_match_tex() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ragged_shaped_paragraphs_preserve_pdftex_ties_at_the_last_special_line() {
|
||||
for geometry in [
|
||||
r"\hangindent=26pt\hangafter=1",
|
||||
r"\hangindent=26pt\hangafter=-1",
|
||||
r"\parshape=2 0pt 91pt 26pt 65pt",
|
||||
r"\prevgraf=1\hangindent=26pt\hangafter=2",
|
||||
] {
|
||||
let source = format!(
|
||||
r"{HEADER}\hsize=91pt\rightskip=0pt plus1fil\linepenalty=10\pretolerance=100\noindent {geometry} aaaa bbbb cccc dddd eeee ffff\par\end"
|
||||
);
|
||||
let execution = native(&source);
|
||||
let reports = reports(&execution);
|
||||
assert_eq!(reports.len(), 1);
|
||||
assert_eq!(reports[0].text.trim_end(), reference(&source), "{geometry}");
|
||||
assert_selected_path(reports[0], &execution);
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_selected_path(r: &ParagraphTraceReport, e: &Execution) {
|
||||
use std::collections::BTreeMap;
|
||||
let mut active = BTreeMap::<usize, (usize, usize, usize, i64)>::new();
|
||||
|
||||
Reference in new issue
Block a user