pub fn load_font_from_bytes(bytes: Vec<u8>) -> FontExpand description
Loads a font from bytes in memory.
Examples found in repository?
examples/basic_char.rs (line 6)
4fn main() {
5 let bytes = include_bytes!("Gudea-Regular.ttf");
6 let font = load_font_from_bytes(bytes.to_vec());
7 let (_, bitmap) = font.render_char('A', 40.0).unwrap();
8 for line in bitmap.lines() {
9 for &pixel in line {
10 if pixel == 0 {
11 print!(" ");
12 } else {
13 print!("#");
14 }
15 }
16 println!("");
17 }
18}More examples
examples/basic_atlas.rs (line 6)
4fn main() {
5 let bytes = include_bytes!("Gudea-Regular.ttf");
6 let font = load_font_from_bytes(bytes.to_vec());
7 let chars = font_atlas::ASCII.iter().cloned().chain(font_atlas::ASCII.iter().cloned());
8 let (_, bitmap, _) = font.make_atlas(chars, 20.0, 1, 128, 128);
9 for line in bitmap.lines() {
10 print!("{:03} ", line.len());
11 for &pixel in line {
12 if pixel == 0 {
13 print!(" ");
14 } else {
15 print!("#");
16 }
17 }
18 println!("");
19 }
20}