gfx_glyph 0.13.3

Fast GPU cached text rendering using gfx-rs & rusttype
Documentation

gfx_glyph crates.io Documentation

Fast GPU cached text rendering using gfx-rs v0.17 & glyph-brush.

Makes use of three kinds of caching to optimise frame performance.

  • Caching of glyph positioning output to avoid repeated cost of identical text rendering on sequential frames.
  • Caches draw calculations to avoid repeated cost of identical text rendering on sequential frames.
  • GPU cache logic to dynamically maintain a GPU texture of rendered glyphs.
use gfx_glyph::{Section, GlyphBrushBuilder};

let garamond: &[u8] = include_bytes!("GaramondNo8-Reg.ttf");
let mut glyph_brush = GlyphBrushBuilder::using_font_bytes(garamond)
    .build(gfx_factory.clone());

let section = Section {
    text: "Hello gfx_glyph",
    ..Section::default() // color, position, etc
};

glyph_brush.queue(section);
glyph_brush.queue(some_other_section);

glyph_brush.draw_queued(&mut gfx_encoder, &gfx_color, &gfx_depth)?;

Examples

Have a look at

  • cargo run --example paragraph --release
  • cargo run --example performance --release
  • cargo run --example varied --release
  • cargo run --example depth --release

Limitations

The current implementation supports OpenGL (3.2 or later) only. Use glyph-brush directly if this is an issue.