mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 15:13:12 -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:
@@ -136,6 +136,7 @@ impl Widget for &mut epaint::TessellationOptions {
|
||||
aa_size: _,
|
||||
anti_alias,
|
||||
coarse_tessellation_culling,
|
||||
round_text_to_pixels,
|
||||
debug_paint_clip_rects,
|
||||
debug_paint_text_rects,
|
||||
debug_ignore_clip_rects,
|
||||
@@ -147,6 +148,9 @@ impl Widget for &mut epaint::TessellationOptions {
|
||||
coarse_tessellation_culling,
|
||||
"Do coarse culling in the tessellator",
|
||||
);
|
||||
ui.checkbox(round_text_to_pixels, "Align text positions to pixel grid")
|
||||
.on_hover_text("Most text already is, so don't expect to see a large change.");
|
||||
|
||||
ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles");
|
||||
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles");
|
||||
ui.checkbox(debug_paint_text_rects, "Paint text bounds");
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user