#wgpu #text #ttf #truetype #font


Simple library for rendering text with wgpu

13 releases (4 breaking)

Uses new Rust 2021

0.6.3 Jul 7, 2022
0.6.2 Jul 5, 2022
0.6.1 Apr 6, 2022
0.5.0 Apr 3, 2022
0.1.4 Mar 25, 2022

#27 in Rendering

Download history 17/week @ 2022-04-21 126/week @ 2022-04-28 116/week @ 2022-05-05 186/week @ 2022-05-12 50/week @ 2022-05-19 39/week @ 2022-05-26 92/week @ 2022-06-02 6/week @ 2022-06-09 8/week @ 2022-06-16 6/week @ 2022-06-23 31/week @ 2022-06-30 69/week @ 2022-07-07 7/week @ 2022-07-14 61/week @ 2022-07-21 35/week @ 2022-07-28 22/week @ 2022-08-04

141 downloads per month

MIT license

696 lines


Build Status Licence crates.io Documentation

wgpu-text is a wrapper over glyph-brush for fast and easy text rendering in wgpu.

This project was inspired by and is similar to wgpu_glyph, but has additional features and is simpler. Also there is no need to include glyph-brush in your project.

Some features are directly implemented from glyph-brush so you should go trough Section docs and Section examples for better understanding of managing and adding text.


Add the following to your Cargo.toml file:

wgpu_text = "0.6.3"


use wgpu_text::section::{Section, Text, Layout, HorizontalAlign};

let brush = wgpu_text::BrushBuilder::using_font_bytes(font).unwrap()
 /* .initial_cache_size((1024, 1024))) */ // use this to avoid resizing cache texture
 /* .with_depth_testing(true) */ // enable/disable depth testing
    .build(&device, &config);
// Directly implemented from glyph_brush.
let section = Section::default()
    .add_text(Text::new("Hello World"))

// on window resize:
        brush.resize_view(config.width as f32, config.height as f32, &queue);

// window event loop:
    winit::event::Event::RedrawRequested(_) => {
        // Has to be queued every frame.
        let text_buffer = brush.draw(&device, &view, &queue);
        // Has to be submitted last so text won't be overlapped.
        queue.submit([some_other_encoder.finish(), text_buffer]);


For more detailed examples look trough examples.

  • cargo run --example <example-name>

Run examples with --release for true performance.


Besides basic text rendering and glyph-brush features, there are some features that add customization:

builtin matrix - default matrix for orthographic projection, feel free to use it for creating custom matrices

custom matrix - ability of providing a custom matrix for purposes of custom view, rotation... (the downside is that it applies to all rendered text)

depth testing - by adding z coordinate, text can be set on top or below other text (if enabled)


  • try to improve docs
  • maybe some new features
  • (wgpu stuff: maybe change to StagingBelt instead of Queue)


All contributions are welcome.


~217K SLoC