Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate bootloader and firmware fonts #4574

Open
obrusvit opened this issue Feb 4, 2025 · 0 comments
Open

Separate bootloader and firmware fonts #4574

obrusvit opened this issue Feb 4, 2025 · 0 comments
Labels
code Code improvements rust Pull requests that update Rust code

Comments

@obrusvit
Copy link
Contributor

obrusvit commented Feb 4, 2025

As of #4536, (and #4536 (comment)) we moved from enum Font to type Font = &'static FontInfo. For convenience, in the older enum approach, some fonts were mapped to the same enum variant during build, e.g. for TS3 (Caesar UI):

    if stage == "bootloader":
        # ...
        font_big = "Font_PixelOperator_Regular_8"
    if stage == "firmware":
        #...
        font_big = "Font_Unifont_Regular_16"

This was done so that:

  • there were less fonts for bootloader (to preserve flash size)
  • using hardcoded font in components was possible, e.g.
let font = Font::FONT_BIG;   // using Font_Unifont_Regular_16 in Firmware but Font_PixelOperator_Regular_8 in Bootloader

In order to preserve the code without too much refactoring a crutch was made in this manner in #4536:

// same for both FW and BL
pub const FONT_NORMAL: crate::ui::display::Font = &Font_PixelOperator_Regular_8_info;

#[cfg(feature = "bootloader")]
pub const FONT_BIG: crate::ui::display::Font = FONT_NORMAL;
#[cfg(not(feature = "bootloader"))]
pub const FONT_BIG: crate::ui::display::Font = &Font_Unifont_Regular_16_info;

This task is to improve it so that:

  • bootloader code only uses the fonts it's supposed to have (others might be feature-gated),
  • components which use specific Font rather take it as a parameter,
  • (optionally) theme/mod.rs is split into theme/mod.rs (common) and theme/firmware.rs.
@obrusvit obrusvit added code Code improvements rust Pull requests that update Rust code labels Feb 4, 2025
@obrusvit obrusvit added this to Firmware Feb 4, 2025
obrusvit added a commit that referenced this issue Feb 4, 2025
- a crutch to preserve code which depends on specific fonts
- see #4574

[no changelog]
obrusvit added a commit that referenced this issue Feb 4, 2025
- a crutch to preserve code which depends on specific fonts
- see #4574

[no changelog]
obrusvit added a commit that referenced this issue Feb 6, 2025
- a crutch to preserve code which depends on specific fonts
- see #4574

[no changelog]
obrusvit added a commit that referenced this issue Feb 6, 2025
- a crutch to preserve code which depends on specific fonts
- see #4574

[no changelog]
obrusvit added a commit that referenced this issue Feb 6, 2025
- a crutch to preserve code which depends on specific fonts
- see #4574

[no changelog]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code improvements rust Pull requests that update Rust code
Projects
Status: No status
Development

No branches or pull requests

1 participant