#font #ttf #truetype #gfx #text

gfx_glyph

Fast GPU cached text rendering using gfx-rs & rusttype

34 releases (12 breaking)

✓ Uses Rust 2018 edition

0.13.1 Dec 21, 2018
0.13.0 Sep 14, 2018
0.12.2 Aug 24, 2018
0.12.0 Jun 29, 2018
0.6.4 Nov 24, 2017

#3 in Rendering

Download history 751/week @ 2018-10-25 895/week @ 2018-11-01 899/week @ 2018-11-08 1570/week @ 2018-11-15 867/week @ 2018-11-22 1123/week @ 2018-11-29 690/week @ 2018-12-06 887/week @ 2018-12-13 676/week @ 2018-12-20 1169/week @ 2018-12-27 975/week @ 2019-01-03 853/week @ 2019-01-10 899/week @ 2019-01-17

4,191 downloads per month
Used in 19 crates (5 directly)

Apache-2.0

140KB
1.5K SLoC

gfx_glyph crates.io Documentation

Fast GPU cached text rendering using gfx-rs & 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.
extern crate gfx_glyph;
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). In future we'll support the upcoming gfx-rs ll releases.

Dependencies

~2.5MB
~44K SLoC