From e080e0d5de727f4c152492653ec627d0feb9e825 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 28 Mar 2026 15:31:06 +0100 Subject: [PATCH] Remove the old pair_kerning path --- Cargo.lock | 8 ----- crates/epaint/src/text/font.rs | 46 +-------------------------- crates/epaint/src/text/text_layout.rs | 27 +++------------- 3 files changed, 5 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed2c5f46f..47fd9501d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4096,14 +4096,6 @@ dependencies = [ "log", ] -[[package]] -name = "shaping_demo" -version = "0.1.0" -dependencies = [ - "eframe", - "env_logger", -] - [[package]] name = "shlex" version = "1.3.0" diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index e3ae9f840..a0e3c965d 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -2,10 +2,7 @@ use emath::{GuiRounding as _, OrderedFloat, Vec2, vec2}; use self_cell::self_cell; -use skrifa::{ - MetadataProvider as _, - raw::{TableProvider as _, tables::kern::SubtableKind}, -}; +use skrifa::MetadataProvider as _; use std::collections::BTreeMap; use vello_cpu::{color, kurbo}; @@ -44,8 +41,6 @@ impl UvRect { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct GlyphInfo { - /// Used for pair-kerning. - /// /// Doesn't need to be unique. /// /// Is `None` for a special "invisible" glyph. @@ -126,12 +121,6 @@ impl SubpixelBin { #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct GlyphAllocation { - /// The glyph ID in the font face that produced this allocation. - /// - /// Used for legacy `kern` table lookup when positioning the overflow - /// character (e.g. `…`) during text truncation. - pub(crate) id: skrifa::GlyphId, - /// Unit: screen pixels. pub advance_width_px: f32, @@ -289,7 +278,6 @@ impl FontCell { }; Some(GlyphAllocation { - id: glyph_id, advance_width_px: glyph_info.advance_width_unscaled.0 * metrics.px_scale_factor, uv_rect, }) @@ -504,38 +492,6 @@ impl FontFace { Some(glyph_info) } - #[inline] - pub(super) fn pair_kerning_pixels( - &self, - metrics: &StyledMetrics, - last_glyph_id: skrifa::GlyphId, - glyph_id: skrifa::GlyphId, - ) -> f32 { - let skrifa_font = &self.font.borrow_dependent().skrifa; - let Ok(kern) = skrifa_font.kern() else { - return 0.0; - }; - kern.subtables() - .find_map(|st| match st.ok()?.kind().ok()? { - SubtableKind::Format0(table_ref) => table_ref.kerning(last_glyph_id, glyph_id), - SubtableKind::Format1(_) => None, - SubtableKind::Format2(subtable2) => subtable2.kerning(last_glyph_id, glyph_id), - SubtableKind::Format3(table_ref) => table_ref.kerning(last_glyph_id, glyph_id), - }) - .unwrap_or_default() as f32 - * metrics.px_scale_factor - } - - #[inline] - pub fn pair_kerning( - &self, - metrics: &StyledMetrics, - last_glyph_id: skrifa::GlyphId, - glyph_id: skrifa::GlyphId, - ) -> f32 { - self.pair_kerning_pixels(metrics, last_glyph_id, glyph_id) / metrics.pixels_per_point - } - #[inline(always)] pub fn styled_metrics( &self, diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index ca7d27e1c..9077f33fc 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -664,33 +664,14 @@ fn replace_last_glyph_with_overflow_character( .unwrap_or_default(); let overflow_glyph_x = if let Some(prev_glyph) = row.glyphs.last() { - // Kern the overflow character properly - let pair_kerning = font_face - .as_mut() - .map(|font_face| { - if let (Some(prev_glyph_id), Some(overflow_glyph_id)) = ( - font_face.glyph_info(prev_glyph.chr).and_then(|g| g.id), - font_face.glyph_info(overflow_character).and_then(|g| g.id), - ) { - font_face.pair_kerning(&font_face_metrics, prev_glyph_id, overflow_glyph_id) - } else { - 0.0 - } - }) - .unwrap_or_default(); - - prev_glyph.max_x() + extra_letter_spacing + pair_kerning + prev_glyph.max_x() + extra_letter_spacing } else { 0.0 // TODO(emilk): heed paragraph leading_space 😬 }; - let replacement_glyph_width = font_face - .as_mut() - .and_then(|f| f.glyph_info(overflow_character)) - .map(|i| { - i.advance_width_unscaled.0 * font_face_metrics.px_scale_factor / pixels_per_point - }) - .unwrap_or_default(); + let replacement_glyph_width = glyph_info.advance_width_unscaled.0 + * font_face_metrics.px_scale_factor + / pixels_per_point; // Check if we're within width budget: if overflow_glyph_x + replacement_glyph_width <= job.effective_wrap_width()