1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-19 12:58:13 +00:00

feat(core): deal with non-breaking spaces

[no changelog]
This commit is contained in:
Ioan Bizău 2024-07-09 11:28:21 +02:00 committed by Ioan Bizău
parent a35e9ba5fa
commit 5188dfc83d
3 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
<%
import json
import re
ALTCOIN_PREFIXES = (
"binance",
@ -55,7 +56,7 @@ impl TranslatedString {
%if any(name.startswith(prefix + "__") for prefix in ALTCOIN_PREFIXES):
#[cfg(feature = "universal_fw")]
%endif
Self::${name} => ${json.dumps(en_data.get(name, '""'))},
Self::${name} => ${re.sub(r'\\u([0-9a-f]{4})', r'\\u{\g<1>}', json.dumps(en_data.get(name, '""')))},
% endfor
}
}

View File

@ -285,6 +285,12 @@ impl Font {
}
pub fn get_glyph(self, ch: char) -> Glyph {
/* have the non-breaking space counted for width but not counted as a
* breaking point */
let ch = match ch {
'\u{00a0}' => '\u{0020}',
c => c,
};
let gl_data = display::get_char_glyph(ch as u16, self.into());
ensure!(!gl_data.is_null(), "Failed to load glyph");

View File

@ -107,7 +107,7 @@ def _resolve_path_to_texts(
if lower:
texts = [t.lower() for t in texts]
texts = [t.strip() for t in texts]
texts = [t.replace("\xa0", " ").strip() for t in texts]
return texts