#text #font #vulkano

vulkano_text

Render text with the DejaVu font using the Vulkano library

18 releases (11 breaking)

✓ Uses Rust 2018 edition

0.12.0 Feb 12, 2020
0.11.0 Jul 3, 2019
0.10.0 May 25, 2019
0.9.0 Nov 8, 2018
0.1.1 Feb 25, 2017

#37 in Graphics APIs

Download history 2/week @ 2019-11-07 19/week @ 2019-11-14 43/week @ 2019-11-21 35/week @ 2019-11-28 20/week @ 2019-12-05 192/week @ 2019-12-12 18/week @ 2019-12-26 3/week @ 2020-01-02 28/week @ 2020-01-09 53/week @ 2020-01-16 3/week @ 2020-01-30 15/week @ 2020-02-06 26/week @ 2020-02-13

140 downloads per month
Used in 2 crates

MIT license

430KB
263 lines

Vulkano Text Build Status dependency status

This library is useful if you are building a game prototype with Vulkano and want a quick way to add basic text rendering:

  • You can only use the DejaVu font
  • The text is rendered on top of the contents of your swapchain image (no depthbuffer or draw ordering)

Usage

Below are relevant lines taken from the triangle.rs example.

Import the library:

extern crate vulkano_text;
use vulkano_text::{DrawText, DrawTextTrait};

Create DrawText:

let mut draw_text = DrawText::new(device.clone(), queue.clone(), swapchain.clone(), &images);

Specify text to draw by calling queue_text:

draw_text.queue_text(200.0, 50.0, 20.0, [1.0, 1.0, 1.0, 1.0], "The quick brown fox jumps over the lazy dog.");
draw_text.queue_text(20.0, 200.0, 190.0, [0.0, 1.0, 1.0, 1.0], "Hello world!");
draw_text.queue_text(x, 350.0, 70.0, [0.51, 0.6, 0.74, 1.0], "Lenny: ( ͡° ͜ʖ ͡°)");
draw_text.queue_text(50.0, 350.0, 70.0, [1.0, 1.0, 1.0, 1.0], "Overlap");

Call draw_text on the AutoCommandBufferBuilder after your game render pass:

.draw_text(&mut draw_text, image_num)

You will also need to recreate DrawText when you recreate your swapchain e.g. due to window resize

Example Render

Result:

Dependencies

~21MB
~457K SLoC