mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
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:
parent
f2193307c4
commit
363836a28e
@ -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>() {
|
||||
|
@ -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());
|
||||
|
BIN
tests/ref/bugs/clamp-panic.png
Normal file
BIN
tests/ref/bugs/clamp-panic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 B |
3
tests/typ/bugs/clamp-panic.typ
Normal file
3
tests/typ/bugs/clamp-panic.typ
Normal file
@ -0,0 +1,3 @@
|
||||
#set page(height: 20pt, margin: 0pt)
|
||||
#v(22pt)
|
||||
#block(fill: red, width: 100%, height: 10pt, radius: 4pt)
|
Loading…
x
Reference in New Issue
Block a user