#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

#1084 in Graphics APIs

Download history 94/week @ 2023-11-07 63/week @ 2023-11-14 105/week @ 2023-11-21 154/week @ 2023-11-28 69/week @ 2023-12-05 101/week @ 2023-12-12 82/week @ 2023-12-19 102/week @ 2023-12-26 65/week @ 2024-01-02 81/week @ 2024-01-09 116/week @ 2024-01-16 45/week @ 2024-01-23 134/week @ 2024-01-30 72/week @ 2024-02-06 196/week @ 2024-02-13 472/week @ 2024-02-20

876 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

~16MB
~296K SLoC