draw: render cursor correctly in position 0

This commit is contained in:
Hilmar Gústafsson
2020-07-22 01:44:06 +02:00
committed by Kenny Levinsen
parent f1811475cd
commit 89c5aeb01d
+8 -4
View File
@@ -150,13 +150,17 @@ impl<'a> Font<'a> {
off = glyph.origin.1 off = glyph.origin.1
} }
} }
let height = buf.get_bounds().3;
for (i, glyph) in glyphs.iter().enumerate() { for (i, glyph) in glyphs.iter().enumerate() {
glyph.draw(buf, (x_off, -off), bg, c); if i == cursor {
x_off += glyph.dimensions.0 as i32 + glyph.origin.0;
if i + 1 == cursor {
let height = buf.get_bounds().3;
self.draw_cursor(buf, c, x_off as u32, height)?; self.draw_cursor(buf, c, x_off as u32, height)?;
} }
glyph.draw(buf, (x_off, -off), bg, c);
x_off += glyph.dimensions.0 as i32 + glyph.origin.0;
}
if cursor == glyphs.len() {
self.draw_cursor(buf, c, x_off as u32, height)?;
} }
Ok((x_off as u32, self.size as u32)) Ok((x_off as u32, self.size as u32))