1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Clamp font size to between 0.1 and 2048 (#5139)

Fix: Font size limit to prevent panic
This commit is contained in:
rustbasic
2024-09-23 02:14:03 +09:00
committed by GitHub
parent c9df2f0783
commit 7c7190f98d

View File

@@ -620,10 +620,11 @@ impl FontsImpl {
/// Get the right font implementation from size and [`FontFamily`].
pub fn font(&mut self, font_id: &FontId) -> &mut Font {
let FontId { size, family } = font_id;
let FontId { mut size, family } = font_id;
size = size.at_least(0.1).at_most(2048.0);
self.sized_family
.entry((OrderedFloat(*size), family.clone()))
.entry((OrderedFloat(size), family.clone()))
.or_insert_with(|| {
let fonts = &self.definitions.families.get(family);
let fonts = fonts
@@ -631,7 +632,7 @@ impl FontsImpl {
let fonts: Vec<Arc<FontImpl>> = fonts
.iter()
.map(|font_name| self.font_impl_cache.font_impl(*size, font_name))
.map(|font_name| self.font_impl_cache.font_impl(size, font_name))
.collect();
Font::new(fonts)