From 61351d170eb1ab719c5aa6b0d6d854d83930131d Mon Sep 17 00:00:00 2001 From: valadaptive Date: Mon, 8 Sep 2025 05:30:32 -0400 Subject: [PATCH] Apply documentation changes --- crates/epaint/src/text/font.rs | 4 ++++ crates/epaint/src/text/fonts.rs | 2 +- crates/epaint/src/text/text_layout.rs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index c90effb0b..938a4979b 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -516,10 +516,14 @@ impl Font<'_> { } } +/// Metrics for a font at a specific screen-space scale. #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct ScaledMetrics { + /// The DPI part of the screen-space scale. pub pixels_per_point: f32, + /// Scale factor, relative to the font's units per em (so, probably much less than 1). pub px_scale_factor: f32, + /// Vertical offset, in UI points (not screen-space). pub y_offset_in_points: f32, /// This is the distance from the top to the baseline. /// diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 278906ec8..b808d21a9 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -799,7 +799,7 @@ impl FontsImpl { } } - /// Get the right font implementation from [`FontFamily`]. + /// Get the right font implementation from [`FontFamily`]. pub fn font(&mut self, family: &FontFamily) -> Font<'_> { let cached_family = self.family_cache.entry(family.clone()).or_insert_with(|| { let fonts = &self.definitions.families.get(family); diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index 1deee327a..775cdac56 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -173,7 +173,9 @@ fn layout_section( let mut last_glyph_id = None; + // Optimization: only recompute `ScaledMetrics` when `FontFaceKey` changes. let mut last_font: Option<(FontFaceKey, Option)> = None; + for chr in job.text[byte_range.clone()].chars() { if job.break_on_newline && chr == '\n' { out_paragraphs.push(Paragraph::from_section_index(section_index));