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

* system/ui: define font character set

* remove debug print statement

* shorter
pull/35299/head
Cameron Clough 4 months ago committed by GitHub
parent 69799fceb4
commit 5667583198
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      system/ui/lib/application.py

@ -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):

Loading…
Cancel
Save