Create a new Ply engine with the given default font.
(default_font: &'static renderer::FontAsset)
| 869 | |
| 870 | /// Create a new Ply engine with the given default font. |
| 871 | pub async fn new(default_font: &'static renderer::FontAsset) -> Self { |
| 872 | renderer::FontManager::load_default(default_font).await; |
| 873 | |
| 874 | let dimensions = Dimensions::new( |
| 875 | macroquad::prelude::screen_width(), |
| 876 | macroquad::prelude::screen_height(), |
| 877 | ); |
| 878 | let mut ply = Self { |
| 879 | context: engine::PlyContext::new(dimensions), |
| 880 | headless: false, |
| 881 | text_input_repeat_key: 0, |
| 882 | text_input_repeat_first: 0.0, |
| 883 | text_input_repeat_last: 0.0, |
| 884 | text_input_repeat_focus_id: 0, |
| 885 | was_text_input_focused: false, |
| 886 | #[cfg(all(feature = "a11y", target_arch = "wasm32"))] |
| 887 | web_a11y_state: accessibility_web::WebAccessibilityState::default(), |
| 888 | #[cfg(all(feature = "a11y", not(target_arch = "wasm32")))] |
| 889 | native_a11y_state: accessibility_native::NativeAccessibilityState::default(), |
| 890 | }; |
| 891 | ply.context.default_font_key = default_font.key(); |
| 892 | ply.set_measure_text_function(renderer::create_measure_text_function()); |
| 893 | ply |
| 894 | } |
| 895 | |
| 896 | /// Create a new Ply engine without text measurement. |
| 897 | /// |
nothing calls this directly
no test coverage detected