summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMax <me@mkor.je>2024-12-08 16:55:34 +0000
committerGitHub <noreply@github.com>2024-12-08 16:55:34 +0000
commit468a60103dca9c6788be2207c9785d5ba771c800 (patch)
treed8f8e9597e2f5d1ed1e38d8d9b1e5a81d211fd10 /crates
parent57f7c167d867094660077d3da75a0207497aa36e (diff)
Fix multiline annotations in over- elems in math changing the baseline (#5459)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-layout/src/math/mat.rs4
-rw-r--r--crates/typst-layout/src/math/shared.rs1
-rw-r--r--crates/typst-layout/src/math/underover.rs4
3 files changed, 5 insertions, 4 deletions
diff --git a/crates/typst-layout/src/math/mat.rs b/crates/typst-layout/src/math/mat.rs
index 6c8b0455..24104f4e 100644
--- a/crates/typst-layout/src/math/mat.rs
+++ b/crates/typst-layout/src/math/mat.rs
@@ -127,7 +127,9 @@ fn layout_vec_body(
let denom_style = style_for_denominator(styles);
let mut flat = vec![];
for child in column {
- flat.push(ctx.layout_into_run(child, styles.chain(&denom_style))?);
+ // We allow linebreaks in cases and vectors, which are functionally
+ // identical to commas.
+ flat.extend(ctx.layout_into_run(child, styles.chain(&denom_style))?.rows());
}
// We pad ascent and descent with the ascent and descent of the paren
// to ensure that normal vectors are aligned with others unless they are
diff --git a/crates/typst-layout/src/math/shared.rs b/crates/typst-layout/src/math/shared.rs
index 13477c10..74e62e8f 100644
--- a/crates/typst-layout/src/math/shared.rs
+++ b/crates/typst-layout/src/math/shared.rs
@@ -121,7 +121,6 @@ pub fn stack(
alternator: LeftRightAlternator,
minimum_ascent_descent: Option<(Abs, Abs)>,
) -> Frame {
- let rows: Vec<_> = rows.into_iter().flat_map(|r| r.rows()).collect();
let AlignmentResult { points, width } = alignments(&rows);
let rows: Vec<_> = rows
.into_iter()
diff --git a/crates/typst-layout/src/math/underover.rs b/crates/typst-layout/src/math/underover.rs
index b1d4825b..1a2c8db6 100644
--- a/crates/typst-layout/src/math/underover.rs
+++ b/crates/typst-layout/src/math/underover.rs
@@ -297,7 +297,7 @@ fn layout_underoverspreader(
if let Some(annotation) = annotation {
let under_style = style_for_subscript(styles);
let annotation_styles = styles.chain(&under_style);
- rows.push(ctx.layout_into_run(annotation, annotation_styles)?);
+ rows.extend(ctx.layout_into_run(annotation, annotation_styles)?.rows());
}
0
}
@@ -305,7 +305,7 @@ fn layout_underoverspreader(
if let Some(annotation) = annotation {
let over_style = style_for_superscript(styles);
let annotation_styles = styles.chain(&over_style);
- rows.push(ctx.layout_into_run(annotation, annotation_styles)?);
+ rows.extend(ctx.layout_into_run(annotation, annotation_styles)?.rows());
}
rows.push(stretched.into());
rows.push(MathRun::new(vec![body]));