From 288c74e332d3a7c959bb74cb78f899fe7378db85 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:42:28 +0900 Subject: [PATCH] Expand max font atlas size from 8k to 16k (#5257) When using fonts with an average of 50,000 characters, 'epaint texture atlas overflowed!' may be printed and cause problems. It is necessary to expand the max value related to texture. * Closes #5256 --------- Co-authored-by: Emil Ernerfeldt --- crates/epaint/src/text/fonts.rs | 2 +- crates/epaint/src/texture_atlas.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 685bdf9b..3cb8e854 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -633,7 +633,7 @@ impl FontsImpl { "pixels_per_point out of range: {pixels_per_point}" ); - let texture_width = max_texture_side.at_most(8 * 1024); + let texture_width = max_texture_side.at_most(16 * 1024); let initial_height = 32; // Keep initial font atlas small, so it is fast to upload to GPU. This will expand as needed anyways. let atlas = TextureAtlas::new([texture_width, initial_height]); diff --git a/crates/epaint/src/texture_atlas.rs b/crates/epaint/src/texture_atlas.rs index b0f0ad03..7ea76f87 100644 --- a/crates/epaint/src/texture_atlas.rs +++ b/crates/epaint/src/texture_atlas.rs @@ -159,8 +159,8 @@ impl TextureAtlas { } fn max_height(&self) -> usize { - // the initial width is likely the max texture side size - self.image.width() + // the initial width is set to the max size + self.image.height().max(self.image.width()) } /// When this get high, it might be time to clear and start over!