egui
egui copied to clipboard
Fix some monospace fonts spacing being non-monospace
On fonts like Jetbrains Mono the rounding to the closest pixel after every glyph made the spacing between the characters non-monospace. This fixes that issue by rounding the glyph location instead of the cursor x position which affects the future characters in a non-expected way.
I tried this out with the default font with pixels_per_point = 1.15
.
Before:
After:
The new code produces some bad kerning in many places:
A possible fix might be to only apply this fix on monospace fonts as those are the ones which need this fix to be quote on quote "monospaced".
Another solution to this problem is to provide the glyph width correctly in the first place. Rendering rounds the glyph_width which makes it be different than the application (for example a cursor drawer). Just rounding the glyph_width on the getter makes the behavior consistent across the codebase.
I originally missjudged my issue. I thought the drawer was messing up the spacings but it was just using a different glyph width to fix the spacing.
@alphaqu could you try the patch in #2490? I don't have an app using Jetbrains Mono, and I'm not exactly sure what I should be looking for to compare between actual and expected rasterization because there are no screenshots here.
The linked patch may address the issue you had if your pixels_per_point
is greater than 1.0. (I.e. on a high DPI display.)