Skip to main content

zest_theme/
typography.rs

1//! Bitmap typography scale — four monospace font sizes the theme
2//! exposes by role, so widgets can ask for `theme.typography.display`
3//! or `theme.typography.body` without picking a `MonoFont` constant
4//! directly.
5
6use embedded_graphics::mono_font::MonoFont;
7
8/// Typography scale. `display` covers hero text on larger panels,
9/// while `heading` / `body` / `caption` handle the regular UI scale.
10#[derive(Copy, Clone, Debug, PartialEq)]
11pub struct Typography<'a> {
12    /// Hero text, such as a wall clock face.
13    pub display: &'a MonoFont<'a>,
14    /// Section headings and other large in-flow UI text.
15    pub heading: &'a MonoFont<'a>,
16    /// Body / label text. The default font widgets use.
17    pub body: &'a MonoFont<'a>,
18    /// Small captions, error strings, hints.
19    pub caption: &'a MonoFont<'a>,
20}
21
22impl<'a> Typography<'a> {
23    /// Construct a typography scale.
24    #[must_use]
25    pub const fn new(
26        display: &'a MonoFont<'a>,
27        heading: &'a MonoFont<'a>,
28        body: &'a MonoFont<'a>,
29        caption: &'a MonoFont<'a>,
30    ) -> Self {
31        Self {
32            display,
33            heading,
34            body,
35            caption,
36        }
37    }
38}