From d77374d03c59d8762705dcc866be52ad65e04dca Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Thu, 6 Aug 2026 12:16:54 +0800 Subject: [PATCH] Fix font fallback logging and avoid repeated lookups --- crates/usvg/src/text/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);