#text #opengl

glium_text

Text drawing with glium and freetype

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

#236 in #opengl

Download history 40/week @ 2022-10-15 57/week @ 2022-10-22 107/week @ 2022-10-29 140/week @ 2022-11-05 67/week @ 2022-11-12 86/week @ 2022-11-19 43/week @ 2022-11-26 75/week @ 2022-12-03 87/week @ 2022-12-10 72/week @ 2022-12-17 55/week @ 2022-12-24 29/week @ 2022-12-31 48/week @ 2023-01-07 23/week @ 2023-01-14 110/week @ 2023-01-21 89/week @ 2023-01-28

276 downloads per month
Used in 2 crates

MIT license

24KB
415 lines

Easy text drawing with glium

Documentation


lib.rs:

This crate allows you to easily write text.

Usage:

# extern crate glium;
# extern crate glium_text;
# extern crate cgmath;
# fn main() {
# let display: glium::Display = unsafe { std::mem::uninitialized() };
// 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

~15MB
~300K SLoC