From d199a17cfcd4f49040f43c67a9e183314e8553dd Mon Sep 17 00:00:00 2001 From: grdddj Date: Mon, 5 Jun 2023 17:03:22 +0200 Subject: [PATCH] feat(core): introduce FONT_BIG as a fifth optional font [no changelog] --- core/SConscript.bootloader | 5 ++++- core/SConscript.bootloader_ci | 5 ++++- core/SConscript.bootloader_emu | 5 ++++- core/SConscript.firmware | 5 ++++- core/SConscript.prodtest | 5 ++++- core/SConscript.reflash | 5 ++++- core/SConscript.unix | 5 ++++- core/embed/lib/fonts/fonts.c | 16 +++++++++++++++ core/embed/lib/fonts/fonts.h | 27 ++++++++++++++++++++------ core/embed/rust/src/ui/display/font.rs | 1 + 10 files changed, 66 insertions(+), 13 deletions(-) diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index 52d7738f61..091401b7e0 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -33,11 +33,13 @@ if TREZOR_MODEL in ('R', ): FONT_DEMIBOLD='Font_PixelOperator_Regular_8' FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO='Font_PixelOperator_Regular_8' -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL='Font_TTHoves_Regular_21' FONT_DEMIBOLD=None FONT_BOLD='Font_TTHoves_Bold_17' FONT_MONO=None + FONT_BIG=None # modtrezorcrypto CCFLAGS_MOD += '-Wno-sequence-point ' @@ -154,6 +156,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) env = Environment(ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DBOOTLOADER_QA={int(BOOTLOADER_QA)}") diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index 8da135655b..e26275462b 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -30,11 +30,13 @@ if TREZOR_MODEL in ('1', 'R'): FONT_DEMIBOLD=None FONT_BOLD=None FONT_MONO='Font_PixelOperatorMono_Regular_8' -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL='Font_Roboto_Regular_20' FONT_DEMIBOLD=None FONT_BOLD=None FONT_MONO='Font_RobotoMono_Medium_20' + FONT_BIG=None # modtrezorcrypto CCFLAGS_MOD += '-Wno-sequence-point ' @@ -138,6 +140,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index e96551fac6..f16f539759 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -32,11 +32,13 @@ if TREZOR_MODEL in ('1', 'R'): FONT_DEMIBOLD='Font_PixelOperator_Regular_8' FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO='Font_PixelOperator_Regular_8' -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL='Font_TTHoves_Regular_21' FONT_DEMIBOLD=None FONT_BOLD='Font_TTHoves_Bold_17' FONT_MONO=None + FONT_BIG=None # modtrezorcrypto CCFLAGS_MOD += '-Wno-sequence-point ' @@ -119,6 +121,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) diff --git a/core/SConscript.firmware b/core/SConscript.firmware index bb9a530ca5..5f85c6b203 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -34,11 +34,13 @@ if TREZOR_MODEL in ('R',): FONT_DEMIBOLD='Font_Unifont_Bold_16' FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO='Font_PixelOperatorMono_Regular_8' -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL='Font_TTHoves_Regular_21' FONT_DEMIBOLD='Font_TTHoves_DemiBold_21' FONT_BOLD='Font_TTHoves_Bold_17' FONT_MONO='Font_RobotoMono_Medium_20' + FONT_BIG=None # modtrezorconfig CPPPATH_MOD += [ @@ -418,6 +420,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index 2b220f5f1d..cb64633b80 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -20,11 +20,13 @@ if TREZOR_MODEL in ('1', 'R'): FONT_DEMIBOLD=None FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO=None -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL=None FONT_DEMIBOLD=None FONT_BOLD='Font_Roboto_Bold_20' FONT_MONO=None + FONT_BIG=None # modtrezorcrypto CPPPATH_MOD += [ @@ -105,6 +107,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) diff --git a/core/SConscript.reflash b/core/SConscript.reflash index 4c4492a87d..612df14a1d 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -18,11 +18,13 @@ if TREZOR_MODEL in ('1', 'R'): FONT_DEMIBOLD=None FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO=None -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL=None FONT_DEMIBOLD=None FONT_BOLD='Font_Roboto_Bold_20' FONT_MONO=None + FONT_BIG=None # modtrezorcrypto CPPPATH_MOD += [ @@ -96,6 +98,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) diff --git a/core/SConscript.unix b/core/SConscript.unix index 078b6c4df7..f9b5adbce5 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -30,11 +30,13 @@ if TREZOR_MODEL in ('R',): FONT_DEMIBOLD='Font_Unifont_Bold_16' FONT_BOLD='Font_PixelOperator_Bold_8' FONT_MONO='Font_PixelOperatorMono_Regular_8' -if TREZOR_MODEL in ('T', ): + FONT_BIG=None +elif TREZOR_MODEL in ('T', ): FONT_NORMAL='Font_TTHoves_Regular_21' FONT_DEMIBOLD='Font_TTHoves_DemiBold_21' FONT_BOLD='Font_TTHoves_Bold_17' FONT_MONO='Font_RobotoMono_Medium_20' + FONT_BIG=None # modtrezorconfig CPPPATH_MOD += [ @@ -374,6 +376,7 @@ tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD) tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD) +tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD) SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX diff --git a/core/embed/lib/fonts/fonts.c b/core/embed/lib/fonts/fonts.c index 17a861a52d..daf3f11cdb 100644 --- a/core/embed/lib/fonts/fonts.c +++ b/core/embed/lib/fonts/fonts.c @@ -68,6 +68,10 @@ int font_height(int font) { #ifdef TREZOR_FONT_MONO_ENABLE case FONT_MONO: return FONT_MONO_HEIGHT; +#endif +#ifdef TREZOR_FONT_BIG_ENABLE + case FONT_BIG: + return FONT_BIG_HEIGHT; #endif } return 0; @@ -90,6 +94,10 @@ int font_max_height(int font) { #ifdef TREZOR_FONT_MONO_ENABLE case FONT_MONO: return FONT_MONO_MAX_HEIGHT; +#endif +#ifdef TREZOR_FONT_BIG_ENABLE + case FONT_BIG: + return FONT_BIG_MAX_HEIGHT; #endif } return 0; @@ -112,6 +120,10 @@ int font_baseline(int font) { #ifdef TREZOR_FONT_MONO_ENABLE case FONT_MONO: return FONT_MONO_BASELINE; +#endif +#ifdef TREZOR_FONT_BIG_ENABLE + case FONT_BIG: + return FONT_BIG_BASELINE; #endif } return 0; @@ -139,6 +151,10 @@ const uint8_t *font_get_glyph(int font, uint8_t c) { #ifdef TREZOR_FONT_MONO_ENABLE case FONT_MONO: return FONT_MONO_DATA[c - ' ']; +#endif +#ifdef TREZOR_FONT_BIG_ENABLE + case FONT_BIG: + return FONT_BIG_DATA[c - ' ']; #endif } return 0; diff --git a/core/embed/lib/fonts/fonts.h b/core/embed/lib/fonts/fonts.h index 3d73fe1139..6d33b881d6 100644 --- a/core/embed/lib/fonts/fonts.h +++ b/core/embed/lib/fonts/fonts.h @@ -45,6 +45,15 @@ #define FONT_NORMAL_BASELINE FONT_DEFINE(TREZOR_FONT_NORMAL_ENABLE, _BASELINE) #endif +#ifdef TREZOR_FONT_BIG_ENABLE +#include TREZOR_FONT_BIG_INCLUDE +#define FONT_BIG (-4) +#define FONT_BIG_DATA TREZOR_FONT_BIG_ENABLE +#define FONT_BIG_HEIGHT FONT_DEFINE(TREZOR_FONT_BIG_ENABLE, _HEIGHT) +#define FONT_BIG_MAX_HEIGHT FONT_DEFINE(TREZOR_FONT_BIG_ENABLE, _MAX_HEIGHT) +#define FONT_BIG_BASELINE FONT_DEFINE(TREZOR_FONT_BIG_ENABLE, _BASELINE) +#endif + #ifdef TREZOR_FONT_DEMIBOLD_ENABLE #include TREZOR_FONT_DEMIBOLD_INCLUDE #define FONT_DEMIBOLD (-5) @@ -89,17 +98,23 @@ #define FONT_MAX_HEIGHT_3 FONT_MAX_HEIGHT_2 #endif -#ifdef TREZOR_FONT_DEMIBOLD_ENABLE -#define FONT_MAX_HEIGHT_4 \ - MAX_FONT_H(FONT_DEMIBOLD_MAX_HEIGHT, FONT_MAX_HEIGHT_3) +#ifdef TREZOR_FONT_BIG_ENABLE +#define FONT_MAX_HEIGHT_4 MAX_FONT_H(FONT_BIG_MAX_HEIGHT, FONT_MAX_HEIGHT_3) #else #define FONT_MAX_HEIGHT_4 FONT_MAX_HEIGHT_3 #endif -#ifdef TREZOR_FONT_MONO_ENABLE -#define FONT_MAX_HEIGHT MAX_FONT_H(FONT_MONO_MAX_HEIGHT, FONT_MAX_HEIGHT_4) +#ifdef TREZOR_FONT_DEMIBOLD_ENABLE +#define FONT_MAX_HEIGHT_5 \ + MAX_FONT_H(FONT_DEMIBOLD_MAX_HEIGHT, FONT_MAX_HEIGHT_4) #else -#define FONT_MAX_HEIGHT FONT_MAX_HEIGHT_4 +#define FONT_MAX_HEIGHT_5 FONT_MAX_HEIGHT_4 +#endif + +#ifdef TREZOR_FONT_MONO_ENABLE +#define FONT_MAX_HEIGHT MAX_FONT_H(FONT_MONO_MAX_HEIGHT, FONT_MAX_HEIGHT_5) +#else +#define FONT_MAX_HEIGHT FONT_MAX_HEIGHT_5 #endif int font_height(int font); diff --git a/core/embed/rust/src/ui/display/font.rs b/core/embed/rust/src/ui/display/font.rs index 8b929a0026..52866a0086 100644 --- a/core/embed/rust/src/ui/display/font.rs +++ b/core/embed/rust/src/ui/display/font.rs @@ -129,6 +129,7 @@ pub enum Font { NORMAL = 1, BOLD = 2, MONO = 3, + BIG = 4, DEMIBOLD = 5, }