Skip to main content

freya_core/style/
text_decoration.rs

1use freya_engine::prelude::SkTextDecoration;
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Default, Debug, Copy, Clone, Hash, PartialEq, Eq)]
5pub enum TextDecoration {
6    #[default]
7    None,
8    Underline,
9    Overline,
10    LineThrough,
11}
12
13impl TextDecoration {
14    pub fn pretty(&self) -> String {
15        match self {
16            Self::None => "none".to_string(),
17            Self::Underline => "underline".to_string(),
18            Self::Overline => "overline".to_string(),
19            Self::LineThrough => "line-through".to_string(),
20        }
21    }
22}
23
24impl From<TextDecoration> for SkTextDecoration {
25    fn from(value: TextDecoration) -> Self {
26        match value {
27            TextDecoration::None => SkTextDecoration::NO_DECORATION,
28            TextDecoration::Underline => SkTextDecoration::UNDERLINE,
29            TextDecoration::Overline => SkTextDecoration::OVERLINE,
30            TextDecoration::LineThrough => SkTextDecoration::LINE_THROUGH,
31        }
32    }
33}