diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-02-27 14:05:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-27 13:05:29 +0000 |
| commit | ba531c371e61e34607bb1e3aa911e2529dac7b35 (patch) | |
| tree | bb7bbb3951f4b90835445a0ba625b148445ffd8f | |
| parent | ae31640c0a62d26b7f2a7a38579293ae48c7c7b7 (diff) | |
Fix float overlap (#3507)
| -rw-r--r-- | crates/typst/src/layout/flow.rs | 6 | ||||
| -rw-r--r-- | tests/ref/bugs/2595-float-overlap.png | bin | 0 -> 15654 bytes | |||
| -rw-r--r-- | tests/ref/bugs/2715-float-order.png | bin | 12944 -> 13006 bytes | |||
| -rw-r--r-- | tests/typ/bugs/2595-float-overlap.typ | 13 | ||||
| -rw-r--r-- | tests/typ/bugs/2715-float-order.typ | 2 |
5 files changed, 17 insertions, 4 deletions
diff --git a/crates/typst/src/layout/flow.rs b/crates/typst/src/layout/flow.rs index 8701d35d..662cf680 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 Binary files differnew file mode 100644 index 00000000..6d8eaf94 --- /dev/null +++ b/tests/ref/bugs/2595-float-overlap.png diff --git a/tests/ref/bugs/2715-float-order.png b/tests/ref/bugs/2715-float-order.png Binary files differindex 76e6db9e..0a4f8812 100644 --- a/tests/ref/bugs/2715-float-order.png +++ b/tests/ref/bugs/2715-float-order.png diff --git a/tests/typ/bugs/2595-float-overlap.typ b/tests/typ/bugs/2595-float-overlap.typ new file mode 100644 index 00000000..7c7f68c9 --- /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 f6ac6219..af0684a1 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( |
