-
-
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
Open
obrusvit
wants to merge
15
commits into
main
Choose a base branch
from
obrusvit/refactor-fonts-handling-to-rust
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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]
obrusvit
added
core
Trezor Core firmware. Runs on Trezor Model T and T2B1.
code
Code improvements
rust
Pull requests that update Rust code
labels
Jan 24, 2025
|
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
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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