freya_core/values/
text_height.rs1use freya_engine::prelude::*;
2
3use crate::parsing::{
4 Parse,
5 ParseError,
6};
7
8impl Parse for TextHeightBehavior {
9 fn parse(value: &str) -> Result<Self, ParseError> {
10 match value {
11 "all" => Ok(TextHeightBehavior::All),
12 "disable-first-ascent" => Ok(TextHeightBehavior::DisableFirstAscent),
13 "disable-least-ascent" => Ok(TextHeightBehavior::DisableLastDescent),
14 "disable-all" => Ok(TextHeightBehavior::DisableAll),
15 _ => Err(ParseError),
16 }
17 }
18}
19
20pub trait TextHeight {
21 fn needs_custom_height(&self) -> bool;
22}
23
24impl TextHeight for TextHeightBehavior {
25 fn needs_custom_height(&self) -> bool {
26 matches!(
27 self,
28 Self::All | Self::DisableFirstAscent | Self::DisableLastDescent
29 )
30 }
31}