diff options
Diffstat (limited to 'src/font/mod.rs')
| -rw-r--r-- | src/font/mod.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/font/mod.rs b/src/font/mod.rs index bedc107d..94ec170e 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -12,6 +12,7 @@ use std::sync::Arc; use ttf_parser::GlyphId; +use crate::eval::{cast_from_value, cast_to_value, Value}; use crate::geom::Em; use crate::util::Buffer; @@ -249,3 +250,27 @@ pub enum VerticalFontMetric { /// present and falls back to the descender from the `hhea` table otherwise. Descender, } + +cast_from_value! { + VerticalFontMetric, + /// The font's ascender, which typically exceeds the height of all glyphs. + "ascender" => Self::Ascender, + /// The approximate height of uppercase letters. + "cap-height" => Self::CapHeight, + /// The approximate height of non-ascending lowercase letters. + "x-height" => Self::XHeight, + /// The baseline on which the letters rest. + "baseline" => Self::Baseline, + /// The font's ascender, which typically exceeds the depth of all glyphs. + "descender" => Self::Descender, +} + +cast_to_value! { + v: VerticalFontMetric => Value::from(match v { + VerticalFontMetric::Ascender => "ascender", + VerticalFontMetric::CapHeight => "cap-height", + VerticalFontMetric::XHeight => "x-height", + VerticalFontMetric::Baseline => "baseline" , + VerticalFontMetric::Descender => "descender", + }) +} |
