Fix font fallback list on macOS with default family

Even with an empty font family we should produce a font fallback list, and we can.
Fixes the missing checkmark (when not affected by clipping).
This commit is contained in:
Simon Hausmann 2021-06-30 15:46:30 +02:00
parent 6ffe456fd8
commit 8dc6ee6fb1

View file

@ -142,14 +142,14 @@ pub(crate) fn font_fallbacks_for_request(
_request: &FontRequest,
_reference_text: &str,
) -> Vec<FontRequest> {
_request
.family
.as_ref()
.and_then(|family| {
core_text::font::new_from_name(&family, _request.pixel_size.unwrap_or_default() as f64)
.ok()
})
.map(|requested_font| {
let requested_font = match core_text::font::new_from_name(
&_request.family.as_ref().map_or_else(|| "", |s| s.as_str()),
_request.pixel_size.unwrap_or_default() as f64,
) {
Ok(f) => f,
Err(_) => return vec![],
};
core_text::font::cascade_list_for_languages(
&requested_font,
&core_foundation::array::CFArray::from_CFTypes(&[]),
@ -164,8 +164,6 @@ pub(crate) fn font_fallbacks_for_request(
.filter(|fallback| !fallback.family.as_ref().unwrap().starts_with(".")) // font-kit asserts when loading `.Apple Fallback`
.take(1) // Take only the top from the fallback list until we mmap the llaaarge font files
.collect::<Vec<_>>()
})
.unwrap_or_default()
}
#[cfg(target_os = "windows")]