Fix float overlap (#3507)

This commit is contained in:
Laurenz 2024-02-27 14:05:29 +01:00 committed by GitHub
parent ae31640c0a
commit ba531c371e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 4 deletions

View File

@ -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)?;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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)

View File

@ -1,4 +1,4 @@
#set page(height: 170pt)
#set page(height: 180pt)
#set figure(placement: auto)
#figure(