glyph_brush crates.io

Documentation

Fast cached text render library using rusttype.

This crate provides render API agnostic rasterization & draw caching logic. Allowing generic vertex generation & re-use of previous frame vertices.

```rust extern crate glyph_brush;

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

let dejavu: &[u8] = includebytes!("../../examples/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. } } ```