From 701d142ebb2a465d49210a57b8fdc26fb9faa986 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 06:32:43 +0000 Subject: [PATCH] Fonts: answer to and load Windows family names from the catalogue The catalogue lists faces under their typographic family only, so has_family missed a Windows family name ("DeckCraft Legacy Semibold") and face() never loaded its file, drawing the last-resort face. has_family and load_cataloged now also take the cataloged faces whose legacy family is the name, loading only those faces' files, as production's catalogue entries did. Co-Authored-By: Claude Opus 5.5 --- crates/fonts/src/fontdb.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rs index 22a614331..4ad2e749a 100644 --- a/crates/fonts/src/fontdb.rs +++ b/crates/fonts/src/fontdb.rs @@ -886,6 +886,14 @@ impl FontDb { for face in loaded.iter() { self.add_catalog_face(&face.info, &face.data); } + if loaded.is_empty() { + // A Windows family name: only the files of its faces, not their whole family. + for info in self.legacy_faces(family) { + if let Ok(data) = self.catalog.load(&info) { + self.add_catalog_face(&info, &data); + } + } + } self.is_loaded(family) } @@ -989,7 +997,14 @@ impl FontDb { if self.is_loaded(family) { return true; } - self.catalog.family(family).is_some() + self.catalog.family(family).is_some() || !self.legacy_faces(family).is_empty() + } + + /// The cataloged faces whose Windows family is `family` ("Segoe UI Semibold"): the catalogue + /// lists them under their typographic family only. + fn legacy_faces(&self, family: &str) -> Vec { + let key = norm(family); + self.catalog.faces().iter().filter(|f| f.legacy_family.as_deref().is_some_and(|lf| norm(lf) == key)).cloned().collect() } pub(crate) fn is_loaded(&self, family: &str) -> bool {