forked from emilk/egui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Round text galley sizes to nearest ui point size (emilk#4578)
Previously, many labels had non-integer widths. This lead to rounding errors. This was most notable for the new `Area` sizing code: We would run the initial sizing pass, to measure the size of e.g. a tooltip. Say the tooltip contains text that was 100.123 ui points wide. With a 16pt border, that becomes 116.123, which is stored in the `Area` state as the width. The next frame, we use that stored size as the wrapping width. With perfect precision, we would then tell the label to wrap to 100.123 pts, which the text would _just_ fit in. However, due to rounding errors we might end up asking it to wrap to 100.12**2** pts, meaning the last word would now wrap and end up on the next line. By rounding label sizes to perfect integers, we avoid such rounding errors, and most ui elements will now end up on perfect integer point coordinates (and `f32` can precisely express and do arithmetic on all integers < 2^24). Visually this has very little impact. Some labels move by a pixel here and there, mostly for the better.
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters