fix(ui): Correct font asset loading paths for test workspace isolation
This commit is contained in:
21
src/gui_2.py
21
src/gui_2.py
@@ -2752,16 +2752,27 @@ class App:
|
|||||||
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_theme_panel")
|
if self.perf_profiling_enabled: self.perf_monitor.end_component("_render_theme_panel")
|
||||||
|
|
||||||
def _load_fonts(self) -> None:
|
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()
|
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)
|
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:
|
else:
|
||||||
self.main_font = None
|
self.main_font = None
|
||||||
|
|
||||||
mono_path = Path("assets/fonts/MapleMono-Regular.ttf")
|
try:
|
||||||
if mono_path.exists():
|
self.mono_font = hello_imgui.load_font("fonts/MapleMono-Regular.ttf", font_size)
|
||||||
self.mono_font = hello_imgui.load_font(str(mono_path), font_size)
|
except Exception as e:
|
||||||
else:
|
print(f"Failed to load mono font: {e}")
|
||||||
self.mono_font = None
|
self.mono_font = None
|
||||||
|
|
||||||
def _post_init(self) -> None:
|
def _post_init(self) -> None:
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ def load_from_config(config: dict) -> None:
|
|||||||
global _current_font_path, _current_font_size, _current_scale, _current_palette
|
global _current_font_path, _current_font_size, _current_scale, _current_palette
|
||||||
t = config.get("theme", {})
|
t = config.get("theme", {})
|
||||||
_current_palette = t.get("palette", "ImGui Dark")
|
_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_font_size = float(t.get("font_size", 16.0))
|
||||||
_current_scale = float(t.get("scale", 1.0))
|
_current_scale = float(t.get("scale", 1.0))
|
||||||
# Don't apply here — imgui context may not exist yet.
|
# Don't apply here — imgui context may not exist yet.
|
||||||
|
|||||||
Reference in New Issue
Block a user