Skip to content

Fix DynamicTextureAtlasBuilder incorrectly padding added textures.#23091

Merged
alice-i-cecile merged 4 commits into
bevyengine:mainfrom
andriyDev:font-padding-fix
Feb 21, 2026
Merged

Fix DynamicTextureAtlasBuilder incorrectly padding added textures.#23091
alice-i-cecile merged 4 commits into
bevyengine:mainfrom
andriyDev:font-padding-fix

Conversation

@andriyDev

@andriyDev andriyDev commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Objective

  • Assets as entities v0 #22939 has been introducing diffs in the testbed_ui Text example, but the only thing that was changing was the order that glyphs are allocated to the font atlas. The font atlas should be resilient to this and produce no diffs in that case.
  • Another PR had similar diffs and also seemed to be due to changing the order of glyphs being allocated.

Solution

  • Previously DynamicTextureAtlasBuilder would allocate glyph size + padding, and then copy the glyph into that rectangle - but this means that copying would start at (0,0) meaning we would "blend" with the top and left edges (which breaks things).
  • Now we copy to (padding, padding).
  • Remove (padding, padding) allocate-able space from the bottom and right to ensure we don't accidentally put textures on the right or bottom edges.

Testing

Note this is orthogonal to #23056 which is about TextureAtlasBuilder, not DynamicTextureAtlasBuilder.

@andriyDev andriyDev changed the title Font padding fix Fix DynamicTextureAtlasBuilder incorrectly padding added textures. Feb 21, 2026
@andriyDev andriyDev added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 21, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in UI Feb 21, 2026
@andriyDev andriyDev requested a review from ickshonpe February 21, 2026 01:39
@github-actions

Copy link
Copy Markdown
Contributor

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-23091

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

@andriyDev andriyDev added the M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered label Feb 21, 2026

@ickshonpe ickshonpe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except I think padding for fonts should probably stay at 2 pixels, at least by default.

Comment thread crates/bevy_text/src/font_atlas.rs Outdated
@andriyDev andriyDev requested a review from ickshonpe February 21, 2026 20:00
@andriyDev andriyDev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 21, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 21, 2026
Merged via the queue into bevyengine:main with commit c495cd4 Feb 21, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in UI Feb 21, 2026
@andriyDev andriyDev deleted the font-padding-fix branch February 21, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants