summaryrefslogtreecommitdiff
path: root/src/font.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-05-13 11:26:51 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-13 11:26:51 +0200
commit33733fd1efda760d65ff9124b6d143a147edbd11 (patch)
treefd378b66417c03179ba0230cbe74649069940886 /src/font.rs
parent3e03667c37b86f0dfe9111c09e3bc2ea0ae70291 (diff)
Expose units_per_em and raw face id
Diffstat (limited to 'src/font.rs')
-rw-r--r--src/font.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/font.rs b/src/font.rs
index 5a83f6c4..01434d0a 100644
--- a/src/font.rs
+++ b/src/font.rs
@@ -69,6 +69,16 @@ impl Face {
&self.ttf
}
+ /// Get the number of units per em.
+ pub fn units_per_em(&self) -> f64 {
+ self.units_per_em
+ }
+
+ /// Convert from font units to an em length.
+ pub fn to_em(&self, units: impl Into<f64>) -> Em {
+ Em::from_units(units, self.units_per_em)
+ }
+
/// Look up a vertical metric.
pub fn vertical_metric(&self, metric: VerticalFontMetric) -> Em {
match metric {
@@ -79,11 +89,6 @@ impl Face {
VerticalFontMetric::Descender => self.descender,
}
}
-
- /// Convert from font units to an em length.
- pub fn to_em(&self, units: impl Into<f64>) -> Em {
- Em::from_units(units, self.units_per_em)
- }
}
/// Identifies a vertical metric of a font.