mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-29 13:06:56 -06:00
Fonts: find fonts where Linux and Flatpak keep them; add and rescan commands (#277)
The font menu lists every family the scan of the system font folders finds,
but on Linux the scan only looked in /usr/share/fonts, /usr/local/share/fonts,
~/.fonts and ~/.local/share/fonts. Fonts under XDG data dirs, in folders
fontconfig is configured with (NixOS, Guix, custom setups) and, inside
Flatpak, the host's fonts never showed.
- system_font_dirs adds $XDG_DATA_HOME/fonts and each $XDG_DATA_DIRS/fonts,
Flatpak's /run/host/{fonts,local-fonts,user-fonts}, and the <dir> entries
of /etc/fonts/fonts.conf, local.conf and conf.d; duplicates are dropped.
- font.add {data} adds a font from its bytes for the session; font.rescan
catalogs the installed fonts again, and the font menu has a
"Rescan Installed Fonts" item for fonts installed while DeckCraft runs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -835,3 +835,13 @@ fn slide_ranges_parse_like_powerpoints_print_box() {
|
||||
let opts = cmd::file::pdf_options(&json!({"slides": [0, 7, 1]}), 2).unwrap();
|
||||
assert_eq!(opts.slides, Some(vec![0, 1]), "indices past the end are dropped");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn font_add_refuses_non_fonts_and_rescan_reports_the_catalog() {
|
||||
let mut s = session();
|
||||
let not_font = crate::cmd::base64_encode(b"definitely not a font file");
|
||||
assert!(s.execute("font.add", &json!({"data": not_font})).is_err());
|
||||
assert!(s.execute("font.add", &json!({})).is_err());
|
||||
let r = s.execute("font.rescan", &json!({})).unwrap();
|
||||
assert!(r["families"].as_u64().unwrap() >= 1, "{r}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user