Skip to content

Commit cd1a786

Browse files
authored
Prevent broken glyph assemblies when font data is incorrect (typst#6688)
1 parent ef86265 commit cd1a786

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

crates/typst-layout/src/math/fragment.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ fn assemble(
739739
}
740740

741741
advance -= max_overlap;
742-
growable += max_overlap - min_overlap;
742+
// In case we have that max_overlap < min_overlap, ensure we
743+
// don't decrease the value of growable.
744+
growable += (max_overlap - min_overlap).max(Abs::zero());
743745
}
744746

745747
full += advance;
585 Bytes
Loading

tests/suite/math/stretch.typ

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,12 @@ $ body^"text" $
9191
}
9292
$body^"long text"$
9393
}
94+
95+
--- math-stretch-min-overlap-exceeds-max ---
96+
// Test that glyph assembly doesn't end up with negative lengths if the max
97+
// overlap calculated is less than the minConnectorOverlap.
98+
#show math.equation: set text(font: "STIX Two Math")
99+
// Warning: glyph has assembly parts with overlap less than minConnectorOverlap
100+
// Hint: its rendering may appear broken - this is probably a font bug
101+
// Hint: please file an issue at https://github.com/typst/typst/issues
102+
$ stretch(->)^"Gauss-Jordan Elimination" $

0 commit comments

Comments
 (0)