Address review

This commit is contained in:
Jeremy Soller 2024-06-06 15:37:07 -06:00
parent 896f36cdab
commit 020701734e
2 changed files with 5 additions and 2 deletions

View file

@ -105,8 +105,8 @@ impl FamilyOwned {
//TODO: what are the edge cases of this?
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct CacheMetrics {
pub font_size_bits: u32,
pub line_height_bits: u32,
font_size_bits: u32,
line_height_bits: u32,
}
impl From<Metrics> for CacheMetrics {

View file

@ -519,6 +519,8 @@ impl ShapeGlyph {
}
}
/// Get the width of the [`ShapeGlyph`] in pixels, either using the provided font size
/// or the [`ShapeGlyph::metrics_opt`] override.
pub fn width(&self, font_size: f32) -> f32 {
self.metrics_opt.map_or(font_size, |x| x.font_size) * self.x_advance
}
@ -613,6 +615,7 @@ impl ShapeWord {
Self { blank, glyphs }
}
/// Get the width of the [`ShapeWord`] in pixels, using the [`ShapeGlyph::width`] function.
pub fn width(&self, font_size: f32) -> f32 {
let mut width = 0.0;
for glyph in self.glyphs.iter() {