Skip to content

Commit be59872

Browse files
committed
Buttons should also detect font from button text if no font was manually specified
1 parent 222a107 commit be59872

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/element.zig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,17 @@ pub const Element = struct {
779779
self.type.button.text = new_text;
780780
self.type.button.translated = new_translated;
781781
if (new_translated.len > 0) {
782-
if (display.generate_text_texture(self.type.button.translated, self.type.button.font)) |texture| {
783-
self.type.button.text_texture = texture;
782+
if (self.type.button.font_name != null) {
783+
trace("use requested font '{s}' for {s}", .{ self.type.button.font_name.?, self.type.button.translated });
784+
if (display.generate_text_texture(self.type.button.translated, self.type.button.font)) |texture| {
785+
self.type.button.text_texture = texture;
786+
}
787+
} else {
788+
const font = @import("chunker.zig").guess_language(self.type.button.translated, display);
789+
trace("use detected font '{s}' for {s}", .{ font.name, self.type.button.translated });
790+
if (display.generate_text_texture(self.type.button.translated, font)) |texture| {
791+
self.type.button.text_texture = texture;
792+
}
784793
}
785794
}
786795
},

0 commit comments

Comments
 (0)