diff --git a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c b/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c index ab12ebffd..79baa6a09 100644 --- a/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c +++ b/core/embed/lib/fonts/font_pixeloperatormono_regular_8.c @@ -72,7 +72,7 @@ /* \ */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_92[] = { 3, 7, 7, 1, 7, 145, 36, 72 }; /* ] */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_93[] = { 3, 7, 7, 0, 7, 228, 146, 120 }; /* ^ */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_94[] = { 5, 3, 7, 0, 7, 34, 162 }; -/* _ */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_95[] = { 8, 1, 7, 0, 0, 255, 0 }; +/* _ */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_95[] = { 7, 1, 7, 0, 0, 254, 0 }; /* ` */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_96[] = { 2, 2, 7, 1, 7, 144 }; /* a */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_97[] = { 5, 5, 7, 0, 5, 112, 95, 23, 128 }; /* b */ static const uint8_t Font_PixelOperatorMono_Regular_8_glyph_98[] = { 5, 7, 7, 0, 7, 132, 61, 24, 199, 192 }; diff --git a/core/embed/lib/fonts/font_unifont_bold_16.h b/core/embed/lib/fonts/font_unifont_bold_16.h index 3dbac99a0..c28e0048d 100644 --- a/core/embed/lib/fonts/font_unifont_bold_16.h +++ b/core/embed/lib/fonts/font_unifont_bold_16.h @@ -3,8 +3,8 @@ #if TREZOR_FONT_BPP != 1 #error Wrong TREZOR_FONT_BPP (expected 1) #endif -#define Font_Unifont_Bold_16_HEIGHT 12 // <--- 12 from 16 -#define Font_Unifont_Bold_16_MAX_HEIGHT 12 // <--- 12 from 15 +#define Font_Unifont_Bold_16_HEIGHT 16 +#define Font_Unifont_Bold_16_MAX_HEIGHT 15 #define Font_Unifont_Bold_16_BASELINE 2 extern const uint8_t* const Font_Unifont_Bold_16[126 + 1 - 32]; extern const uint8_t Font_Unifont_Bold_16_glyph_nonprintable[]; diff --git a/core/embed/lib/fonts/font_unifont_regular_16.h b/core/embed/lib/fonts/font_unifont_regular_16.h index 2ecaa9d8f..f9a1ec2c1 100644 --- a/core/embed/lib/fonts/font_unifont_regular_16.h +++ b/core/embed/lib/fonts/font_unifont_regular_16.h @@ -3,8 +3,8 @@ #if TREZOR_FONT_BPP != 1 #error Wrong TREZOR_FONT_BPP (expected 1) #endif -#define Font_Unifont_Regular_16_HEIGHT 12 // <--- 12 from 16 -#define Font_Unifont_Regular_16_MAX_HEIGHT 12 // <--- 12 from 15 +#define Font_Unifont_Regular_16_HEIGHT 16 +#define Font_Unifont_Regular_16_MAX_HEIGHT 15 #define Font_Unifont_Regular_16_BASELINE 2 extern const uint8_t* const Font_Unifont_Regular_16[126 + 1 - 32]; extern const uint8_t Font_Unifont_Regular_16_glyph_nonprintable[]; diff --git a/core/embed/rust/src/ui/component/label.rs b/core/embed/rust/src/ui/component/label.rs index 3c7b839db..0bbc21a21 100644 --- a/core/embed/rust/src/ui/component/label.rs +++ b/core/embed/rust/src/ui/component/label.rs @@ -76,7 +76,6 @@ where pub fn text_area(&self) -> Rect { // XXX only works on single-line labels - assert!(self.layout.bounds.height() <= self.font().text_max_height()); let available_width = self.layout.bounds.width(); let width = self.font().text_width(self.text.as_ref()); let height = self.font().text_height(); diff --git a/core/embed/rust/src/ui/display/font.rs b/core/embed/rust/src/ui/display/font.rs index e6ad0f362..942d9af90 100644 --- a/core/embed/rust/src/ui/display/font.rs +++ b/core/embed/rust/src/ui/display/font.rs @@ -178,6 +178,16 @@ impl Font { self.text_width(text) - first_char_bearing - last_char_bearing } + pub fn visible_text_height(&self, text: &str) -> i16 { + let (mut ascent, mut descent) = (0, 0); + for c in text.chars() { + let glyph = self.get_glyph(c); + ascent = ascent.max(glyph.bearing_y); + descent = descent.max(glyph.height - glyph.bearing_y); + } + ascent + descent + } + /// Returning the x-bearing (offset) of the first character. /// Useful to enforce that the text is positioned correctly (e.g. centered). pub fn start_x_bearing(self, text: &str) -> i16 { diff --git a/core/embed/rust/src/ui/model_tr/component/homescreen.rs b/core/embed/rust/src/ui/model_tr/component/homescreen.rs index eb60413c7..657cf5bc4 100644 --- a/core/embed/rust/src/ui/model_tr/component/homescreen.rs +++ b/core/embed/rust/src/ui/model_tr/component/homescreen.rs @@ -25,7 +25,7 @@ use super::{ const AREA: Rect = constant::screen(); const TOP_CENTER: Point = AREA.top_center(); -const LABEL_Y: i16 = constant::HEIGHT - 15; +const LABEL_Y: i16 = constant::HEIGHT - 18; const LABEL_AREA: Rect = AREA.split_top(LABEL_Y).1; const LOCKED_INSTRUCTION_Y: i16 = 27; const LOCKED_INSTRUCTION_AREA: Rect = AREA.split_top(LOCKED_INSTRUCTION_Y).1; @@ -141,7 +141,7 @@ where let mut outset = Insets::uniform(LABEL_OUTSET); // the margin at top is bigger (caused by text-height vs line-height?) // compensate by shrinking the outset - outset.top -= 2; + outset.top -= 5; rect_fill(self.label.text_area().outset(outset), theme::BG); self.label.paint(); } diff --git a/core/embed/rust/src/ui/model_tr/component/input_methods/choice.rs b/core/embed/rust/src/ui/model_tr/component/input_methods/choice.rs index 4dc9a9d93..5ddf7fabc 100644 --- a/core/embed/rust/src/ui/model_tr/component/input_methods/choice.rs +++ b/core/embed/rust/src/ui/model_tr/component/input_methods/choice.rs @@ -217,7 +217,7 @@ where // Getting the row area for the choices - so that displaying // items in the used font will show them in the middle vertically. let area_height_half = self.pad.area.height() / 2; - let font_size_half = theme::FONT_CHOICE_ITEMS.text_height() / 2; + let font_size_half = theme::FONT_CHOICE_ITEMS.visible_text_height("Ay") / 2; let center_row_area = self .pad .area diff --git a/core/embed/rust/src/ui/model_tr/component/input_methods/choice_item.rs b/core/embed/rust/src/ui/model_tr/component/input_methods/choice_item.rs index ad0fb4c74..0661e3be3 100644 --- a/core/embed/rust/src/ui/model_tr/component/input_methods/choice_item.rs +++ b/core/embed/rust/src/ui/model_tr/component/input_methods/choice_item.rs @@ -92,7 +92,11 @@ impl Choice for ChoiceItem { /// Showing both the icon and text, if the icon is available. fn paint_center(&self, area: Rect, inverse: bool) { let width = text_icon_width(Some(self.text.as_ref()), self.icon, self.font); - paint_rounded_highlight(area, Offset::new(width, self.font.text_height()), inverse); + paint_rounded_highlight( + area, + Offset::new(width, self.font.visible_text_height("Ay")), + inverse, + ); paint_text_icon( area, width, @@ -171,7 +175,7 @@ fn paint_text_icon( let mut baseline = area.bottom_center() - Offset::x(width / 2); if let Some(icon) = icon { - let height_diff = font.text_height() - icon.toif.height(); + let height_diff = font.visible_text_height("Ay") - icon.toif.height(); let vertical_offset = Offset::y(-height_diff / 2); icon.draw( baseline + vertical_offset, diff --git a/core/embed/rust/src/ui/model_tr/component/share_words.rs b/core/embed/rust/src/ui/model_tr/component/share_words.rs index 1935e32df..24283950a 100644 --- a/core/embed/rust/src/ui/model_tr/component/share_words.rs +++ b/core/embed/rust/src/ui/model_tr/component/share_words.rs @@ -15,7 +15,7 @@ use heapless::{String, Vec}; use super::{common::display_left, scrollbar::SCROLLBAR_SPACE, theme, ScrollBar}; const WORDS_PER_PAGE: usize = 3; -const EXTRA_LINE_HEIGHT: i16 = 2; +const EXTRA_LINE_HEIGHT: i16 = -2; const NUMBER_X_OFFSET: i16 = 0; const WORD_X_OFFSET: i16 = 25; const NUMBER_FONT: Font = Font::DEMIBOLD;