Grow font atlases instead of creating new ones
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently, when the space occupied by glyphs in a font atlas exceeds the space available, a new font atlas is created and the handle is stored in a vec.
This means that glyphs from the same "font" will be spread across multiple atlases, which probably reduces batching when rendering, and means that there is one extra step (iterating a vec that now has multiple entries) to find the correct atlas handle for a particular glyph.
## What solution would you like?
Since #19410, we can now "grow" textures, and all the pieces are in place to be able to grow a font atlas.
I would like to be able to configure a:
- starting atlas size
- maximum atlas size
And have the atlases grow to the maximum when needed, only spilling into a new texture after the maximum size is reached.
## What alternative(s) have you considered?
Folks are dreaming up alternative font rendering solutions, but this is a relatively easy improvement to the current renderer.
We could also simply make the current static atlas size configurable. It's pretty conservative right now at 512x512. Not as fancy, but it might be useful to some folks.
## Additional context
I implemented most of this once here: https://github.com/rparrett/bevy/commits/grow-font-atlases but it has become slightly rotten and some of the decisions there might not necessarily align with current thinking, and I never got around to fully characterizing the performance.
This is a little bit of a niche optimization, because you are unlikely to overflow the current atlases unless you're using a very large font size or *many* different glyphs.
Contributor guide
Assessment
This issue has not been assessed yet.