23 releases (14 breaking)
Uses old Rust 2015
0.14.0 | Jan 16, 2019 |
---|---|
0.13.0 | Jul 23, 2018 |
0.12.0 | Jun 7, 2018 |
0.11.0 | Jan 18, 2017 |
0.0.2 | Mar 24, 2015 |
#1061 in Graphics APIs
59 downloads per month
Used in 2 crates
25KB
415 lines
Easy text drawing with glium
lib.rs
:
This crate allows you to easily write text.
Usage:
// The `TextSystem` contains the shaders and elements used for text display.
let system = glium_text::TextSystem::new(&display);
// Creating a `FontTexture`, which a regular `Texture` which contains the font.
// Note that loading the systems fonts is not covered by this library.
let font = glium_text::FontTexture::new(&display, std::fs::File::open(&std::path::Path::new("my_font.ttf")).unwrap(), 24).unwrap();
// Creating a `TextDisplay` which contains the elements required to draw a specific sentence.
let text = glium_text::TextDisplay::new(&system, &font, "Hello world!");
// Finally, drawing the text is done like this:
let matrix = [[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]];
glium_text::draw(&text, &system, &mut display.draw(), matrix, (1.0, 1.0, 0.0, 1.0));
Dependencies
~14–19MB
~317K SLoC