freya_core/style/
text_height.rs1use freya_engine::prelude::*;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Default)]
6pub enum TextHeightBehavior {
7 All = 0,
9 DisableFirstAscent = 1,
11 DisableLastDescent = 2,
13 #[default]
15 DisableAll = 3,
16}
17
18impl TextHeightBehavior {
19 pub fn needs_custom_height(&self) -> bool {
20 matches!(
21 self,
22 Self::All | Self::DisableFirstAscent | Self::DisableLastDescent
23 )
24 }
25
26 pub fn pretty(&self) -> String {
27 match self {
28 Self::All => "All".to_string(),
29 Self::DisableFirstAscent => "DisableFirstAscent".to_string(),
30 Self::DisableLastDescent => "DisableLastDescent".to_string(),
31 Self::DisableAll => "DisableAll".to_string(),
32 }
33 }
34}
35
36impl From<TextHeightBehavior> for SkTextHeightBehavior {
37 fn from(value: TextHeightBehavior) -> Self {
38 match value {
39 TextHeightBehavior::All => SkTextHeightBehavior::All,
40 TextHeightBehavior::DisableAll => SkTextHeightBehavior::DisableAll,
41 TextHeightBehavior::DisableFirstAscent => SkTextHeightBehavior::DisableFirstAscent,
42 TextHeightBehavior::DisableLastDescent => SkTextHeightBehavior::DisableLastDescent,
43 }
44 }
45}