From 45a109633f8299394214d64c85aaf55fcca8ba83 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 8 Sep 2025 14:32:39 +0200 Subject: [PATCH] Small naming and docstring improvements --- crates/epaint/src/text/font.rs | 6 +++--- crates/epaint/src/text/text_layout.rs | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) 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; }