diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-01-17 16:43:26 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-01-17 17:32:51 +0100 |
| commit | fe56fb29fa14d76647a02d25e125571154b122f6 (patch) | |
| tree | 296d22ae8584013f21f448a040b31cbde9d9eb2d | |
| parent | cb69648e2f048e90ca819e147927a00831cef119 (diff) | |
Fix emptyness check in `into_par_items`
| -rw-r--r-- | crates/typst/src/math/row.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/typst/src/math/row.rs b/crates/typst/src/math/row.rs index f569e258..87ac154d 100644 --- a/crates/typst/src/math/row.rs +++ b/crates/typst/src/math/row.rs @@ -262,6 +262,7 @@ impl MathRow { let mut ascent = Abs::zero(); let mut descent = Abs::zero(); let mut frame = Frame::new(Size::zero(), FrameKind::Soft); + let mut empty = true; let finalize_frame = |frame: &mut Frame, x, ascent, descent| { frame.set_size(Size::new(x, ascent + descent)); @@ -299,6 +300,7 @@ impl MathRow { let pos = Point::new(x, -y); x += fragment.width(); frame.push_frame(pos, fragment.into_frame()); + empty = false; if class == Some(MathClass::Binary) || (class == Some(MathClass::Relation) @@ -311,6 +313,7 @@ impl MathRow { finalize_frame(&mut frame_prev, x, ascent, descent); items.push(MathParItem::Frame(frame_prev)); + empty = true; x = Abs::zero(); ascent = Abs::zero(); @@ -327,7 +330,9 @@ impl MathRow { } } - if !frame.is_empty() { + // Don't use `frame.is_empty()` because even an empty frame can + // contribute width (if it had hidden content). + if !empty { finalize_frame(&mut frame, x, ascent, descent); items.push(MathParItem::Frame(frame)); } |
