summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPgBiel <9021226+PgBiel@users.noreply.github.com>2025-06-13 01:41:29 -0300
committerPgBiel <9021226+PgBiel@users.noreply.github.com>2025-06-28 22:39:35 -0300
commit858e620ef783e24bcbe7c78c3ef501f88d51fa78 (patch)
treea3dcfe2a6406bbb4cdb135e87de3cb9a5decfff7
parent8c416b88f27633009c4453ec2cd37b03a76228c9 (diff)
fix footer layout order and consecutive footer pushing
-rw-r--r--crates/typst-layout/src/grid/layouter.rs12
-rw-r--r--crates/typst-layout/src/grid/repeated.rs10
2 files changed, 19 insertions, 3 deletions
diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs
index 31e17894..d4604091 100644
--- a/crates/typst-layout/src/grid/layouter.rs
+++ b/crates/typst-layout/src/grid/layouter.rs
@@ -1600,12 +1600,20 @@ impl<'a> GridLayouter<'a> {
//
// Use index for iteration to avoid borrow conflict.
//
+ // Note that repeating footers are in reverse order.
+ //
// TODO(subfooters): "pending footers" vector for footers we're
// about to place. Needed for widow prevention of non-repeated
// footers.
let mut i = 0;
- while let Some(footer) = self.repeating_footers.get(i) {
- self.layout_footer(footer, false, engine, self.finished.len())?;
+ while let Some(footer_index) = self.repeating_footers.len().checked_sub(1 + i)
+ {
+ self.layout_footer(
+ self.repeating_footers[footer_index],
+ false,
+ engine,
+ self.finished.len(),
+ )?;
i += 1;
}
}
diff --git a/crates/typst-layout/src/grid/repeated.rs b/crates/typst-layout/src/grid/repeated.rs
index 2f9a5a94..2ebd2d9a 100644
--- a/crates/typst-layout/src/grid/repeated.rs
+++ b/crates/typst-layout/src/grid/repeated.rs
@@ -550,9 +550,17 @@ impl<'a> GridLayouter<'a> {
return Ok(());
}
+ // Collect upcoming consecutive footers, they will start repeating with
+ // this one if compatible
+ let mut min_level = next_footer.level;
let first_conflicting_index = other_footers
.iter()
- .take_while(|f| f.level > next_footer.level)
+ .take_while(|f| {
+ // TODO(subfooters): check for short-lived
+ let compatible = f.repeated && f.level > min_level;
+ min_level = f.level;
+ compatible
+ })
.count()
+ 1;