Fix layout panic in rounded rectangle

Fixes #1216 both by hardening the rounded rectangle against negative size and by ensuring that the negative size doesn't occur in the first place for this case.
This commit is contained in:
Laurenz 2023-05-23 15:30:28 +02:00
parent f2193307c4
commit 363836a28e
4 changed files with 9 additions and 1 deletions

View File

@ -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::<PlaceElem>() {

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

View File

@ -0,0 +1,3 @@
#set page(height: 20pt, margin: 0pt)
#v(22pt)
#block(fill: red, width: 100%, height: 10pt, radius: 4pt)