Skip to main content

graphics/
fonts.rs

1use crate::lvgl;
2
3// Every generated range has unique C symbols in separate archive members.
4// These aliases reference only the selected range, with no runtime registry.
5macro_rules! selected_fonts {
6    ($($name:ident),* $(,)?) => {
7        unsafe extern "C" {
8            $(
9                #[link_name = concat!(stringify!($name), "_", env!("XILA_FONT_VARIANT"))]
10                static $name: lvgl::lv_font_t;
11            )*
12        }
13    };
14}
15
16selected_fonts!(
17    font_montserrat_10,
18    font_montserrat_14,
19    font_montserrat_18,
20    font_montserrat_28,
21    font_unscii_8,
22    font_unscii_16,
23);
24
25pub const fn get_font_small() -> &'static lvgl::lv_font_t {
26    unsafe { &font_montserrat_10 }
27}
28
29pub const fn get_font_medium() -> &'static lvgl::lv_font_t {
30    unsafe { &font_montserrat_14 }
31}
32
33pub const fn get_font_large() -> &'static lvgl::lv_font_t {
34    unsafe { &font_montserrat_18 }
35}
36
37pub const fn get_font_extra_large() -> &'static lvgl::lv_font_t {
38    unsafe { &font_montserrat_28 }
39}
40
41pub const fn get_font_monospace_small() -> &'static lvgl::lv_font_t {
42    unsafe { &font_unscii_8 }
43}
44
45pub const fn get_font_monospace_medium() -> &'static lvgl::lv_font_t {
46    unsafe { &font_unscii_16 }
47}