Skip to content

Commit 45423f3

Browse files
committed
Fallback to GenericFamily::SansSerif if no font is set
1 parent 2f51bef commit 45423f3

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

internal/compiler/passes/embed_glyphs.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,11 @@ pub fn embed_glyphs<'a>(
137137
let font = {
138138
let mut query = collection.query();
139139

140-
if let Some(ref family) = family {
141-
query.set_families(std::iter::once(fontique::QueryFamily::from(
142-
family.as_str(),
143-
)));
140+
query.set_families(std::iter::once(if let Some(ref family) = family {
141+
fontique::QueryFamily::from(family.as_str())
144142
} else {
145-
query.set_families(std::iter::once(fontique::QueryFamily::Generic(
146-
fontique::GenericFamily::SansSerif,
147-
)));
148-
}
143+
fontique::QueryFamily::Generic(fontique::GenericFamily::SansSerif)
144+
}));
149145

150146
let mut font = None;
151147

internal/core/graphics.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ impl FontRequest {
164164
let mut collection = sharedfontique::get_collection();
165165

166166
let mut query = collection.query();
167-
query.set_families(
168-
self.family.as_ref().map(|family| fontique::QueryFamily::from(family.as_str())),
169-
);
167+
query.set_families(std::iter::once(if let Some(family) = self.family.as_ref() {
168+
fontique::QueryFamily::from(family.as_str())
169+
} else {
170+
fontique::QueryFamily::Generic(fontique::GenericFamily::SansSerif)
171+
}));
170172

171173
query.set_attributes(fontique::Attributes {
172174
weight: self

0 commit comments

Comments
 (0)