diff --git a/src/attrs.rs b/src/attrs.rs index d241fe4f1a..ea8b671376 100644 --- a/src/attrs.rs +++ b/src/attrs.rs @@ -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 for CacheMetrics { diff --git a/src/shape.rs b/src/shape.rs index ef834d84c1..e631f16cef 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -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() {