diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 17adf979f..0210f902f 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -293,7 +293,7 @@ impl FontImpl { } #[inline] - pub(super) fn pair_kerning_screen_space( + pub(super) fn pair_kerning_pixels( &self, metrics: &ScaledMetrics, last_glyph_id: ab_glyph::GlyphId, @@ -309,7 +309,7 @@ impl FontImpl { last_glyph_id: ab_glyph::GlyphId, glyph_id: ab_glyph::GlyphId, ) -> f32 { - self.pair_kerning_screen_space(metrics, last_glyph_id, glyph_id) / metrics.pixels_per_point + self.pair_kerning_pixels(metrics, last_glyph_id, glyph_id) / metrics.pixels_per_point } #[inline(always)] @@ -534,7 +534,7 @@ pub struct ScaledMetrics { /// Translates "unscaled" units to physical (screen) pixels. pub px_scale_factor: f32, - /// Vertical offset, in UI points (not screen-space). + /// Vertical offset, in UI points. pub y_offset_in_points: f32, /// This is the distance from the top to the baseline. diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index 945e66d48..d6d450e85 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -204,11 +204,10 @@ fn layout_section( if let (Some(font_impl), Some(last_glyph_id), Some(glyph_id)) = (&font_impl, last_glyph_id, glyph_info.id) { - paragraph.cursor_x_px += font_impl.pair_kerning_screen_space( - &font_impl_metrics, - last_glyph_id, - glyph_id, - ); + paragraph.cursor_x_px += + font_impl.pair_kerning_pixels(&font_impl_metrics, last_glyph_id, glyph_id); + + // Only apply extra_letter_spacing to glyphs after the first one: paragraph.cursor_x_px += extra_letter_spacing * pixels_per_point; }