Before going any further, we actually need a font. I chose Lucida console, but pick the one you prefer, it doesn't really matter. Once downloaded, put it in the assets folder as well. Now, time to actually load the font:
let font = ttf_context.load_font("assets/lucida.ttf", 128).expect(" Couldn't load the font");
Note that if you want to apply a style to your font (such as bold, italic, strikethrough, or underline), that's the object on which you need to apply it. Here is an example:
Now, two steps are remaining to be able to actually display text:
- Render the text.
- Create a texture from it.
Let's write a function in order to do so:
fn create_texture_from_text<'a>(texture_creator: ...