Vertically center glyphs in Line::paint based on ascender/descender for line

This commit is contained in:
Nathan Sobo
2021-04-06 09:15:21 -06:00
parent fc4135d55b
commit 2a9e71d725
5 changed files with 18 additions and 14 deletions
+4 -3
View File
@@ -228,8 +228,6 @@ impl FontSystemState {
let line = CTLine::new_with_attributed_string(string.as_concrete_TypeRef());
let width = line.get_typographic_bounds().width as f32;
let mut utf16_chars = text.encode_utf16();
let mut char_ix = 0;
let mut prev_utf16_ix = 0;
@@ -268,8 +266,11 @@ impl FontSystemState {
runs.push(Run { font_id, glyphs })
}
let typographic_bounds = line.get_typographic_bounds();
Line {
width,
width: typographic_bounds.width as f32,
ascent: typographic_bounds.ascent as f32,
descent: typographic_bounds.descent as f32,
runs,
font_size,
len: char_ix + 1,