From 1ddd143e4530392e2087ef32f468e09f53571378 Mon Sep 17 00:00:00 2001 From: valadaptive Date: Thu, 7 Aug 2025 18:55:15 -0400 Subject: [PATCH] Fix panic if no fonts loaded --- crates/epaint/src/text/font.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 3d73eaa80..29d834369 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -390,7 +390,12 @@ impl Font<'_> { /// Returns a value rounded to [`emath::GUI_ROUNDING`]. #[inline(always)] pub fn row_height(&self, font_size: f32) -> f32 { - let Some(first_font) = self.fonts_by_id.get(&self.cached_family.fonts[0]) else { + let Some(first_font) = self + .cached_family + .fonts + .first() + .and_then(|key| self.fonts_by_id.get(key)) + else { return 0.0; }; first_font.row_height(font_size)