swrenderer: Don't overflow for font bigger than 256px

Fixes #7936
This commit is contained in:
Olivier Goffart 2025-03-25 15:51:18 +01:00 committed by GitHub
parent d2e839a7c4
commit 1efe8c8d5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 2 deletions

View file

@ -279,6 +279,7 @@ pub async fn run_passes(
});
// This is not perfect, as this includes translations that may not be used.
#[cfg(feature = "bundle-translations")]
if let Some(translation_builder) = doc.translation_builder.as_ref() {
translation_builder.collect_characters_seen(&mut characters_seen);
}

View file

@ -65,8 +65,12 @@ impl GlyphRenderer for PixelFont {
sdf: self.bitmap_font.sdf,
})
}
fn scale_delta(&self) -> super::Fixed<u16, 8> {
super::Fixed::from_integer(self.glyphs.pixel_size as u16) / self.pixel_size.get() as u16
fn scale_delta(&self) -> Fixed<u16, 8> {
Fixed::try_from_fixed(Fixed::<u32, 8>::from_fraction(
self.glyphs.pixel_size as u32,
self.pixel_size.get() as u32,
))
.unwrap()
}
}

View file

@ -28,4 +28,12 @@ export component TestCase inherits Window {
font-italic: true;
}
}
// Issue #7936
Text {
text: "s";
font-size: 256px;
color: red;
opacity: 0.1;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before After
Before After