From 6147ff3668ab680a4ec57f73552cab95c050420a Mon Sep 17 00:00:00 2001 From: Fishhh Date: Sat, 30 Nov 2024 16:59:38 +0100 Subject: [PATCH] Round `PlacedRow` positions to pixels during multiline layout --- crates/epaint/src/text/fonts.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index b2fa099e0..a26442991 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -728,6 +728,10 @@ struct GalleyCache { impl GalleyCache { fn layout_multiline(&mut self, fonts: &mut FontsImpl, job: LayoutJob) -> Galley { + let pixels_per_point = fonts.pixels_per_point; + let round_to_pixel = + move |point: emath::Pos2| (point * pixels_per_point).round() / pixels_per_point; + let mut current_section = 0; let mut current = 0; let mut left_max_rows = job.wrap.max_rows; @@ -830,7 +834,7 @@ impl GalleyCache { super::PlacedRow { row: placed_row.row.clone(), - pos: new_pos, + pos: round_to_pixel(new_pos), ends_with_newline: placed_row.ends_with_newline, } }));