use bevy::prelude::{Font as BevyFont, *}; use std::ops::Deref; use unic_langid::LanguageIdentifier; /// Font #[derive(Resource)] pub struct Font(pub Handle); impl FromWorld for Font { fn from_world(world: &mut World) -> Self { let asset_server = world.resource::(); let font = asset_server.load("fonts/FiraSans-Bold.ttf"); Self(font) } } /// Locales #[derive(Resource)] pub struct Locales(pub Vec); impl Locales { pub fn index(&self, locale: &LanguageIdentifier) -> usize { self.iter() .position(|item| item == locale) .expect("index not found") } } impl Deref for Locales { type Target = Vec; fn deref(&self) -> &Self::Target { &self.0 } }