bevy/crates/bevy_ui/src
ickshonpe 0b0ef583b6
Improved Text Rendering (#10537)
# Objective

The quality of Bevy's text rendering can vary wildly depending on the
font, font size, pixel alignment and scale factor.

But this situation can be improved dramatically with some small
adjustments.

## Solution

* Text node positions are rounded to the nearest physical pixel before
rendering.
* Each glyph texture has a 1-pixel wide transparent border added along
its edges.

This means font atlases will use more memory because of the extra pixel
of padding for each glyph but it's more than worth it I think (although
glyph size is increased by 2 pixels on both axes, the net increase is 1
pixel as the font texture atlas's padding has been removed).

## Results

Screenshots are from the 'ui' example with a scale factor of 1.5. 

Things can get much uglier with the right font and worst scale
factor<sup>tm</sup>.

### before 
<img width="300" alt="list-bad-text"
src="https://github.com/bevyengine/bevy/assets/27962798/482b384d-8743-4bae-9a65-468ff1b4c301">

### after
<img width="300" alt="good_list_text"
src="https://github.com/bevyengine/bevy/assets/27962798/34323b0a-f714-47ba-9728-a59804987bc8">
 
---

## Changelog
* Font texture atlases are no longer padded.
* Each glyph texture has a 1-pixel wide padding added along its edges.
* Text node positions are rounded to the nearest physical pixel before
rendering.
2023-11-14 13:44:25 +00:00
..
layout Update UI alignment docs (#10303) 2023-10-29 15:32:11 +00:00
render Improved Text Rendering (#10537) 2023-11-14 13:44:25 +00:00
widget Fix crash with certain right-aligned text (#10271) 2023-10-26 22:09:34 +00:00
accessibility.rs Various accessibility API updates. (#9989) 2023-10-02 21:22:52 +00:00
camera_config.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
focus.rs Fix the clippy::explicit_iter_loop lint (#9834) 2023-09-19 03:35:22 +00:00
geometry.rs don't Implement Display for Val (#10345) 2023-11-02 21:54:41 +00:00
lib.rs Add UI Materials (#9506) 2023-11-03 22:33:01 +00:00
measurement.rs Change the default for the measure_func field of ContentSize to None. (#9346) 2023-08-07 23:06:40 +00:00
node_bundles.rs UI Materials: ignore entities with a BackgroundColor component (#10434) 2023-11-07 20:04:10 +00:00
stack.rs Add stack index to Node (#9853) 2023-10-31 23:32:51 +00:00
ui_material.rs Add UI Materials (#9506) 2023-11-03 22:33:01 +00:00
ui_node.rs Add stack index to Node (#9853) 2023-10-31 23:32:51 +00:00
update.rs Do not panic on non-UI child of UI entity (#9621) 2023-08-29 10:49:40 +00:00