diff --git a/crates/usvg/src/text/mod.rs b/crates/usvg/src/text/mod.rs index cdeaa7a8e..0d91bea15 100644 --- a/crates/usvg/src/text/mod.rs +++ b/crates/usvg/src/text/mod.rs @@ -161,6 +161,7 @@ impl FontResolver<'_> { pub fn default_fallback_selector() -> FallbackSelectionFn<'static> { Box::new(|c, exclude_fonts, fontdb| { let base_font_id = exclude_fonts[0]; + let base_face = fontdb.face(base_font_id)?; // Iterate over fonts and check if any of them support the specified char. for face in fontdb.faces() { @@ -170,7 +171,6 @@ impl FontResolver<'_> { } // Check that the new face has the same style. - let base_face = fontdb.face(base_font_id)?; if base_face.style != face.style && base_face.weight != face.weight && base_face.stretch != face.stretch @@ -192,7 +192,7 @@ impl FontResolver<'_> { .families .iter() .find(|f| f.1 == fontdb::Language::English_UnitedStates) - .unwrap_or(&base_face.families[0]); + .unwrap_or(&face.families[0]); log::warn!("Fallback from {} to {}.", base_family.0, new_family.0); return Some(face.id);