fix(ui): The font menu's filters don't keep every font loaded

The class, Recently Added and Show Similar Fonts filters read every
family's kind through face(), which loads the family and keeps its bytes
for the session (with no size cap). They use family_kind now, which
reads each file and lets it go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
moppeeer
2026-10-12 09:56:51 +02:00
co-authored by Claude Opus 5.5
parent 5116b6ade6
commit b2d8d3af7b
+5 -3
View File
@@ -91,10 +91,12 @@ fn lock(kinds: &SharedKinds) -> std::sync::MutexGuard<'_, Kinds> {
kinds.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
}
/// A family's kind, and whether its file was added within [`ADDED_WITHIN`].
/// A family's kind, and whether its file was added within [`ADDED_WITHIN`]. Read without keeping
/// the family loaded: the filters look at every installed family.
fn family_kind(fonts: &designcraft_fonts::ScopedFonts<'static>, family: &str) -> (FaceKind, bool) {
let face = fonts.face(family, &regular(&fonts.styles(family)));
(face.kind(), face.added().and_then(|t| t.elapsed().ok()).is_some_and(|age| age < ADDED_WITHIN))
fonts
.family_kind(family)
.map_or((FaceKind::default(), false), |(kind, added)| (kind, added.and_then(|t| t.elapsed().ok()).is_some_and(|age| age < ADDED_WITHIN)))
}
/// The families' kinds, starting to read them the first time they're needed for `scope`.