diff --git a/parley/src/layout/cluster.rs b/parley/src/layout/cluster.rs index e56bc7fa..b72f9da6 100644 --- a/parley/src/layout/cluster.rs +++ b/parley/src/layout/cluster.rs @@ -131,6 +131,7 @@ impl<'a, B: Brush> Cluster<'a, B> { x: 0., y: 0., advance: self.data.advance, + text_range: self.text_range(), })) } else { let start = self.run.data.glyph_start + self.data.glyph_offset as usize; @@ -451,7 +452,7 @@ impl<'a> Iterator for GlyphIter<'a> { match self { Self::Single(glyph) => glyph.take(), Self::Slice(iter) => { - let glyph = *iter.next()?; + let glyph = iter.next()?.clone(); Some(glyph) } } diff --git a/parley/src/layout/data.rs b/parley/src/layout/data.rs index 50ffb400..986287ab 100644 --- a/parley/src/layout/data.rs +++ b/parley/src/layout/data.rs @@ -440,6 +440,7 @@ impl LayoutData { x: g.x, y: g.y, advance: g.advance, + text_range: source_range.clone(), } })); glyph_count += glyph_len; diff --git a/parley/src/layout/mod.rs b/parley/src/layout/mod.rs index 7633df82..24bab62a 100644 --- a/parley/src/layout/mod.rs +++ b/parley/src/layout/mod.rs @@ -210,13 +210,14 @@ pub struct Cluster<'a, B: Brush> { } /// Glyph with an offset and advance. -#[derive(Copy, Clone, Default, Debug)] +#[derive(Clone, Default, Debug)] pub struct Glyph { pub id: GlyphId, pub style_index: u16, pub x: f32, pub y: f32, pub advance: f32, + pub text_range: Range, } impl Glyph {