diff options
| author | Max <me@mkor.je> | 2025-03-31 09:38:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-31 09:38:04 +0000 |
| commit | 012e14d40cb44997630cf6469a446f217f2e9057 (patch) | |
| tree | 71f60052b2e8eae87c0c9ac2c20faebc293a1f39 /crates/typst-layout/src/math/shared.rs | |
| parent | 4f0fbfb7e003f6ae88c1b210fdb7b38f795fc9e4 (diff) | |
Unify layout of `vec` and `cases` with `mat` (#5934)
Diffstat (limited to 'crates/typst-layout/src/math/shared.rs')
| -rw-r--r-- | crates/typst-layout/src/math/shared.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/typst-layout/src/math/shared.rs b/crates/typst-layout/src/math/shared.rs index 5aebdaca..600c130d 100644 --- a/crates/typst-layout/src/math/shared.rs +++ b/crates/typst-layout/src/math/shared.rs @@ -117,7 +117,6 @@ pub fn stack( gap: Abs, baseline: usize, alternator: LeftRightAlternator, - minimum_ascent_descent: Option<(Abs, Abs)>, ) -> Frame { let AlignmentResult { points, width } = alignments(&rows); let rows: Vec<_> = rows @@ -125,13 +124,9 @@ pub fn stack( .map(|row| row.into_line_frame(&points, alternator)) .collect(); - let padded_height = |height: Abs| { - height.max(minimum_ascent_descent.map_or(Abs::zero(), |(a, d)| a + d)) - }; - let mut frame = Frame::soft(Size::new( width, - rows.iter().map(|row| padded_height(row.height())).sum::<Abs>() + rows.iter().map(|row| row.height()).sum::<Abs>() + rows.len().saturating_sub(1) as f64 * gap, )); @@ -142,14 +137,11 @@ pub fn stack( } else { Abs::zero() }; - let ascent_padded_part = minimum_ascent_descent - .map_or(Abs::zero(), |(a, _)| (a - row.ascent())) - .max(Abs::zero()); - let pos = Point::new(x, y + ascent_padded_part); + let pos = Point::new(x, y); if i == baseline { - frame.set_baseline(y + row.baseline() + ascent_padded_part); + frame.set_baseline(y + row.baseline()); } - y += padded_height(row.height()) + gap; + y += row.height() + gap; frame.push_frame(pos, row); } |
