diff --git a/crates/typst/src/math/row.rs b/crates/typst/src/math/row.rs index 5234ca2cd..60afe64e5 100644 --- a/crates/typst/src/math/row.rs +++ b/crates/typst/src/math/row.rs @@ -159,10 +159,19 @@ impl MathRun { pub fn into_fragment(self, ctx: &MathContext, styles: StyleChain) -> MathFragment { if self.0.len() == 1 { - self.0.into_iter().next().unwrap() - } else { - FrameFragment::new(ctx, styles, self.into_frame(ctx, styles)).into() + return self.0.into_iter().next().unwrap(); } + + // Fragments without a math_size are ignored: the notion of size do not + // apply to them, so their text-likeness is meaningless. + let text_like = self + .iter() + .filter(|e| e.math_size().is_some()) + .all(|e| e.is_text_like()); + + FrameFragment::new(ctx, styles, self.into_frame(ctx, styles)) + .with_text_like(text_like) + .into() } /// Returns a builder that lays out the [`MathFragment`]s into a possibly diff --git a/tests/ref/math-attach-horizontal-align.png b/tests/ref/math-attach-horizontal-align.png index 507cb0ffd..8aa2a3767 100644 Binary files a/tests/ref/math-attach-horizontal-align.png and b/tests/ref/math-attach-horizontal-align.png differ diff --git a/tests/ref/math-attach-to-group.png b/tests/ref/math-attach-to-group.png index a3d1923eb..ea4115fce 100644 Binary files a/tests/ref/math-attach-to-group.png and b/tests/ref/math-attach-to-group.png differ diff --git a/tests/ref/math-root-large-body.png b/tests/ref/math-root-large-body.png index 3dd4d848e..b8d9edfbd 100644 Binary files a/tests/ref/math-root-large-body.png and b/tests/ref/math-root-large-body.png differ diff --git a/tests/suite/math/attach.typ b/tests/suite/math/attach.typ index c9510c6a5..c5ca57357 100644 --- a/tests/suite/math/attach.typ +++ b/tests/suite/math/attach.typ @@ -84,9 +84,9 @@ $ (-1)^n + (1/2 + 3)^(-1/2) $ // Test that the attachments are aligned horizontally. $ x_1 p_1 frak(p)_1 2_1 dot_1 lg_1 !_1 \\_1 ]_1 "ip"_1 op("iq")_1 \ x^1 b^1 frak(b)^1 2^1 dot^1 lg^1 !^1 \\^1 ]^1 "ib"^1 op("id")^1 \ - x_1 y_1 "_"_1 x^1 l^1 "`"^1 attach(I,tl:1,bl:1,tr:1,br:1) + "_"_1 "`"^1 x_1 y_1 x^1 l^1 attach(I,tl:1,bl:1,tr:1,br:1) scripts(sum)_1^1 integral_1^1 abs(1/2)_1^1 \ - x^1_1, "("b y")"^1_1 != (b y)^1_1, "[∫]"_1 [integral]_1 $ + x^1_1, ")"^1_1 (b y)^1_1, "[∫]"_1 [integral]_1 $ --- math-attach-limit --- // Test limit.