Load the default font. Stored outside the cache and never evicted.
(asset: &'static FontAsset)
| 188 | |
| 189 | /// Load the default font. Stored outside the cache and never evicted. |
| 190 | pub async fn load_default(asset: &'static FontAsset) { |
| 191 | let font = match asset { |
| 192 | FontAsset::Bytes { data, .. } => { |
| 193 | macroquad::text::load_ttf_font_from_bytes(data) |
| 194 | .expect("Failed to load font from bytes") |
| 195 | } |
| 196 | FontAsset::Path(path) => { |
| 197 | let resolved = resolve_asset_path(path); |
| 198 | macroquad::text::load_ttf_font(resolved).await |
| 199 | .unwrap_or_else(|e| panic!("Failed to load font '{}': {:?}", path, e)) |
| 200 | } |
| 201 | }; |
| 202 | let mut fm = FONT_MANAGER.lock().unwrap(); |
| 203 | fm.default_font = Some(DefaultFont { key: asset.key(), font }); |
| 204 | } |
| 205 | |
| 206 | /// Ensure a font is loaded (no-op if already cached). |
| 207 | pub async fn ensure(asset: &'static FontAsset) { |
nothing calls this directly
no test coverage detected