use alloc::sync::Arc;12use bevy_asset::Asset;3use bevy_reflect::TypePath;45/// An [`Asset`] that contains the data for a loaded font, if loaded as an asset.6///7/// Loaded by [`FontLoader`](crate::FontLoader).8///9/// # A note on fonts10///11/// `Font` may differ from the everyday notion of what a "font" is.12/// A font *face* (e.g. Fira Sans Semibold Italic) is part of a font *family* (e.g. Fira Sans),13/// and is distinguished from other font faces in the same family14/// by its style (e.g. italic), its weight (e.g. bold) and its stretch (e.g. condensed).15///16/// Bevy currently loads a single font face as a single `Font` asset.17#[derive(Debug, TypePath, Clone, Asset)]18pub struct Font {19/// Content of a font file as bytes20pub data: Arc<Vec<u8>>,21}2223impl Font {24/// Creates a [`Font`] from bytes25pub fn try_from_bytes(26font_data: Vec<u8>,27) -> Result<Self, cosmic_text::ttf_parser::FaceParsingError> {28use cosmic_text::ttf_parser;29ttf_parser::Face::parse(&font_data, 0)?;30Ok(Self {31data: Arc::new(font_data),32})33}34}353637