waft_winui/theme/
typography.rs1use super::generated::*;
4use waft_embedder::{Color, FontWeight};
5use waft_painting::TextStyle;
6
7pub const FONT_FAMILY: &str = "Selawik";
9
10#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
12pub enum TextBlockStyle {
13 Caption,
14 Body,
15 BodyStrong,
16 BodyLarge,
17 BodyLargeStrong,
18 Subtitle,
19 Title,
20 TitleLarge,
21 Display,
22}
23
24impl TextBlockStyle {
25 pub fn font(self, r: &ThemeResources) -> (f64, FontWeight) {
27 match self {
28 TextBlockStyle::Caption => (r.caption_text_block_font_size, FontWeight::W400),
29 TextBlockStyle::Body => (r.body_text_block_font_size, FontWeight::W400),
30 TextBlockStyle::BodyStrong => (r.body_text_block_font_size, FontWeight::W600),
31 TextBlockStyle::BodyLarge => (r.body_large_text_block_font_size, FontWeight::W400),
32 TextBlockStyle::BodyLargeStrong => {
33 (r.body_large_text_block_font_size, FontWeight::W600)
34 }
35 TextBlockStyle::Subtitle => (r.subtitle_text_block_font_size, FontWeight::W600),
36 TextBlockStyle::Title => (r.title_text_block_font_size, FontWeight::W600),
37 TextBlockStyle::TitleLarge => (r.title_large_text_block_font_size, FontWeight::W600),
38 TextBlockStyle::Display => (r.display_text_block_font_size, FontWeight::W600),
39 }
40 }
41
42 pub fn text_style(self, r: &ThemeResources, color: Color) -> TextStyle {
44 let (size, weight) = self.font(r);
45 control_text_style(r, size, weight, color)
46 }
47}
48
49pub fn control_text_style(
51 r: &ThemeResources,
52 size: f64,
53 weight: FontWeight,
54 color: Color,
55) -> TextStyle {
56 TextStyle::new()
57 .font_family(r.content_control_theme_font_family)
58 .font_size(size)
59 .font_weight(weight)
60 .color(color)
61}