fix(ui): Correct font asset loading paths for test workspace isolation

This commit is contained in:
2026-03-08 21:52:35 -04:00
parent 605b2ac024
commit c6dd055da8
2 changed files with 18 additions and 7 deletions

View File

@@ -2752,16 +2752,27 @@ class App:
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_theme_panel")
def _load_fonts(self) -> None:
# Set hello_imgui assets folder to the actual absolute path
assets_dir = Path(__file__).parent.parent / "assets"
if assets_dir.exists():
hello_imgui.set_assets_folder(str(assets_dir.absolute()))
font_path, font_size = theme.get_font_loading_params()
if font_path and Path(font_path).exists():
if font_path:
# Just try loading it directly; hello_imgui will look in the assets folder
try:
self.main_font = hello_imgui.load_font_ttf_with_font_awesome_icons(font_path, font_size)
except Exception as e:
print(f"Failed to load main font {font_path}: {e}")
self.main_font = None
else:
self.main_font = None
mono_path = Path("assets/fonts/MapleMono-Regular.ttf")
if mono_path.exists():
self.mono_font = hello_imgui.load_font(str(mono_path), font_size)
else:
try:
self.mono_font = hello_imgui.load_font("fonts/MapleMono-Regular.ttf", font_size)
except Exception as e:
print(f"Failed to load mono font: {e}")
self.mono_font = None
def _post_init(self) -> None:

View File

@@ -241,7 +241,7 @@ def load_from_config(config: dict) -> None:
global _current_font_path, _current_font_size, _current_scale, _current_palette
t = config.get("theme", {})
_current_palette = t.get("palette", "ImGui Dark")
_current_font_path = t.get("font_path", "assets/fonts/Inter-Regular.ttf")
_current_font_path = t.get("font_path", "fonts/Inter-Regular.ttf")
_current_font_size = float(t.get("font_size", 16.0))
_current_scale = float(t.get("scale", 1.0))
# Don't apply here — imgui context may not exist yet.