glyph_brush crates.io

Documentation

Fast caching text render library using ab_glyph. 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 glyphbrush::{abglyph::FontArc, BrushAction, BrushError, GlyphBrushBuilder, Section, Text};

let dejavu = FontArc::tryfromslice(includebytes!("../../fonts/DejaVuSans.ttf"))?; let mut glyphbrush = GlyphBrushBuilder::using_font(dejavu).build();

glyphbrush.queue(Section::default().addtext(Text::new("Hello glyphbrush"))); glyphbrush.queue(someothersection);

match glyphbrush.processqueued( |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 + glyph_brush texture cache and retry. } } ```

Examples

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