Crates.io | glyph_brush |
lib.rs | glyph_brush |
version | |
source | src |
created_at | 2018-09-01 19:53:43.026939+00 |
updated_at | 2025-02-21 19:39:11.934397+00 |
description | Fast cached text render library using ab_glyph |
homepage | |
repository | https://github.com/alexheretic/glyph-brush |
max_upload_size | |
id | 82546 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.
use glyph_brush::{ab_glyph::FontArc, BrushAction, BrushError, GlyphBrushBuilder, Section, Text};
let dejavu = FontArc::try_from_slice(include_bytes!("../../fonts/DejaVuSans.ttf"))?;
let mut glyph_brush = GlyphBrushBuilder::using_font(dejavu).build();
glyph_brush.queue(Section::default().add_text(Text::new("Hello glyph_brush")));
glyph_brush.queue(some_other_section);
match glyph_brush.process_queued(
|rect, tex_data| update_texture(rect, tex_data),
|vertex_data| into_vertex(vertex_data),
) {
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.
}
}
Have a look at
cargo run --example opengl --release