mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Align point and linebreak should not increase math row height (#4306)
This commit is contained in:
parent
9adcd9a1f8
commit
df6e347bc5
@ -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)
|
||||
}
|
||||
|
BIN
tests/ref/issue-4187-alignment-point-affects-row-height.png
Normal file
BIN
tests/ref/issue-4187-alignment-point-affects-row-height.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 282 B |
@ -256,6 +256,16 @@ $ q &= sum_k ln A \
|
||||
],
|
||||
)
|
||||
|
||||
--- issue-4187-alignment-point-affects-row-height ---
|
||||
// In this bug, a row of "-" only should have a very small height; but
|
||||
// after adding an alignment point "&", the row gains a larger height.
|
||||
// We need to test alignment point "&" does not affect a row's height.
|
||||
#box($ - - $, fill: silver)
|
||||
#box($ - - $, fill: silver) \
|
||||
#box($ a \ - - $, fill: silver)
|
||||
#box($ &- - \ &a $, fill: silver)
|
||||
#box($ &a \ &- - $, fill: silver)
|
||||
|
||||
--- issue-numbering-hint ---
|
||||
// In this bug, the hint and error messages for an equation
|
||||
// being reference mentioned that it was a "heading" and was
|
||||
|
Loading…
x
Reference in New Issue
Block a user