Browse Source

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

Fix: Font size limit to prevent panic
pull/5149/head
rustbasic 2 months ago
committed by GitHub
parent
commit
7c7190f98d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      crates/epaint/src/text/fonts.rs

7
crates/epaint/src/text/fonts.rs

@ -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)

Loading…
Cancel
Save