wgpu-text

Build Status Licence crates.io Documentation

wgpu-text is a wrapper over glyph-brush for easier text rendering in wgpu.

This project was inspired by and is similar to wgpuglyph_, 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 adding and managing text.

Example: ```rust use wgputext::BrushBuilder; use wgputext::section::{Section, Text, Layout, HorizontalAlign}; let brush = BrushBuilder::usingfontbytes(font).unwrap() /* .initialcachesize((1024, 1024))) / // use this to avoid resizing cache texture / .withdepthtesting(true) */ // enable/disable depth testing .build(&device, format, width, height); let section = Section::default() .addtext(Text::new("Hello World")) .withlayout(Layout::default().h_align(HorizontalAlign::Center));

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

Features

Besides basic text rendering and glyph-brush features, there are some features that add customization: - builtin matrix - default matrix for orthogonal projection - custom matrix - ability of providing a custom matrix for purposes of custom view, rotation... - depth testing - by adding z coordinate text can be set on top or below other text

Examples

Look trough examples for more. * cargo run --example <example-name>

Run examples with --release for true performance.

Goals

Contributing

All contributions are welcome.