fix: find_fonts_dir also checks ../fonts/ for dev (target/{debug,release})

This commit is contained in:
Developer
2026-05-16 22:16:07 +08:00
parent f76c59b6cf
commit 4e7768d265

View File

@@ -55,10 +55,17 @@ pub fn setup_fonts(ctx: &egui::Context, selected_name: &str) -> String {
}
fn find_fonts_dir() -> PathBuf {
// 1. CWD + fonts/ (cargo run from project root)
let cwd_fonts = PathBuf::from("fonts");
if cwd_fonts.is_dir() {
return cwd_fonts;
}
// 2. CWD + ../fonts/ (exe running from target/{debug,release})
let parent_fonts = PathBuf::from("../fonts");
if parent_fonts.is_dir() {
return parent_fonts;
}
// 3. Exe parent + fonts/ (deployed, fonts next to exe)
if let Ok(exe) = std::env::current_exe() {
if let Some(parent) = exe.parent() {
let p = parent.join("fonts");
@@ -67,5 +74,6 @@ fn find_fonts_dir() -> PathBuf {
}
}
}
// 4. Fallback (will fail with file-not-found, graceful fallback to bundled font)
PathBuf::from("fonts")
}