Expand description
A lot of stuff was based on macroquads font system, just removed dpi_scaling and font_scaling and added fallback font support
Example
// Include Fonts
const NOTO_SANS: &[u8] = include_bytes!("../assets/fonts/NotoSans-Regular.ttf");
const NOTO_SANS_JP: &[u8] = include_bytes!("../assets/fonts/NotoSansJP-Regular.otf");
// Window Config for macroquad
fn window_conf() -> Conf { ... }
#[macroquad::main(window_conf)]
async fn main() {
// Start by creating a fonts instance to handle all your fonts
let mut fonts = Fonts::default();
// Load fonts, the order you load fonts is the order it uses for lookups
fonts.load_font_from_bytes("Noto Sans", NOTO_SANS).unwrap();
fonts.load_font_from_bytes("Noto Sans JP", NOTO_SANS_JP).unwrap();
loop {
// Draw text
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;
}
}
Structs§
- Font
- Stores font data, also stores caches for much faster rendering times
- Fonts
- Text
Params - Text parameters for Fonts::draw_text_ex
Enums§
- Draw
From - Where to draw from on the screen