diff --git a/crates/typst/src/layout/flow.rs b/crates/typst/src/layout/flow.rs index 8701d35d9..662cf6804 100644 --- a/crates/typst/src/layout/flow.rs +++ b/crates/typst/src/layout/flow.rs @@ -253,7 +253,7 @@ impl<'a> FlowLayouter<'a> { } if let Some(first) = lines.first() { - if !self.regions.size.y.fits(first.height()) && !self.regions.in_last() { + while !self.regions.size.y.fits(first.height()) && !self.regions.in_last() { let carry: Vec<_> = self.items.drain(sticky..).collect(); self.finish_region(engine, false)?; for item in carry { @@ -400,7 +400,7 @@ impl<'a> FlowLayouter<'a> { FlowItem::Fractional(_) => {} FlowItem::Frame { ref frame, movable, .. } => { let height = frame.height(); - if !self.regions.size.y.fits(height) && !self.regions.in_last() { + while !self.regions.size.y.fits(height) && !self.regions.in_last() { self.finish_region(engine, false)?; } @@ -613,7 +613,7 @@ impl<'a> FlowLayouter<'a> { self.initial = self.regions.size; self.has_footnotes = false; - // Try to place floats. + // Try to place floats into the next region. for item in std::mem::take(&mut self.pending_floats) { self.layout_item(engine, item)?; } diff --git a/tests/ref/bugs/2595-float-overlap.png b/tests/ref/bugs/2595-float-overlap.png new file mode 100644 index 000000000..6d8eaf941 Binary files /dev/null and b/tests/ref/bugs/2595-float-overlap.png differ diff --git a/tests/ref/bugs/2715-float-order.png b/tests/ref/bugs/2715-float-order.png index 76e6db9e6..0a4f8812e 100644 Binary files a/tests/ref/bugs/2715-float-order.png and b/tests/ref/bugs/2715-float-order.png differ diff --git a/tests/typ/bugs/2595-float-overlap.typ b/tests/typ/bugs/2595-float-overlap.typ new file mode 100644 index 000000000..7c7f68c93 --- /dev/null +++ b/tests/typ/bugs/2595-float-overlap.typ @@ -0,0 +1,13 @@ +#set page(height: 80pt) + +Start. + +#place(auto, float: true, [ + #block(height: 100%, width: 100%, fill: aqua) +]) + +#place(auto, float: true, [ + #block(height: 100%, width: 100%, fill: red) +]) + +#lorem(20) diff --git a/tests/typ/bugs/2715-float-order.typ b/tests/typ/bugs/2715-float-order.typ index f6ac6219b..af0684a1c 100644 --- a/tests/typ/bugs/2715-float-order.typ +++ b/tests/typ/bugs/2715-float-order.typ @@ -1,4 +1,4 @@ -#set page(height: 170pt) +#set page(height: 180pt) #set figure(placement: auto) #figure(