Linux: scan the Flatpak host font folders (#1937)

Inside a Flatpak, /usr/share/fonts and /usr/local/share/fonts are the runtime's and the home font
folders aren't exposed, so WordCraft listed only the runtime's fonts. Flatpak mounts the host's
system, local and user fonts at /run/host/fonts, /run/host/local-fonts and /run/host/user-fonts
for every app, and its main branch (after 1.19.2) also mounts ~/.fonts at
/run/host/user-fonts-legacy when the XDG user font folder exists too; scan those as well.
Folders that don't exist are skipped, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tydude001andClaude Opus 5.5 committed 2026-10-15 11:11:34 -05:00
1 parent fd0bb2fb1e
commit 57a000e978
1 file changed
+14
+14
View File
@@ -736,6 +736,10 @@ pub fn system_font_dirs() -> Vec<std::path::PathBuf> {
dirs.push(h.join(".fonts"));
dirs.push(h.join(".local/share/fonts"));
}
// Flatpak (#1937): the folders above are the runtime's, and the host's system, local and
// user fonts are mounted here instead (no filesystem permission needed). Flatpak after
// 1.19.2 also mounts ~/.fonts, at user-fonts-legacy when the XDG user font folder exists too.
dirs.extend(["/run/host/fonts", "/run/host/local-fonts", "/run/host/user-fonts", "/run/host/user-fonts-legacy"].map(Into::into));
}
dirs
}
@@ -1710,6 +1714,16 @@ mod tests_sysfonts;
mod tests {
use super::*;
#[test]
#[cfg(all(unix, not(target_os = "macos"), not(target_arch = "wasm32")))]
fn system_font_dirs_include_the_flatpak_host_folders() {
// Inside a Flatpak, /usr/share/fonts is the runtime's: the host's fonts are under /run/host (#1937).
let dirs = system_font_dirs();
for d in ["/usr/share/fonts", "/run/host/fonts", "/run/host/local-fonts", "/run/host/user-fonts", "/run/host/user-fonts-legacy"] {
assert!(dirs.contains(&std::path::PathBuf::from(d)), "{d} missing from {dirs:?}");
}
}
#[test]
fn east_asian_run_fallback_is_cached_per_char_set() {
let db = FontDb::with_font_dirs(Vec::new());