Files
vectorcraft/crates/ui-egui/src/tests_fonts.rs
T
bflatasticandClaude Opus 5.5 d324138bc1 Fonts: drop the plain font dropdown now that no picker uses it (review of #397)
Find Font and the Glyphs panel were widgets::font_dropdown's last
callers; the font menu's own tests cover searching and Enter. ROADMAP:
the Glyphs panel and Find Font's Replace With use the font menu, without
its live preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 07:32:12 +07:00

34 lines
1.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! The font menus list the installed fonts without asking for them (#36).
use serde_json::json;
use vectorcraft_engine::Session;
use vectorcraft_text::{FontDb, system_font_dirs};
use crate::{VectorcraftApp, menus};
#[test]
fn type_font_menu_lists_every_available_family() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({})).unwrap();
let fonts = |app: &VectorcraftApp| -> Vec<String> {
menus::menu_entries(app).into_iter().filter(|e| e.path == ["Type", "Font"]).map(|e| e.label).collect()
};
let labels = fonts(&app);
assert_eq!(labels, *FontDb::global().menu_family_list());
let installed = FontDb::with_font_dirs(system_font_dirs());
installed.load_system_fonts();
let missing: Vec<String> = installed.menu_family_list().iter().filter(|f| !labels.contains(f)).cloned().collect();
assert!(missing.is_empty(), "installed but not in Type › Font: {missing:?}");
// The menu is built every frame, from a list built once.
assert_eq!(fonts(&app), labels);
}
#[test]
fn the_character_panel_menu_refreshes_the_font_list() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({})).unwrap();
// The installed fonts are always listed: the menu offers to look for new ones instead.
let text = crate::tests_labels::painted_text(&mut app, crate::panels::character::menu);
assert!(text.contains("Refresh Font List") && !text.contains("System Fonts"), "{text}");
}