From 4ff4dccb1ed2bab82ae9dd745fccd3b5fc6e0436 Mon Sep 17 00:00:00 2001 From: Ryan Bluth Date: Tue, 5 Mar 2024 08:09:15 -0500 Subject: [PATCH] Don't panic when replacment glyph is not found --- crates/epaint/src/text/font.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 989698d7dac..7520c971a89 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -370,9 +370,11 @@ impl Font { .glyph_info_no_cache_or_fallback(PRIMARY_REPLACEMENT_CHAR) .or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR)) .unwrap_or_else(|| { - panic!( - "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}" - ) + #[cfg(feature = "log")] + log::warn!( + "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}. Will use empty glyph." + ); + (0, GlyphInfo::default()) }); slf.replacement_glyph = replacement_glyph;