system/ui: define character set for loading fonts (#35298)

* system/ui: define font character set

* remove debug print statement

* shorter
This commit is contained in:
Cameron Clough
2025-05-20 15:47:10 +01:00
committed by GitHub
parent 69799fceb4
commit 5667583198
+12 -1
View File
@@ -190,12 +190,23 @@ class GuiApplication:
"Inter-Black.ttf",
)
# Create a character set from our keyboard layouts
from openpilot.system.ui.widgets.keyboard import KEYBOARD_LAYOUTS
all_chars = ""
for layout in KEYBOARD_LAYOUTS.values():
all_chars.update(key for row in layout for key in row)
all_chars = "".join(all_chars)
codepoint_count = rl.ffi.new("int *", 1)
codepoints = rl.load_codepoints(all_chars, codepoint_count)
for index, font_file in enumerate(font_files):
with as_file(FONT_DIR.joinpath(font_file)) as fspath:
font = rl.load_font_ex(fspath.as_posix(), 120, None, 0)
font = rl.load_font_ex(fspath.as_posix(), 120, codepoints, codepoint_count[0])
rl.set_texture_filter(font.texture, rl.TextureFilter.TEXTURE_FILTER_BILINEAR)
self._fonts[index] = font
rl.unload_codepoints(codepoints)
rl.gui_set_font(self._fonts[FontWeight.NORMAL])
def _set_styles(self):