diff options
Diffstat (limited to 'src/frame.rs')
| -rw-r--r-- | src/frame.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/frame.rs b/src/frame.rs index b0442a06..29125962 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -171,14 +171,19 @@ pub struct Text { pub face_id: FaceId, /// The font size. pub size: Length, - /// The width of the text run. - pub width: Length, /// Glyph color. pub fill: Paint, /// The glyphs. pub glyphs: Vec<Glyph>, } +impl Text { + /// The width of the text run. + pub fn width(&self) -> Length { + self.glyphs.iter().map(|g| g.x_advance.to_length(self.size)).sum() + } +} + /// A glyph in a run of shaped text. #[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct Glyph { |
