refactor mega-commit.
- reorganised the entire project so that the entire kernel is a single codebase rather than a kernel and a libk.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
use libm::include_font;
|
||||
pub static FONT_SPLEEN_8X16: Font =
|
||||
Font::new(include_font!("./kernel/resources/font/spleen-8x16.psf"));
|
||||
|
||||
pub static FONT_CP850_8X16: Font =
|
||||
Font::new(include_font!("./kernel/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 fn default() -> &'static Font {
|
||||
&FONT_CP850_8X16
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user