Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save range of original text in glyph #110

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion parley/src/layout/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
}
Expand Down
1 change: 1 addition & 0 deletions parley/src/layout/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ impl<B: Brush> LayoutData<B> {
x: g.x,
y: g.y,
advance: g.advance,
text_range: source_range.clone(),
}
}));
glyph_count += glyph_len;
Expand Down
3 changes: 2 additions & 1 deletion parley/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>,
}

impl Glyph {
Expand Down