From c6dd055da80555dd35ae2f581c7eaec75b49cea4 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 8 Mar 2026 21:52:35 -0400 Subject: [PATCH] fix(ui): Correct font asset loading paths for test workspace isolation --- src/gui_2.py | 23 +++++++++++++++++------ src/theme_2.py | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gui_2.py b/src/gui_2.py index e59594d..14a2b80 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -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(): - self.main_font = hello_imgui.load_font_ttf_with_font_awesome_icons(font_path, font_size) + + 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: diff --git a/src/theme_2.py b/src/theme_2.py index bbe72b6..cc42a35 100644 --- a/src/theme_2.py +++ b/src/theme_2.py @@ -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.