mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-24 02:06:54 -06:00
22 lines
1.0 KiB
Rust
22 lines
1.0 KiB
Rust
//! A new session finds the installed system fonts by family name (#22). One test in its own
|
|
//! process, so the process-wide database starts fresh, as it does when the app starts.
|
|
|
|
use designcraft_fonts::{FontDb, system_font_dirs};
|
|
|
|
#[test]
|
|
fn a_fresh_session_finds_installed_fonts_by_name() {
|
|
let bundled = FontDb::with_font_dirs(vec![]).families();
|
|
let probe = FontDb::with_font_dirs(system_font_dirs());
|
|
probe.load_system_fonts();
|
|
// An installed family that isn't bundled and that loads.
|
|
let installed = probe.families();
|
|
let Some(family) = installed.iter().filter(|f| !bundled.contains(f)).find(|f| probe.face(f, "Regular").family == **f) else {
|
|
eprintln!("no system fonts installed: nothing to check");
|
|
return;
|
|
};
|
|
// The first lookup in the session: nothing has scanned the font folders yet.
|
|
assert!(FontDb::global().has_family(family));
|
|
assert_eq!(&FontDb::global().face(family, "Regular").family, family);
|
|
assert!(FontDb::global().families().contains(family));
|
|
}
|