diff --git a/assets/fonts/D2Coding-Ver1.3.2-20180524.ttf b/assets/fonts/D2Coding-Ver1.3.2-20180524.ttf new file mode 100644 index 0000000..65b7bbb Binary files /dev/null and b/assets/fonts/D2Coding-Ver1.3.2-20180524.ttf differ diff --git a/examples/render_text_add_kr.rs b/examples/render_text_add_kr.rs new file mode 100644 index 0000000..bb2bb04 --- /dev/null +++ b/examples/render_text_add_kr.rs @@ -0,0 +1,43 @@ +use macroquad::prelude::*; + +use macroquad_text::Fonts; + +// 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"); +const D2_KR: &[u8] = include_bytes!("../assets/fonts/D2Coding-Ver1.3.2-20180524.ttf"); + +// Window config for macroquad +fn window_conf() -> Conf { + Conf { + window_title: "Rendering Text Example".to_owned(), + window_width: 390, + window_height: 367, + high_dpi: true, + window_resizable: true, + ..Default::default() + } +} + +#[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(); + fonts.load_font_from_bytes("D2", D2_KR).unwrap(); + + loop { + // Draw text + fonts.draw_text("Nice", 20.0, 0.0, 69.5, Color::from([1.0; 4])); + fonts.draw_text("良い", 20.0, 89.0, 69.5, Color::from([1.0; 4])); + fonts.draw_text("Nice 良い", 20.0, 178.0, 69., Color::from([1.0; 4])); + fonts.draw_text("한글 테스트", 20.0, 268.0, 69., Color::from([1.0; 4])); + + next_frame().await; + } +}