SSJKQR6X6L2KUJI2YPLMBQU3PTR2RYAQQR6N35MDMOCOTV6ZDUEAC EEO6C4YSWFW3JOZ3JH6K7X4TKAUTVJD53CQNYZHI2QY6REGEXUCAC GROTV3H2V6BHU5CA7WSLVYDCWAR7GHUP5JV2QOGPLJ6N3553T4MAC DKGUNP6LG3DJ35VMHU42K3VJO5JJ5UVYI4PLM72HO5ZNAQ4P366AC MT6IBX7SGLE26XIFZY53WYNHSJZMSDVDRJP3VYPXIQ4DKY75XVXAC O5P6HCPWGMGJBFJEMC3SYQJ5OEW2AQV4KEJCMRVTTS3K6M45Z3BAC PAOLWMH7TLJLNAWBJBWP7KB7YGDFUPASMTFU33KZ3QW5JXJMPXCAC L6RIUKGLJZLAOKFGUDTZKBPP4HUBPEZAKHJEQHO34WFF62AB2ZIQC KMU4E426CB2NDRJEK7B4GSL22P62CJPPZRK45X3JV5WP5NIBIGRQC 7CBRRVV3GLVLBHNPQNRHSA2ZCLHIMCHFEMWMZNOICY2OZLB7DGPAC RWAEE6C6YZEFU226ACROCZQYSPVW4QQLKDBY4S5BGTDGHQD5LJSAC impl Default for TextSystem {fn default() -> Self {Self {fonts: FontSystem::new(),
impl TextSystem {pub fn new<S: assets_manager::source::Source>(assets: &AssetCache<S>,) -> color_eyre::Result<Self> {let required_fonts = ["fonts.poiret_one.PoiretOne-Regular","fonts.noto_color_emoji.NotoColorEmoji-Regular",];let fonts: Vec<_> = required_fonts.into_iter().map(|id| {let font_data_handle = assets.load::<FontData>(id)?;let font_data: Arc<Vec<u8>> = Arc::new(font_data_handle.read().0.clone());Ok((id, Source::Binary(font_data)))}).collect::<Result<Vec<_>, color_eyre::Report>>()?;// Until we can assume otherwise, hardcode thislet locale = "en-US".to_string();let mut db = glyphon::fontdb::Database::new();#[cfg(not(target_arch = "wasm32"))]{db.load_system_fonts();}for (id, source) in fonts.into_iter() {let ids = db.load_font_source(source);log::warn!("laoded {id} into {ids}");}// Set up default families// Default to emoji for sans serifdb.set_sans_serif_family("Noto Color Emoji");let fonts = FontSystem::new_with_locale_and_db(locale, db);Ok(Self {fonts,
let font_name = "fonts.poiret_one.PoiretOne-Regular";let font_data_handle = match assets.load::<FontData>(font_name) {Ok(hnd) => hnd,Err(e) => {log::error!("failed to load font {font_name}: {e}");return;}};let current_reload_id = self.loaded_fonts.get(font_name);if current_reload_id.is_none()|| current_reload_id.is_some_and(|old_id| old_id < &font_data_handle.last_reload_id()){// Load the font into the systemself.loaded_fonts.insert(font_name.to_string(), font_data_handle.last_reload_id());self.fonts.db_mut().load_font_data(font_data_handle.read().0.clone());log::info!("successfully loaded font {font_name}!");}