From 375617e060c8bce292e2e3f8ce07139a775fadbc Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 18:58:26 +0000 Subject: [PATCH] Expose caret stops for hit testing --- crates/text/src/positioned.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/text/src/positioned.rs b/crates/text/src/positioned.rs index 2587c8b22..81afdbae9 100644 --- a/crates/text/src/positioned.rs +++ b/crates/text/src/positioned.rs @@ -74,11 +74,13 @@ pub struct PositionedGlyph { } impl PositionedGlyph { - fn width_stops(&self) -> impl Iterator + '_ { + /// Source caret stops as fractions of glyph width. + pub fn width_stops(&self) -> impl Iterator + '_ { std::iter::once((self.byte, 0.0)).chain(self.carets.iter().copied()).chain(std::iter::once((self.byte + self.len, 1.0))) } - fn stops_along(&self, extent: f64) -> impl Iterator + '_ { + /// Source caret stops measured from the logical leading edge. + pub fn stops_along(&self, extent: f64) -> impl Iterator + '_ { let (width, start) = if self.width > 0.0 && self.width.is_finite() { (self.width, if self.width_start.is_finite() { self.width_start } else { 0.0 }) } else {