mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-12 04:42:13 +08:00
b6dbb0fd8d
* pt 2 * fix line height * fixup html renderer * fix sidebar * fix label line height * firehose fixups * fix ssh value font styling * fixup inputbot * do experimental mode * pairing dialog numbers * fix radius for prime user * add emoji to firehose mode * full screen registration * fix registration btn size * fix update and alerts * debugging * Revert "debugging" This reverts commit 0095372e9479d8c727bcc8a78061f582d852133d. * firehose styling * fix offroad alerts missing bottom spacing expansion * huge oof * huge oof
16 lines
513 B
Python
16 lines
513 B
Python
import pyray as rl
|
|
from openpilot.system.ui.lib.application import FONT_SCALE
|
|
|
|
_cache: dict[int, rl.Vector2] = {}
|
|
|
|
|
|
def measure_text_cached(font: rl.Font, text: str, font_size: int, spacing: int = 0) -> rl.Vector2:
|
|
"""Caches text measurements to avoid redundant calculations."""
|
|
key = hash((font.texture.id, text, font_size, spacing))
|
|
if key in _cache:
|
|
return _cache[key]
|
|
|
|
result = rl.measure_text_ex(font, text, font_size * FONT_SCALE, spacing) # noqa: TID251
|
|
_cache[key] = result
|
|
return result
|