glyph_brush_draw_cache

Crates.ioglyph_brush_draw_cache
lib.rsglyph_brush_draw_cache
version0.1.6
sourcesrc
created_at2020-05-23 15:37:26.808657
updated_at2024-06-22 11:47:30.850418
descriptionTexture draw cache for ab_glyph
homepage
repositoryhttps://github.com/alexheretic/glyph-brush
max_upload_size
id244911
size156,574
Alex Butler (alexheretic)

documentation

README

glyph_brush_draw_cache crates.io Documentation

Rasterization cache for ab_glyph used in glyph_brush.

  • Manages a texture. Draws glyphs into it and provides texture rect lookup for glyphs.
  • Automatic re-use & reordering when needed.
use glyph_brush_draw_cache::DrawCache;

// build a cache with default settings
let mut draw_cache = DrawCache::builder().build();

// queue up some glyphs to store in the cache
for (font_id, glyph) in glyphs {
    draw_cache.queue_glyph(font_id, glyph);
}

// process everything in the queue, rasterizing & uploading as necessary
draw_cache.cache_queued(&fonts, |rect, tex_data| update_texture(rect, tex_data))?;

// access a given glyph's texture position & pixel position for the texture quad
match draw_cache.rect_for(font_id, &glyph) {
    Some((tex_coords, px_coords)) => {}
    None => {/* The glyph has no outline, or wasn't queued up to be cached */}
}

Example

See the draw_cache_guts example to see how it works (run it from the top level).

cargo run --example draw_cache_guts

Commit count: 461

cargo fmt