Skip to content

Commit

Permalink
Expand max font atlas size from 8k to 16k (emilk#5257)
Browse files Browse the repository at this point in the history
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 emilk#5256

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
2 people authored and hacknus committed Oct 30, 2024
1 parent 139f001 commit 805eec3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/epaint/src/text/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 2 additions & 2 deletions crates/epaint/src/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit 805eec3

Please sign in to comment.