text/text.rs
1use graphics::{text, Transformed};
2use graphics_buffer::*;
3
4fn main() {
5 // Initalize the buffer
6 let mut buffer = RenderBuffer::new(150, 40);
7 buffer.clear([0.0, 0.0, 0.0, 1.0]);
8
9 // Load the font and initialize glyphs
10 let mut glyphs = buffer_glyphs_from_bytes(include_bytes!("roboto.ttf")).unwrap();
11
12 // Draw text
13 text(
14 [1.0; 4],
15 30,
16 "Oh boy!",
17 &mut glyphs,
18 IDENTITY.trans(10.0, 30.0),
19 &mut buffer,
20 )
21 .unwrap();
22
23 // Save the image
24 buffer.save("text.png").unwrap();
25}