emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.88k stars 1.58k forks source link

add feature to disable text-to-pixel snapping during layout #5057

Open drewmiller opened 3 weeks ago

drewmiller commented 3 weeks ago

Recognizing that a switch to Cosmic Text is on the way per #56 , I also wanted to implement a temporary feature which disables what I call "text snapping"--i.e., where we round to the nearest pixel on the x and y axis when rendering text. This results in text being laid out in different ways across pixel_per_point values. Such snapping improves font rendering in the absence of other anti-aliasing approaches which will be provided by Cosmic Text. For some contexts, however, maintaining the layout is more important across pixel_per_point values. This feature allows for that until Cosmic Text saves the day.

emilk commented 3 weeks ago

Note that we already have a setting for this, though maybe it is not by the actual text layout engine: https://docs.rs/epaint/latest/epaint/tessellator/struct.TessellationOptions.html#structfield.round_text_to_pixels

drewmiller commented 3 weeks ago

Note that we already have a setting for this, though maybe it is not by the actual text layout engine: https://docs.rs/epaint/latest/epaint/tessellator/struct.TessellationOptions.html#structfield.round_text_to_pixels

My concerns are primarily around the layout of the text, so I haven't had a chance to investigate the interaction with tesselation, but I will. I'll come back to you.