mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-05 17:56:10 +00:00
feat(core/rust): make font changes for TR
[no changelog]
This commit is contained in:
parent
d199a17cfc
commit
ef2d2a3e75
@ -30,11 +30,11 @@ PYOPT = ARGUMENTS.get('PYOPT', '1')
|
||||
FROZEN = True
|
||||
|
||||
if TREZOR_MODEL in ('R',):
|
||||
FONT_NORMAL='Font_Unifont_Regular_16'
|
||||
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
||||
FONT_DEMIBOLD='Font_Unifont_Bold_16'
|
||||
FONT_BOLD='Font_PixelOperator_Bold_8'
|
||||
FONT_MONO='Font_PixelOperatorMono_Regular_8'
|
||||
FONT_BIG=None
|
||||
FONT_BIG='Font_Unifont_Regular_16'
|
||||
elif TREZOR_MODEL in ('T', ):
|
||||
FONT_NORMAL='Font_TTHoves_Regular_21'
|
||||
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
|
||||
|
@ -26,11 +26,11 @@ FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
|
||||
RASPI = os.getenv('TREZOR_EMULATOR_RASPI') == '1'
|
||||
|
||||
if TREZOR_MODEL in ('R',):
|
||||
FONT_NORMAL='Font_Unifont_Regular_16'
|
||||
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
||||
FONT_DEMIBOLD='Font_Unifont_Bold_16'
|
||||
FONT_BOLD='Font_PixelOperator_Bold_8'
|
||||
FONT_MONO='Font_PixelOperatorMono_Regular_8'
|
||||
FONT_BIG=None
|
||||
FONT_BIG='Font_Unifont_Regular_16'
|
||||
elif TREZOR_MODEL in ('T', ):
|
||||
FONT_NORMAL='Font_TTHoves_Regular_21'
|
||||
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
|
||||
|
@ -45,7 +45,7 @@ where
|
||||
pub fn new(label: T, notification: Option<(T, u8)>) -> Self {
|
||||
let invisible_btn_layout = ButtonLayout::htc_none_htc("".into(), "".into());
|
||||
Self {
|
||||
label: Label::centered(label, theme::TEXT_NORMAL),
|
||||
label: Label::centered(label, theme::TEXT_BIG),
|
||||
notification,
|
||||
invisible_buttons: Child::new(ButtonController::new(invisible_btn_layout)),
|
||||
}
|
||||
@ -158,8 +158,8 @@ where
|
||||
"Click to Unlock"
|
||||
};
|
||||
Lockscreen {
|
||||
label: Child::new(Label::centered(label, theme::TEXT_NORMAL)),
|
||||
instruction: Child::new(Label::centered(instruction_str.into(), theme::TEXT_MONO)),
|
||||
label: Child::new(Label::centered(label, theme::TEXT_BIG)),
|
||||
instruction: Child::new(Label::centered(instruction_str.into(), theme::TEXT_NORMAL)),
|
||||
invisible_buttons: Child::new(ButtonController::new(invisible_btn_layout)),
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,8 @@ where
|
||||
value: 0,
|
||||
loader_y_offset: 0,
|
||||
indeterminate,
|
||||
description: Paragraphs::new(
|
||||
Paragraph::new(&theme::TEXT_NORMAL, description).centered(),
|
||||
)
|
||||
.into_child(),
|
||||
description: Paragraphs::new(Paragraph::new(&theme::TEXT_BIG, description).centered())
|
||||
.into_child(),
|
||||
description_pad: Pad::with_background(theme::BG),
|
||||
update_description,
|
||||
}
|
||||
@ -75,8 +73,7 @@ where
|
||||
.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::NORMAL.line_height() * description_lines);
|
||||
let (loader, description) = rest.split_bottom(Font::BIG.line_height() * description_lines);
|
||||
self.title.place(title);
|
||||
self.loader_y_offset = loader.center().y - constant::screen().center().y;
|
||||
self.description.place(description);
|
||||
|
@ -50,7 +50,7 @@ where
|
||||
headline: Option<&'static str>,
|
||||
button_text: Option<&'static str>,
|
||||
) -> Self {
|
||||
let p1 = Paragraphs::new(Paragraph::new(&theme::TEXT_NORMAL, text))
|
||||
let p1 = Paragraphs::new(Paragraph::new(&theme::TEXT_BIG, text))
|
||||
.with_placement(LinearPlacement::vertical().align_at_center());
|
||||
|
||||
let buttons = button_text.map(|text| {
|
||||
|
@ -19,7 +19,7 @@ const EXTRA_LINE_HEIGHT: i16 = 2;
|
||||
const NUMBER_X_OFFSET: i16 = 5;
|
||||
const NUMBER_WORD_OFFSET: i16 = 20;
|
||||
const NUMBER_FONT: Font = Font::DEMIBOLD;
|
||||
const WORD_FONT: Font = Font::NORMAL;
|
||||
const WORD_FONT: Font = Font::BIG;
|
||||
const INFO_TOP_OFFSET: i16 = 15;
|
||||
const MAX_WORDS: usize = 33; // super-shamir has 33 words, all other have less
|
||||
|
||||
|
@ -317,10 +317,10 @@ extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut M
|
||||
if !reverse {
|
||||
paragraphs
|
||||
.add(Paragraph::new(&theme::TEXT_BOLD, action))
|
||||
.add(Paragraph::new(&theme::TEXT_MONO, description));
|
||||
.add(Paragraph::new(&theme::TEXT_NORMAL, description));
|
||||
} else {
|
||||
paragraphs
|
||||
.add(Paragraph::new(&theme::TEXT_MONO, description))
|
||||
.add(Paragraph::new(&theme::TEXT_NORMAL, description))
|
||||
.add(Paragraph::new(&theme::TEXT_BOLD, action));
|
||||
}
|
||||
paragraphs.into_paragraphs()
|
||||
@ -350,7 +350,7 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map
|
||||
extra: extra.unwrap_or_else(StrBuffer::empty),
|
||||
data: data.try_into()?,
|
||||
description_font: &theme::TEXT_BOLD,
|
||||
extra_font: &theme::TEXT_MONO,
|
||||
extra_font: &theme::TEXT_NORMAL,
|
||||
data_font: &theme::TEXT_MONO_DATA,
|
||||
}
|
||||
.into_paragraphs();
|
||||
@ -409,11 +409,11 @@ extern "C" fn new_confirm_reset_device(n_args: usize, args: *const Obj, kwargs:
|
||||
let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
|
||||
let button: StrBuffer = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?;
|
||||
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_MONO)
|
||||
.text_mono("By continuing you agree to Trezor Company's terms and conditions.".into())
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_NORMAL)
|
||||
.text_normal("By continuing you agree to Trezor Company's terms and conditions.".into())
|
||||
.newline()
|
||||
.newline()
|
||||
.text_mono("More info at".into())
|
||||
.text_normal("More info at".into())
|
||||
.newline()
|
||||
.text_bold("trezor.io/tos".into());
|
||||
let formatted = FormattedText::new(ops);
|
||||
@ -514,7 +514,7 @@ extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs:
|
||||
let paragraphs = Paragraphs::new([
|
||||
Paragraph::new(&theme::TEXT_BOLD, "Address:".into()),
|
||||
Paragraph::new(&theme::TEXT_MONO, address).break_after(),
|
||||
Paragraph::new(&theme::TEXT_MONO, description.into()),
|
||||
Paragraph::new(&theme::TEXT_NORMAL, description.into()),
|
||||
Paragraph::new(&theme::TEXT_MONO, amount_change),
|
||||
Paragraph::new(&theme::TEXT_BOLD, "New amount:".into()),
|
||||
Paragraph::new(&theme::TEXT_MONO, amount_new),
|
||||
@ -648,12 +648,12 @@ fn tutorial_screen(
|
||||
btn_layout: ButtonLayout<StrBuffer>,
|
||||
btn_actions: ButtonActions,
|
||||
) -> Page<StrBuffer> {
|
||||
let mut ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_MONO);
|
||||
let mut ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_NORMAL);
|
||||
// Add title if present
|
||||
if !title.is_empty() {
|
||||
ops = ops.text_bold(title.into()).newline().newline_half()
|
||||
}
|
||||
ops = ops.text_mono(text.into());
|
||||
ops = ops.text_normal(text.into());
|
||||
|
||||
let formatted = FormattedText::new(ops);
|
||||
Page::new(btn_layout, btn_actions, formatted)
|
||||
@ -713,9 +713,9 @@ extern "C" fn tutorial(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj
|
||||
},
|
||||
// This page is special
|
||||
5 => {
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_MONO)
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_NORMAL)
|
||||
.newline()
|
||||
.text_mono("Tutorial complete.".into())
|
||||
.text_normal("Tutorial complete.".into())
|
||||
.newline()
|
||||
.newline()
|
||||
.alignment(Alignment::Center)
|
||||
@ -829,9 +829,9 @@ extern "C" fn new_confirm_fido(n_args: usize, args: *const Obj, kwargs: *mut Map
|
||||
)
|
||||
};
|
||||
|
||||
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
||||
let ops = OpTextLayout::new(theme::TEXT_NORMAL)
|
||||
.newline()
|
||||
.text_mono(app_name.clone())
|
||||
.text_normal(app_name.clone())
|
||||
.newline()
|
||||
.text_bold(account);
|
||||
let formatted = FormattedText::new(ops);
|
||||
@ -860,7 +860,7 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -
|
||||
|
||||
let content = Frame::new(
|
||||
title,
|
||||
Paragraphs::new([Paragraph::new(&theme::TEXT_MONO, description)]),
|
||||
Paragraphs::new([Paragraph::new(&theme::TEXT_NORMAL, description)]),
|
||||
);
|
||||
let obj = if time_ms == 0 {
|
||||
// No timer, used when we only want to draw the dialog once and
|
||||
@ -884,11 +884,11 @@ extern "C" fn new_show_mismatch() -> Obj {
|
||||
|
||||
let btn_layout = ButtonLayout::arrow_none_text("QUIT".into());
|
||||
let btn_actions = ButtonActions::cancel_none_confirm();
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_MONO)
|
||||
let ops = OpTextLayout::<StrBuffer>::new(theme::TEXT_NORMAL)
|
||||
.text_bold("ADDRESS MISMATCH?".into())
|
||||
.newline()
|
||||
.newline_half()
|
||||
.text_mono("Please contact Trezor support at".into())
|
||||
.text_normal("Please contact Trezor support at".into())
|
||||
.newline()
|
||||
.text_bold("trezor.io/support".into());
|
||||
let formatted = FormattedText::new(ops);
|
||||
@ -1079,9 +1079,9 @@ extern "C" fn new_show_checklist(n_args: usize, args: *const Obj, kwargs: *mut M
|
||||
let iter = Iter::try_from_obj_with_buf(items, &mut iter_buf)?;
|
||||
for (i, item) in iter.enumerate() {
|
||||
let style = match i.cmp(&active) {
|
||||
Ordering::Less => &theme::TEXT_MONO,
|
||||
Ordering::Less => &theme::TEXT_NORMAL,
|
||||
Ordering::Equal => &theme::TEXT_BOLD,
|
||||
Ordering::Greater => &theme::TEXT_MONO,
|
||||
Ordering::Greater => &theme::TEXT_NORMAL,
|
||||
};
|
||||
let text: StrBuffer = item.try_into()?;
|
||||
paragraphs.add(Paragraph::new(style, text));
|
||||
@ -1116,7 +1116,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let button: StrBuffer = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?;
|
||||
let dry_run: bool = kwargs.get(Qstr::MP_QSTR_dry_run)?.try_into()?;
|
||||
|
||||
let paragraphs = Paragraphs::new([Paragraph::new(&theme::TEXT_MONO, description)]);
|
||||
let paragraphs = Paragraphs::new([Paragraph::new(&theme::TEXT_NORMAL, description)]);
|
||||
|
||||
let title = if dry_run {
|
||||
"SEED CHECK"
|
||||
|
@ -13,12 +13,16 @@ 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::MONO;
|
||||
pub const FONT_BUTTON: Font = Font::NORMAL;
|
||||
pub const FONT_HEADER: Font = Font::BOLD;
|
||||
pub const FONT_CHOICE_ITEMS: Font = Font::NORMAL;
|
||||
pub const FONT_CHOICE_ITEMS: Font = Font::BIG;
|
||||
|
||||
// Text constants.
|
||||
pub const TEXT_NORMAL: TextStyle = TextStyle::new(Font::NORMAL, FG, BG, FG, FG);
|
||||
pub const TEXT_NORMAL: TextStyle = TextStyle::new(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::BIG, FG, BG, FG, FG);
|
||||
pub const TEXT_DEMIBOLD: TextStyle = TextStyle::new(Font::DEMIBOLD, FG, BG, FG, FG);
|
||||
pub const TEXT_BOLD: TextStyle = TextStyle::new(Font::BOLD, FG, BG, FG, FG)
|
||||
.with_page_breaking(PageBreaking::CutAndInsertEllipsisBoth)
|
||||
|
@ -403,10 +403,10 @@ def test_hide_passphrase_from_host(client: Client):
|
||||
)
|
||||
client.debug.press_yes()
|
||||
elif client.debug.model == "R":
|
||||
client.debug.press_right()
|
||||
layout = client.debug.wait_layout()
|
||||
assert "will not be displayed" in layout.text_content()
|
||||
client.debug.press_right()
|
||||
client.debug.press_right()
|
||||
client.debug.press_yes()
|
||||
|
||||
client.watch_layout()
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user