forked from AetherRitual/taiko-replay-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_common.py
More file actions
18 lines (15 loc) · 720 Bytes
/
ui_common.py
File metadata and controls
18 lines (15 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Shared UI utilities for viewer.py and profile_viewer.py."""
import pygame
# Font name priority: DejaVu (Linux), then common Windows/macOS faces, then default
FONT_PREF = ["DejaVu Sans", "Segoe UI", "Arial", "Helvetica", ""]
FONT_MONO_PREF = ["DejaVu Sans Mono", "Consolas", "Courier New", ""]
def sysfont(name_pref: list, size: int, bold: bool = False) -> pygame.font.Font:
"""Return the first available font from name_pref, falling back to the pygame default."""
for name in name_pref:
try:
f = pygame.font.SysFont(name, size, bold=bold)
if f is not None:
return f
except Exception:
continue
return pygame.font.Font(None, size)