From 57a000e97853cd8094ec0b9a522f96f274f78201 Mon Sep 17 00:00:00 2001 From: tydude001 Date: Thu, 15 Oct 2026 11:04:44 -0500 Subject: [PATCH] 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 --- crates/fonts/src/fontdb.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rs index 5f07295138..98e3c4630f 100644 --- a/crates/fonts/src/fontdb.rs +++ b/crates/fonts/src/fontdb.rs @@ -736,6 +736,10 @@ pub fn system_font_dirs() -> Vec { 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());