
* Remove cfg!(feature = "metal-auto-capture") This cfg! has existed since the initial commit, but the corresponding feature has never been part of Cargo.toml * Remove unnecessary handle_create_window_events call * Remove EventLoopProxyPtr wrapper * Remove unnecessary statics * Fix unrelated deprecation warning to fix CI
26 lines
601 B
Rust
26 lines
601 B
Rust
use crate::Font;
|
|
use anyhow::Result;
|
|
use bevy_asset::{AssetLoader, LoadContext, LoadedAsset};
|
|
use bevy_utils::BoxedFuture;
|
|
|
|
#[derive(Default)]
|
|
pub struct FontLoader;
|
|
|
|
impl AssetLoader for FontLoader {
|
|
fn load<'a>(
|
|
&'a self,
|
|
bytes: &'a [u8],
|
|
load_context: &'a mut LoadContext,
|
|
) -> BoxedFuture<'a, Result<()>> {
|
|
Box::pin(async move {
|
|
let font = Font::try_from_bytes(bytes.into())?;
|
|
load_context.set_default_asset(LoadedAsset::new(font));
|
|
Ok(())
|
|
})
|
|
}
|
|
|
|
fn extensions(&self) -> &[&str] {
|
|
&["ttf"]
|
|
}
|
|
}
|