Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

40
vendor/bevy_text/src/font_loader.rs vendored Normal file
View File

@@ -0,0 +1,40 @@
use crate::Font;
use bevy_asset::{io::Reader, AssetLoader, LoadContext};
use thiserror::Error;
#[derive(Default)]
/// An [`AssetLoader`] for [`Font`]s, for use by the [`AssetServer`](bevy_asset::AssetServer)
pub struct FontLoader;
/// Possible errors that can be produced by [`FontLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum FontLoaderError {
/// The contents that could not be parsed
#[error(transparent)]
Content(#[from] cosmic_text::ttf_parser::FaceParsingError),
/// An [IO](std::io) Error
#[error(transparent)]
Io(#[from] std::io::Error),
}
impl AssetLoader for FontLoader {
type Asset = Font;
type Settings = ();
type Error = FontLoaderError;
async fn load(
&self,
reader: &mut dyn Reader,
_settings: &(),
_load_context: &mut LoadContext<'_>,
) -> Result<Font, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let font = Font::try_from_bytes(bytes)?;
Ok(font)
}
fn extensions(&self) -> &[&str] {
&["ttf", "otf"]
}
}