41 releases

0.17.1 Feb 10, 2023
0.17.0 May 23, 2020
0.16.0 Sep 20, 2019
0.15.0 May 3, 2019
0.6.4 Nov 24, 2017

#430 in Graphics APIs

Download history 559/week @ 2024-09-26 320/week @ 2024-10-03 257/week @ 2024-10-10 379/week @ 2024-10-17 448/week @ 2024-10-24 531/week @ 2024-10-31 313/week @ 2024-11-07 180/week @ 2024-11-14 482/week @ 2024-11-21 576/week @ 2024-11-28 1124/week @ 2024-12-05 1606/week @ 2024-12-12 524/week @ 2024-12-19 213/week @ 2024-12-26 783/week @ 2025-01-02 789/week @ 2025-01-09

2,586 downloads per month
Used in 17 crates (6 directly)

Apache-2.0

185KB
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–11MB
~123K SLoC