Skip to main content

cranpose_ui/text/
style.rs

1use super::decoration::{Shadow, TextDecoration};
2use super::font::{FontFamily, FontStyle, FontSynthesis, FontWeight};
3use super::paragraph::{TextAlign, TextDirection, TextIndent};
4use super::unit::TextUnit;
5use crate::modifier::Color;
6
7#[derive(Clone, Debug, PartialEq)]
8pub struct TextStyle {
9    pub color: Option<Color>,
10    pub font_size: TextUnit,
11    pub font_weight: Option<FontWeight>,
12    pub font_style: Option<FontStyle>,
13    pub font_synthesis: Option<FontSynthesis>,
14    pub font_family: Option<FontFamily>,
15    pub font_feature_settings: Option<String>,
16    pub letter_spacing: TextUnit,
17    pub baseline_shift: Option<f32>, // TODO: Implement BaselineShift struct/enum
18    pub text_geometric_transform: Option<()>, // TODO: Implement TextGeometricTransform
19    pub locale_list: Option<()>,     // TODO: Implement LocaleList
20    pub background: Option<Color>,
21    pub text_decoration: Option<TextDecoration>,
22    pub shadow: Option<Shadow>,
23    pub text_align: Option<TextAlign>,
24    pub text_direction: Option<TextDirection>,
25    pub line_height: TextUnit,
26    pub text_indent: Option<TextIndent>,
27}
28
29impl Default for TextStyle {
30    fn default() -> Self {
31        Self {
32            color: None, // Unspecified
33            font_size: TextUnit::Unspecified,
34            font_weight: None,
35            font_style: None,
36            font_synthesis: None,
37            font_family: None,
38            font_feature_settings: None,
39            letter_spacing: TextUnit::Unspecified,
40            baseline_shift: None,
41            text_geometric_transform: None,
42            locale_list: None,
43            background: None,
44            text_decoration: None,
45            shadow: None,
46            text_align: None,
47            text_direction: None,
48            line_height: TextUnit::Unspecified,
49            text_indent: None,
50        }
51    }
52}