euv_core/style/text_prop/impl.rs
1use super::*;
2
3/// Default typography style (`14px` Sans Regular, `1.4` line height).
4impl Default for TextStyle {
5 /// Creates the default UI text style.
6 ///
7 /// # Returns
8 ///
9 /// - `Self` - Default `TextStyle`.
10 fn default() -> Self {
11 Self {
12 family: FontFamily::Sans,
13 font_size: 14.0,
14 weight: FontWeight::Normal,
15 line_height: 1.4,
16 letter_spacing: 0.0,
17 align: TextAlign::Left,
18 overflow: TextOverflow::Wrap,
19 color: COLOR_BLACK,
20 underline: false,
21 strikethrough: false,
22 }
23 }
24}
25
26/// Numeric weight helpers for `FontWeight`.
27impl FontWeight {
28 /// Returns the OpenType numeric weight (`300..=700`).
29 ///
30 /// # Arguments
31 ///
32 /// - `&Self` - Font weight variant.
33 ///
34 /// # Returns
35 ///
36 /// - `u16` - OpenType numeric weight value.
37 #[must_use]
38 pub const fn numeric(&self) -> u16 {
39 match *self {
40 Self::Light => 300,
41 Self::Normal => 400,
42 Self::Medium => 500,
43 Self::SemiBold => 600,
44 Self::Bold => 700,
45 }
46 }
47
48 /// Returns true when the weight renders bold strokes (`>= 600`).
49 ///
50 /// # Arguments
51 ///
52 /// - `&Self` - Font weight variant.
53 ///
54 /// # Returns
55 ///
56 /// - `bool` - True for `SemiBold` and `Bold`.
57 #[must_use]
58 pub const fn is_bold(&self) -> bool {
59 matches!(*self, Self::SemiBold | Self::Bold)
60 }
61}