Ceil measured width for Text element

This commit is contained in:
Antonio Scandurra 2023-11-10 13:03:39 +01:00
parent a30b47aa5f
commit 6929a71827
2 changed files with 10 additions and 1 deletions

View file

@ -101,7 +101,12 @@ impl<V: 'static> Element<V> for Text<V> {
.map(|line| line.wrap_count() + 1)
.sum::<usize>();
let size = Size {
width: lines.iter().map(|line| line.layout.width).max().unwrap(),
width: lines
.iter()
.map(|line| line.layout.width)
.max()
.unwrap()
.ceil(),
height: line_height * line_count,
};

View file

@ -785,6 +785,10 @@ impl Pixels {
Self(self.0.round())
}
pub fn ceil(&self) -> Self {
Self(self.0.ceil())
}
pub fn scale(&self, factor: f32) -> ScaledPixels {
ScaledPixels(self.0 * factor)
}