33 breaking releases

Uses old Rust 2015

0.33.0 Nov 14, 2023
0.31.0 Nov 16, 2022
0.29.0 Nov 28, 2021
0.28.0 Mar 15, 2021
0.4.1 Jun 25, 2015

#22 in #gfx

Download history 18/week @ 2024-07-01 16/week @ 2024-07-15 9/week @ 2024-07-22 72/week @ 2024-07-29 7/week @ 2024-08-05 12/week @ 2024-08-12 20/week @ 2024-08-26 138/week @ 2024-09-23 1/week @ 2024-09-30 1/week @ 2024-10-07 5/week @ 2024-10-14

145 downloads per month
Used in fewer than 6 crates

MIT license

385KB
611 lines

gfx_text Build Status crates.io

Library for drawing text for gfx-rs graphics API. Uses freetype-rs underneath.

Usage

Basic usage:

// Initialize text renderer.
let mut text = gfx_text::new(factory).build().unwrap();

// In render loop:

// Add some text 10 pixels down and right from the top left screen corner.
text.add(
    "The quick brown fox jumps over the lazy dog",  // Text to add
    [10, 10],                                       // Position
    [0.65, 0.16, 0.16, 1.0],                        // Text color
);

// Draw text.
text.draw(&mut stream);

See API documentation for overview of all available methods.

You can skip default font by disabling include-font feature:

[dependencies.gfx_text]
version = "*"
default-features = false

Examples

See this example on how to draw text in various styles: different sizes, colors, fonts, etc.

Output:

License

Dependencies

~10MB
~214K SLoC