glyph_brush
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.
extern crate glyph_brush;
use glyph_brush::{BrushAction, BrushError, GlyphBrushBuilder, Section};
let dejavu: &[u8] = include_bytes!("../../examples/DejaVuSans.ttf");
let mut glyph_brush = GlyphBrushBuilder::using_font_bytes(dejavu).build();
glyph_brush.queue(Section {
text: "Hello glyph_brush",
..Section::default()
});
glyph_brush.queue(some_other_section);
match glyph_brush.process_queued(
screen_dimensions,
|rect, tex_data| update_texture(rect, tex_data),
|vertex_data| into_vertex(vertex_data),
) {
Ok(BrushAction::Draw(vertices)) => {
}
Ok(BrushAction::ReDraw) => {
}
Err(BrushError::TextureTooSmall { suggested, .. }) => {
}
}