trezor-firmware icon indicating copy to clipboard operation
trezor-firmware copied to clipboard

refactor(core): simplify fonts handling

Open obrusvit opened this issue 5 months ago • 7 comments

This PR aims to further simplify the font handling in core.

The main objective was to get rid of the numerous macros, which are quite cumbersome to work with. This is achieved by introducing struct font_info_t which is filled with needed data for each font during font generation by gen_font.py. Then there is a function get_font_info defined In the core/embed/lib/fonts/fonts.c which is used to access font data.

Unfortunately, I was unable to get rid of the FONT_MAX_HEIGHT calculation as it must be done in compile time. However, there is only one usage so getting rid of it is perhaps feasible. https://github.com/trezor/trezor-firmware/blob/02533aa27a44ed661166465648438f62cd6a0449/core/embed/lib/buffers.h#L32

TODO:

  • [x] _UPPER fonts seems not effective
  • [x] problems with translated strings

obrusvit avatar Sep 18 '24 22:09 obrusvit