From 991b3662f06ba1821d96262c22dc4ff8104a7cec Mon Sep 17 00:00:00 2001 From: obrusvit Date: Fri, 31 Jan 2025 13:56:34 +0100 Subject: [PATCH] refactor(core): do not expose fonts outside layouts - common components now take Font as a parameter, e.g. shape::Text - FormattedText now does not have `text_normal(txt)`, `text_bold(txt)` methods etc. but we use `text(txt, font)` instead [no changelog] --- core/embed/rust/src/ui/component/connect.rs | 21 +- core/embed/rust/src/ui/component/marquee.rs | 3 +- .../rust/src/ui/component/text/layout.rs | 12 +- core/embed/rust/src/ui/component/text/op.rs | 54 ++--- .../rust/src/ui/component/text/paragraphs.rs | 32 +-- core/embed/rust/src/ui/display/font.rs | 2 - .../rust/src/ui/layout_bolt/bootloader/mod.rs | 37 ++-- .../src/ui/layout_bolt/bootloader/welcome.rs | 40 ++-- .../src/ui/layout_bolt/component/button.rs | 6 +- .../ui/layout_bolt/component/homescreen.rs | 15 +- .../layout_bolt/component/keyboard/bip39.rs | 6 +- .../component/keyboard/passphrase.rs | 3 +- .../ui/layout_bolt/component/keyboard/pin.rs | 17 +- .../layout_bolt/component/keyboard/slip39.rs | 3 +- .../ui/layout_bolt/component/number_input.rs | 8 +- .../src/ui/layout_bolt/component/progress.rs | 6 +- .../src/ui/layout_bolt/component/result.rs | 7 +- .../ui/layout_bolt/component/share_words.rs | 9 +- .../layout_bolt/component/welcome_screen.rs | 6 +- .../src/ui/layout_bolt/theme/bootloader.rs | 47 ++--- .../rust/src/ui/layout_bolt/theme/mod.rs | 107 +++++----- .../rust/src/ui/layout_bolt/ui_firmware.rs | 18 +- .../src/ui/layout_caesar/bootloader/menu.rs | 19 +- .../src/ui/layout_caesar/bootloader/mod.rs | 23 +-- .../ui/layout_caesar/bootloader/welcome.rs | 45 ++-- .../ui/layout_caesar/component/bl_confirm.rs | 6 +- .../src/ui/layout_caesar/component/button.rs | 16 +- .../layout_caesar/component/changing_text.rs | 22 +- .../component/coinjoin_progress.rs | 9 +- .../ui/layout_caesar/component/homescreen.rs | 14 +- .../component/input_methods/choice_item.rs | 3 +- .../component/input_methods/pin.rs | 12 +- .../src/ui/layout_caesar/component/loader.rs | 3 +- .../ui/layout_caesar/component/progress.rs | 6 +- .../ui/layout_caesar/component/share_words.rs | 16 +- .../src/ui/layout_caesar/component/title.rs | 6 +- .../src/ui/layout_caesar/theme/bootloader.rs | 11 +- .../rust/src/ui/layout_caesar/theme/mod.rs | 22 +- .../rust/src/ui/layout_caesar/ui_firmware.rs | 56 ++--- .../src/ui/layout_delizia/bootloader/mod.rs | 31 +-- .../ui/layout_delizia/bootloader/welcome.rs | 20 +- .../src/ui/layout_delizia/component/button.rs | 6 +- .../src/ui/layout_delizia/component/footer.rs | 36 ++-- .../ui/layout_delizia/component/homescreen.rs | 19 +- .../component/keyboard/bip39.rs | 6 +- .../component/keyboard/passphrase.rs | 3 +- .../layout_delizia/component/keyboard/pin.rs | 11 +- .../component/keyboard/slip39.rs | 3 +- .../layout_delizia/component/number_input.rs | 6 +- .../component/number_input_slider.rs | 13 +- .../ui/layout_delizia/component/progress.rs | 6 +- .../src/ui/layout_delizia/component/result.rs | 7 +- .../layout_delizia/component/share_words.rs | 6 +- .../component/welcome_screen.rs | 5 +- .../src/ui/layout_delizia/theme/bootloader.rs | 47 ++--- .../rust/src/ui/layout_delizia/theme/mod.rs | 193 ++++++++++-------- .../rust/src/ui/layout_delizia/ui_firmware.rs | 23 ++- core/embed/rust/src/ui/shape/text.rs | 10 +- 58 files changed, 600 insertions(+), 599 deletions(-) diff --git a/core/embed/rust/src/ui/component/connect.rs b/core/embed/rust/src/ui/component/connect.rs index df9fd5747f..dab5760a59 100644 --- a/core/embed/rust/src/ui/component/connect.rs +++ b/core/embed/rust/src/ui/component/connect.rs @@ -2,7 +2,7 @@ use crate::{ strutil::TString, ui::{ component::{Component, Event, EventCtx, Never, Pad}, - display::{font::FONT_NORMAL, Color}, + display::{Color, Font}, geometry::{Alignment, Offset, Rect}, shape::{self, Renderer}, }, @@ -12,10 +12,11 @@ pub struct Connect { fg: Color, bg: Pad, message: TString<'static>, + font: Font, } impl Connect { - pub fn new(message: T, fg: Color, bg: Color) -> Self + pub fn new(message: T, font: Font, fg: Color, bg: Color) -> Self where T: Into>, { @@ -23,6 +24,7 @@ impl Connect { fg, bg: Pad::with_background(bg), message: message.into(), + font, }; instance.bg.clear(); @@ -43,16 +45,17 @@ impl Component for Connect { } fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { - let font = FONT_NORMAL; - self.bg.render(target); self.message.map(|t| { - shape::Text::new(self.bg.area.center() + Offset::y(font.text_height() / 2), t) - .with_fg(self.fg) - .with_font(font) - .with_align(Alignment::Center) - .render(target); + shape::Text::new( + self.bg.area.center() + Offset::y(self.font.text_height() / 2), + t, + self.font, + ) + .with_fg(self.fg) + .with_align(Alignment::Center) + .render(target); }); } } diff --git a/core/embed/rust/src/ui/component/marquee.rs b/core/embed/rust/src/ui/component/marquee.rs index 104a96c694..7c7ef5a6e0 100644 --- a/core/embed/rust/src/ui/component/marquee.rs +++ b/core/embed/rust/src/ui/component/marquee.rs @@ -124,8 +124,7 @@ impl Marquee { let text_height = self.font.text_height(); let pos = self.area.top_left() + Offset::new(offset, text_height - 1); self.text.map(|t| { - shape::Text::new(pos, t) - .with_font(self.font) + shape::Text::new(pos, t, self.font) .with_fg(self.fg) .render(target); }); diff --git a/core/embed/rust/src/ui/component/text/layout.rs b/core/embed/rust/src/ui/component/text/layout.rs index 6a49b70daa..20ccd892d9 100644 --- a/core/embed/rust/src/ui/component/text/layout.rs +++ b/core/embed/rust/src/ui/component/text/layout.rs @@ -511,16 +511,14 @@ where R: Renderer<'s>, { fn text(&mut self, cursor: Point, layout: &TextLayout, text: &str) { - shape::Text::new(cursor, text) - .with_font(layout.style.text_font) + shape::Text::new(cursor, text, layout.style.text_font) .with_fg(layout.style.text_color) .with_alpha(self.alpha) .render(self.renderer); } fn hyphen(&mut self, cursor: Point, layout: &TextLayout) { - shape::Text::new(cursor, "-") - .with_font(layout.style.text_font) + shape::Text::new(cursor, "-", layout.style.text_font) .with_fg(layout.style.hyphen_color) .with_alpha(self.alpha) .render(self.renderer); @@ -535,8 +533,7 @@ where .with_alpha(self.alpha) .render(self.renderer); } else { - shape::Text::new(cursor, ELLIPSIS) - .with_font(layout.style.text_font) + shape::Text::new(cursor, ELLIPSIS, layout.style.text_font) .with_fg(layout.style.ellipsis_color) .with_alpha(self.alpha) .render(self.renderer); @@ -551,8 +548,7 @@ where .with_alpha(self.alpha) .render(self.renderer); } else { - shape::Text::new(cursor, ELLIPSIS) - .with_font(layout.style.text_font) + shape::Text::new(cursor, ELLIPSIS, layout.style.text_font) .with_fg(layout.style.ellipsis_color) .with_alpha(self.alpha) .render(self.renderer); diff --git a/core/embed/rust/src/ui/component/text/op.rs b/core/embed/rust/src/ui/component/text/op.rs index 3c199b46a4..39e30ad395 100644 --- a/core/embed/rust/src/ui/component/text/op.rs +++ b/core/embed/rust/src/ui/component/text/op.rs @@ -1,10 +1,7 @@ use crate::{ strutil::TString, ui::{ - display::{ - font::{FONT_BOLD, FONT_BOLD_UPPER, FONT_DEMIBOLD, FONT_MONO, FONT_NORMAL}, - Color, Font, - }, + display::{Color, Font}, geometry::{Alignment, Offset, Rect}, util::ResultExt, }, @@ -111,13 +108,14 @@ impl<'a> OpTextLayout<'a> { }; } // Drawing text - Op::Text(text, continued) => { + Op::Text(text, font, continued) => { // Try to fit text on the current page and if they do not fit, // return the appropriate OutOfBounds message // Inserting the ellipsis at the very beginning of the text if needed // (just for incomplete texts that were separated) layout.continues_from_prev_page = continued; + layout.style.text_font = font; let fit = text.map(|t| layout.layout_text(t, cursor, sink)); @@ -162,7 +160,7 @@ impl<'a> OpTextLayout<'a> { let mut skipped = 0; ops_iter.filter_map(move |op| { match op { - Op::Text(text, _continued) if skipped < skip_bytes => { + Op::Text(text, font, _continued) if skipped < skip_bytes => { let skip_text_bytes_if_fits_partially = skip_bytes - skipped; skipped = skipped.saturating_add(text.len()); if skipped > skip_bytes { @@ -171,6 +169,7 @@ impl<'a> OpTextLayout<'a> { // Signifying that the text continues from previous page Some(Op::Text( text.skip_prefix(skip_text_bytes_if_fits_partially), + font, true, )) } else { @@ -201,26 +200,24 @@ impl<'a> OpTextLayout<'a> { self } - pub fn text(self, text: TString<'a>) -> Self { - self.with_new_item(Op::Text(text, false)) + pub fn text(self, text: impl Into>, font: Font) -> Self { + self.with_new_item(Op::Text(text.into(), font, false)) } pub fn newline(self) -> Self { - self.text("\n".into()) + let font = self.layout.style.text_font; + self.text("\n", font) } pub fn newline_half(self) -> Self { - self.text("\r".into()) + let font = self.layout.style.text_font; + self.text("\r", font) } pub fn next_page(self) -> Self { self.with_new_item(Op::NextPage) } - pub fn font(self, font: Font) -> Self { - self.with_new_item(Op::Font(font)) - } - pub fn offset(self, offset: Offset) -> Self { self.with_new_item(Op::CursorOffset(offset)) } @@ -240,31 +237,6 @@ impl<'a> OpTextLayout<'a> { pub fn line_spacing(self, spacing: i16) -> Self { self.with_new_item(Op::LineSpacing(spacing)) } -} - -// Op-adding aggregation operations -impl<'a> OpTextLayout<'a> { - // TODO: use TextStyle instead because we do not want e.g. BOLD_UPPER in all - // layouts - pub fn text_normal(self, text: impl Into>) -> Self { - self.font(FONT_NORMAL).text(text.into()) - } - - pub fn text_mono(self, text: impl Into>) -> Self { - self.font(FONT_MONO).text(text.into()) - } - - pub fn text_bold(self, text: impl Into>) -> Self { - self.font(FONT_BOLD).text(text.into()) - } - - pub fn text_bold_upper(self, text: impl Into>) -> Self { - self.font(FONT_BOLD_UPPER).text(text.into()) - } - - pub fn text_demibold(self, text: impl Into>) -> Self { - self.font(FONT_DEMIBOLD).text(text.into()) - } pub fn chunkify_text(self, chunks: Option<(Chunks, i16)>) -> Self { if let Some(chunks) = chunks { @@ -277,10 +249,10 @@ impl<'a> OpTextLayout<'a> { #[derive(Clone)] pub enum Op<'a> { - /// Render text with current color and font. + /// Render text with current color and specified font. /// Bool signifies whether this is a split Text Op continued from previous /// page. If true, a leading ellipsis will be rendered. - Text(TString<'a>, bool), + Text(TString<'a>, Font, bool), /// Set current text color. Color(Color), /// Set currently used font. diff --git a/core/embed/rust/src/ui/component/text/paragraphs.rs b/core/embed/rust/src/ui/component/text/paragraphs.rs index 421ca94712..e1075a7554 100644 --- a/core/embed/rust/src/ui/component/text/paragraphs.rs +++ b/core/embed/rust/src/ui/component/text/paragraphs.rs @@ -4,11 +4,7 @@ use crate::{ strutil::TString, ui::{ component::{Component, Event, EventCtx, Never, Paginate}, - display::{ - font::{FONT_NORMAL, FONT_SUB}, - toif::Icon, - Color, - }, + display::{font::Font, toif::Icon, Color}, geometry::{Alignment, Dimensions, Insets, LinearPlacement, Offset, Point, Rect}, shape::{self, Renderer}, }, @@ -559,13 +555,15 @@ pub struct Checklist { icon_current: Icon, icon_done: Icon, icon_done_color: Option, - show_numerals: bool, + numeral_font: Option, /// How wide will the left icon column be check_width: i16, /// Offset of the icon representing DONE done_offset: Offset, /// Offset of the icon representing CURRENT current_offset: Offset, + /// Offset of the numeral representing the ordinal number of the task + numeral_offset: Offset, } impl<'a, T> Checklist @@ -585,10 +583,11 @@ where icon_current, icon_done, icon_done_color: None, - show_numerals: false, + numeral_font: None, check_width: 0, done_offset: Offset::zero(), current_offset: Offset::zero(), + numeral_offset: Offset::zero(), } } @@ -612,8 +611,13 @@ where self } - pub fn with_numerals(mut self) -> Self { - self.show_numerals = true; + pub fn with_numerals(mut self, numerals_font: Font) -> Self { + self.numeral_font = Some(numerals_font); + self + } + + pub fn with_numeral_offset(mut self, offset: Offset) -> Self { + self.numeral_offset = offset; self } @@ -628,9 +632,9 @@ where self.render_icon(base + self.done_offset, self.icon_done, color, target) } else { // current and future tasks - ordinal numbers or icon on current task - if self.show_numerals { - let num_offset = Offset::new(4, FONT_NORMAL.visible_text_height("1")); - self.render_numeral(base + num_offset, i, l.style.text_color, target); + if let Some(font) = self.numeral_font { + let offset = self.numeral_offset; + self.render_numeral(base + offset, i, font, l.style.text_color, target); } else if i == current_visible { let color = l.style.text_color; self.render_icon(base + self.current_offset, self.icon_current, color, target); @@ -643,12 +647,12 @@ where &self, base_point: Point, n: usize, + font: Font, color: Color, target: &mut impl Renderer<'s>, ) { let numeral = uformat!("{}.", n + 1); - shape::Text::new(base_point, numeral.as_str()) - .with_font(FONT_SUB) + shape::Text::new(base_point, numeral.as_str(), font) .with_fg(color) .render(target); } diff --git a/core/embed/rust/src/ui/display/font.rs b/core/embed/rust/src/ui/display/font.rs index 3813068eed..a777136bac 100644 --- a/core/embed/rust/src/ui/display/font.rs +++ b/core/embed/rust/src/ui/display/font.rs @@ -7,8 +7,6 @@ use crate::ui::{ shape::{Bitmap, BitmapFormat}, }; -pub use super::super::fonts::*; - #[cfg(feature = "translations")] use crate::translations::flash; #[cfg(feature = "translations")] diff --git a/core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs b/core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs index 9fbc825de3..5476c6e9a3 100644 --- a/core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs +++ b/core/embed/rust/src/ui/layout_bolt/bootloader/mod.rs @@ -4,7 +4,7 @@ use crate::{ trezorhal::secbool::secbool, ui::{ component::{connect::Connect, Label}, - display::{self, font, Color, Icon}, + display::{self, Color, Icon}, geometry::{Point, Rect}, layout::simplified::{run, show}, }, @@ -16,8 +16,9 @@ use super::{ bl_confirm::{Confirm, ConfirmTitle}, Button, ResultScreen, WelcomeScreen, }, - theme, + fonts, theme::{ + self, bootloader::{ button_bld, button_bld_menu, button_confirm, button_wipe_cancel, button_wipe_confirm, BLD_BG, BLD_FG, BLD_TITLE_COLOR, BLD_WIPE_COLOR, CHECK24, CHECK40, DOWNLOAD32, FIRE32, @@ -73,11 +74,14 @@ impl UIBolt { display::sync(); render_on_display(None, Some(bg_color), |target| { - shape::Text::new(Point::new(SCREEN.width() / 2, SCREEN.height() - 45), text) - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(fg_color) - .render(target); + shape::Text::new( + Point::new(SCREEN.width() / 2, SCREEN.height() - 45), + text, + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(fg_color) + .render(target); let center = SCREEN.center() + Offset::y(-20); let inactive_color = bg_color.blend(fg_color, 85); @@ -319,7 +323,12 @@ impl BootloaderUI for UIBolt { fn screen_connect(initial_setup: bool) { let bg = if initial_setup { WELCOME_COLOR } else { BLD_BG }; - let mut frame = Connect::new("Waiting for host...", BLD_TITLE_COLOR, bg); + let mut frame = Connect::new( + "Waiting for host...", + fonts::FONT_NORMAL, + BLD_TITLE_COLOR, + bg, + ); show(&mut frame, true); } @@ -383,9 +392,8 @@ impl BootloaderUI for UIBolt { // Draw vendor string if present if let Some(text) = vendor_str { let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5 - 50); - shape::Text::new(pos, text) + shape::Text::new(pos, text, fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) //COLOR_BL_BG .render(target); @@ -400,9 +408,8 @@ impl BootloaderUI for UIBolt { version[2] )); - shape::Text::new(pos, version_text.as_str()) + shape::Text::new(pos, version_text.as_str(), fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } @@ -415,17 +422,15 @@ impl BootloaderUI for UIBolt { unwrap!(uwrite!(text, "starting in {} s", wait)); let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5); - shape::Text::new(pos, text.as_str()) + shape::Text::new(pos, text.as_str(), fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } core::cmp::Ordering::Less => { let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5); - shape::Text::new(pos, "click to continue ...") + shape::Text::new(pos, "click to continue ...", fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } diff --git a/core/embed/rust/src/ui/layout_bolt/bootloader/welcome.rs b/core/embed/rust/src/ui/layout_bolt/bootloader/welcome.rs index 7e6dbbdd52..c7630786c0 100644 --- a/core/embed/rust/src/ui/layout_bolt/bootloader/welcome.rs +++ b/core/embed/rust/src/ui/layout_bolt/bootloader/welcome.rs @@ -1,15 +1,17 @@ use crate::ui::{ component::{Component, Event, EventCtx, Never, Pad}, constant::screen, - display::{font, toif::Toif}, + display::toif::Toif, geometry::{Alignment, Alignment2D, Offset, Rect}, - shape, - shape::Renderer, + shape::{self, Renderer}, }; -use super::super::theme::{ - bootloader::{START_URL, WELCOME_COLOR}, - GREY_MEDIUM, WHITE, +use super::super::{ + fonts, + theme::{ + bootloader::{START_URL, WELCOME_COLOR}, + GREY_MEDIUM, WHITE, + }, }; pub struct Welcome { @@ -39,17 +41,23 @@ impl Component for Welcome { fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { self.bg.render(target); - shape::Text::new(screen().top_center() + Offset::y(102), "Get started with") - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(GREY_MEDIUM) - .render(target); + shape::Text::new( + screen().top_center() + Offset::y(102), + "Get started with", + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(GREY_MEDIUM) + .render(target); - shape::Text::new(screen().top_center() + Offset::y(126), "your Trezor at") - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(GREY_MEDIUM) - .render(target); + shape::Text::new( + screen().top_center() + Offset::y(126), + "your Trezor at", + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(GREY_MEDIUM) + .render(target); let icon = unwrap!(Toif::new(START_URL)); shape::ToifImage::new(screen().top_center() + Offset::y(135), icon) diff --git a/core/embed/rust/src/ui/layout_bolt/component/button.rs b/core/embed/rust/src/ui/layout_bolt/component/button.rs index 978025a379..3577d1db98 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/button.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/button.rs @@ -186,8 +186,7 @@ impl Button { + Offset::new(-width / 2, height / 2) + Offset::y(Self::BASELINE_OFFSET); text.map(|text| { - shape::Text::new(start_of_baseline, text) - .with_font(style.font) + shape::Text::new(start_of_baseline, text, style.font) .with_fg(style.text_color) .render(target); }); @@ -548,8 +547,7 @@ impl IconText { } if use_text { - shape::Text::new(text_pos, self.text) - .with_font(style.font) + shape::Text::new(text_pos, self.text, style.font) .with_fg(style.text_color) .render(target); } diff --git a/core/embed/rust/src/ui/layout_bolt/component/homescreen.rs b/core/embed/rust/src/ui/layout_bolt/component/homescreen.rs index 504f5c2480..9696777457 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/homescreen.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/homescreen.rs @@ -7,7 +7,6 @@ use crate::{ ui::{ component::{text::TextStyle, Component, Event, EventCtx, Pad, Timer}, display::{ - font, image::{ImageInfo, ToifFormat}, toif::Icon, Color, @@ -22,7 +21,7 @@ use crate::{ use crate::ui::constant::{HEIGHT, WIDTH}; use super::{ - super::{constant, theme::IMAGE_HOMESCREEN}, + super::{constant, fonts, theme::IMAGE_HOMESCREEN}, theme, Loader, LoaderMsg, }; @@ -120,9 +119,8 @@ impl Homescreen { fn render_loader<'s>(&'s self, target: &mut impl Renderer<'s>) { TR::progress__locking_device.map_translated(|t| { - shape::Text::new(TOP_CENTER + Offset::y(HOLD_Y), t) + shape::Text::new(TOP_CENTER + Offset::y(HOLD_Y), t, fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(theme::FG); }); self.loader.render(target) @@ -233,9 +231,8 @@ impl Component for Homescreen { let style = theme::TEXT_DEMIBOLD; let pos = Point::new(self.pad.area.center().x, LABEL_Y); - shape::Text::new(pos, t) + shape::Text::new(pos, t, style.text_font) .with_align(Alignment::Center) - .with_font(style.text_font) .with_fg(theme::FG) .render(target); }); @@ -267,8 +264,7 @@ impl Component for Homescreen { style.text_font.vert_center(banner.y0, banner.y1, "A"), ); - shape::Text::new(text_pos, t) - .with_font(style.text_font) + shape::Text::new(text_pos, t, style.text_font) .with_fg(style.text_color) .render(target); @@ -401,8 +397,7 @@ impl Component for Lockscreen<'_> { 0, ) + item.offset; - shape::Text::new(text_pos, t) - .with_font(item.style.text_font) + shape::Text::new(text_pos, t, item.style.text_font) .with_fg(item.style.text_color) .render(target); diff --git a/core/embed/rust/src/ui/layout_bolt/component/keyboard/bip39.rs b/core/embed/rust/src/ui/layout_bolt/component/keyboard/bip39.rs index 9ba528d58f..bff9298b93 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/keyboard/bip39.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/keyboard/bip39.rs @@ -113,8 +113,7 @@ impl Component for Bip39Input { // Content starts in the left-center point, offset by 16px to the right and 8px // to the bottom. let text_baseline = area.top_left().center(area.bottom_left()) + Offset::new(16, 8); - shape::Text::new(text_baseline, text) - .with_font(style.font) + shape::Text::new(text_baseline, text, style.font) .with_fg(style.text_color) .render(target); @@ -122,8 +121,7 @@ impl Component for Bip39Input { if let Some(word) = self.suggested_word.and_then(|w| w.get(text.len()..)) { let word_baseline = text_baseline + Offset::new(width, 0); let style = self.button_suggestion.style(); - shape::Text::new(word_baseline, word) - .with_font(style.font) + shape::Text::new(word_baseline, word, style.font) .with_fg(style.text_color) .render(target); } diff --git a/core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs b/core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs index 5bdde78d83..d4c71b3ecf 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs @@ -355,8 +355,7 @@ impl Component for Input { let text_to_display = long_line_content_with_ellipsis(text, "...", style.text_font, available_area_width); - shape::Text::new(text_baseline, &text_to_display) - .with_font(style.text_font) + shape::Text::new(text_baseline, &text_to_display, style.text_font) .with_fg(style.text_color) .render(target); diff --git a/core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs b/core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs index feba4d6262..987d45dec8 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/keyboard/pin.rs @@ -9,7 +9,6 @@ use crate::{ base::ComponentExt, text::TextStyle, Child, Component, Event, EventCtx, Label, Maybe, Never, Pad, Timer, }, - display::font, event::TouchEvent, geometry::{Alignment, Alignment2D, Grid, Insets, Offset, Rect}, shape::{self, Renderer}, @@ -17,6 +16,7 @@ use crate::{ }; use super::super::{ + super::fonts, button::{ Button, ButtonContent, ButtonMsg::{self, Clicked}, @@ -363,22 +363,20 @@ impl PinDots { } fn render_digits<'s>(&self, area: Rect, target: &mut impl Renderer<'s>) { - let center = area.center() + Offset::y(font::FONT_MONO.text_height() / 2); + let center = area.center() + Offset::y(fonts::FONT_MONO.text_height() / 2); let right = - center + Offset::x(font::FONT_MONO.text_width("0") * (MAX_VISIBLE_DOTS as i16) / 2); + center + Offset::x(fonts::FONT_MONO.text_width("0") * (MAX_VISIBLE_DOTS as i16) / 2); let digits = self.digits.len(); if digits <= MAX_VISIBLE_DOTS { - shape::Text::new(center, &self.digits) + shape::Text::new(center, &self.digits, fonts::FONT_MONO) .with_align(Alignment::Center) - .with_font(font::FONT_MONO) .with_fg(self.style.text_color) .render(target); } else { let offset: usize = digits.saturating_sub(MAX_VISIBLE_DIGITS); - shape::Text::new(right, &self.digits[offset..]) + shape::Text::new(right, &self.digits[offset..], fonts::FONT_MONO) .with_align(Alignment::End) - .with_font(font::FONT_MONO) .with_fg(self.style.text_color) .render(target); } @@ -422,11 +420,10 @@ impl PinDots { } if last_digit && digits > 0 { let last = &self.digits[(digits - 1)..digits]; - cursor.y = area.center().y + (font::FONT_MONO.text_height() / 2); + cursor.y = area.center().y + (fonts::FONT_MONO.text_height() / 2); let offset = Offset::x(Self::DOT / 2); - shape::Text::new(cursor + offset, last) + shape::Text::new(cursor + offset, last, fonts::FONT_MONO) .with_align(Alignment::Center) - .with_font(font::FONT_MONO) .with_fg(self.style.text_color) .render(target); } else { diff --git a/core/embed/rust/src/ui/layout_bolt/component/keyboard/slip39.rs b/core/embed/rust/src/ui/layout_bolt/component/keyboard/slip39.rs index e1fa99222e..90882722ac 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/keyboard/slip39.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/keyboard/slip39.rs @@ -156,8 +156,7 @@ impl Component for Slip39Input { .assert_if_debugging_ui("Text buffer is too small"); } } - shape::Text::new(text_baseline, text.as_str()) - .with_font(style.font) + shape::Text::new(text_baseline, text.as_str(), style.font) .with_fg(style.text_color) .render(target); diff --git a/core/embed/rust/src/ui/layout_bolt/component/number_input.rs b/core/embed/rust/src/ui/layout_bolt/component/number_input.rs index f752f8b23c..0ffaabe61a 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/number_input.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/number_input.rs @@ -9,13 +9,12 @@ use crate::{ text::paragraphs::{Paragraph, Paragraphs}, Child, Component, Event, EventCtx, Pad, }, - display::font, geometry::{Alignment, Grid, Insets, Offset, Rect}, shape::{self, Renderer}, }, }; -use super::{theme, Button, ButtonMsg}; +use super::{super::fonts, theme, Button, ButtonMsg}; #[cfg_attr(feature = "debug", derive(ufmt::derive::uDebug))] pub enum NumberInputDialogMsg { @@ -206,14 +205,13 @@ impl Component for NumberInput { let mut buf = [0u8; 10]; if let Some(text) = strutil::format_i64(self.value as i64, &mut buf) { - let digit_font = font::FONT_DEMIBOLD; + let digit_font = fonts::FONT_DEMIBOLD; let y_offset = digit_font.text_height() / 2 + Button::BASELINE_OFFSET; shape::Bar::new(self.area).with_bg(theme::BG).render(target); - shape::Text::new(self.area.center() + Offset::y(y_offset), text) + shape::Text::new(self.area.center() + Offset::y(y_offset), text, digit_font) .with_align(Alignment::Center) .with_fg(theme::FG) - .with_font(digit_font) .render(target); } diff --git a/core/embed/rust/src/ui/layout_bolt/component/progress.rs b/core/embed/rust/src/ui/layout_bolt/component/progress.rs index f938d4400f..18177938eb 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/progress.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/progress.rs @@ -13,14 +13,14 @@ use crate::{ text::paragraphs::{Paragraph, Paragraphs}, Child, Component, Event, EventCtx, Label, Never, Pad, }, - display::{font, LOADER_MAX}, + display::LOADER_MAX, geometry::{Insets, Offset, Rect}, shape::Renderer, util::animation_disabled, }, }; -use super::super::constant; +use super::super::{constant, fonts}; pub struct Progress { title: Child>, @@ -65,7 +65,7 @@ impl Component for Progress { .map(|t| t.chars().filter(|c| *c == '\n').count() as i16); let (title, rest) = Self::AREA.split_top(self.title.inner().max_size().y); let (loader, description) = - rest.split_bottom(font::FONT_NORMAL.line_height() * description_lines); + rest.split_bottom(fonts::FONT_NORMAL.line_height() * description_lines); let loader = loader.inset(Insets::top(theme::CONTENT_BORDER)); self.title.place(title); self.loader_y_offset = loader.center().y - constant::screen().center().y; diff --git a/core/embed/rust/src/ui/layout_bolt/component/result.rs b/core/embed/rust/src/ui/layout_bolt/component/result.rs index a5435c6a11..1752cf4f34 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/result.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/result.rs @@ -3,7 +3,7 @@ use crate::{ ui::{ component::{text::TextStyle, Child, Component, Event, EventCtx, Label, Never, Pad}, constant::screen, - display::{font, Color, Icon}, + display::{Color, Icon}, geometry::{Alignment2D, Insets, Offset, Point, Rect}, shape, shape::Renderer, @@ -12,6 +12,7 @@ use crate::{ use super::super::{ constant::WIDTH, + fonts, theme::{FG, RESULT_FOOTER_START, RESULT_PADDING}, }; @@ -34,11 +35,11 @@ impl ResultStyle { } pub const fn message_style(&self) -> TextStyle { - TextStyle::new(font::FONT_NORMAL, self.fg_color, self.bg_color, FG, FG) + TextStyle::new(fonts::FONT_NORMAL, self.fg_color, self.bg_color, FG, FG) } pub const fn title_style(&self) -> TextStyle { - TextStyle::new(font::FONT_BOLD_UPPER, self.fg_color, self.bg_color, FG, FG) + TextStyle::new(fonts::FONT_BOLD_UPPER, self.fg_color, self.bg_color, FG, FG) } } diff --git a/core/embed/rust/src/ui/layout_bolt/component/share_words.rs b/core/embed/rust/src/ui/layout_bolt/component/share_words.rs index 9b385dff58..4c17e1bf05 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/share_words.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/share_words.rs @@ -2,13 +2,13 @@ use crate::{ strutil::TString, ui::{ component::{Component, Event, EventCtx, Never, Paginate}, - display::{font, Font}, + display::Font, geometry::{Offset, Rect}, shape::{self, Renderer}, }, }; -use super::super::theme; +use super::super::{fonts, theme}; use heapless::Vec; #[cfg(feature = "ui_debug")] @@ -16,7 +16,7 @@ use ufmt::uwrite; const WORDS_PER_PAGE: usize = 4; const TOP_PADDING_OFFSET: i16 = 13; -const WORD_FONT: Font = font::FONT_MONO; +const WORD_FONT: Font = fonts::FONT_MONO; const MAX_WORDS: usize = 33; // super-shamir has 33 words, all other have less /// Showing the given share words. @@ -75,8 +75,7 @@ impl<'a> Component for ShareWords<'a> { } else { uformat!(" {}. {}", ordinal, w) }; - shape::Text::new(base, &text_fmt) - .with_font(WORD_FONT) + shape::Text::new(base, &text_fmt, WORD_FONT) .with_fg(theme::FG) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_bolt/component/welcome_screen.rs b/core/embed/rust/src/ui/layout_bolt/component/welcome_screen.rs index bb4e5b5bab..9ff915893c 100644 --- a/core/embed/rust/src/ui/layout_bolt/component/welcome_screen.rs +++ b/core/embed/rust/src/ui/layout_bolt/component/welcome_screen.rs @@ -5,6 +5,8 @@ use crate::ui::{ shape::Renderer, }; +#[cfg(not(feature = "bootloader"))] +use super::super::fonts; use super::theme; #[cfg(feature = "bootloader")] use super::theme::bootloader::DEVICE_NAME; @@ -19,7 +21,7 @@ use crate::{ ui::{display, geometry::Alignment}, }; #[cfg(not(feature = "bootloader"))] -const MODEL_NAME_FONT: display::Font = display::font::FONT_DEMIBOLD; +const MODEL_NAME_FONT: display::Font = fonts::FONT_DEMIBOLD; pub struct WelcomeScreen { area: Rect, @@ -66,9 +68,9 @@ impl Component for WelcomeScreen { shape::Text::new( self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN), model::FULL_NAME, + MODEL_NAME_FONT, ) .with_align(Alignment::Center) - .with_font(MODEL_NAME_FONT) .with_fg(theme::FG) .render(target); diff --git a/core/embed/rust/src/ui/layout_bolt/theme/bootloader.rs b/core/embed/rust/src/ui/layout_bolt/theme/bootloader.rs index 3569841f69..56c948a132 100644 --- a/core/embed/rust/src/ui/layout_bolt/theme/bootloader.rs +++ b/core/embed/rust/src/ui/layout_bolt/theme/bootloader.rs @@ -1,13 +1,14 @@ use crate::ui::{ component::{text::TextStyle, LineBreaking::BreakWordsNoHyphen}, constant::{HEIGHT, WIDTH}, - display::{font, Color}, + display::Color, geometry::{Offset, Point, Rect}, util::include_res, }; use super::super::{ component::{ButtonStyle, ButtonStyleSheet, ResultStyle}, + fonts, theme::{BLACK, FG, GREY_DARK, GREY_LIGHT, WHITE}, }; @@ -76,7 +77,7 @@ pub const START_URL: &[u8] = include_res!("layout_bolt/res/start.toif"); pub fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_BG, button_color: WHITE, background_color: BLD_BG, @@ -85,7 +86,7 @@ pub fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_BG, button_color: BLD_INSTALL_BTN_COLOR_ACTIVE, background_color: BLD_BG, @@ -94,7 +95,7 @@ pub fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREY_DARK, background_color: FG, @@ -108,7 +109,7 @@ pub fn button_confirm() -> ButtonStyleSheet { pub fn button_wipe_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: WHITE, button_color: BLD_WIPE_CANCEL_BTN_COLOR, background_color: BLD_WIPE_COLOR, @@ -117,7 +118,7 @@ pub fn button_wipe_cancel() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: WHITE, button_color: BLD_WIPE_CANCEL_BTN_COLOR_ACTIVE, background_color: BLD_WIPE_COLOR, @@ -126,7 +127,7 @@ pub fn button_wipe_cancel() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: WHITE, @@ -140,7 +141,7 @@ pub fn button_wipe_cancel() -> ButtonStyleSheet { pub fn button_wipe_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_WIPE_COLOR, button_color: BLD_WIPE_BTN_COLOR, background_color: BLD_WIPE_COLOR, @@ -149,7 +150,7 @@ pub fn button_wipe_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_WIPE_COLOR, button_color: BLD_WIPE_BTN_COLOR_ACTIVE, background_color: BLD_WIPE_COLOR, @@ -158,7 +159,7 @@ pub fn button_wipe_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREY_DARK, background_color: FG, @@ -172,7 +173,7 @@ pub fn button_wipe_confirm() -> ButtonStyleSheet { pub fn button_bld_menu() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_FG, button_color: BLD_BG, background_color: BLD_BG, @@ -181,7 +182,7 @@ pub fn button_bld_menu() -> ButtonStyleSheet { border_width: 2, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_FG, button_color: BLD_BG, background_color: BLD_BG, @@ -190,7 +191,7 @@ pub fn button_bld_menu() -> ButtonStyleSheet { border_width: 2, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: BLD_BG, background_color: BLD_BG, @@ -204,7 +205,7 @@ pub fn button_bld_menu() -> ButtonStyleSheet { pub fn button_bld() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_FG, button_color: BLD_BTN_COLOR, background_color: BLD_BG, @@ -213,7 +214,7 @@ pub fn button_bld() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: BLD_FG, button_color: BLD_BTN_COLOR_ACTIVE, background_color: BLD_BG, @@ -222,7 +223,7 @@ pub fn button_bld() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: BLD_BTN_COLOR, background_color: BLD_BG, @@ -235,7 +236,7 @@ pub fn button_bld() -> ButtonStyleSheet { pub const fn text_title(bg: Color) -> TextStyle { TextStyle::new( - font::FONT_BOLD_UPPER, + fonts::FONT_BOLD_UPPER, BLD_TITLE_COLOR, bg, BLD_TITLE_COLOR, @@ -244,29 +245,29 @@ pub const fn text_title(bg: Color) -> TextStyle { } pub const TEXT_NORMAL: TextStyle = - TextStyle::new(font::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); + TextStyle::new(fonts::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); pub const TEXT_WARNING: TextStyle = TextStyle::new( - font::FONT_BOLD_UPPER, + fonts::FONT_BOLD_UPPER, BLD_WARN_COLOR, BLD_BG, BLD_WARN_COLOR, BLD_WARN_COLOR, ); pub const fn text_fingerprint(bg: Color) -> TextStyle { - TextStyle::new(font::FONT_NORMAL, BLD_FG, bg, BLD_FG, BLD_FG) + TextStyle::new(fonts::FONT_NORMAL, BLD_FG, bg, BLD_FG, BLD_FG) .with_line_breaking(BreakWordsNoHyphen) } pub const TEXT_BOLD: TextStyle = - TextStyle::new(font::FONT_BOLD_UPPER, BLD_FG, BLD_BG, BLD_FG, BLD_FG); + TextStyle::new(fonts::FONT_BOLD_UPPER, BLD_FG, BLD_BG, BLD_FG, BLD_FG); pub const TEXT_WIPE_BOLD: TextStyle = TextStyle::new( - font::FONT_BOLD_UPPER, + fonts::FONT_BOLD_UPPER, BLD_WIPE_TEXT_COLOR, BLD_WIPE_COLOR, BLD_WIPE_TEXT_COLOR, BLD_WIPE_TEXT_COLOR, ); pub const TEXT_WIPE_NORMAL: TextStyle = TextStyle::new( - font::FONT_NORMAL, + fonts::FONT_NORMAL, BLD_WIPE_TEXT_COLOR, BLD_WIPE_COLOR, BLD_WIPE_TEXT_COLOR, diff --git a/core/embed/rust/src/ui/layout_bolt/theme/mod.rs b/core/embed/rust/src/ui/layout_bolt/theme/mod.rs index 17a1f6e25d..17dfbf8749 100644 --- a/core/embed/rust/src/ui/layout_bolt/theme/mod.rs +++ b/core/embed/rust/src/ui/layout_bolt/theme/mod.rs @@ -8,13 +8,16 @@ use crate::{ text::{layout::Chunks, LineBreaking, PageBreaking, TextStyle}, FixedHeightBar, }, - display::{font, Color}, + display::Color, geometry::{Insets, Offset}, util::{include_icon, include_res}, }, }; -use super::component::{ButtonStyle, ButtonStyleSheet, LoaderStyle, LoaderStyleSheet, ResultStyle}; +use super::{ + component::{ButtonStyle, ButtonStyleSheet, LoaderStyle, LoaderStyleSheet, ResultStyle}, + fonts, +}; pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500); @@ -118,15 +121,15 @@ pub const fn label_default() -> TextStyle { } pub const fn label_keyboard() -> TextStyle { - TextStyle::new(font::FONT_DEMIBOLD, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_DEMIBOLD, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT) } pub const fn label_keyboard_prompt() -> TextStyle { - TextStyle::new(font::FONT_DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) } pub const fn label_keyboard_warning() -> TextStyle { - TextStyle::new(font::FONT_DEMIBOLD, RED, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_DEMIBOLD, RED, BG, GREY_LIGHT, GREY_LIGHT) } pub const fn label_keyboard_minor() -> TextStyle { @@ -155,7 +158,7 @@ pub const fn label_progress() -> TextStyle { pub const fn label_title() -> TextStyle { TextStyle::new( - font::FONT_BOLD_UPPER, + fonts::FONT_BOLD_UPPER, GREY_LIGHT, BG, GREY_LIGHT, @@ -164,17 +167,17 @@ pub const fn label_title() -> TextStyle { } pub const fn label_subtitle() -> TextStyle { - TextStyle::new(font::FONT_MONO, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_MONO, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) } pub const fn label_coinjoin_progress() -> TextStyle { - TextStyle::new(font::FONT_BOLD_UPPER, FG, YELLOW, FG, FG) + TextStyle::new(fonts::FONT_BOLD_UPPER, FG, YELLOW, FG, FG) } pub const fn button_default() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -183,7 +186,7 @@ pub const fn button_default() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -192,7 +195,7 @@ pub const fn button_default() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -206,7 +209,7 @@ pub const fn button_default() -> ButtonStyleSheet { pub const fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREEN, background_color: BG, @@ -215,7 +218,7 @@ pub const fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -224,7 +227,7 @@ pub const fn button_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: GREEN_DARK, background_color: BG, @@ -238,7 +241,7 @@ pub const fn button_confirm() -> ButtonStyleSheet { pub const fn button_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: RED, background_color: BG, @@ -247,7 +250,7 @@ pub const fn button_cancel() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: RED_DARK, background_color: BG, @@ -256,7 +259,7 @@ pub const fn button_cancel() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: RED, background_color: BG, @@ -274,7 +277,7 @@ pub const fn button_danger() -> ButtonStyleSheet { pub const fn button_reset() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: YELLOW, background_color: BG, @@ -283,7 +286,7 @@ pub const fn button_reset() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: YELLOW_DARK, background_color: BG, @@ -292,7 +295,7 @@ pub const fn button_reset() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: YELLOW, background_color: BG, @@ -306,7 +309,7 @@ pub const fn button_reset() -> ButtonStyleSheet { pub const fn button_moreinfo() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: BG, background_color: BG, @@ -315,7 +318,7 @@ pub const fn button_moreinfo() -> ButtonStyleSheet { border_width: 2, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: BG, background_color: BG, @@ -324,7 +327,7 @@ pub const fn button_moreinfo() -> ButtonStyleSheet { border_width: 2, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: BG, background_color: BG, @@ -338,7 +341,7 @@ pub const fn button_moreinfo() -> ButtonStyleSheet { pub const fn button_info() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: BLUE, background_color: BG, @@ -347,7 +350,7 @@ pub const fn button_info() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: FG, button_color: BLUE_DARK, background_color: BG, @@ -356,7 +359,7 @@ pub const fn button_info() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_BOLD_UPPER, + font: fonts::FONT_BOLD_UPPER, text_color: GREY_LIGHT, button_color: BLUE, background_color: BG, @@ -370,7 +373,7 @@ pub const fn button_info() -> ButtonStyleSheet { pub const fn button_pin() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -379,7 +382,7 @@ pub const fn button_pin() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -388,7 +391,7 @@ pub const fn button_pin() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: BG, // so there is no "button" itself, just the text background_color: BG, @@ -402,7 +405,7 @@ pub const fn button_pin() -> ButtonStyleSheet { pub const fn button_pin_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN, background_color: BG, @@ -411,7 +414,7 @@ pub const fn button_pin_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -420,7 +423,7 @@ pub const fn button_pin_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -434,7 +437,7 @@ pub const fn button_pin_confirm() -> ButtonStyleSheet { pub const fn button_pin_autocomplete() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREY_DARK, // same as PIN buttons background_color: BG, @@ -443,7 +446,7 @@ pub const fn button_pin_autocomplete() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -452,7 +455,7 @@ pub const fn button_pin_autocomplete() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: BG, background_color: BG, @@ -466,7 +469,7 @@ pub const fn button_pin_autocomplete() -> ButtonStyleSheet { pub const fn button_suggestion_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREEN_DARK, button_color: GREEN, background_color: BG, @@ -475,7 +478,7 @@ pub const fn button_suggestion_confirm() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -484,7 +487,7 @@ pub const fn button_suggestion_confirm() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -498,7 +501,7 @@ pub const fn button_suggestion_confirm() -> ButtonStyleSheet { pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: GREY_DARK, // same as PIN buttons background_color: BG, @@ -507,7 +510,7 @@ pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_DARK, background_color: BG, @@ -516,7 +519,7 @@ pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_LIGHT, button_color: BG, background_color: BG, @@ -530,7 +533,7 @@ pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { pub const fn button_counter() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: FG, button_color: GREY_DARK, background_color: BG, @@ -539,7 +542,7 @@ pub const fn button_counter() -> ButtonStyleSheet { border_width: 0, }, active: &ButtonStyle { - font: font::FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: FG, button_color: GREY_MEDIUM, background_color: BG, @@ -548,7 +551,7 @@ pub const fn button_counter() -> ButtonStyleSheet { border_width: 0, }, disabled: &ButtonStyle { - font: font::FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: GREY_DARK, background_color: BG, @@ -594,12 +597,12 @@ pub const fn loader_lock_icon() -> LoaderStyleSheet { } pub const TEXT_NORMAL: TextStyle = - TextStyle::new(font::FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); pub const TEXT_DEMIBOLD: TextStyle = - TextStyle::new(font::FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); pub const TEXT_BOLD: TextStyle = - TextStyle::new(font::FONT_BOLD_UPPER, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_MONO: TextStyle = TextStyle::new(font::FONT_MONO, FG, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_BOLD_UPPER, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_MONO: TextStyle = TextStyle::new(fonts::FONT_MONO, FG, BG, GREY_LIGHT, GREY_LIGHT) .with_line_breaking(LineBreaking::BreakWordsNoHyphen) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_PAGE_NEXT, 0) @@ -630,13 +633,13 @@ pub fn get_chunkified_text_style(character_length: usize) -> &'static TextStyle } pub const TEXT_NORMAL_OFF_WHITE: TextStyle = - TextStyle::new(font::FONT_NORMAL, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_NORMAL, OFF_WHITE, BG, GREY_LIGHT, GREY_LIGHT); pub const TEXT_CHECKLIST_DEFAULT: TextStyle = - TextStyle::new(font::FONT_NORMAL, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_NORMAL, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT); pub const TEXT_CHECKLIST_SELECTED: TextStyle = - TextStyle::new(font::FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); pub const TEXT_CHECKLIST_DONE: TextStyle = - TextStyle::new(font::FONT_NORMAL, GREEN_DARK, BG, GREY_LIGHT, GREY_LIGHT); + TextStyle::new(fonts::FONT_NORMAL, GREEN_DARK, BG, GREY_LIGHT, GREY_LIGHT); pub const CONTENT_BORDER: i16 = 0; pub const BUTTON_HEIGHT: i16 = 50; diff --git a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs index 60a6ff5656..be68f5d192 100644 --- a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs @@ -40,7 +40,7 @@ use super::{ PassphraseKeyboard, PinKeyboard, Progress, SelectWordCount, SetBrightnessDialog, ShareWords, SimplePage, Slip39Input, }, - theme, UIBolt, + fonts, theme, UIBolt, }; impl FirmwareUI for UIBolt { @@ -187,14 +187,14 @@ impl FirmwareUI for UIBolt { let mut ops = OpTextLayout::new(theme::TEXT_NORMAL); for item in IterBuf::new().try_iterate(items)? { if item.is_str() { - ops = ops.text_normal(TString::try_from(item)?) + ops = ops.text(TString::try_from(item)?, fonts::FONT_NORMAL) } else { let [emphasis, text]: [Obj; 2] = util::iter_into_array(item)?; let text: TString = text.try_into()?; if emphasis.try_into()? { - ops = ops.text_demibold(text); + ops = ops.text(text, fonts::FONT_DEMIBOLD) } else { - ops = ops.text_normal(text); + ops = ops.text(text, fonts::FONT_NORMAL); } } } @@ -1109,7 +1109,8 @@ impl FirmwareUI for UIBolt { } fn show_wait_text(text: TString<'static>) -> Result { - let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + let layout = + RootComponent::new(Connect::new(text, fonts::FONT_NORMAL, theme::FG, theme::BG)); Ok(layout) } @@ -1335,8 +1336,11 @@ mod tests { ); let ops = OpTextLayout::new(theme::TEXT_NORMAL) - .text_normal("Testing text layout, with some text, and some more text. And ") - .text_bold_upper("parameters!"); + .text( + "Testing text layout, with some text, and some more text. And ", + fonts::FONT_NORMAL, + ) + .text("parameters!", fonts::FONT_BOLD_UPPER); let formatted = FormattedText::new(ops); let mut layout = Dialog::new(formatted, buttons); layout.place(SCREEN); diff --git a/core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs b/core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs index 56dd5437a1..88371fdc89 100644 --- a/core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs +++ b/core/embed/rust/src/ui/layout_caesar/bootloader/menu.rs @@ -5,7 +5,7 @@ use crate::{ ui::{ component::{Child, Component, Event, EventCtx, Pad}, constant::screen, - display::{font, Icon}, + display::Icon, geometry::{Alignment, Alignment2D, Offset, Point, Rect}, layout::simplified::ReturnToC, shape, @@ -15,6 +15,7 @@ use crate::{ use super::super::{ component::{ButtonLayout, Choice, ChoiceFactory, ChoicePage}, + fonts, theme::bootloader::{BLD_BG, BLD_FG, ICON_EXIT, ICON_REDO, ICON_TRASH}, }; @@ -58,17 +59,19 @@ impl Choice for MenuChoice { .with_fg(BLD_FG) .render(target); - shape::Text::new(SCREEN_CENTER, self.first_line) + shape::Text::new(SCREEN_CENTER, self.first_line, fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); - shape::Text::new(SCREEN_CENTER + Offset::y(10), self.second_line) - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(BLD_FG) - .render(target); + shape::Text::new( + SCREEN_CENTER + Offset::y(10), + self.second_line, + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(BLD_FG) + .render(target); } fn btn_layout(&self) -> ButtonLayout { diff --git a/core/embed/rust/src/ui/layout_caesar/bootloader/mod.rs b/core/embed/rust/src/ui/layout_caesar/bootloader/mod.rs index b4da01866f..ce80c5fd84 100644 --- a/core/embed/rust/src/ui/layout_caesar/bootloader/mod.rs +++ b/core/embed/rust/src/ui/layout_caesar/bootloader/mod.rs @@ -6,7 +6,7 @@ use crate::{ component::{connect::Connect, Label, LineBreaking::BreakWordsNoHyphen}, constant, constant::{HEIGHT, SCREEN}, - display::{self, font, Color, Icon}, + display::{self, Color, Icon}, geometry::{Alignment2D, Offset, Point}, layout::simplified::{run, show, ReturnToC}, }, @@ -17,7 +17,7 @@ use super::{ bl_confirm::{Confirm, ConfirmMsg}, ResultScreen, WelcomeScreen, }, - cshape, + cshape, fonts, theme::{ bootloader::{BLD_BG, BLD_FG, ICON_ALERT, ICON_SPINNER, ICON_SUCCESS}, ICON_ARM_LEFT, ICON_ARM_RIGHT, TEXT_BOLD, TEXT_NORMAL, @@ -74,15 +74,13 @@ impl UICaesar { .render(target); } - shape::Text::new(SCREEN.center() + Offset::y(8), text) + shape::Text::new(SCREEN.center() + Offset::y(8), text, fonts::FONT_BOLD) .with_align(Alignment::Center) - .with_font(font::FONT_BOLD) .with_fg(fg_color) .render(target); - shape::Text::new(SCREEN.center() + Offset::y(20), text2) + shape::Text::new(SCREEN.center() + Offset::y(20), text2, fonts::FONT_BOLD) .with_align(Alignment::Center) - .with_font(font::FONT_BOLD) .with_fg(fg_color) .render(target); }); @@ -276,7 +274,7 @@ impl BootloaderUI for UICaesar { } fn screen_connect(_initial_setup: bool) { - let mut frame = Connect::new("Waiting for host...", BLD_FG, BLD_BG); + let mut frame = Connect::new("Waiting for host...", fonts::FONT_NORMAL, BLD_FG, BLD_BG); show(&mut frame, false); } @@ -324,9 +322,8 @@ impl BootloaderUI for UICaesar { // Draw vendor string if present if let Some(text) = vendor_str { let pos = Point::new(constant::WIDTH / 2, 36); - shape::Text::new(pos, text) + shape::Text::new(pos, text, fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) //COLOR_BL_BG .render(target); @@ -341,9 +338,8 @@ impl BootloaderUI for UICaesar { version[2] )); - shape::Text::new(pos, version_text.as_str()) + shape::Text::new(pos, version_text.as_str(), fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } @@ -356,15 +352,14 @@ impl BootloaderUI for UICaesar { unwrap!(uwrite!(text, "starting in {} s", wait)); let pos = Point::new(constant::WIDTH / 2, HEIGHT - 5); - shape::Text::new(pos, text.as_str()) + shape::Text::new(pos, text.as_str(), fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } core::cmp::Ordering::Less => { let pos = Point::new(constant::WIDTH / 2, HEIGHT - 2); - shape::Text::new(pos, "CONTINUE") + shape::Text::new(pos, "CONTINUE", fonts::FONT_NORMAL) .with_align(Alignment::Center) .with_fg(BLD_FG) .render(target); diff --git a/core/embed/rust/src/ui/layout_caesar/bootloader/welcome.rs b/core/embed/rust/src/ui/layout_caesar/bootloader/welcome.rs index 11facb0d70..6bd167e11f 100644 --- a/core/embed/rust/src/ui/layout_caesar/bootloader/welcome.rs +++ b/core/embed/rust/src/ui/layout_caesar/bootloader/welcome.rs @@ -1,12 +1,14 @@ use crate::ui::{ component::{Component, Event, EventCtx, Never, Pad}, - display::font, geometry::{Alignment, Offset, Rect}, shape, shape::Renderer, }; -use super::super::theme::bootloader::{BLD_BG, BLD_FG}; +use super::{ + super::theme::bootloader::{BLD_BG, BLD_FG}, + fonts, +}; pub struct Welcome { bg: Pad, @@ -37,22 +39,31 @@ impl Component for Welcome { let top_center = self.bg.area.top_center(); - shape::Text::new(top_center + Offset::y(24), "Get started with") - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(BLD_FG) - .render(target); + shape::Text::new( + top_center + Offset::y(24), + "Get started with", + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(BLD_FG) + .render(target); - shape::Text::new(top_center + Offset::y(32), "your Trezor at") - .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) - .with_fg(BLD_FG) - .render(target); + shape::Text::new( + top_center + Offset::y(32), + "your Trezor at", + fonts::FONT_NORMAL, + ) + .with_align(Alignment::Center) + .with_fg(BLD_FG) + .render(target); - shape::Text::new(top_center + Offset::y(48), "trezor.io/start") - .with_align(Alignment::Center) - .with_font(font::FONT_BOLD) - .with_fg(BLD_FG) - .render(target); + shape::Text::new( + top_center + Offset::y(48), + "trezor.io/start", + fonts::FONT_BOLD, + ) + .with_align(Alignment::Center) + .with_fg(BLD_FG) + .render(target); } } diff --git a/core/embed/rust/src/ui/layout_caesar/component/bl_confirm.rs b/core/embed/rust/src/ui/layout_caesar/component/bl_confirm.rs index 0de9d17ebd..56654f770c 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/bl_confirm.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/bl_confirm.rs @@ -2,7 +2,7 @@ use crate::{ strutil::TString, ui::{ component::{Child, Component, ComponentExt, Event, EventCtx, Label, Pad}, - display::{font, Color}, + display::Color, geometry::{Point, Rect}, shape, shape::Renderer, @@ -10,6 +10,7 @@ use crate::{ }; use super::{ + super::fonts, theme::{BUTTON_HEIGHT, TITLE_AREA_HEIGHT, WHITE}, ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos, }; @@ -200,8 +201,7 @@ impl Component for Confirm<'_> { let mut display_top_left = |text: TString| { text.map(|t| { - shape::Text::new(Point::zero(), t) - .with_font(font::FONT_BOLD) + shape::Text::new(Point::zero(), t, fonts::FONT_BOLD) .with_fg(WHITE) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_caesar/component/button.rs b/core/embed/rust/src/ui/layout_caesar/component/button.rs index fcb004b948..72b71a1131 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/button.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/button.rs @@ -4,7 +4,7 @@ use crate::{ ui::{ component::{Component, Event, EventCtx, Never}, constant, - display::{font, Color, Font, Icon}, + display::{Color, Font, Icon}, event::PhysicalButton, geometry::{Alignment2D, Offset, Point, Rect}, shape, @@ -12,7 +12,7 @@ use crate::{ }, }; -use super::{loader::DEFAULT_DURATION_MS, theme}; +use super::{super::fonts, loader::DEFAULT_DURATION_MS, theme}; const HALF_SCREEN_BUTTON_WIDTH: i16 = constant::WIDTH / 2 - 1; @@ -232,8 +232,8 @@ impl Component for Button { shape::Text::new( self.get_text_baseline(style) - Offset::x(style.font.start_x_bearing(t)), t, + style.font, ) - .with_font(style.font) .with_fg(fg_color) .render(target); }), @@ -367,7 +367,7 @@ impl ButtonDetails { pub fn text(text: TString<'static>) -> Self { Self { content: ButtonContent::Text(text), - font: font::FONT_NORMAL_UPPER, + font: fonts::FONT_NORMAL_UPPER, duration: None, with_outline: true, with_arms: false, @@ -381,7 +381,7 @@ impl ButtonDetails { pub fn icon(icon: Icon) -> Self { Self { content: ButtonContent::Icon(icon), - font: font::FONT_NORMAL_UPPER, + font: fonts::FONT_NORMAL_UPPER, duration: None, with_outline: false, with_arms: false, @@ -561,7 +561,7 @@ impl ButtonLayout { Some( ButtonDetails::text("i".into()) .with_fixed_width(theme::BUTTON_ICON_WIDTH) - .with_font(font::FONT_NORMAL), + .with_font(fonts::FONT_NORMAL), ), ) } @@ -574,7 +574,7 @@ impl ButtonLayout { Some( ButtonDetails::text("i".into()) .with_fixed_width(theme::BUTTON_ICON_WIDTH) - .with_font(font::FONT_NORMAL), + .with_font(fonts::FONT_NORMAL), ), ) } @@ -695,7 +695,7 @@ impl ButtonLayout { Some( ButtonDetails::text("i".into()) .with_fixed_width(theme::BUTTON_ICON_WIDTH) - .with_font(font::FONT_NORMAL), + .with_font(fonts::FONT_NORMAL), ), ) } diff --git a/core/embed/rust/src/ui/layout_caesar/component/changing_text.rs b/core/embed/rust/src/ui/layout_caesar/component/changing_text.rs index f153ec930c..878a79a19d 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/changing_text.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/changing_text.rs @@ -2,14 +2,14 @@ use crate::{ strutil::ShortString, ui::{ component::{Component, Event, EventCtx, Never, Pad}, - display::{font, Font}, + display::Font, geometry::{Alignment, Point, Rect}, shape::{self, Renderer}, util::long_line_content_with_ellipsis, }, }; -use super::theme; +use super::{super::fonts, theme}; /// Component that allows for "allocating" a standalone line of text anywhere /// on the screen and updating it arbitrarily - without affecting the rest @@ -43,11 +43,11 @@ impl ChangingTextLine { } pub fn center_mono(text: &str, max_len: usize) -> Self { - Self::new(text, font::FONT_MONO, Alignment::Center, max_len) + Self::new(text, fonts::FONT_MONO, Alignment::Center, max_len) } pub fn center_bold(text: &str, max_len: usize) -> Self { - Self::new(text, font::FONT_BOLD_UPPER, Alignment::Center, max_len) + Self::new(text, fonts::FONT_BOLD_UPPER, Alignment::Center, max_len) } /// Not showing ellipsis at the beginning of longer texts. @@ -110,24 +110,20 @@ impl ChangingTextLine { fn render_left<'s>(&'s self, target: &mut impl Renderer<'s>) { let baseline = Point::new(self.pad.area.x0, self.y_baseline()); - shape::Text::new(baseline, self.text.as_ref()) - .with_font(self.font) - .render(target); + shape::Text::new(baseline, self.text.as_ref(), self.font).render(target); } fn render_center<'s>(&'s self, target: &mut impl Renderer<'s>) { let baseline = Point::new(self.pad.area.bottom_center().x, self.y_baseline()); - shape::Text::new(baseline, self.text.as_ref()) + shape::Text::new(baseline, self.text.as_ref(), self.font) .with_align(Alignment::Center) - .with_font(self.font) .render(target); } fn render_right<'s>(&'s self, target: &mut impl Renderer<'s>) { let baseline = Point::new(self.pad.area.x1, self.y_baseline()); - shape::Text::new(baseline, self.text.as_ref()) + shape::Text::new(baseline, self.text.as_ref(), self.font) .with_align(Alignment::End) - .with_font(self.font) .render(target); } @@ -145,9 +141,7 @@ impl ChangingTextLine { let x_offset = if self.text.len() % 2 == 0 { 0 } else { 2 }; let baseline = Point::new(self.pad.area.x0 + x_offset, self.y_baseline()); - shape::Text::new(baseline, &text_to_display) - .with_font(self.font) - .render(target); + shape::Text::new(baseline, &text_to_display, self.font).render(target); } } diff --git a/core/embed/rust/src/ui/layout_caesar/component/coinjoin_progress.rs b/core/embed/rust/src/ui/layout_caesar/component/coinjoin_progress.rs index f704bcd9f7..34a27ce771 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/coinjoin_progress.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/coinjoin_progress.rs @@ -9,7 +9,6 @@ use crate::{ text::util::{text_multiline, text_multiline_bottom}, Component, Event, EventCtx, }, - display::font, geometry::{Alignment, Alignment2D, Insets, Offset, Rect}, shape, shape::Renderer, @@ -17,7 +16,7 @@ use crate::{ }, }; -use super::super::{cshape, theme}; +use super::super::{cshape, fonts, theme}; const FOOTER_TEXT_MARGIN: i16 = 8; const LOADER_OFFSET: i16 = -15; @@ -88,7 +87,7 @@ impl Component for CoinJoinProgress { target, self.area, TR::coinjoin__title_progress.into(), - font::FONT_BOLD, + fonts::FONT_BOLD, theme::FG, theme::BG, Alignment::Center, @@ -111,7 +110,7 @@ impl Component for CoinJoinProgress { target, self.area, TR::coinjoin__do_not_disconnect.into(), - font::FONT_BOLD, + fonts::FONT_BOLD, theme::FG, theme::BG, Alignment::Center, @@ -121,7 +120,7 @@ impl Component for CoinJoinProgress { target, rest.inset(Insets::bottom(FOOTER_TEXT_MARGIN)), self.text, - font::FONT_NORMAL, + fonts::FONT_NORMAL, theme::FG, theme::BG, Alignment::Center, diff --git a/core/embed/rust/src/ui/layout_caesar/component/homescreen.rs b/core/embed/rust/src/ui/layout_caesar/component/homescreen.rs index 1758db03b3..1a0cfa97aa 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/homescreen.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/homescreen.rs @@ -7,7 +7,6 @@ use crate::{ component::{Child, Component, Event, EventCtx, Label}, constant::{HEIGHT, WIDTH}, display::{ - font, image::{ImageInfo, ToifFormat}, Font, Icon, }, @@ -19,8 +18,9 @@ use crate::{ }; use super::{ - super::constant, theme, ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos, - CancelConfirmMsg, LoaderMsg, ProgressLoader, + super::{constant, fonts}, + theme, ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos, CancelConfirmMsg, + LoaderMsg, ProgressLoader, }; const AREA: Rect = constant::screen(); @@ -33,7 +33,7 @@ const LOGO_ICON_TOP_MARGIN: i16 = 12; const LOCK_ICON_TOP_MARGIN: i16 = 12; const NOTIFICATION_HEIGHT: i16 = 12; const LABEL_OUTSET: i16 = 3; -const NOTIFICATION_FONT: Font = font::FONT_NORMAL_UPPER; +const NOTIFICATION_FONT: Font = fonts::FONT_NORMAL_UPPER; const NOTIFICATION_ICON: Icon = theme::ICON_WARNING; const COINJOIN_CORNER: Point = AREA.top_right().ofs(Offset::new(-2, 2)); @@ -114,9 +114,8 @@ impl Homescreen { // TODO: fill warning icons here as well? TR::homescreen__title_no_usb_connection.map_translated(|t| { - shape::Text::new(baseline, t) + shape::Text::new(baseline, t, NOTIFICATION_FONT) .with_align(Alignment::Center) - .with_font(NOTIFICATION_FONT) .render(target) }); } else if let Some((notification, _level)) = &self.notification { @@ -125,9 +124,8 @@ impl Homescreen { .render(target); notification.map(|c| { - shape::Text::new(baseline, c) + shape::Text::new(baseline, c, NOTIFICATION_FONT) .with_align(Alignment::Center) - .with_font(NOTIFICATION_FONT) .render(target) }); diff --git a/core/embed/rust/src/ui/layout_caesar/component/input_methods/choice_item.rs b/core/embed/rust/src/ui/layout_caesar/component/input_methods/choice_item.rs index d260cd3b58..d0b5fee349 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/input_methods/choice_item.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/input_methods/choice_item.rs @@ -217,8 +217,7 @@ fn render_text_icon<'s>( // Possibly shifting the baseline left, when there is a text bearing. // This is to center the text properly. baseline = baseline - Offset::x(font.start_x_bearing(text)); - shape::Text::new(baseline, text) - .with_font(font) + shape::Text::new(baseline, text, font) .with_fg(fg_color) .render(target); } diff --git a/core/embed/rust/src/ui/layout_caesar/component/input_methods/pin.rs b/core/embed/rust/src/ui/layout_caesar/component/input_methods/pin.rs index bc94cbe78f..558e68ff25 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/input_methods/pin.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/input_methods/pin.rs @@ -7,15 +7,15 @@ use crate::{ component::{ text::common::TextBox, Child, Component, ComponentExt, Event, EventCtx, Timer, }, - display::{font, Icon}, + display::Icon, geometry::Rect, shape::Renderer, }, }; use super::super::{ - theme, ButtonDetails, ButtonLayout, CancelConfirmMsg, ChangingTextLine, ChoiceFactory, - ChoiceItem, ChoicePage, + super::fonts, theme, ButtonDetails, ButtonLayout, CancelConfirmMsg, ChangingTextLine, + ChoiceFactory, ChoiceItem, ChoicePage, }; #[derive(Clone, Copy)] @@ -164,7 +164,7 @@ impl<'a> PinEntry<'a> { let mut pin_line = pin_line_content .map(|s| ChangingTextLine::center_bold(s, MAX_PIN_LENGTH).without_ellipsis()); if show_subprompt { - pin_line.update_font(font::FONT_NORMAL); + pin_line.update_font(fonts::FONT_NORMAL); } Self { @@ -202,10 +202,10 @@ impl<'a> PinEntry<'a> { let s = ShortString::new(); s.capacity() >= MAX_PIN_LENGTH }); - let mut used_font = font::FONT_BOLD; + let mut used_font = fonts::FONT_BOLD; let pin_line_text = if self.is_empty() && !self.subprompt.is_empty() { // Showing the subprompt in NORMAL font - used_font = font::FONT_NORMAL; + used_font = fonts::FONT_NORMAL; self.subprompt.map(|s| unwrap!(ShortString::try_from(s))) } else if self.is_empty() { unwrap!(ShortString::try_from(EMPTY_PIN_STR)) diff --git a/core/embed/rust/src/ui/layout_caesar/component/loader.rs b/core/embed/rust/src/ui/layout_caesar/component/loader.rs index 703b413a15..b62822f747 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/loader.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/loader.rs @@ -197,8 +197,7 @@ impl Loader { style.font.horz_center(self.area.x0, self.area.x1, t), style.font.vert_center(self.area.y0, self.area.y1, "A"), ); - shape::Text::new(pt, t) - .with_font(style.font) + shape::Text::new(pt, t, style.font) .with_fg(text_color) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_caesar/component/progress.rs b/core/embed/rust/src/ui/layout_caesar/component/progress.rs index 3aa7f3f047..4d0f7743e2 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/progress.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/progress.rs @@ -9,7 +9,7 @@ use crate::{ Child, Component, Event, EventCtx, Label, Never, Pad, }, constant, - display::{font, Icon, LOADER_MAX}, + display::{Icon, LOADER_MAX}, geometry::{Alignment2D, Offset, Rect}, shape, shape::Renderer, @@ -17,7 +17,7 @@ use crate::{ }, }; -use super::super::{cshape, theme}; +use super::super::{cshape, fonts, theme}; const BOTTOM_DESCRIPTION_MARGIN: i16 = 10; const LOADER_Y_OFFSET_TITLE: i16 = -10; @@ -99,7 +99,7 @@ impl Component for Progress { }; let (_loader, description) = rest.split_bottom( - BOTTOM_DESCRIPTION_MARGIN + font::FONT_NORMAL.line_height() * description_lines, + BOTTOM_DESCRIPTION_MARGIN + fonts::FONT_NORMAL.line_height() * description_lines, ); self.title.place(title); self.loader_y_offset = loader_y_offset; diff --git a/core/embed/rust/src/ui/layout_caesar/component/share_words.rs b/core/embed/rust/src/ui/layout_caesar/component/share_words.rs index 5eae35b363..1448859e29 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/share_words.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/share_words.rs @@ -5,7 +5,7 @@ use crate::{ component::{ text::util::text_multiline, Child, Component, Event, EventCtx, Never, Paginate, }, - display::{font, Font}, + display::Font, geometry::{Alignment, Offset, Rect}, shape::{self, Renderer}, }, @@ -15,14 +15,14 @@ use heapless::Vec; #[cfg(feature = "ui_debug")] use ufmt::uwrite; -use super::{scrollbar::SCROLLBAR_SPACE, theme, ScrollBar}; +use super::{super::fonts, scrollbar::SCROLLBAR_SPACE, theme, ScrollBar}; const WORDS_PER_PAGE: usize = 3; const EXTRA_LINE_HEIGHT: i16 = -2; const NUMBER_X_OFFSET: i16 = 0; const WORD_X_OFFSET: i16 = 25; -const NUMBER_FONT: Font = font::FONT_DEMIBOLD; -const WORD_FONT: Font = font::FONT_BIG; +const NUMBER_FONT: Font = fonts::FONT_DEMIBOLD; +const WORD_FONT: Font = fonts::FONT_BIG; const INFO_TOP_OFFSET: i16 = 20; const MAX_WORDS: usize = 33; // super-shamir has 33 words, all other have less @@ -81,7 +81,7 @@ impl<'a> ShareWords<'a> { target, self.area.split_top(INFO_TOP_OFFSET).1, final_text.as_str().into(), - font::FONT_NORMAL, + fonts::FONT_NORMAL, theme::FG, theme::BG, Alignment::Start, @@ -104,13 +104,11 @@ impl<'a> ShareWords<'a> { let base = self.area.top_left() + Offset::y(y_offset); let ordinal_txt = uformat!("{}.", ordinal); - shape::Text::new(base + Offset::x(NUMBER_X_OFFSET), &ordinal_txt) - .with_font(NUMBER_FONT) + shape::Text::new(base + Offset::x(NUMBER_X_OFFSET), &ordinal_txt, NUMBER_FONT) .with_fg(theme::FG) .render(target); word.map(|w| { - shape::Text::new(base + Offset::x(WORD_X_OFFSET), w) - .with_font(WORD_FONT) + shape::Text::new(base + Offset::x(WORD_X_OFFSET), w, WORD_FONT) .with_fg(theme::FG) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_caesar/component/title.rs b/core/embed/rust/src/ui/layout_caesar/component/title.rs index 675d3efea7..bcb8647bed 100644 --- a/core/embed/rust/src/ui/layout_caesar/component/title.rs +++ b/core/embed/rust/src/ui/layout_caesar/component/title.rs @@ -60,8 +60,7 @@ impl Title { let text_height = theme::FONT_HEADER.text_height(); let title_baseline = area.top_left() + Offset::y(text_height - 1); title.map(|s| { - shape::Text::new(title_baseline, s) - .with_font(theme::FONT_HEADER) + shape::Text::new(title_baseline, s, theme::FONT_HEADER) .with_fg(theme::FG) .render(target); }); @@ -76,9 +75,8 @@ impl Title { let text_height = theme::FONT_HEADER.text_height(); let title_baseline = area.top_center() + Offset::y(text_height - 1); title.map(|s| { - shape::Text::new(title_baseline, s) + shape::Text::new(title_baseline, s, theme::FONT_HEADER) .with_align(Alignment::Center) - .with_font(theme::FONT_HEADER) .with_fg(theme::FG) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs b/core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs index c17b42c343..3ba3411265 100644 --- a/core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs +++ b/core/embed/rust/src/ui/layout_caesar/theme/bootloader.rs @@ -1,9 +1,6 @@ -use crate::ui::{ - component::text::TextStyle, - display::{font, Color}, - util::include_icon, -}; +use crate::ui::{component::text::TextStyle, display::Color, util::include_icon}; +use super::super::fonts; pub use super::super::theme::{BLACK, WHITE}; pub const BLD_BG: Color = BLACK; @@ -17,5 +14,5 @@ include_icon!(ICON_REDO, "layout_caesar/res/redo.toif"); include_icon!(ICON_EXIT, "layout_caesar/res/exit.toif"); pub const TEXT_NORMAL: TextStyle = - TextStyle::new(font::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); -pub const TEXT_BOLD: TextStyle = TextStyle::new(font::FONT_BOLD, BLD_FG, BLD_BG, BLD_FG, BLD_FG); + TextStyle::new(fonts::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); +pub const TEXT_BOLD: TextStyle = TextStyle::new(fonts::FONT_BOLD, BLD_FG, BLD_BG, BLD_FG, BLD_FG); diff --git a/core/embed/rust/src/ui/layout_caesar/theme/mod.rs b/core/embed/rust/src/ui/layout_caesar/theme/mod.rs index a2d380d011..aefe48bf2e 100644 --- a/core/embed/rust/src/ui/layout_caesar/theme/mod.rs +++ b/core/embed/rust/src/ui/layout_caesar/theme/mod.rs @@ -3,11 +3,13 @@ use crate::ui::{ text::{layout::Chunks, TextStyle}, LineBreaking, PageBreaking, }, - display::{font, Color, Font}, + display::{Color, Font}, geometry::Offset, util::include_icon, }; +use super::fonts; + pub mod bootloader; // Color palette. @@ -17,26 +19,26 @@ pub const FG: Color = WHITE; // Default foreground (text & icon) color. pub const BG: Color = BLACK; // Default background color. // Font constants. -pub const FONT_BUTTON: Font = font::FONT_NORMAL_UPPER; -pub const FONT_HEADER: Font = font::FONT_BOLD_UPPER; -pub const FONT_CHOICE_ITEMS: Font = font::FONT_BIG; +pub const FONT_BUTTON: Font = fonts::FONT_NORMAL_UPPER; +pub const FONT_HEADER: Font = fonts::FONT_BOLD_UPPER; +pub const FONT_CHOICE_ITEMS: Font = fonts::FONT_BIG; // Text constants. -pub const TEXT_NORMAL: TextStyle = TextStyle::new(font::FONT_NORMAL, FG, BG, FG, FG) +pub const TEXT_NORMAL: TextStyle = TextStyle::new(fonts::FONT_NORMAL, FG, BG, FG, FG) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_NEXT_PAGE, ELLIPSIS_ICON_MARGIN) .with_prev_page_icon(ICON_PREV_PAGE, PREV_PAGE_ICON_MARGIN); -pub const TEXT_BIG: TextStyle = TextStyle::new(font::FONT_BIG, FG, BG, FG, FG); -pub const TEXT_DEMIBOLD: TextStyle = TextStyle::new(font::FONT_DEMIBOLD, FG, BG, FG, FG); -pub const TEXT_BOLD: TextStyle = TextStyle::new(font::FONT_BOLD, FG, BG, FG, FG) +pub const TEXT_BIG: TextStyle = TextStyle::new(fonts::FONT_BIG, FG, BG, FG, FG); +pub const TEXT_DEMIBOLD: TextStyle = TextStyle::new(fonts::FONT_DEMIBOLD, FG, BG, FG, FG); +pub const TEXT_BOLD: TextStyle = TextStyle::new(fonts::FONT_BOLD, FG, BG, FG, FG) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_NEXT_PAGE, ELLIPSIS_ICON_MARGIN) .with_prev_page_icon(ICON_PREV_PAGE, PREV_PAGE_ICON_MARGIN); -pub const TEXT_BOLD_UPPER: TextStyle = TextStyle::new(font::FONT_BOLD_UPPER, FG, BG, FG, FG) +pub const TEXT_BOLD_UPPER: TextStyle = TextStyle::new(fonts::FONT_BOLD_UPPER, FG, BG, FG, FG) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_NEXT_PAGE, ELLIPSIS_ICON_MARGIN) .with_prev_page_icon(ICON_PREV_PAGE, PREV_PAGE_ICON_MARGIN); -pub const TEXT_MONO: TextStyle = TextStyle::new(font::FONT_MONO, FG, BG, FG, FG) +pub const TEXT_MONO: TextStyle = TextStyle::new(fonts::FONT_MONO, FG, BG, FG, FG) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_NEXT_PAGE, ELLIPSIS_ICON_MARGIN) .with_prev_page_icon(ICON_PREV_PAGE, PREV_PAGE_ICON_MARGIN); diff --git a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs index 337bf2a5d4..d6f8393e24 100644 --- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs @@ -20,7 +20,6 @@ use crate::{ }, Component, ComponentExt, Empty, FormattedText, Label, LineBreaking, Paginate, Timeout, }, - display::font, geometry, layout::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, @@ -40,7 +39,7 @@ use super::{ PassphraseEntry, PinEntry, Progress, ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WordlistEntry, WordlistType, }, - constant, theme, UICaesar, + constant, fonts, theme, UICaesar, }; use heapless::Vec; @@ -116,13 +115,13 @@ impl FirmwareUI for UICaesar { if chunkify { ops = ops.chunkify_text(None); } - ops = ops.text_normal(label).newline(); + ops = ops.text(label, fonts::FONT_NORMAL).newline(); } if chunkify { // Chunkifying the address into smaller pieces when requested ops = ops.chunkify_text(Some((theme::MONO_CHUNKS, 2))); } - ops = ops.text_mono(address); + ops = ops.text(address, fonts::FONT_MONO); let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted).with_title(title) }; @@ -271,9 +270,9 @@ impl FirmwareUI for UICaesar { let ops = OpTextLayout::new(theme::TEXT_NORMAL) .newline() - .text_normal(app_name) + .text(app_name, fonts::FONT_NORMAL) .newline() - .text_bold(account); + .text(account, fonts::FONT_BOLD); let formatted = FormattedText::new(ops); Page::new(btn_layout, btn_actions, formatted) @@ -473,11 +472,11 @@ impl FirmwareUI for UICaesar { ) }; let ops = OpTextLayout::new(theme::TEXT_NORMAL) - .text_normal(TR::reset__by_continuing) + .text(TR::reset__by_continuing, fonts::FONT_NORMAL) .next_page() - .text_normal(TR::reset__more_info_at) + .text(TR::reset__more_info_at, fonts::FONT_NORMAL) .newline() - .text_bold(TR::reset__tos_link); + .text(TR::reset__tos_link, fonts::FONT_BOLD); let formatted = FormattedText::new(ops).vertically_centered(); content_in_button_page(title, formatted, button, Some("".into()), false) @@ -514,7 +513,7 @@ impl FirmwareUI for UICaesar { let right_btn = has_pages_after.then(|| { ButtonDetails::text("i".into()) .with_fixed_width(theme::BUTTON_ICON_WIDTH) - .with_font(font::FONT_NORMAL) + .with_font(fonts::FONT_NORMAL) }); let middle_btn = Some(ButtonDetails::armed_text(TR::buttons__confirm.into())); @@ -550,14 +549,14 @@ impl FirmwareUI for UICaesar { let (btn_layout, btn_actions) = btns_summary_page(!info_pages.is_empty()); let ops = OpTextLayout::new(theme::TEXT_MONO) - .text_bold(amount_label) + .text(amount_label, fonts::FONT_BOLD) .newline() - .text_mono(amount) + .text(amount, fonts::FONT_MONO) .newline() .newline() - .text_bold(fee_label) + .text(fee_label, fonts::FONT_BOLD) .newline() - .text_mono(fee); + .text(fee, fonts::FONT_MONO); let formatted = FormattedText::new(ops); Page::new(btn_layout, btn_actions, formatted) @@ -576,9 +575,9 @@ impl FirmwareUI for UICaesar { ops = ops.next_page(); } ops = ops - .text_bold(unwrap!(TString::try_from(key))) + .text(unwrap!(TString::try_from(key)), fonts::FONT_BOLD) .newline() - .text_mono(unwrap!(TString::try_from(value))); + .text(unwrap!(TString::try_from(value)), fonts::FONT_MONO); } let formatted = FormattedText::new(ops).vertically_centered(); @@ -767,7 +766,7 @@ impl FirmwareUI for UICaesar { ) }; - let ops = OpTextLayout::new(theme::TEXT_NORMAL).text_normal(text); + let ops = OpTextLayout::new(theme::TEXT_NORMAL).text(text, fonts::FONT_NORMAL); let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted) @@ -784,9 +783,9 @@ impl FirmwareUI for UICaesar { let btn_layout = ButtonLayout::text_none_arrow_wide(TR::buttons__skip.into()); let btn_actions = ButtonActions::cancel_none_next(); let ops = OpTextLayout::new(theme::TEXT_NORMAL) - .text_normal(TR::backup__new_wallet_created) + .text(TR::backup__new_wallet_created, fonts::FONT_NORMAL) .newline() - .text_normal(TR::backup__it_should_be_backed_up_now); + .text(TR::backup__it_should_be_backed_up_now, fonts::FONT_NORMAL); let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted) .with_title(TR::words__title_success.into()) @@ -794,8 +793,8 @@ impl FirmwareUI for UICaesar { 1 => { let btn_layout = ButtonLayout::up_arrow_none_text(TR::buttons__back_up.into()); let btn_actions = ButtonActions::prev_none_confirm(); - let ops = - OpTextLayout::new(theme::TEXT_NORMAL).text_normal(TR::backup__recover_anytime); + let ops = OpTextLayout::new(theme::TEXT_NORMAL) + .text(TR::backup__recover_anytime, fonts::FONT_NORMAL); let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted) .with_title(TR::backup__title_backup_wallet.into()) @@ -1070,12 +1069,12 @@ impl FirmwareUI for UICaesar { let btn_layout = ButtonLayout::arrow_none_text(TR::buttons__quit.into()); let btn_actions = ButtonActions::cancel_none_confirm(); let ops = OpTextLayout::new(theme::TEXT_NORMAL) - .text_bold_upper(title) + .text(title, fonts::FONT_BOLD_UPPER) .newline() .newline_half() - .text_normal(TR::addr_mismatch__contact_support_at) + .text(TR::addr_mismatch__contact_support_at, fonts::FONT_NORMAL) .newline() - .text_bold(TR::addr_mismatch__support_url); + .text(TR::addr_mismatch__support_url, fonts::FONT_BOLD); let formatted = FormattedText::new(ops); Page::new(btn_layout, btn_actions, formatted) }; @@ -1172,7 +1171,8 @@ impl FirmwareUI for UICaesar { } fn show_wait_text(text: TString<'static>) -> Result { - let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + let layout = + RootComponent::new(Connect::new(text, fonts::FONT_NORMAL, theme::FG, theme::BG)); Ok(layout) } @@ -1192,13 +1192,13 @@ impl FirmwareUI for UICaesar { let mut ops = OpTextLayout::new(theme::TEXT_NORMAL); ops = ops.alignment(geometry::Alignment::Center); if !value.is_empty() { - ops = ops.text_bold_upper(value); + ops = ops.text(value, fonts::FONT_BOLD_UPPER); if !description.is_empty() { ops = ops.newline(); } } if !description.is_empty() { - ops = ops.text_normal(description); + ops = ops.text(description, fonts::FONT_NORMAL); } let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted) @@ -1327,7 +1327,7 @@ fn tutorial_screen( btn_layout: ButtonLayout, btn_actions: ButtonActions, ) -> Page { - let ops = OpTextLayout::new(theme::TEXT_NORMAL).text_normal(text); + let ops = OpTextLayout::new(theme::TEXT_NORMAL).text(text, fonts::FONT_NORMAL); let formatted = FormattedText::new(ops).vertically_centered(); Page::new(btn_layout, btn_actions, formatted).with_title(title) } diff --git a/core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs b/core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs index f24baf6d66..6cfc0ae32a 100644 --- a/core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs +++ b/core/embed/rust/src/ui/layout_delizia/bootloader/mod.rs @@ -4,7 +4,7 @@ use crate::{ trezorhal::secbool::secbool, ui::{ component::{connect::Connect, Label}, - display::{self, font, Color, Icon}, + display::{self, Color, Icon}, geometry::{Alignment, Offset, Point, Rect}, layout::simplified::{run, show}, }, @@ -17,8 +17,9 @@ use super::{ Button, ResultScreen, WelcomeScreen, }, cshape::{render_loader, LoaderRange}, - theme, + fonts, theme::{ + backlight, bootloader::{ button_bld, button_bld_menu, button_confirm, button_wipe_cancel, button_wipe_confirm, BLD_BG, BLD_FG, BLD_TITLE_COLOR, BLD_WIPE_COLOR, CHECK24, CHECK40, DOWNLOAD24, FIRE32, @@ -72,8 +73,7 @@ impl UIDelizia { display::sync(); render_on_display(None, Some(bg_color), |target| { - shape::Text::new(PROGRESS_TEXT_ORIGIN, text) - .with_font(font::FONT_NORMAL) + shape::Text::new(PROGRESS_TEXT_ORIGIN, text, fonts::FONT_DEMIBOLD) .with_fg(BLD_FG) .render(target); @@ -107,9 +107,9 @@ impl UIDelizia { shape::Text::new( SCREEN.center() + Offset::y(loader_offset + center_text_offset), center_text, + fonts::FONT_DEMIBOLD, ) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(GREY) .render(target); } @@ -325,7 +325,7 @@ impl BootloaderUI for UIDelizia { if fading { Self::fadein(); } else { - display::set_backlight(theme::backlight::get_backlight_normal()); + display::set_backlight(backlight::get_backlight_normal()); } } @@ -359,7 +359,12 @@ impl BootloaderUI for UIDelizia { fn screen_connect(initial_setup: bool) { let bg = if initial_setup { WELCOME_COLOR } else { BLD_BG }; - let mut frame = Connect::new("Waiting for host...", BLD_TITLE_COLOR, bg); + let mut frame = Connect::new( + "Waiting for host...", + fonts::FONT_DEMIBOLD, + BLD_TITLE_COLOR, + bg, + ); show(&mut frame, true); } @@ -423,9 +428,8 @@ impl BootloaderUI for UIDelizia { // Draw vendor string if present if let Some(text) = vendor_str { let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5 - 50); - shape::Text::new(pos, text) + shape::Text::new(pos, text, fonts::FONT_DEMIBOLD) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) //COLOR_BL_BG .render(target); @@ -440,9 +444,8 @@ impl BootloaderUI for UIDelizia { version[2] )); - shape::Text::new(pos, version_text.as_str()) + shape::Text::new(pos, version_text.as_str(), fonts::FONT_DEMIBOLD) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } @@ -455,17 +458,15 @@ impl BootloaderUI for UIDelizia { unwrap!(uwrite!(text, "starting in {} s", wait)); let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5); - shape::Text::new(pos, text.as_str()) + shape::Text::new(pos, text.as_str(), fonts::FONT_DEMIBOLD) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } core::cmp::Ordering::Less => { let pos = Point::new(SCREEN.width() / 2, SCREEN.height() - 5); - shape::Text::new(pos, "click to continue ...") + shape::Text::new(pos, "click to continue ...", fonts::FONT_DEMIBOLD) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(BLD_FG) .render(target); } diff --git a/core/embed/rust/src/ui/layout_delizia/bootloader/welcome.rs b/core/embed/rust/src/ui/layout_delizia/bootloader/welcome.rs index 0e63ae0efe..8b1e3daf7f 100644 --- a/core/embed/rust/src/ui/layout_delizia/bootloader/welcome.rs +++ b/core/embed/rust/src/ui/layout_delizia/bootloader/welcome.rs @@ -1,12 +1,14 @@ use crate::ui::{ component::{Component, Event, EventCtx, Never, Pad}, constant::screen, - display::font, geometry::{Offset, Point, Rect}, shape::{self, Renderer}, }; -use super::super::theme::{BLACK, GREY, WHITE}; +use super::{ + super::theme::{BLACK, GREY, WHITE}, + fonts, +}; const TEXT_ORIGIN: Point = Point::new(0, 105); const STRIDE: i16 = 22; @@ -37,29 +39,27 @@ impl Component for Welcome { fn render<'s>(&'s self, target: &mut impl Renderer<'s>) { self.bg.render(target); + let font = fonts::FONT_DEMIBOLD; - shape::Text::new(TEXT_ORIGIN, "Get started") - .with_font(font::FONT_NORMAL) + shape::Text::new(TEXT_ORIGIN, "Get started", font) .with_fg(GREY) .render(target); - shape::Text::new(TEXT_ORIGIN + Offset::y(STRIDE), "with your Trezor") - .with_font(font::FONT_NORMAL) + shape::Text::new(TEXT_ORIGIN + Offset::y(STRIDE), "with your Trezor", font) .with_fg(GREY) .render(target); - shape::Text::new(TEXT_ORIGIN + Offset::y(2 * STRIDE), "at") - .with_font(font::FONT_NORMAL) + shape::Text::new(TEXT_ORIGIN + Offset::y(2 * STRIDE), "at", font) .with_fg(GREY) .render(target); - let at_width = font::FONT_NORMAL.text_width("at "); + let at_width = font.text_width("at "); shape::Text::new( TEXT_ORIGIN + Offset::new(at_width, 2 * STRIDE), "trezor.io/start", + font, ) - .with_font(font::FONT_NORMAL) .with_fg(WHITE) .render(target); } diff --git a/core/embed/rust/src/ui/layout_delizia/component/button.rs b/core/embed/rust/src/ui/layout_delizia/component/button.rs index 9a09e01f0b..1d79b4cbbb 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/button.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/button.rs @@ -213,8 +213,7 @@ impl Button { Alignment::End => self.area.right_center() - Offset::x(Self::BASELINE_OFFSET.x), } + y_offset; text.map(|text| { - shape::Text::new(start_of_baseline, text) - .with_font(style.font) + shape::Text::new(start_of_baseline, text, style.font) .with_fg(style.text_color) .with_align(self.text_align) .with_alpha(alpha) @@ -438,8 +437,7 @@ impl IconText { let mut show_text = |text: &str, rect: Rect| { let text_pos = rect.left_center() + baseline_offset; let text_pos = Point::new(rect.top_left().x + Self::ICON_SPACE, text_pos.y); - shape::Text::new(text_pos, text) - .with_font(style.font) + shape::Text::new(text_pos, text, style.font) .with_fg(style.text_color) .with_alpha(alpha) .render(target) diff --git a/core/embed/rust/src/ui/layout_delizia/component/footer.rs b/core/embed/rust/src/ui/layout_delizia/component/footer.rs index bc8d6ba355..b1bd9033b4 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/footer.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/footer.rs @@ -2,7 +2,7 @@ use crate::{ strutil::TString, ui::{ component::{text::TextStyle, Component, Event, EventCtx, Never}, - display::{font::FONT_SUB, Color, Font}, + display::{Color, Font}, event::SwipeEvent, geometry::{Alignment, Alignment2D, Direction, Offset, Point, Rect}, lerp::Lerp, @@ -10,7 +10,7 @@ use crate::{ }, }; -use super::theme; +use super::{super::fonts::FONT_SUB, theme}; /// Component showing a task instruction, e.g. "Swipe up", and an optional /// content consisting of one of these: @@ -278,11 +278,14 @@ impl<'a> FooterContent<'a> { area_description.bottom_center() - Offset::y(text_description_font_descent); description.map(|t| { - Text::new(text_description_baseline, t) - .with_font(Footer::STYLE_DESCRIPTION.text_font) - .with_fg(Footer::STYLE_DESCRIPTION.text_color) - .with_align(Alignment::Center) - .render(target) + Text::new( + text_description_baseline, + t, + Footer::STYLE_DESCRIPTION.text_font, + ) + .with_fg(Footer::STYLE_DESCRIPTION.text_color) + .with_align(Alignment::Center) + .render(target) }); } @@ -299,11 +302,14 @@ impl<'a> FooterContent<'a> { let text_instruction_baseline = area_instruction.bottom_center() - Offset::y(text_instruction_font_descent); instruction.map(|t| { - Text::new(text_instruction_baseline, t) - .with_font(Footer::STYLE_INSTRUCTION.text_font) - .with_fg(Footer::STYLE_INSTRUCTION.text_color) - .with_align(Alignment::Center) - .render(target) + Text::new( + text_instruction_baseline, + t, + Footer::STYLE_INSTRUCTION.text_font, + ) + .with_fg(Footer::STYLE_INSTRUCTION.text_color) + .with_align(Alignment::Center) + .render(target) }); } } @@ -369,19 +375,17 @@ impl PageCounter { let base_foreslash = Point::new(counter_start_x + width_num_curr + offset_x.x, counter_y); let base_num_max = Point::new(counter_end_x, counter_y); - Text::new(base_num_curr, &string_curr) + Text::new(base_num_curr, &string_curr, self.font) .with_align(Alignment::Start) .with_fg(color) - .with_font(self.font) .render(target); shape::ToifImage::new(base_foreslash, theme::ICON_FORESLASH.toif) .with_align(Alignment2D::BOTTOM_LEFT) .with_fg(color) .render(target); - Text::new(base_num_max, &string_max) + Text::new(base_num_max, &string_max, self.font) .with_align(Alignment::End) .with_fg(color) - .with_font(self.font) .render(target); FooterContent::render_instruction(target, area, &self.instruction); diff --git a/core/embed/rust/src/ui/layout_delizia/component/homescreen.rs b/core/embed/rust/src/ui/layout_delizia/component/homescreen.rs index fb4710796e..f9924f98b0 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/homescreen.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/homescreen.rs @@ -7,7 +7,7 @@ use crate::{ trezorhal::usb::usb_configured, ui::{ component::{Component, Event, EventCtx, Timer}, - display::{font, image::ImageInfo, Color}, + display::{image::ImageInfo, Color}, event::TouchEvent, geometry::{Alignment, Alignment2D, Offset, Point, Rect}, layout::util::get_user_custom_image, @@ -24,7 +24,10 @@ use crate::ui::{ }; use super::{ - super::cshape::{self, UnlockOverlay}, + super::{ + cshape::{self, UnlockOverlay}, + fonts, + }, constant, theme, theme::{GREY_LIGHT, HOMESCREEN_ICON, ICON_KEY}, Loader, LoaderMsg, @@ -83,8 +86,7 @@ fn render_notif<'s>(notif: HomescreenNotification, top: i16, target: &mut impl R .with_alpha(NOTIFICATION_BG_ALPHA) .render(target); - shape::Text::new(text_pos, t) - .with_font(style.text_font) + shape::Text::new(text_pos, t, style.text_font) .with_fg(notif.color_text) .render(target); }); @@ -491,9 +493,8 @@ impl Homescreen { fn render_loader<'s>(&'s self, target: &mut impl Renderer<'s>) { TR::progress__locking_device.map_translated(|t| { - shape::Text::new(TOP_CENTER + Offset::y(HOLD_Y), t) + shape::Text::new(TOP_CENTER + Offset::y(HOLD_Y), t, fonts::FONT_NORMAL) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(theme::FG); }); self.loader.render(target) @@ -855,8 +856,7 @@ impl Component for Lockscreen { t.map_translated(|t| { let text_pos = Point::new(6, offset); - shape::Text::new(text_pos, t) - .with_font(theme::TEXT_SUB_GREY.text_font) + shape::Text::new(text_pos, t, theme::TEXT_SUB_GREY.text_font) .with_fg(theme::TEXT_SUB_GREY.text_color) .render(target); }) @@ -873,8 +873,7 @@ impl Component for Lockscreen { screen().y1 - offset, ); - shape::Text::new(text_pos, t) - .with_font(theme::TEXT_SUB_GREY.text_font) + shape::Text::new(text_pos, t, theme::TEXT_SUB_GREY.text_font) .with_fg(theme::GREY_DARK) .render(target); }); diff --git a/core/embed/rust/src/ui/layout_delizia/component/keyboard/bip39.rs b/core/embed/rust/src/ui/layout_delizia/component/keyboard/bip39.rs index 147ba3e1f9..5878951a81 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/keyboard/bip39.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/keyboard/bip39.rs @@ -142,16 +142,14 @@ impl Component for Bip39Input { }; // Render text input + suggested completion - shape::Text::new(text_base, text) - .with_font(style.font) + shape::Text::new(text_base, text, style.font) .with_fg(style.text_color) .with_align(Alignment::Start) .render(target); if let Some(word) = self.suggested_word.and_then(|w| w.get(text.len()..)) { let word_baseline = text_base + Offset::x(width); let style = self.button_suggestion.style(); - shape::Text::new(word_baseline, word) - .with_font(style.font) + shape::Text::new(word_baseline, word, style.font) .with_fg(style.text_color) .with_align(Alignment::Start) .render(target); diff --git a/core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs b/core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs index b7a760d81d..7636dde139 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/keyboard/passphrase.rs @@ -458,8 +458,7 @@ impl Component for Input { let text_to_display = long_line_content_with_ellipsis(text, "...", style.text_font, available_area_width); - shape::Text::new(text_baseline, &text_to_display) - .with_font(style.text_font) + shape::Text::new(text_baseline, &text_to_display, style.text_font) .with_fg(style.text_color) .render(target); diff --git a/core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs b/core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs index e95ea62e55..1cedf3a3ac 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/keyboard/pin.rs @@ -10,7 +10,6 @@ use crate::{ text::TextStyle, Component, Event, EventCtx, Label, Never, Pad, Timer, }, - display::font::FONT_MONO, event::TouchEvent, geometry::{Alignment, Alignment2D, Direction, Grid, Insets, Offset, Rect}, shape::{self, Renderer}, @@ -27,6 +26,7 @@ use super::super::super::{ theme, }, cshape, + fonts::FONT_MONO, }; pub enum PinKeyboardMsg { @@ -609,16 +609,14 @@ impl PinDots { let digits = self.digits.len(); if digits <= MAX_VISIBLE_DIGITS { - shape::Text::new(left, &self.digits) + shape::Text::new(left, &self.digits, FONT_MONO) .with_align(Alignment::Start) - .with_font(FONT_MONO) .with_fg(self.style.text_color) .render(target); } else { let offset: usize = digits.saturating_sub(MAX_VISIBLE_DIGITS); - shape::Text::new(left, &self.digits[offset..]) + shape::Text::new(left, &self.digits[offset..], FONT_MONO) .with_align(Alignment::Start) - .with_font(FONT_MONO) .with_fg(self.style.text_color) .render(target); } @@ -669,9 +667,8 @@ impl PinDots { if last_digit && digits > 0 { let last = &self.digits[(digits - 1)..digits]; cursor.y = area.left_center().y + (FONT_MONO.visible_text_height("1") / 2); - shape::Text::new(cursor, last) + shape::Text::new(cursor, last, FONT_MONO) .with_align(Alignment::Start) - .with_font(FONT_MONO) .with_fg(self.style.text_color) .render(target); } else { diff --git a/core/embed/rust/src/ui/layout_delizia/component/keyboard/slip39.rs b/core/embed/rust/src/ui/layout_delizia/component/keyboard/slip39.rs index 2e34fbfa93..3f4b27d9bf 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/keyboard/slip39.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/keyboard/slip39.rs @@ -166,8 +166,7 @@ impl Component for Slip39Input { .assert_if_debugging_ui("Text buffer is too small"); } } - shape::Text::new(text_center, text.as_str()) - .with_font(style.font) + shape::Text::new(text_center, text.as_str(), style.font) .with_fg(style.text_color) .with_align(Alignment::Center) .render(target); diff --git a/core/embed/rust/src/ui/layout_delizia/component/number_input.rs b/core/embed/rust/src/ui/layout_delizia/component/number_input.rs index 74f941faaf..a5a50d2c59 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/number_input.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/number_input.rs @@ -6,14 +6,13 @@ use crate::{ text::paragraphs::{Paragraph, Paragraphs}, Component, Event, EventCtx, Pad, }, - display::font::FONT_DEMIBOLD, event::SwipeEvent, geometry::{Alignment, Direction, Grid, Insets, Offset, Rect}, shape::{self, Renderer}, }, }; -use super::{theme, Button, ButtonMsg}; +use super::{super::fonts::FONT_DEMIBOLD, theme, Button, ButtonMsg}; pub enum NumberInputDialogMsg { Confirmed(u32), @@ -156,10 +155,9 @@ impl Component for NumberInput { let y_offset = digit_font.text_height() / 2; shape::Bar::new(self.area).with_bg(theme::BG).render(target); - shape::Text::new(self.area.center() + Offset::y(y_offset), text) + shape::Text::new(self.area.center() + Offset::y(y_offset), text, digit_font) .with_align(Alignment::Center) .with_fg(theme::FG) - .with_font(digit_font) .render(target); } diff --git a/core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs b/core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs index 97bf34b179..e70f533f43 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/number_input_slider.rs @@ -225,11 +225,14 @@ impl Component for NumberInputSlider { if !self.touching { let text_height = theme::TEXT_BOLD.text_font.line_height(); - shape::Text::new(self.area.center() + Offset::new(0, text_height / 2), &str) - .with_font(theme::TEXT_BOLD.text_font) - .with_fg(theme::TEXT_BOLD.text_color) - .with_align(Alignment::Center) - .render(target); + shape::Text::new( + self.area.center() + Offset::new(0, text_height / 2), + &str, + theme::TEXT_BOLD.text_font, + ) + .with_fg(theme::TEXT_BOLD.text_color) + .with_align(Alignment::Center) + .render(target); } } } diff --git a/core/embed/rust/src/ui/layout_delizia/component/progress.rs b/core/embed/rust/src/ui/layout_delizia/component/progress.rs index 71b270b2b9..9924ccfe8a 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/progress.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/progress.rs @@ -8,7 +8,7 @@ use crate::{ text::paragraphs::{Paragraph, Paragraphs}, Component, Event, EventCtx, Label, Never, Pad, }, - display::{font, LOADER_MAX}, + display::LOADER_MAX, geometry::{Insets, Offset, Rect}, shape::Renderer, util::animation_disabled, @@ -18,7 +18,7 @@ use crate::{ use super::super::{ constant, cshape::{render_loader, LoaderRange}, - theme, + fonts, theme, }; pub struct Progress { @@ -62,7 +62,7 @@ impl Component for Progress { .map(|t| t.chars().filter(|c| *c == '\n').count() as i16); let (title, rest) = Self::AREA.split_top(self.title.max_size().y); let (loader, description) = - rest.split_bottom(font::FONT_NORMAL.line_height() * description_lines); + rest.split_bottom(fonts::FONT_NORMAL.line_height() * description_lines); let loader = loader.inset(Insets::top(theme::CONTENT_BORDER)); self.title.place(title); self.loader_y_offset = loader.center().y - constant::screen().center().y; diff --git a/core/embed/rust/src/ui/layout_delizia/component/result.rs b/core/embed/rust/src/ui/layout_delizia/component/result.rs index 577576a562..32da17402e 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/result.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/result.rs @@ -3,13 +3,14 @@ use crate::{ ui::{ component::{text::TextStyle, Component, Event, EventCtx, Label, Never, Pad}, constant::screen, - display::{font, Color, Icon}, + display::{Color, Icon}, geometry::{Alignment2D, Insets, Offset, Point, Rect}, shape::{self, Renderer}, }, }; use super::{ + super::fonts, constant::WIDTH, theme::{FG, RESULT_FOOTER_START, RESULT_PADDING}, }; @@ -33,11 +34,11 @@ impl ResultStyle { } pub const fn message_style(&self) -> TextStyle { - TextStyle::new(font::FONT_NORMAL, self.fg_color, self.bg_color, FG, FG) + TextStyle::new(fonts::FONT_NORMAL, self.fg_color, self.bg_color, FG, FG) } pub const fn title_style(&self) -> TextStyle { - TextStyle::new(font::FONT_BOLD, self.fg_color, self.bg_color, FG, FG) + TextStyle::new(fonts::FONT_BOLD, self.fg_color, self.bg_color, FG, FG) } } diff --git a/core/embed/rust/src/ui/layout_delizia/component/share_words.rs b/core/embed/rust/src/ui/layout_delizia/component/share_words.rs index 42138c28b3..01182b0df4 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/share_words.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/share_words.rs @@ -94,8 +94,7 @@ impl<'a> ShareWords<'a> { let word_baseline = area.center() + Offset::y(theme::TEXT_SUPER.text_font.visible_text_height("A") / 2); word.map(|w| { - shape::Text::new(word_baseline, w) - .with_font(theme::TEXT_SUPER.text_font) + shape::Text::new(word_baseline, w, theme::TEXT_SUPER.text_font) .with_align(Alignment::Center) .render(target); }); @@ -207,8 +206,7 @@ impl<'a> Component for ShareWords<'a> { .visible_text_height("1"), ); let ordinal = uformat!("{}.", ordinal_val); - shape::Text::new(ordinal_pos, &ordinal) - .with_font(theme::TEXT_SUB_GREY_LIGHT.text_font) + shape::Text::new(ordinal_pos, &ordinal, theme::TEXT_SUB_GREY_LIGHT.text_font) .with_fg(theme::GREY) .render(target); diff --git a/core/embed/rust/src/ui/layout_delizia/component/welcome_screen.rs b/core/embed/rust/src/ui/layout_delizia/component/welcome_screen.rs index 96c25e83d0..6cdd1db03f 100644 --- a/core/embed/rust/src/ui/layout_delizia/component/welcome_screen.rs +++ b/core/embed/rust/src/ui/layout_delizia/component/welcome_screen.rs @@ -1,11 +1,10 @@ use crate::ui::{ component::{Component, Event, EventCtx, Never}, - display::font, geometry::{Alignment, Alignment2D, Offset, Rect}, shape::{self, Renderer}, }; -use super::theme; +use super::{super::fonts, theme}; const TEXT_BOTTOM_MARGIN: i16 = 54; const ICON_TOP_MARGIN: i16 = 48; @@ -47,9 +46,9 @@ impl Component for WelcomeScreen { shape::Text::new( self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN), model::FULL_NAME, + fonts::FONT_NORMAL, ) .with_align(Alignment::Center) - .with_font(font::FONT_NORMAL) .with_fg(theme::FG) .render(target); } diff --git a/core/embed/rust/src/ui/layout_delizia/theme/bootloader.rs b/core/embed/rust/src/ui/layout_delizia/theme/bootloader.rs index 9cbb08f995..52afcf0aab 100644 --- a/core/embed/rust/src/ui/layout_delizia/theme/bootloader.rs +++ b/core/embed/rust/src/ui/layout_delizia/theme/bootloader.rs @@ -1,13 +1,14 @@ use crate::ui::{ component::{text::TextStyle, LineBreaking::BreakWordsNoHyphen}, constant::{HEIGHT, WIDTH}, - display::{font, Color}, + display::Color, geometry::{Offset, Point, Rect}, util::include_res, }; use super::super::{ component::{ButtonStyle, ButtonStyleSheet, ResultStyle}, + fonts, theme::{BLACK, FG, GREY_DARK, GREY_LIGHT, WHITE}, }; @@ -73,21 +74,21 @@ pub const CHECK40: &[u8] = include_res!("layout_delizia/res/check40.toif"); pub fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_BG, button_color: WHITE, icon_color: BLD_BG, background_color: BLD_BG, }, active: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_BG, button_color: BLD_INSTALL_BTN_COLOR_ACTIVE, icon_color: BLD_BG, background_color: BLD_BG, }, disabled: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: FG, button_color: GREY_DARK, icon_color: BLD_BG, @@ -99,21 +100,21 @@ pub fn button_confirm() -> ButtonStyleSheet { pub fn button_wipe_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: WHITE, button_color: BLD_WIPE_CANCEL_BTN_COLOR, icon_color: WHITE, background_color: BLD_WIPE_COLOR, }, active: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: WHITE, button_color: BLD_WIPE_CANCEL_BTN_COLOR_ACTIVE, icon_color: WHITE, background_color: BLD_WIPE_COLOR, }, disabled: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: GREY_LIGHT, button_color: GREY_DARK, icon_color: GREY_LIGHT, @@ -125,21 +126,21 @@ pub fn button_wipe_cancel() -> ButtonStyleSheet { pub fn button_wipe_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_WIPE_COLOR, button_color: BLD_WIPE_BTN_COLOR, icon_color: BLD_WIPE_COLOR, background_color: BLD_WIPE_COLOR, }, active: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_WIPE_COLOR, button_color: BLD_WIPE_BTN_COLOR_ACTIVE, icon_color: BLD_WIPE_COLOR, background_color: BLD_WIPE_COLOR, }, disabled: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: FG, button_color: GREY_DARK, icon_color: FG, @@ -151,21 +152,21 @@ pub fn button_wipe_confirm() -> ButtonStyleSheet { pub fn button_bld_menu() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_FG, button_color: BLD_BG, icon_color: BLD_FG, background_color: BLD_BG, }, active: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_FG, button_color: BLD_BG, icon_color: BLD_FG, background_color: BLD_BG, }, disabled: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: GREY_LIGHT, button_color: BLD_BG, icon_color: GREY_LIGHT, @@ -177,21 +178,21 @@ pub fn button_bld_menu() -> ButtonStyleSheet { pub fn button_bld() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_FG, button_color: BLD_BTN_COLOR, icon_color: BLD_FG, background_color: BLD_BG, }, active: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: BLD_FG, button_color: BLD_BTN_COLOR_ACTIVE, icon_color: BLD_FG, background_color: BLD_BG, }, disabled: &ButtonStyle { - font: font::FONT_BOLD, + font: fonts::FONT_BOLD, text_color: GREY_LIGHT, button_color: BLD_BTN_COLOR, icon_color: GREY_LIGHT, @@ -202,7 +203,7 @@ pub fn button_bld() -> ButtonStyleSheet { pub const fn text_title(bg: Color) -> TextStyle { TextStyle::new( - font::FONT_BOLD, + fonts::FONT_BOLD, BLD_TITLE_COLOR, bg, BLD_TITLE_COLOR, @@ -211,28 +212,28 @@ pub const fn text_title(bg: Color) -> TextStyle { } pub const TEXT_NORMAL: TextStyle = - TextStyle::new(font::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); + TextStyle::new(fonts::FONT_NORMAL, BLD_FG, BLD_BG, BLD_FG, BLD_FG); pub const TEXT_WARNING: TextStyle = TextStyle::new( - font::FONT_BOLD, + fonts::FONT_BOLD, BLD_WARN_COLOR, BLD_BG, BLD_WARN_COLOR, BLD_WARN_COLOR, ); pub const fn text_fingerprint(bg: Color) -> TextStyle { - TextStyle::new(font::FONT_NORMAL, BLD_FG, bg, BLD_FG, BLD_FG) + TextStyle::new(fonts::FONT_NORMAL, BLD_FG, bg, BLD_FG, BLD_FG) .with_line_breaking(BreakWordsNoHyphen) } -pub const TEXT_BOLD: TextStyle = TextStyle::new(font::FONT_BOLD, BLD_FG, BLD_BG, BLD_FG, BLD_FG); +pub const TEXT_BOLD: TextStyle = TextStyle::new(fonts::FONT_BOLD, BLD_FG, BLD_BG, BLD_FG, BLD_FG); pub const TEXT_WIPE_BOLD: TextStyle = TextStyle::new( - font::FONT_BOLD, + fonts::FONT_BOLD, BLD_WIPE_TEXT_COLOR, BLD_WIPE_COLOR, BLD_WIPE_TEXT_COLOR, BLD_WIPE_TEXT_COLOR, ); pub const TEXT_WIPE_NORMAL: TextStyle = TextStyle::new( - font::FONT_NORMAL, + fonts::FONT_NORMAL, BLD_WIPE_TEXT_COLOR, BLD_WIPE_COLOR, BLD_WIPE_TEXT_COLOR, diff --git a/core/embed/rust/src/ui/layout_delizia/theme/mod.rs b/core/embed/rust/src/ui/layout_delizia/theme/mod.rs index c4f9c34dfd..d7f1be9e45 100644 --- a/core/embed/rust/src/ui/layout_delizia/theme/mod.rs +++ b/core/embed/rust/src/ui/layout_delizia/theme/mod.rs @@ -9,16 +9,16 @@ use crate::{ text::{layout::Chunks, LineBreaking, PageBreaking, TextStyle}, FixedHeightBar, }, - display::{ - font::{FONT_BIG, FONT_BOLD, FONT_DEMIBOLD, FONT_MONO, FONT_NORMAL, FONT_SUB}, - Color, - }, + display::Color, geometry::{Insets, Offset}, util::include_icon, }, }; -use super::component::{ButtonStyle, ButtonStyleSheet, LoaderStyle, LoaderStyleSheet, ResultStyle}; +use super::{ + component::{ButtonStyle, ButtonStyleSheet, LoaderStyle, LoaderStyleSheet, ResultStyle}, + fonts, +}; pub const ERASE_HOLD_DURATION: Duration = Duration::from_millis(1500); @@ -140,15 +140,27 @@ pub const fn label_default() -> TextStyle { } pub const fn label_keyboard() -> TextStyle { - TextStyle::new(FONT_DEMIBOLD, GREY_EXTRA_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new( + fonts::FONT_DEMIBOLD, + GREY_EXTRA_LIGHT, + BG, + GREY_LIGHT, + GREY_LIGHT, + ) } pub const fn label_keyboard_prompt() -> TextStyle { - TextStyle::new(FONT_DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) } pub const fn label_keyboard_warning() -> TextStyle { - TextStyle::new(FONT_DEMIBOLD, ORANGE_LIGHT, BG, GREY_LIGHT, GREY_LIGHT) + TextStyle::new( + fonts::FONT_DEMIBOLD, + ORANGE_LIGHT, + BG, + GREY_LIGHT, + GREY_LIGHT, + ) } pub const fn label_keyboard_minor() -> TextStyle { @@ -177,7 +189,7 @@ pub const fn label_progress() -> TextStyle { pub const fn label_title_main() -> TextStyle { TextStyle::new( - FONT_NORMAL, + fonts::FONT_DEMIBOLD, GREY_EXTRA_LIGHT, GREY_DARK, GREY_LIGHT, @@ -186,35 +198,41 @@ pub const fn label_title_main() -> TextStyle { } pub const fn label_title_danger() -> TextStyle { - TextStyle::new(FONT_NORMAL, ORANGE_LIGHT, GREY_DARK, GREY_LIGHT, GREY_LIGHT) + TextStyle::new( + fonts::FONT_DEMIBOLD, + ORANGE_LIGHT, + GREY_DARK, + GREY_LIGHT, + GREY_LIGHT, + ) } pub const fn label_title_sub() -> TextStyle { - TextStyle::new(FONT_SUB, GREY, GREY_DARK, GREY_LIGHT, GREY_LIGHT) + TextStyle::new(fonts::FONT_SUB, GREY, GREY_DARK, GREY_LIGHT, GREY_LIGHT) } pub const fn label_coinjoin_progress() -> TextStyle { - TextStyle::new(FONT_BOLD, FG, ORANGE_DIMMED, FG, FG) + TextStyle::new(fonts::FONT_DEMIBOLD, FG, ORANGE_DIMMED, FG, FG) } pub const fn button_default() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREY, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_EXTRA_LIGHT, button_color: BG, icon_color: GREY_EXTRA_LIGHT, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREY_LIGHT, @@ -226,21 +244,21 @@ pub const fn button_default() -> ButtonStyleSheet { pub const fn button_warning_high() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_DIMMED, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_DIMMED, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_DIMMED, @@ -252,21 +270,21 @@ pub const fn button_warning_high() -> ButtonStyleSheet { pub const fn button_warning_low() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREEN_LIME, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREEN_LIME, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREEN_LIME, @@ -279,14 +297,14 @@ pub const fn button_warning_low() -> ButtonStyleSheet { pub const fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_DARK, icon_color: GREEN_LIME, background_color: GREEN_DARK, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_LIGHT, icon_color: GREEN_DARK, @@ -294,7 +312,7 @@ pub const fn button_confirm() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -306,14 +324,14 @@ pub const fn button_confirm() -> ButtonStyleSheet { pub const fn button_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: ORANGE_DARK, icon_color: ORANGE_LIGHT, background_color: GREEN_DARK, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_DARK, button_color: ORANGE_LIGHT, icon_color: ORANGE_DARK, @@ -321,7 +339,7 @@ pub const fn button_cancel() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -333,21 +351,21 @@ pub const fn button_cancel() -> ButtonStyleSheet { pub const fn button_danger() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_DIMMED, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_LIGHT, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: ORANGE_LIGHT, button_color: BG, icon_color: ORANGE_LIGHT, @@ -360,21 +378,21 @@ pub const fn button_danger() -> ButtonStyleSheet { pub const fn button_keyboard() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_NORMAL, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: GREY_EXTRA_DARK, icon_color: GREY_LIGHT, background_color: BG, }, active: &ButtonStyle { - font: FONT_NORMAL, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: GREY_LIGHT, icon_color: BG, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_NORMAL, + font: fonts::FONT_DEMIBOLD, text_color: GREY_DARK, button_color: BG, // so there is no "button" itself, just the text icon_color: GREY_LIGHT, @@ -386,14 +404,14 @@ pub const fn button_keyboard() -> ButtonStyleSheet { pub const fn button_keyboard_cancel() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: BG, // TODO: gradient icon_color: ORANGE_LIGHT, background_color: BG, }, active: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: ORANGE_LIGHT, icon_color: BG, @@ -401,7 +419,7 @@ pub const fn button_keyboard_cancel() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: BG, icon_color: GREEN_LIGHT, @@ -413,14 +431,14 @@ pub const fn button_keyboard_cancel() -> ButtonStyleSheet { pub const fn button_keyboard_erase() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: BG, // TODO: gradient icon_color: GREY, background_color: BG, }, active: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREY_LIGHT, icon_color: BG, @@ -428,7 +446,7 @@ pub const fn button_keyboard_erase() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: BG, icon_color: GREEN_LIGHT, @@ -442,21 +460,21 @@ pub const fn button_keyboard_erase() -> ButtonStyleSheet { pub const fn button_pin_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_DARK, icon_color: GREEN_LIME, background_color: BG, }, active: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: FG, button_color: GREEN_LIGHT, icon_color: GREEN_DARK, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: GREY_DARK, button_color: BG, icon_color: GREY_DARK, @@ -468,14 +486,14 @@ pub const fn button_pin_confirm() -> ButtonStyleSheet { pub const fn button_passphrase_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_LIGHT, icon_color: GREEN_LIME, background_color: GREEN_DARK, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_LIGHT, icon_color: GREEN_DARK, @@ -483,7 +501,7 @@ pub const fn button_passphrase_confirm() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -495,14 +513,14 @@ pub const fn button_passphrase_confirm() -> ButtonStyleSheet { pub const fn button_passphrase_confirm_empty() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY, button_color: GREY_EXTRA_DARK, icon_color: GREY, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: GREY_LIGHT, icon_color: BG, @@ -510,7 +528,7 @@ pub const fn button_passphrase_confirm_empty() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -522,14 +540,14 @@ pub const fn button_passphrase_confirm_empty() -> ButtonStyleSheet { pub const fn button_passphrase_next() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, // TODO: gradient icon_color: GREY_LIGHT, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, // TODO: gradient icon_color: GREY_LIGHT, @@ -537,7 +555,7 @@ pub const fn button_passphrase_next() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: GREY_LIGHT, @@ -549,14 +567,14 @@ pub const fn button_passphrase_next() -> ButtonStyleSheet { pub const fn button_recovery_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_LIGHT, icon_color: GREEN_LIME, background_color: GREEN_DARK, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_DARK, button_color: GREEN_LIGHT, icon_color: GREEN_DARK, @@ -564,7 +582,7 @@ pub const fn button_recovery_confirm() -> ButtonStyleSheet { }, // used in SLIP-39 recovery for "*" disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: BG, icon_color: BG, @@ -576,14 +594,14 @@ pub const fn button_recovery_confirm() -> ButtonStyleSheet { pub const fn button_suggestion_confirm() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, // difference button_color: GREEN_LIGHT, icon_color: GREEN_LIME, background_color: GREEN_DARK, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREEN_LIME, button_color: GREEN_LIGHT, icon_color: GREEN_DARK, @@ -591,7 +609,7 @@ pub const fn button_suggestion_confirm() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -603,14 +621,14 @@ pub const fn button_suggestion_confirm() -> ButtonStyleSheet { pub const fn button_recovery_autocomplete() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_LIGHT, button_color: GREY_EXTRA_DARK, icon_color: GREY_LIGHT, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: FG, icon_color: BG, @@ -618,7 +636,7 @@ pub const fn button_recovery_autocomplete() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: BG, icon_color: BG, @@ -630,14 +648,14 @@ pub const fn button_recovery_autocomplete() -> ButtonStyleSheet { pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY, button_color: BG, icon_color: BG, background_color: BG, }, active: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: BG, button_color: FG, icon_color: BG, @@ -645,7 +663,7 @@ pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { }, // not used disabled: &ButtonStyle { - font: FONT_MONO, + font: fonts::FONT_MONO, text_color: BG, button_color: BG, icon_color: BG, @@ -657,21 +675,21 @@ pub const fn button_suggestion_autocomplete() -> ButtonStyleSheet { pub const fn button_counter() -> ButtonStyleSheet { ButtonStyleSheet { normal: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY, button_color: GREY_EXTRA_DARK, icon_color: GREY, background_color: BG, }, active: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: BG, button_color: GREY_LIGHT, icon_color: BG, background_color: BG, }, disabled: &ButtonStyle { - font: FONT_DEMIBOLD, + font: fonts::FONT_DEMIBOLD, text_color: GREY_DARK, button_color: BG, icon_color: GREY_DARK, @@ -706,16 +724,19 @@ pub const fn loader_lock_icon() -> LoaderStyleSheet { } } -pub const TEXT_SUPER: TextStyle = TextStyle::new(FONT_BIG, GREY_EXTRA_LIGHT, BG, GREY, GREY); +pub const TEXT_SUPER: TextStyle = TextStyle::new(fonts::FONT_BIG, GREY_EXTRA_LIGHT, BG, GREY, GREY); pub const TEXT_MAIN_GREY_EXTRA_LIGHT: TextStyle = - TextStyle::new(FONT_NORMAL, GREY_EXTRA_LIGHT, BG, GREY, GREY); -pub const TEXT_MAIN_GREY_LIGHT: TextStyle = TextStyle::new(FONT_NORMAL, GREY_LIGHT, BG, GREY, GREY); -pub const TEXT_SUB_GREY_LIGHT: TextStyle = TextStyle::new(FONT_SUB, GREY_LIGHT, BG, GREY, GREY); -pub const TEXT_SUB_GREY: TextStyle = TextStyle::new(FONT_SUB, GREY, BG, GREY, GREY); + TextStyle::new(fonts::FONT_DEMIBOLD, GREY_EXTRA_LIGHT, BG, GREY, GREY); +pub const TEXT_MAIN_GREY_LIGHT: TextStyle = + TextStyle::new(fonts::FONT_DEMIBOLD, GREY_LIGHT, BG, GREY, GREY); +pub const TEXT_SUB_GREY_LIGHT: TextStyle = + TextStyle::new(fonts::FONT_SUB, GREY_LIGHT, BG, GREY, GREY); +pub const TEXT_SUB_GREY: TextStyle = TextStyle::new(fonts::FONT_SUB, GREY, BG, GREY, GREY); pub const TEXT_SUB_GREEN_LIME: TextStyle = - TextStyle::new(FONT_SUB, GREEN_LIME, BG, GREEN_LIME, GREEN_LIME); -pub const TEXT_WARNING: TextStyle = TextStyle::new(FONT_NORMAL, ORANGE_LIGHT, BG, GREY, GREY); -pub const TEXT_MONO: TextStyle = TextStyle::new(FONT_MONO, GREY_EXTRA_LIGHT, BG, GREY, GREY) + TextStyle::new(fonts::FONT_SUB, GREEN_LIME, BG, GREEN_LIME, GREEN_LIME); +pub const TEXT_WARNING: TextStyle = + TextStyle::new(fonts::FONT_DEMIBOLD, ORANGE_LIGHT, BG, GREY, GREY); +pub const TEXT_MONO: TextStyle = TextStyle::new(fonts::FONT_MONO, GREY_EXTRA_LIGHT, BG, GREY, GREY) .with_line_breaking(LineBreaking::BreakWordsNoHyphen) .with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth) .with_ellipsis_icon(ICON_PAGE_NEXT, 0) @@ -738,9 +759,12 @@ pub const TEXT_MONO_ADDRESS_CHUNKS_SMALLER_X_OFFSET: TextStyle = TEXT_MONO .with_ellipsis_icon(ICON_PAGE_NEXT, -12); // TODO: remove TextStyles below when ui-t3t1 done -pub const TEXT_NORMAL: TextStyle = TextStyle::new(FONT_NORMAL, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_DEMIBOLD: TextStyle = TextStyle::new(FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_BOLD: TextStyle = TextStyle::new(FONT_BOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_NORMAL: TextStyle = + TextStyle::new(fonts::FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_DEMIBOLD: TextStyle = + TextStyle::new(fonts::FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_BOLD: TextStyle = + TextStyle::new(fonts::FONT_DEMIBOLD, FG, BG, GREY_LIGHT, GREY_LIGHT); /// Decide the text style of chunkified text according to its length. pub fn get_chunkified_text_style(character_length: usize) -> &'static TextStyle { @@ -754,12 +778,17 @@ pub fn get_chunkified_text_style(character_length: usize) -> &'static TextStyle } } -pub const TEXT_NORMAL_GREY_EXTRA_LIGHT: TextStyle = - TextStyle::new(FONT_NORMAL, GREY_EXTRA_LIGHT, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_CHECKLIST_DEFAULT: TextStyle = TextStyle::new(FONT_SUB, GREY, BG, GREY, GREY); +pub const TEXT_NORMAL_GREY_EXTRA_LIGHT: TextStyle = TextStyle::new( + fonts::FONT_DEMIBOLD, + GREY_EXTRA_LIGHT, + BG, + GREY_LIGHT, + GREY_LIGHT, +); +pub const TEXT_CHECKLIST_DEFAULT: TextStyle = TextStyle::new(fonts::FONT_SUB, GREY, BG, GREY, GREY); pub const TEXT_CHECKLIST_SELECTED: TextStyle = - TextStyle::new(FONT_NORMAL, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT); -pub const TEXT_CHECKLIST_DONE: TextStyle = TextStyle::new(FONT_SUB, GREY, BG, GREY, GREY); + TextStyle::new(fonts::FONT_DEMIBOLD, GREY_LIGHT, BG, GREY_LIGHT, GREY_LIGHT); +pub const TEXT_CHECKLIST_DONE: TextStyle = TextStyle::new(fonts::FONT_SUB, GREY, BG, GREY, GREY); /// Spacing between components (e.g. header and main content) and offsets from /// the side of the screen. Generally applied everywhere except the top side of diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs index aa4af5f497..9f509a7703 100644 --- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs @@ -20,7 +20,7 @@ use crate::{ }, Border, CachedJpeg, ComponentExt, Empty, FormattedText, Never, Timeout, }, - geometry::{self, Direction}, + geometry::{self, Direction, Offset}, layout::{ obj::{LayoutMaybeTrace, LayoutObj, RootComponent}, util::{PropsList, RecoveryType}, @@ -42,7 +42,7 @@ use super::{ self, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings, ConfirmValue, ShowInfoParams, }, - theme, UIDelizia, + fonts, theme, UIDelizia, }; impl FirmwareUI for UIDelizia { @@ -223,14 +223,14 @@ impl FirmwareUI for UIDelizia { let mut ops = OpTextLayout::new(theme::TEXT_NORMAL); for item in IterBuf::new().try_iterate(items)? { if item.is_str() { - ops = ops.text_normal(TString::try_from(item)?) + ops = ops.text(TString::try_from(item)?, fonts::FONT_NORMAL) } else { let [emphasis, text]: [Obj; 2] = util::iter_into_array(item)?; let text: TString = text.try_into()?; if emphasis.try_into()? { - ops = ops.text_demibold(text); + ops = ops.text(text, fonts::FONT_DEMIBOLD); } else { - ops = ops.text_normal(text); + ops = ops.text(text, fonts::FONT_NORMAL); } } } @@ -803,7 +803,11 @@ impl FirmwareUI for UIDelizia { .with_spacing(theme::CHECKLIST_SPACING), ) .with_check_width(theme::CHECKLIST_CHECK_WIDTH) - .with_numerals() + .with_numerals(fonts::FONT_SUB) + .with_numeral_offset(Offset::new( + 4, + fonts::FONT_DEMIBOLD.visible_text_height("1"), + )) .with_icon_done_color(theme::GREEN) .with_done_offset(theme::CHECKLIST_DONE_OFFSET); @@ -1068,7 +1072,12 @@ impl FirmwareUI for UIDelizia { } fn show_wait_text(text: TString<'static>) -> Result { - let layout = RootComponent::new(Connect::new(text, theme::FG, theme::BG)); + let layout = RootComponent::new(Connect::new( + text, + fonts::FONT_DEMIBOLD, + theme::FG, + theme::BG, + )); Ok(layout) } diff --git a/core/embed/rust/src/ui/shape/text.rs b/core/embed/rust/src/ui/shape/text.rs index 82c9f83085..10552870e2 100644 --- a/core/embed/rust/src/ui/shape/text.rs +++ b/core/embed/rust/src/ui/shape/text.rs @@ -1,5 +1,5 @@ use crate::ui::{ - display::{font::FONT_NORMAL, Color, Font}, + display::{Color, Font}, geometry::{Alignment, Offset, Point, Rect}, }; @@ -28,13 +28,13 @@ pub struct Text<'a> { impl<'a> Text<'a> { /// Creates a `shape::Text` structure with a specified /// text (`str`) and the bottom-left corner (`pos`). - pub fn new(pos: Point, text: &'a str) -> Self { + pub fn new(pos: Point, text: &'a str, font: Font) -> Self { Self { pos, text, color: Color::white(), alpha: 255, - font: FONT_NORMAL, + font, align: Alignment::Start, bounds: Rect::zero(), } @@ -44,10 +44,6 @@ impl<'a> Text<'a> { Self { color, ..self } } - pub fn with_font(self, font: Font) -> Self { - Self { font, ..self } - } - pub fn with_align(self, align: Alignment) -> Self { Self { align, ..self } }