Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Jun 6, 2024
1 parent 5794a68 commit 268f507
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 268f507

Please sign in to comment.