Reject unordered paragraph breaks

This commit is contained in:
Dylan M. Taylor committed 2026-11-15 19:18:30 +00:00
1 parent 935dc00846
commit b0cbe87bdb
1 file changed
+5
+5
View File
@@ -197,6 +197,11 @@ pub fn compose_with<G: Glyph, F: Flexibility, M: Measure>(
p: &Params,
) -> Option<Vec<(usize, bool)>> {
let n = g.len();
// The search assumes increasing break positions when indexing its prefix sums.
// Reject malformed candidates before they can make a later line run backwards.
if cands.windows(2).any(|pair| pair[0].end >= pair[1].end) {
return None;
}
if n == 0 {
return Some(vec![]);
}