Skip to content

Commit bcd5897

Browse files
2 parents 9c1f966 + 6709e67 commit bcd5897

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/aero_kernel/src/rendy.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ use stivale_boot::v2::StivaleFramebufferTag;
3535

3636
use crate::utils::sync::Mutex;
3737

38-
static FONT: &[u8] = include_bytes!("../../font.bin");
38+
static FONT: &[[u8; FONT_HEIGHT]; FONT_GLYPHS] =
39+
unsafe { &core::mem::transmute(*include_bytes!("../../font.bin")) };
3940

4041
// This is an example of how the rendered screen will look like:
4142
//
@@ -53,6 +54,7 @@ static FONT: &[u8] = include_bytes!("../../font.bin");
5354

5455
const FONT_WIDTH: usize = 8;
5556
const FONT_HEIGHT: usize = 16;
57+
const FONT_GLYPHS: usize = 256;
5658

5759
const DEFAULT_MARGIN: usize = 64 / 2;
5860
const TAB_SIZE: usize = 4;
@@ -553,12 +555,7 @@ impl<'this> DebugRendy<'this> {
553555

554556
let x = self.offset_x + x * FONT_WIDTH;
555557
let y = self.offset_y + y * FONT_HEIGHT;
556-
let glyph = unsafe {
557-
core::slice::from_raw_parts(
558-
FONT.as_ptr().offset(ch as isize * FONT_HEIGHT as isize) as *const u8,
559-
FONT_HEIGHT,
560-
)
561-
};
558+
let glyph = &FONT[ch as usize];
562559

563560
// naming: fx, fy for font coordinates and gx, gy for glyph coordinates
564561
for gy in 0..FONT_HEIGHT {
@@ -575,7 +572,7 @@ impl<'this> DebugRendy<'this> {
575572
};
576573

577574
for gx in 0..FONT_WIDTH {
578-
let draw = glyph[gy] & (1 << (FONT_WIDTH - gx)) != 0;
575+
let draw = glyph[gy] & (1 << (FONT_WIDTH - gx - 1)) != 0;
579576
let color = if draw {
580577
char.fg
581578
} else if char.bg == u32::MAX {

0 commit comments

Comments
 (0)