cossonleo / wgpu_glyph

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)

Home Page:https://docs.rs/wgpu_glyph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wgpu_glyph

Integration status crates.io Documentation License

A fast text renderer for wgpu, powered by glyph_brush

use wgpu_glyph::{Section, GlyphBrushBuilder};

let font: &[u8] = include_bytes!("SomeFont.ttf");
let mut glyph_brush = GlyphBrushBuilder::using_font_bytes(font)
    .build(&mut device, render_format);

let section = Section {
    text: "Hello wgpu_glyph",
    ..Section::default() // color, position, etc
};

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

glyph_brush.draw_queued(
    &mut device,
    &mut encoder,
    &frame.view,
    frame.width.round() as u32,
    frame.height.round() as u32,
);

device.get_queue().submit(&[encoder.finish()]);

Examples

Have a look at

About

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)

https://docs.rs/wgpu_glyph

License:MIT License


Languages

Language:Rust 95.8%Language:GLSL 4.2%