Skip to content

Extract text colors per glyph #20245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ickshonpe
Copy link
Contributor

Objective

Colors are extracted per text section, transforms per glyph.
This makes it awkward to set colors for individual glyphs as they have to be batched separately.

Solution

  • Add color: LinearRgba and translation: Vec2 fields to ExtractedGlyph.
  • Move the transform fields from ExtractedGlyph and ExtractedUiItem to ExtractedUiNode.
  • Move the rect field from ExtractedUiNode to ExtractedUiItem.

ExtractedUiNodes are smaller by 16 bytes, from 208 to 192 bytes in size.
ExtractedGlyphs are smaller by 8 bytes, from 48 to 40 bytes in size.

Testing

Output from the UI examples should be unchanged, main ones to check are testbed_ui, testbed_full_ui, text_debug, text_wrap_debug and ui_transform.

Not a performance motivated change but this should show a marginal improvement over main, YMMV:

cargo run --example many_glyphs --release -- --no-text2d

@ickshonpe ickshonpe added A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets A-Text Rendering and layout for characters D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 22, 2025
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 A-UI Graphical user interfaces, styles, layouts, and widgets D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes 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.

2 participants