mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-09 01:33:41 +08:00
7933c10c97
* debug * hacks everywhere but kind of works * by font * fix sidebar * stash * test update * just use a const * just use a const * better * clean up * fix label * simplify * gpt5 is yet again garbage * rm that * clean up * rm * blank * clean up * I really don't like this but shrug * fix * fix experimental text
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
|