1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Add tessellation option to toggle rounding text to pixel coordinates

On by default and only there for testing
This commit is contained in:
Emil Ernerfeldt
2021-10-27 08:56:06 +02:00
parent 8e4fd942a9
commit ddd52f47c5
2 changed files with 14 additions and 1 deletions

View File

@@ -274,6 +274,10 @@ pub struct TessellationOptions {
/// This likely makes
pub coarse_tessellation_culling: bool,
/// If `true` (default) align text to mesh grid.
/// This makes the text sharper on most platforms.
pub round_text_to_pixels: bool,
/// Output the clip rectangles to be painted.
pub debug_paint_clip_rects: bool,
@@ -291,6 +295,7 @@ impl Default for TessellationOptions {
aa_size: 1.0,
anti_alias: true,
coarse_tessellation_culling: true,
round_text_to_pixels: true,
debug_paint_text_rects: false,
debug_paint_clip_rects: false,
debug_ignore_clip_rects: false,
@@ -311,7 +316,11 @@ impl TessellationOptions {
impl TessellationOptions {
#[inline(always)]
pub fn round_to_pixel(&self, point: f32) -> f32 {
(point * self.pixels_per_point).round() / self.pixels_per_point
if self.round_text_to_pixels {
(point * self.pixels_per_point).round() / self.pixels_per_point
} else {
point
}
}
}