mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-18 00:15:44 +00:00
Keep upstream's split of layout_para and install the pinned fonts at its start. Refit the main tests added since (#4250 widow and footnote length, #4720 chart fallback font) to the pinned test fonts. Merge the two wordcraft-layout dev-dependency tables. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
Rust
30 lines
1.2 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 wordcraft_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));
|
|
}
|
|
|
|
#[cfg(feature = "test-support")]
|
|
#[test]
|
|
fn test_initialization_cannot_replace_an_application_database() {
|
|
let db = FontDb::global();
|
|
assert!(!FontDb::init_test_fonts());
|
|
assert!(std::ptr::eq(db, FontDb::global()));
|
|
}
|