#opengl #glium #drawing #text #freetype

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

#1061 in Graphics APIs

Download history 11/week @ 2024-07-21 26/week @ 2024-07-28 2/week @ 2024-08-04 9/week @ 2024-08-11 2/week @ 2024-08-18 8/week @ 2024-08-25 11/week @ 2024-09-01 11/week @ 2024-09-08 10/week @ 2024-09-15 62/week @ 2024-09-22 62/week @ 2024-09-29 5/week @ 2024-10-06 13/week @ 2024-10-13 4/week @ 2024-10-20 14/week @ 2024-10-27 28/week @ 2024-11-03

59 downloads per month
Used in 2 crates

MIT license

25KB
415 lines

Easy text drawing with glium

Documentation


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