wgpu_text 0.1.2

Simple library for rendering text with wgpu
Documentation

wgpu-text

Licence crates.io Documentation

wgpu-text is a wrapper over glyph-brush for simpler 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 for better understanding of adding and managing text.

Example:

use wgpu_text::BrushBuilder;
use wgpu_text::section::{Section, Text, Layout, HorizontalAlign};
let brush = BrushBuilder::using_font_bytes(font).unwrap().build(
        &device, format, width, height);
let section = Section::default()
    .add_text(Text::new("Hello World"))
    .with_layout(Layout::default().h_align(HorizontalAlign::Center));

// window event loop:
    winit::event::Event::RedrawRequested(_) => {
        // Has to be queued every frame.
        brush.queue(&section);
        let cmd_buffer = brush.draw_queued(&device, &view, &queue);
        // Has to be submitted last so text won't be overlapped.
        queue.submit(cmd_buffer);
        frame.submit();
    }

Examples

Look trough examples for more.

  • cargo run --example <example-name>

Goals

  • improve docs
  • improve examples
  • maybe some new features