-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Text background colors #18892
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
Text background colors #18892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my one comment this looks great!
Co-authored-by: Olle Lukowski <lukowskiolle@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with render entity extraction so my review of extract_text_background_colors
was pretty basic.
In queue_text
, we could optionally move the computation of section_rects
in the already existing main glyphs loop to avoid having a second linear scan of all the glyphs.
Co-authored-by: Gilles Henaux <ghx_github_priv@fastmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Release notes look good.
# Objective Add background colors for text. Fixes bevyengine#18889 ## Solution New component `TextBackgroundColor`, add it to any UI `Text` or `TextSpan` entity to add a background color to its text. New field on `TextLayoutInfo` `section_rects` holds the list of bounding rects for each text section. The bounding rects are generated in `TextPipeline::queue_text` during text layout, `extract_text_background_colors` extracts the colored background rects for rendering. Didn't include `Text2d` support because of z-order issues. The section rects can also be used to implement interactions targeting individual text sections. ## Testing Includes a basic example that can be used for testing: ``` cargo run --example text_background_colors ``` --- ## Showcase  Using a proportional font with kerning the results aren't so tidy (since the bounds of adjacent glyphs can overlap) but it still works fine:  --------- Co-authored-by: Olle Lukowski <lukowskiolle@gmail.com> Co-authored-by: Gilles Henaux <ghx_github_priv@fastmail.com>
Objective
Add background colors for text.
Fixes #18889
Solution
New component
TextBackgroundColor
, add it to any UIText
orTextSpan
entity to add a background color to its text.New field on
TextLayoutInfo
section_rects
holds the list of bounding rects for each text section.The bounding rects are generated in
TextPipeline::queue_text
during text layout,extract_text_background_colors
extracts the colored background rects for rendering.Didn't include
Text2d
support because of z-order issues.The section rects can also be used to implement interactions targeting individual text sections.
Testing
Includes a basic example that can be used for testing:
Showcase
Using a proportional font with kerning the results aren't so tidy (since the bounds of adjacent glyphs can overlap) but it still works fine: