1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use { super::Bitmap, serde::{Deserialize, Serialize}, }; /// Holds a `BitmapFont` in a `.pak` file. For data transport only. #[derive(Debug, Deserialize, PartialEq, Serialize)] pub struct BitmapFont { def: String, pages: Vec<Bitmap>, } impl BitmapFont { pub(crate) fn new(def: String, pages: Vec<Bitmap>) -> Self { Self { def, pages } } // TODO: We could pre-pack this instead of raw text! /// Gets the main `.fnt` file in original text form pub fn def(&self) -> &str { self.def.as_str() } /// Gets an iterator of `Bitmap` pages within this `BitmapFont`. pub fn pages(&self) -> impl Iterator<Item = &Bitmap> { self.pages.iter() } }