Skip to content
Draw text for gfx using freetype
Rust
Branch: master
Clone or download
Latest commit a6c2d5c Jun 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
examples
scripts
src Fix measuring text height Mar 12, 2018
.gitignore
.travis.yml
Cargo.toml
LICENSE
README.md

README.md

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

You can’t perform that action at this time.