Calculate an overshoot when mousing to build columnar selections

This commit is contained in:
Antonio Scandurra 2021-11-24 10:28:32 +01:00
parent 2b9db911c7
commit d19d3bbe45
6 changed files with 66 additions and 22 deletions

View file

@ -157,6 +157,17 @@ impl FontCache {
bounds.width() * self.em_scale(font_id, font_size)
}
pub fn em_advance(&self, font_id: FontId, font_size: f32) -> f32 {
let glyph_id;
let advance;
{
let state = self.0.read();
glyph_id = state.fonts.glyph_for_char(font_id, 'm').unwrap();
advance = state.fonts.advance(font_id, glyph_id).unwrap();
}
advance.x() * self.em_scale(font_id, font_size)
}
pub fn line_height(&self, font_id: FontId, font_size: f32) -> f32 {
let height = self.metric(font_id, |m| m.bounding_box.height());
(height * self.em_scale(font_id, font_size)).ceil()