-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
Refactor fonts handling to rust #4536
base: main
Are you sure you want to change the base?
Conversation
- application layer should not deal with fonts at all - distinction between MONO and others is preserved by bool argument in `should_show_more` interpreted as `is_data` [no changelog]
[no changelog]
[no changelog]
[no changelog]
- see #3771 [no changelog]
- todo: prodtest/main.c
[no changelog]
- font usage changed from enum Font to pointers to FontInfo structs - components from all layouts and also common components changed [no changelog]
[no changelog]
|
Unfortunately, designated initializer is not possible if gfx_text_attr_t normal_text_attr = {
.font = FONT_NORMAL,
.fg_color = COLOR_BL_FG,
.bg_color = COLOR_BL_BG,
}; Alternative for
|
I think we can revert to While we are structuring the fonts by layouts, maybe we can move the to the existing layout folders, i.e.:
|
This PR changes the font handling from
enum Font
to direct usage ofstruct FontInfo
. While doing so, it became apparent that generating rust files instead of C is a better way go. The main problem was thatconst
C variables are bound tostatic
variables in Rust (andstatic
variables cannot be used inconst
context). Each font is supplied in the following struct:The benefits are:
enum Font
allows more flexible fonts handling - each layout can now specify the fonts and their operational names on their ownenum Font
Font
inFormattedText
where it should be replaced byTextStyle
Paragraphs
- usage inChecklist
, which should be separated by layouts or implemented throughFormattedText
enum
value to some data which might benull
), this results in removing someunsafe
blocks andunwrap
sThe drawbacks are:
prodtest
andbootloader_ci
. This will be a private impl.core/embed/rust/src/ui/display/fonts/mod.rs
Measurement of
FLASH
size onT3T1
showed negligible increase by 1 block only (512 B
).TODO:
prodtest
andbootloader_ci
build does not work yet - trying to have one or twoconst font_info_t*
clippy
compiling with all featuresstage
(either"bootloader"
or"firmware"
). I'm not sure that the current approach gets this right. Only some fonts are used from the bootloader so I pressume that the compiler does not include the others for bootloader binary.USE_RGB_COLOURS