summaryrefslogtreecommitdiff
path: root/src/frame.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-12-07 16:36:39 +0100
committerLaurenz <laurmaedje@gmail.com>2021-12-07 16:36:39 +0100
commit40b87d4066fe85cb3fde6cf84cd60d748273ae25 (patch)
tree792b2e5edd8e72649d9fdcac24dc07620bf0f15c /src/frame.rs
parent26bdc1f0f6fe8113d7fcfb4d5aca46aa5238ccd8 (diff)
Set Rules Episode II: Attack of the properties
Diffstat (limited to 'src/frame.rs')
-rw-r--r--src/frame.rs9
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 {