Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Merge pull request #228 from EthanSuquet/fix/hide-dot-system-fonts

Brandon Thomasaafd565b99f9
diff --cc crates/text/src/fontdb.rs
index 14c4f8d4d,a0df4bfd0..708911543
--- a/crates/text/src/fontdb.rs
+++ b/crates/text/src/fontdb.rs
@@@ -602,10 -473,25 +607,27 @@@ impl FontDb
list
}
+ /// The families font menus and lists show: [`FontDb::family_list`] without the system's hidden
+ /// families, whose names start with "." (macOS keeps ".SF NS", ".LastResort" and others for its
+ /// own interface, and Mac apps don't list them). Those still resolve by name, for documents and
+ /// fallbacks that name them. Cheap to call every frame.
+ pub fn menu_family_list(&self) -> Arc<[String]> {
+ let all = self.family_list();
+ let mut cache = self.menu_cache.lock().unwrap_or_else(|e| e.into_inner());
+ if let Some((from, list)) = cache.as_ref()
+ && Arc::ptr_eq(from, &all)
+ {
+ return list.clone();
+ }
+ let list: Arc<[String]> = all.iter().filter(|f| !f.starts_with('.')).cloned().collect();
+ *cache = Some((all, list.clone()));
+ list
+ }
+
/// Style names available for `family`: upright styles by weight, then italics.
pub fn styles(&self, family: &str) -> Vec<String> {
+ let (family, _) = self.canonical(family, "");
+ let family = family.as_str();
let mut v: Vec<(bool, f32, String)> =
self.read_faces().iter().filter(|f| f.family.eq_ignore_ascii_case(family)).map(|f| (f.italic, f.weight, f.style.clone())).collect();
if let Some(c) = self.read_catalog().get(&family.to_ascii_lowercase()) {