# Objective Add background colors for text. Fixes #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> |
||
|---|---|---|
| .. | ||
| box_shadow.rs | ||
| box_shadow.wgsl | ||
| debug_overlay.rs | ||
| mod.rs | ||
| pipeline.rs | ||
| render_pass.rs | ||
| ui_material_pipeline.rs | ||
| ui_material.wgsl | ||
| ui_texture_slice_pipeline.rs | ||
| ui_texture_slice.wgsl | ||
| ui_vertex_output.wgsl | ||
| ui.wgsl | ||