diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs index a21f81424..5e01f51d0 100644 --- a/library/src/layout/flow.rs +++ b/library/src/layout/flow.rs @@ -243,6 +243,11 @@ impl<'a> FlowLayouter<'a> { block: &Content, styles: StyleChain, ) -> SourceResult<()> { + // Skip directly if regino is already full. + if self.regions.is_full() { + self.finish_region()?; + } + // Placed elements that are out of flow produce placed items which // aren't aligned later. if let Some(placed) = block.to::() { diff --git a/src/geom/rounded.rs b/src/geom/rounded.rs index f445dfcb8..24b524485 100644 --- a/src/geom/rounded.rs +++ b/src/geom/rounded.rs @@ -52,7 +52,7 @@ fn stroke_segments( let mut connection = Connection::default(); let mut path = Path::new(); let mut always_continuous = true; - let max_radius = size.x.min(size.y) / 2.0; + let max_radius = size.x.min(size.y).max(Abs::zero()) / 2.0; for side in [Side::Top, Side::Right, Side::Bottom, Side::Left] { let continuous = stroke.get_ref(side) == stroke.get_ref(side.next_cw()); diff --git a/tests/ref/bugs/clamp-panic.png b/tests/ref/bugs/clamp-panic.png new file mode 100644 index 000000000..c0c4912e3 Binary files /dev/null and b/tests/ref/bugs/clamp-panic.png differ diff --git a/tests/typ/bugs/clamp-panic.typ b/tests/typ/bugs/clamp-panic.typ new file mode 100644 index 000000000..5f167c76b --- /dev/null +++ b/tests/typ/bugs/clamp-panic.typ @@ -0,0 +1,3 @@ +#set page(height: 20pt, margin: 0pt) +#v(22pt) +#block(fill: red, width: 100%, height: 10pt, radius: 4pt)