diff options
| author | Leedehai <18319900+Leedehai@users.noreply.github.com> | 2024-06-04 11:30:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-04 15:30:43 +0000 |
| commit | df6e347bc55bdcbf370645442290198c0bcdd3fe (patch) | |
| tree | 7077226a019dcc51f65f1cc1716e577870441d7c /crates | |
| parent | 9adcd9a1f894b212e2757277781955a7d5b8bba8 (diff) | |
Align point and linebreak should not increase math row height (#4306)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/math/row.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/typst/src/math/row.rs b/crates/typst/src/math/row.rs index 0681752a..cb909b0b 100644 --- a/crates/typst/src/math/row.rs +++ b/crates/typst/src/math/row.rs @@ -117,11 +117,19 @@ impl MathRun { } pub fn ascent(&self) -> Abs { - self.iter().map(MathFragment::ascent).max().unwrap_or_default() + self.iter() + .filter(|e| affects_row_height(e)) + .map(|e| e.ascent()) + .max() + .unwrap_or_default() } pub fn descent(&self) -> Abs { - self.iter().map(MathFragment::descent).max().unwrap_or_default() + self.iter() + .filter(|e| affects_row_height(e)) + .map(|e| e.descent()) + .max() + .unwrap_or_default() } pub fn class(&self) -> MathClass { @@ -386,3 +394,7 @@ impl MathRunFrameBuilder { frame } } + +fn affects_row_height(fragment: &MathFragment) -> bool { + !matches!(fragment, MathFragment::Align | MathFragment::Linebreak) +} |
