freya_core/values/
decoration.rs

1use freya_engine::prelude::*;
2
3use crate::parsing::{
4    Parse,
5    ParseError,
6};
7
8impl Parse for TextDecoration {
9    fn parse(value: &str) -> Result<Self, ParseError> {
10        let mut decoration = TextDecoration::default();
11        let values = value.split_ascii_whitespace();
12
13        for val in values {
14            decoration.set(
15                match val {
16                    "underline" => TextDecoration::UNDERLINE,
17                    "overline" => TextDecoration::OVERLINE,
18                    "line-through" => TextDecoration::LINE_THROUGH,
19                    _ => TextDecoration::NO_DECORATION,
20                },
21                true,
22            );
23        }
24
25        Ok(decoration)
26    }
27}
28
29impl Parse for TextDecorationStyle {
30    fn parse(value: &str) -> Result<Self, ParseError> {
31        Ok(match value {
32            "solid" => TextDecorationStyle::Solid,
33            "double" => TextDecorationStyle::Double,
34            "dotted" => TextDecorationStyle::Dotted,
35            "dashed" => TextDecorationStyle::Dashed,
36            "wavy" => TextDecorationStyle::Wavy,
37            _ => TextDecorationStyle::Solid,
38        })
39    }
40}