#font #ttf #truetype #gfx #text

gfx_glyph

Fast GPU cached text rendering using gfx-rs & ab_glyph

40 releases

0.17.0 May 23, 2020
0.16.0 Sep 20, 2019
0.15.0 May 3, 2019
0.14.0 Feb 12, 2019
0.6.4 Nov 24, 2017

#24 in Data formats

Download history 921/week @ 2022-01-30 507/week @ 2022-02-06 737/week @ 2022-02-13 809/week @ 2022-02-20 800/week @ 2022-02-27 572/week @ 2022-03-06 663/week @ 2022-03-13 689/week @ 2022-03-20 521/week @ 2022-03-27 811/week @ 2022-04-03 747/week @ 2022-04-10 875/week @ 2022-04-17 750/week @ 2022-04-24 752/week @ 2022-05-01 874/week @ 2022-05-08 1332/week @ 2022-05-15

3,839 downloads per month
Used in 18 crates (7 directly)

Apache-2.0

180KB
3K SLoC

gfx_glyph crates.io Documentation

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

use gfx_glyph::{ab_glyph::FontArc, GlyphBrushBuilder, Section, Text};

let dejavu = FontArc::try_from_slice(include_bytes!("../../fonts/DejaVuSans.ttf"))?;
let mut glyph_brush = GlyphBrushBuilder::using_font(dejavu).build(gfx_factory.clone());

// set the text scale, font, color, position, etc
let section = Section::default()
    .add_text(Text::new("Hello gfx_glyph"));

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

glyph_brush.use_queue().draw(&mut gfx_encoder, &gfx_color)?;

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.

Dependencies

~5.5MB
~116K SLoC