cepetr 1 month ago committed by GitHub
commit 0c0172e050
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 };

@ -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[];

@ -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[];

@ -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();

@ -178,6 +178,30 @@ impl Font {
self.text_width(text) - first_char_bearing - last_char_bearing
}
/// Calculates the height of visible text.
///
/// It determines this height by finding the highest
/// pixel above the baseline and the lowest pixel below the baseline among
/// the glyphs representing the characters in the provided text.
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
}
/// Calculates the height of text containing both uppercase
/// and lowercase characters.
///
/// This function computes the height of a string containing both
/// uppercase and lowercase characters of the given font.
pub fn allcase_text_height(self) -> i16 {
self.visible_text_height("Ay")
}
/// 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 {

@ -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();
}

@ -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.allcase_text_height() / 2;
let center_row_area = self
.pad
.area

@ -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.allcase_text_height()),
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.allcase_text_height() - icon.toif.height();
let vertical_offset = Offset::y(-height_diff / 2);
icon.draw(
baseline + vertical_offset,

@ -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;

Loading…
Cancel
Save