glyph_brush crates.io

Documentation

Fast caching text render library using rusttype. Provides render API agnostic rasterization & draw caching logic.

Makes extensive use of caching to optimise frame performance.

The crate is designed to be easily wrapped to create a convenient render API specific version, for example gfx-glyph.

```rust use glyph_brush::{BrushAction, BrushError, GlyphBrushBuilder, Section};

let dejavu: &[u8] = includebytes!("DejaVuSans.ttf"); let mut glyphbrush = GlyphBrushBuilder::usingfontbytes(dejavu).build();

glyphbrush.queue(Section { text: "Hello glyphbrush", ..Section::default() }); glyphbrush.queue(someother_section);

match glyphbrush.processqueued( screendimensions, |rect, texdata| updatetexture(rect, texdata), |vertexdata| intovertex(vertexdata), ) { Ok(BrushAction::Draw(vertices)) => { // Draw new vertices. } Ok(BrushAction::ReDraw) => { // Re-draw last frame's vertices unmodified. } Err(BrushError::TextureTooSmall { suggested }) => { // Enlarge texture + glyphbrush texture cache and retry. } } ```

Examples

Have a look at * cargo run --example opengl --release