Skip to content

Commit ea0d0be

Browse files
committed
slint-compiler: Fix fallback family handling for glyph embedding on Linux
For macOS and Windows we've had hard-coded fallbacks, but none for Linux after the fontconfig removal. So go through the same fallback families as when using fontique regularly, and add emoji as parley tries that within. This fixes picking up glyphs such as "←→↵⌫".
1 parent 6b3ea3d commit ea0d0be

File tree

1 file changed

+18
-37
lines changed

1 file changed

+18
-37
lines changed

internal/compiler/passes/embed_glyphs.rs

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -269,47 +269,28 @@ pub fn embed_glyphs<'a>(
269269

270270
#[inline(never)] // workaround https://github.com/rust-lang/rust/issues/104099
271271
fn get_fallback_fonts(compiler_config: &CompilerConfiguration) -> Vec<Font> {
272-
#[allow(unused)]
273-
let mut fallback_families: Vec<String> = Vec::new();
272+
let mut fallback_fonts = Vec::new();
274273

275-
#[cfg(target_os = "macos")]
276-
{
277-
fallback_families = ["Menlo", "Apple Symbols", "Apple Color Emoji"]
278-
.into_iter()
279-
.map(Into::into)
280-
.collect::<Vec<String>>();
281-
}
274+
let mut collection = sharedfontique::get_collection();
275+
let mut query = collection.query();
276+
query.set_families(
277+
sharedfontique::FALLBACK_FAMILIES.into_iter().map(fontique::QueryFamily::Generic).chain(
278+
core::iter::once(fontique::QueryFamily::Generic(fontique::GenericFamily::Emoji)),
279+
),
280+
);
282281

283-
#[cfg(target_family = "windows")]
284-
{
285-
fallback_families = ["Segoe UI Emoji", "Segoe UI Symbol", "Arial", "Wingdings"]
286-
.into_iter()
287-
.map(Into::into)
288-
.collect::<Vec<String>>();
289-
}
282+
query.matches_with(|query_font| {
283+
if let Some(font) = compiler_config
284+
.load_font_by_id(&query_font)
285+
.ok()
286+
.map(|fontdue_font| Font { font: query_font.clone(), fontdue_font })
287+
{
288+
fallback_fonts.push(font);
289+
}
290290

291-
let fallback_fonts = fallback_families
292-
.iter()
293-
.filter_map(|fallback_family| {
294-
let mut collection = sharedfontique::get_collection();
295-
let mut query = collection.query();
296-
query.set_families(std::iter::once(fontique::QueryFamily::from(
297-
fallback_family.as_str(),
298-
)));
299-
let mut font = None;
300-
query.matches_with(|query_font| {
301-
font = Some(query_font.clone());
302-
fontique::QueryStatus::Stop
303-
});
291+
fontique::QueryStatus::Continue
292+
});
304293

305-
font.and_then(|font| {
306-
compiler_config
307-
.load_font_by_id(&font)
308-
.ok()
309-
.map(|fontdue_font| Font { font, fontdue_font })
310-
})
311-
})
312-
.collect::<Vec<_>>();
313294
fallback_fonts
314295
}
315296

0 commit comments

Comments
 (0)