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