render character under block cursor
This commit is contained in:
parent
0d42c85195
commit
eddb089f27
3 changed files with 66 additions and 19 deletions
|
@ -186,7 +186,7 @@ pub struct Run {
|
|||
pub glyphs: Vec<Glyph>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Glyph {
|
||||
pub id: GlyphId,
|
||||
pub position: Vector2F,
|
||||
|
@ -210,10 +210,14 @@ impl Line {
|
|||
self.layout.width
|
||||
}
|
||||
|
||||
pub fn font_size(&self) -> f32 {
|
||||
self.layout.font_size
|
||||
}
|
||||
|
||||
pub fn x_for_index(&self, index: usize) -> f32 {
|
||||
for run in &self.layout.runs {
|
||||
for glyph in &run.glyphs {
|
||||
if glyph.index == index {
|
||||
if glyph.index >= index {
|
||||
return glyph.position.x();
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +225,18 @@ impl Line {
|
|||
self.layout.width
|
||||
}
|
||||
|
||||
pub fn font_for_index(&self, index: usize) -> Option<FontId> {
|
||||
for run in &self.layout.runs {
|
||||
for glyph in &run.glyphs {
|
||||
if glyph.index >= index {
|
||||
return Some(run.font_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn index_for_x(&self, x: f32) -> Option<usize> {
|
||||
if x >= self.layout.width {
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue