mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-05 14:22:33 +00:00
centering
This commit is contained in:
parent
8d824e4ef2
commit
ec9ad35e71
@ -266,7 +266,20 @@ impl TextLayout {
|
||||
|
||||
cursor.x += match self.align {
|
||||
Alignment::Start => 0,
|
||||
Alignment::Center => (remaining_width - span.advance.x) / 2,
|
||||
Alignment::Center => {
|
||||
let start_bearing_x = self.style.text_font.start_x_bearing(&remaining_text[..span.length]);
|
||||
let mut visible_width = self.style.text_font.visible_text_width(&remaining_text[..span.length]);
|
||||
|
||||
if span.advance.y> 0 && span.insert_hyphen_before_line_break {
|
||||
let hyphen_width = self.style.text_font.visible_text_width("-");
|
||||
let hyphen_bearing_x = self.style.text_font.start_x_bearing("-");
|
||||
visible_width = span.advance.x - start_bearing_x + hyphen_width + hyphen_bearing_x;
|
||||
}
|
||||
if cursor.x != init_cursor.x {
|
||||
|
||||
}
|
||||
((remaining_width - visible_width) / 2) - start_bearing_x
|
||||
},
|
||||
Alignment::End => remaining_width - span.advance.x,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user