mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Return 0.0 if font not found in glyph_width instead of panic (#7559)
This commit is contained in:
@@ -478,12 +478,11 @@ impl Font<'_> {
|
||||
/// Width of this character in points.
|
||||
pub fn glyph_width(&mut self, c: char, font_size: f32) -> f32 {
|
||||
let (key, glyph_info) = self.glyph_info(c);
|
||||
let font = &self
|
||||
.fonts_by_id
|
||||
.get(&key)
|
||||
.expect("Nonexistent font ID")
|
||||
.ab_glyph_font;
|
||||
glyph_info.advance_width_unscaled.0 * font.px_scale_factor(font_size)
|
||||
if let Some(font) = &self.fonts_by_id.get(&key) {
|
||||
glyph_info.advance_width_unscaled.0 * font.ab_glyph_font.px_scale_factor(font_size)
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Can we display this glyph?
|
||||
|
||||
Reference in New Issue
Block a user