Introduce PhysicalGlyph for offsetting and scaling

This commit is contained in:
Héctor Ramón Jiménez 2023-06-20 06:07:24 +02:00
parent e8b10fd675
commit eb09cf0259
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 79 additions and 38 deletions

View file

@ -696,7 +696,6 @@ impl Edit for Editor {
) where
F: FnMut(i32, i32, u32, u32, Color),
{
let font_size = self.buffer.metrics().font_size;
let line_height = self.buffer.metrics().line_height;
for run in self.buffer.layout_runs() {
@ -852,16 +851,27 @@ impl Edit for Editor {
}
for glyph in run.glyphs.iter() {
let (cache_key, x_int, y_int) = (glyph.cache_key, glyph.x_int, glyph.y_int);
let physical_glyph = glyph.physical((0., 0.), 1.0);
let glyph_color = match glyph.color_opt {
Some(some) => some,
None => color,
};
cache.with_pixels(font_system, cache_key, glyph_color, |x, y, color| {
f(x_int + x, line_y as i32 + y_int + y, 1, 1, color);
});
cache.with_pixels(
font_system,
physical_glyph.cache_key,
glyph_color,
|x, y, color| {
f(
physical_glyph.x + x,
line_y as i32 + physical_glyph.y + y,
1,
1,
color,
);
},
);
}
}
}