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 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-29 06:32:43 +00:00
co-authored by Claude Opus 5.5
parent 13ea89fa06
commit 701d142ebb
+16 -1
View File
@@ -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<craft::font_catalog::FaceInfo> {
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 {