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