Crates.io | macroquad-text |
lib.rs | macroquad-text |
version | 0.2.0 |
source | src |
created_at | 2021-12-29 09:20:55.912342 |
updated_at | 2023-09-10 23:43:25.800554 |
description | A Simple way to draw text in macroquad with support of using glyphs from multiple fonts in a single draw_text call, also known as fallback fonts |
homepage | https://github.com/Ricky12Awesome/macroquad-text |
repository | https://github.com/Ricky12Awesome/macroquad-text |
max_upload_size | |
id | 504718 |
size | 50,788 |
A Simple way to draw text in macroquad with support of using glyphs from multiple fonts in a single draw_text call, also known as fallback fonts
I made this because the one provided by macroquad doesn't support this
From render_text example
use macroquad::prelude::*;
use macroquad_text::Fonts;
const NOTO_SANS: &[u8] = include_bytes!("../assets/fonts/NotoSans-Regular.ttf");
const NOTO_SANS_JP: &[u8] = include_bytes!("../assets/fonts/NotoSansJP-Regular.otf");
fn window_conf() -> Conf { /* ommitted */ }
#[macroquad::main(window_conf)]
async fn main() {
let mut fonts = Fonts::default();
fonts.load_font_from_bytes("Noto Sans", NOTO_SANS).unwrap();
fonts.load_font_from_bytes("Noto Sans JP", NOTO_SANS_JP).unwrap();
loop {
fonts.draw_text("Nice", 20.0, 0.0, 69, Color::from([1.0; 4]));
fonts.draw_text("良い", 20.0, 89.0, 69, Color::from([1.0; 4]));
fonts.draw_text("Nice 良い", 20.0, 178.0, 69, Color::from([1.0; 4]));
next_frame().await;
}
}