Commit 5f9f063 1 parent 9fa8613 commit 5f9f063 Copy full SHA for 5f9f063
File tree 1 file changed +10
-0
lines changed
rust_programs/ttf_renderer/src
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,16 @@ impl Font {
98
98
Some ( glyph_index) => self . glyphs . get ( glyph_index. 0 ) ,
99
99
}
100
100
}
101
+
102
+ pub fn scaled_line_height ( & self , font_size : Size ) -> isize {
103
+ let scale_factor = font_size. height as f64 / self . units_per_em as f64 ;
104
+ // TODO(PT): A 'scale' method for the layout metrics as a whole, similar to the glyph metrics
105
+ let scaled_ascent = self . global_layout_metrics . ascent as f64 * scale_factor;
106
+ let scaled_descent = self . global_layout_metrics . descent as f64 * scale_factor;
107
+ let scaled_line_gap = self . global_layout_metrics . line_gap as f64 * scale_factor;
108
+ let scaled_line_height = scaled_ascent - scaled_descent + scaled_line_gap;
109
+ scaled_line_height as isize
110
+ }
101
111
}
102
112
103
113
pub fn parse ( font_data : & [ u8 ] ) -> Font {
You can’t perform that action at this time.
0 commit comments