use libm::include_font; pub mod ibm_vga_8x16; pub static FONT_SPLEEN_8X16: Font = Font::new(include_font!("./libk/resources/font/spleen-8x16.psf")); pub static FONT_CP850_8X16: Font = Font::new(include_font!("./libk/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]) -> Font { Font { 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 } pub const fn default() -> &'static Font { &FONT_CP850_8X16 } }