Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Oct 30, 2025

Objective

We've got two parallel text renderings implementations, one for UI and one for 2d, that we try to keep feature equivalent.
bevy_ui and bevy_text use coordinates increasing downwards, but bevy_sprite uses coordinates increasing upwards.
In the extract_text2d_sprite text extraction function each y-coordinate is negated individually. If instead, in extract_text2d_sprite, we invert the y-axis for each text layout's local coordinate space, then the function can be made to more closely match bevy_ui_render's extraction code. Which should make it easier to maintain and extend the parallel implementations.

Fixes #21693

Solution

Invert the y-axis for the local coordinate space instead of negating each glyph’s y value. Flip the glyph sprites so their orientation is unchanged.

…negating the individual y-coords. Flip the sprites on the y-axis so the glyphs are still drawn with the correct orientation.
@github-actions
Copy link
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-21694

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.

@ickshonpe ickshonpe added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change A-Text Rendering and layout for characters S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 30, 2025
@ickshonpe ickshonpe added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Oct 30, 2025
@kfc35
Copy link
Contributor

kfc35 commented Nov 11, 2025

Is there a reason why flip_y is not set to true for the has_strikethrough and has_underline portions?

I’m very new here and just trying to understand things better; this is not a blocking comment!

@ickshonpe
Copy link
Contributor Author

Is there a reason why flip_y is not set to true for the has_strikethrough and has_underline portions?

I’m very new here and just trying to understand things better; this is not a blocking comment!

The underline and strikethrough lines are untextured, so flip_y doesn't do anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen A-Text Rendering and layout for characters C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Flip coordinates along the Y-axis for Text2d rendering

3 participants