pub struct Psf2Font {
font: &'static [u8],
header: Psf2Header,
}Expand description
A loaded and parsed PSF2 font, ready for rendering into a BasicFramebuffer.
Fields§
§font: &'static [u8]The raw font file bytes (glyph bitmaps start at header.header_size).
header: Psf2HeaderImplementations§
Source§impl Psf2Font
impl Psf2Font
Sourcepub fn glyph_height(&self) -> usize
pub fn glyph_height(&self) -> usize
Return the height of one glyph in pixels.
Source§impl Psf2Font
impl Psf2Font
Sourcepub fn init() -> Self
pub fn init() -> Self
Load and parse the built-in PSF2 font embedded in the kernel binary.
§Panics
Panics if the embedded file’s magic number does not match MAGIC_NUMBER.
Sourcefn parse_char(&self, c: char) -> Option<&'static [u8]>
fn parse_char(&self, c: char) -> Option<&'static [u8]>
Return the raw glyph bytes for character c, or None if c has no glyph.
Sourcepub fn draw_char(
&self,
fb: &BasicFramebuffer,
c: char,
x: usize,
y: usize,
font_color: Option<u32>,
) -> usize
pub fn draw_char( &self, fb: &BasicFramebuffer, c: char, x: usize, y: usize, font_color: Option<u32>, ) -> usize
Render one character into the framebuffer at pixel position (x, y).
Returns the x position immediately after the glyph, or the original x if the
character has no glyph or falls outside the framebuffer bounds.
Sourcepub fn draw_string(
&self,
fb: &BasicFramebuffer,
string: &str,
x: &mut usize,
y: &mut usize,
font_color: Option<u32>,
)
pub fn draw_string( &self, fb: &BasicFramebuffer, string: &str, x: &mut usize, y: &mut usize, font_color: Option<u32>, )
Render a string into the framebuffer, advancing *x/*y after each character.
'\n' wraps to the next line.