summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst/src/math/matrix.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst/src/math/matrix.rs b/crates/typst/src/math/matrix.rs
index 34e0611a..95164e82 100644
--- a/crates/typst/src/math/matrix.rs
+++ b/crates/typst/src/math/matrix.rs
@@ -458,6 +458,12 @@ fn layout_mat_body(
gap: Axes<Rel<Abs>>,
span: Span,
) -> SourceResult<Frame> {
+ let ncols = rows.first().map_or(0, |row| row.len());
+ let nrows = rows.len();
+ if ncols == 0 || nrows == 0 {
+ return Ok(Frame::soft(Size::zero()));
+ }
+
let gap = gap.zip_map(ctx.regions.base(), Rel::relative_to);
let half_gap = gap * 0.5;
@@ -483,12 +489,6 @@ fn layout_mat_body(
_ => (AugmentOffsets::default(), AugmentOffsets::default(), default_stroke),
};
- let ncols = rows.first().map_or(0, |row| row.len());
- let nrows = rows.len();
- if ncols == 0 || nrows == 0 {
- return Ok(Frame::soft(Size::zero()));
- }
-
// Before the full matrix body can be laid out, the
// individual cells must first be independently laid out
// so we can ensure alignment across rows and columns.