chore(core): rename `OpTextLayout::add_text` to `add_text_with_font`
What changed, and why it matters
This commit is a simple rename of a Rust function from `add_text` to `add_text_with_font` across several UI layout files. It does not change any behavior, logic, or security properties of the code. It is a routine code cleanup with no user-visible or security impact.
No action required. This is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames OpTextLayout::add_text to add_text_with_font and updates all call sites in op.rs, layout_bolt/ui_firmware.rs, layout_caesar/ui_firmware.rs, layout_delizia/ui_firmware.rs, layout_eckhart/flow/show_thp_pairing_code.rs, and layout_eckhart/ui_firmware.rs. The method signature and behavior remain identical: it accepts text and a Font, then adds an Op::Text item. No functional changes are introduced.
Changed components
core/embed/rust/src/ui/component/text/op.rscore/embed/rust/src/ui/layout_bolt/ui_firmware.rscore/embed/rust/src/ui/layout_caesar/ui_firmware.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rscore/embed/rust/src/ui/layout_eckhart/flow/show_thp_pairing_code.rscore/embed/rust/src/ui/layout_eckhart/ui_firmware.rsInspect captured patch +56 / −51
diff --git a/core/embed/rust/src/ui/component/text/op.rs b/core/embed/rust/src/ui/component/text/op.rs
index 5ebf6303..1072427f 100644
--- a/core/embed/rust/src/ui/component/text/op.rs
+++ b/core/embed/rust/src/ui/component/text/op.rs
@@ -200,7 +200,7 @@ impl<'a> OpTextLayout<'a> {
self
}
- pub fn add_text(&mut self, text: impl Into<TString<'a>>, font: Font) -> &mut Self {
+ pub fn add_text_with_font(&mut self, text: impl Into<TString<'a>>, font: Font) -> &mut Self {
self.add_new_item(Op::Text(text.into(), font, false))
}
@@ -210,12 +210,12 @@ impl<'a> OpTextLayout<'a> {
pub fn add_newline(&mut self) -> &mut Self {
let font = self.layout.style.text_font;
- self.add_text("\n", font)
+ self.add_text_with_font("\n", font)
}
pub fn add_newline_half(&mut self) -> &mut Self {
let font = self.layout.style.text_font;
- self.add_text("\r", font)
+ self.add_text_with_font("\r", font)
}
pub fn add_next_page(&mut self) -> &mut Self {
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 cee7f2b1..7f832d11 100644
--- a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs
@@ -203,14 +203,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.add_text(TString::try_from(item)?, fonts::FONT_NORMAL);
+ ops.add_text_with_font(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.add_text(text, fonts::FONT_DEMIBOLD);
+ ops.add_text_with_font(text, fonts::FONT_DEMIBOLD);
} else {
- ops.add_text(text, fonts::FONT_NORMAL);
+ ops.add_text_with_font(text, fonts::FONT_NORMAL);
}
}
}
@@ -1493,11 +1493,11 @@ mod tests {
);
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(
+ ops.add_text_with_font(
"Testing text layout, with some text, and some more text. And ",
fonts::FONT_NORMAL,
)
- .add_text("parameters!", fonts::FONT_BOLD_UPPER);
+ .add_text_with_font("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/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
index 7a5ce5aa..b6378c72 100644
--- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
@@ -118,13 +118,14 @@ impl FirmwareUI for UICaesar {
if chunkify {
ops.add_chunkify_text(None);
}
- ops.add_text(label, fonts::FONT_NORMAL).add_newline();
+ ops.add_text_with_font(label, fonts::FONT_NORMAL)
+ .add_newline();
}
if chunkify {
// Chunkifying the address into smaller pieces when requested
ops.add_chunkify_text(Some((theme::MONO_CHUNKS, 2)));
}
- ops.add_text(address, fonts::FONT_MONO);
+ ops.add_text_with_font(address, fonts::FONT_MONO);
let formatted = FormattedText::new(ops).vertically_centered();
Page::new(btn_layout, btn_actions, formatted).with_title(title)
};
@@ -286,9 +287,9 @@ impl FirmwareUI for UICaesar {
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
ops.add_newline()
- .add_text(app_name, fonts::FONT_NORMAL)
+ .add_text_with_font(app_name, fonts::FONT_NORMAL)
.add_newline()
- .add_text(account, fonts::FONT_BOLD);
+ .add_text_with_font(account, fonts::FONT_BOLD);
let formatted = FormattedText::new(ops);
Page::new(btn_layout, btn_actions, formatted)
@@ -468,11 +469,11 @@ impl FirmwareUI for UICaesar {
)
};
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(TR::reset__by_continuing, fonts::FONT_NORMAL)
+ ops.add_text_with_font(TR::reset__by_continuing, fonts::FONT_NORMAL)
.add_next_page()
- .add_text(TR::reset__more_info_at, fonts::FONT_NORMAL)
+ .add_text_with_font(TR::reset__more_info_at, fonts::FONT_NORMAL)
.add_newline()
- .add_text(TR::reset__tos_link, fonts::FONT_BOLD);
+ .add_text_with_font(TR::reset__tos_link, fonts::FONT_BOLD);
let formatted = FormattedText::new(ops).vertically_centered();
content_in_button_page(title, formatted, button, Some("".into()), false, false)
@@ -558,16 +559,17 @@ impl FirmwareUI for UICaesar {
let mut ops = OpTextLayout::new(theme::TEXT_MONO);
if let Some(title) = title {
- ops.add_text(title, fonts::FONT_BOLD_UPPER).add_newline();
+ ops.add_text_with_font(title, fonts::FONT_BOLD_UPPER)
+ .add_newline();
}
let mut has_amount = false;
if let Some(amount) = amount {
if let Some(amount_label) = amount_label {
has_amount = true;
- ops.add_text(amount_label, fonts::FONT_BOLD)
+ ops.add_text_with_font(amount_label, fonts::FONT_BOLD)
.add_newline()
- .add_text(amount, fonts::FONT_MONO);
+ .add_text_with_font(amount, fonts::FONT_MONO);
}
}
@@ -576,9 +578,9 @@ impl FirmwareUI for UICaesar {
ops.add_newline();
}
ops.add_newline()
- .add_text(fee_label, fonts::FONT_BOLD)
+ .add_text_with_font(fee_label, fonts::FONT_BOLD)
.add_newline()
- .add_text(fee, fonts::FONT_MONO);
+ .add_text_with_font(fee, fonts::FONT_MONO);
}
let formatted = FormattedText::new(ops);
@@ -597,9 +599,12 @@ impl FirmwareUI for UICaesar {
// Each key-value pair is on its own page
ops.add_next_page();
}
- ops.add_text(unwrap!(TString::try_from(key)), fonts::FONT_BOLD)
+ ops.add_text_with_font(unwrap!(TString::try_from(key)), fonts::FONT_BOLD)
.add_newline()
- .add_text(unwrap!(TString::try_from(value)), fonts::FONT_MONO);
+ .add_text_with_font(
+ unwrap!(TString::try_from(value)),
+ fonts::FONT_MONO,
+ );
}
let formatted = FormattedText::new(ops).vertically_centered();
@@ -808,7 +813,7 @@ impl FirmwareUI for UICaesar {
};
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(text, fonts::FONT_NORMAL);
+ ops.add_text_with_font(text, fonts::FONT_NORMAL);
let formatted = FormattedText::new(ops).vertically_centered();
Page::new(btn_layout, btn_actions, formatted)
@@ -825,9 +830,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 mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(TR::backup__new_wallet_created, fonts::FONT_NORMAL)
+ ops.add_text_with_font(TR::backup__new_wallet_created, fonts::FONT_NORMAL)
.add_newline()
- .add_text(TR::backup__it_should_be_backed_up_now, fonts::FONT_NORMAL);
+ .add_text_with_font(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())
@@ -836,7 +841,7 @@ impl FirmwareUI for UICaesar {
let btn_layout = ButtonLayout::up_arrow_none_text(TR::buttons__back_up.into());
let btn_actions = ButtonActions::prev_none_confirm();
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(TR::backup__recover_anytime, fonts::FONT_NORMAL);
+ ops.add_text_with_font(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,13 +1075,13 @@ impl FirmwareUI for UICaesar {
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
ops.add_alignment(geometry::Alignment::Center);
if !title.is_empty() {
- ops.add_text(title, fonts::FONT_BOLD_UPPER);
+ ops.add_text_with_font(title, fonts::FONT_BOLD_UPPER);
if !description.is_empty() {
ops.add_newline();
}
}
if !description.is_empty() {
- ops.add_text(description, fonts::FONT_NORMAL);
+ ops.add_text_with_font(description, fonts::FONT_NORMAL);
}
let formatted = FormattedText::new(ops).vertically_centered();
Page::new(btn_layout, btn_actions, formatted)
@@ -1233,12 +1238,12 @@ impl FirmwareUI for UICaesar {
let btn_layout = ButtonLayout::arrow_none_text(TR::buttons__quit.into());
let btn_actions = ButtonActions::cancel_none_confirm();
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(title, fonts::FONT_BOLD_UPPER)
+ ops.add_text_with_font(title, fonts::FONT_BOLD_UPPER)
.add_newline()
.add_newline_half()
- .add_text(TR::addr_mismatch__contact_support_at, fonts::FONT_NORMAL)
+ .add_text_with_font(TR::addr_mismatch__contact_support_at, fonts::FONT_NORMAL)
.add_newline()
- .add_text(TR::addr_mismatch__support_url, fonts::FONT_BOLD);
+ .add_text_with_font(TR::addr_mismatch__support_url, fonts::FONT_BOLD);
let formatted = FormattedText::new(ops);
Page::new(btn_layout, btn_actions, formatted)
};
@@ -1391,13 +1396,13 @@ impl FirmwareUI for UICaesar {
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
ops.add_alignment(geometry::Alignment::Center);
if !value.is_empty() {
- ops.add_text(value, fonts::FONT_BOLD_UPPER);
+ ops.add_text_with_font(value, fonts::FONT_BOLD_UPPER);
if !description.is_empty() {
ops.add_newline();
}
}
if !description.is_empty() {
- ops.add_text(description, fonts::FONT_NORMAL);
+ ops.add_text_with_font(description, fonts::FONT_NORMAL);
}
let formatted = FormattedText::new(ops).vertically_centered();
Page::new(btn_layout, btn_actions, formatted)
@@ -1533,7 +1538,7 @@ fn tutorial_screen(
btn_actions: ButtonActions,
) -> Page {
let mut ops = OpTextLayout::new(theme::TEXT_NORMAL);
- ops.add_text(text, fonts::FONT_NORMAL);
+ ops.add_text_with_font(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/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
index dfcacfe3..6bfe8470 100644
--- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
@@ -253,12 +253,12 @@ 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.add_text(TString::try_from(item)?, fonts::FONT_DEMIBOLD);
+ ops.add_text_with_font(TString::try_from(item)?, fonts::FONT_DEMIBOLD);
} else {
let [_emphasis, text]: [Obj; 2] = util::iter_into_array(item)?;
let text: TString = text.try_into()?;
// emphasis not implemented on Delizia
- ops.add_text(text, fonts::FONT_DEMIBOLD);
+ ops.add_text_with_font(text, fonts::FONT_DEMIBOLD);
}
}
diff --git a/core/embed/rust/src/ui/layout_eckhart/flow/show_thp_pairing_code.rs b/core/embed/rust/src/ui/layout_eckhart/flow/show_thp_pairing_code.rs
index 3215d6f9..7df84878 100644
--- a/core/embed/rust/src/ui/layout_eckhart/flow/show_thp_pairing_code.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/flow/show_thp_pairing_code.rs
@@ -55,12 +55,12 @@ pub fn new_show_thp_pairing_code(
code: TString<'static>,
) -> Result<SwipeFlow, error::Error> {
let mut ops = OpTextLayout::new(theme::firmware::TEXT_REGULAR);
- ops.add_text(description, fonts::FONT_SATOSHI_REGULAR_38)
+ ops.add_text_with_font(description, fonts::FONT_SATOSHI_REGULAR_38)
.add_newline()
.add_newline()
.add_newline()
.add_alignment(Alignment::Center)
- .add_text(code, fonts::FONT_SATOSHI_EXTRALIGHT_72);
+ .add_text_with_font(code, fonts::FONT_SATOSHI_EXTRALIGHT_72);
let screen =
TextScreen::new(FormattedText::new(ops)).with_header(Header::new(title).with_menu_button());
let main_content = screen.map(|msg| match msg {
diff --git a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
index a9fcd05f..70ba19d1 100644
--- a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs
@@ -172,16 +172,16 @@ impl FirmwareUI for UIEckhart {
for item in IterBuf::new().try_iterate(items)? {
if item.is_str() {
- ops.add_text(TString::try_from(item)?, font);
+ ops.add_text_with_font(TString::try_from(item)?, font);
} else {
let [emphasis, text]: [Obj; 2] = util::iter_into_array(item)?;
let text: TString = text.try_into()?;
if emphasis.try_into()? {
ops.add_color(theme::WHITE)
- .add_text(text, font)
+ .add_text_with_font(text, font)
.add_color(text_style.text_color);
} else {
- ops.add_text(text, font);
+ ops.add_text_with_font(text, font);
}
}
}
@@ -408,11 +408,11 @@ impl FirmwareUI for UIEckhart {
let mut ops = OpTextLayout::new(theme::firmware::TEXT_REGULAR);
ops.add_offset(Offset::y(16))
.add_color(theme::RED)
- .add_text(sell_amount, font)
+ .add_text_with_font(sell_amount, font)
.add_offset(Offset::y(44))
.add_newline()
.add_color(theme::GREEN_LIME)
- .add_text(buy_amount, font);
+ .add_text_with_font(buy_amount, font);
let screen = TextScreen::new(FormattedText::new(ops))
.with_subtitle(subtitle)
.with_header(Header::new(title).with_menu_button())
@@ -612,12 +612,12 @@ impl FirmwareUI for UIEckhart {
op_layout
.add_line_spacing(3)
.add_color(theme::GREY_EXTRA_LIGHT)
- .add_text(title, fonts::FONT_SATOSHI_MEDIUM_26)
+ .add_text_with_font(title, fonts::FONT_SATOSHI_MEDIUM_26)
.add_newline()
.add_offset(Offset::y(24))
.add_color(theme::GREY_LIGHT)
.add_line_spacing(16)
- .add_text(description, fonts::FONT_MONO_MEDIUM_38);
+ .add_text_with_font(description, fonts::FONT_MONO_MEDIUM_38);
}
Some((op_layout, n_pages))
@@ -1239,9 +1239,9 @@ impl FirmwareUI for UIEckhart {
let mut ops = OpTextLayout::new(text_style);
let text: TString = " is your Trezor's name.".into();
ops.add_color(theme::GREEN)
- .add_text(device_name, font)
+ .add_text_with_font(device_name, font)
.add_color(text_style.text_color)
- .add_text(text, font);
+ .add_text_with_font(text, font);
let screen = TextScreen::new(FormattedText::new(ops))
.with_header(Header::new("Pair with new device".into()).with_close_button())
.with_action_bar(ActionBar::new_text_only("Continue on host".into()));
@@ -1258,12 +1258,12 @@ impl FirmwareUI for UIEckhart {
code: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
let mut ops = OpTextLayout::new(theme::firmware::TEXT_REGULAR);
- ops.add_text(description, fonts::FONT_SATOSHI_REGULAR_38)
+ ops.add_text_with_font(description, fonts::FONT_SATOSHI_REGULAR_38)
.add_newline()
.add_newline()
.add_newline()
.add_alignment(Alignment::Center)
- .add_text(code, fonts::FONT_SATOSHI_EXTRALIGHT_72);
+ .add_text_with_font(code, fonts::FONT_SATOSHI_EXTRALIGHT_72);
let screen = crate::ui::component::BLEHandler::new(
TextScreen::new(FormattedText::new(ops))
.with_header(Header::new(title))
@@ -1355,8 +1355,8 @@ impl FirmwareUI for UIEckhart {
let text_style = theme::TEXT_REGULAR;
let mut ops = OpTextLayout::new(text_style);
- ops.add_text(description, text_style.text_font)
- .add_text(url, theme::TEXT_MONO_MEDIUM.text_font);
+ ops.add_text_with_font(description, text_style.text_font)
+ .add_text_with_font(url, theme::TEXT_MONO_MEDIUM.text_font);
let screen = TextScreen::new(FormattedText::new(ops))
.with_header(Header::new(title))
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.