Skip to content

Commit

Permalink
Ensure that absolute LineHeight is always > 0.0
Browse files Browse the repository at this point in the history
Fixes issue #2002.
#2002

The gist of the problem is that `LineHeight::to_absolute` in conjunction
with other widgets may inadvertently return `0.0`. This triggers a panic in `cosmic_text`.

The original issue has a minimal example.
  • Loading branch information
joshuamegnauth54 committed Aug 31, 2023
1 parent c9bd487 commit f8f051a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ impl LineHeight {
/// Returns the [`LineHeight`] in absolute logical pixels.
pub fn to_absolute(self, text_size: Pixels) -> Pixels {
match self {
Self::Relative(factor) => Pixels(factor * text_size.0),
Self::Relative(factor) => {
Pixels((factor * text_size.0).max(f32::MIN_POSITIVE))
}
Self::Absolute(pixels) => pixels,
}
}
Expand Down

0 comments on commit f8f051a

Please sign in to comment.