use libm::include_font; pub const FONT_SPLEEN_8X16: Font = Font::new(include_font!("../../../resources/font/spleen-8x16.psf")); pub const FONT_CP850_8X16: Font = Font::new(include_font!("../../../resources/font/cp850-8x16.psf")); // pub struct Font(pub [[u8; 16]; 512]); pub struct Font { width: usize, height: usize, length: u16, data: [[u8; 16]; 512], } impl Font { pub const fn new(data: [[u8; 16]; 512]) -> Self { Self { width: 8, height: 16, length: data.len() as u16, data, } } pub const fn glyph_for(&self, c: u16) -> &[u8] { if c > self.length { return &self.data[0]; } &self.data[c as usize] } pub const fn width(&self) -> usize { self.width } pub const fn height(&self) -> usize { self.height } } impl Default for Font { fn default() -> Self { FONT_CP850_8X16 } }