rootvg_text/properties.rs
1use glyphon::cosmic_text::Align;
2use glyphon::{Attrs, Family, Metrics, Shaping, Stretch, Style, Weight, Wrap};
3
4/// The style of a font
5#[derive(Debug, Clone, Copy, PartialEq)]
6pub struct TextProperties {
7 /// The metrics of the font (font size and line height)
8 ///
9 /// By default this is set to `Metrics { font_size: 14.0, line_height: 16.0 }`.
10 pub metrics: Metrics,
11 /// The text alignment
12 ///
13 /// Setting to `None` will use `Align::Right` for RTL lines, and `Align::Left`
14 /// for LTR lines.
15 ///
16 /// By default this is set to `None`.
17 pub align: Option<Align>,
18 /// The text attributes
19 ///
20 /// By default this is set to:
21 ///```
22 ///Attrs {
23 /// color_opt: None,
24 /// family: Family::SansSerif,
25 /// stretch: Stretch::Normal,
26 /// style: Style::Normal,
27 /// weight: Weight::NORMAL,
28 /// metadata: 0,
29 ///}
30 /// ```
31 pub attrs: Attrs<'static>,
32 /// The text wrapping
33 ///
34 /// By default this is set to `Wrap::None`.
35 pub wrap: Wrap,
36 /// The text shaping
37 ///
38 /// By default this is set to `Shaping::Basic`.
39 pub shaping: Shaping,
40}
41
42impl Default for TextProperties {
43 fn default() -> Self {
44 Self {
45 metrics: Metrics {
46 font_size: 14.0,
47 line_height: 16.0,
48 },
49 align: None,
50 attrs: Attrs {
51 color_opt: None,
52 family: Family::SansSerif,
53 stretch: Stretch::Normal,
54 style: Style::Normal,
55 weight: Weight::NORMAL,
56 metadata: 0,
57 },
58 wrap: Wrap::None,
59 shaping: Shaping::Basic,
60 }
61 }
62}