Skip to main content

Psf2Font

Struct Psf2Font 

Source
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: Psf2Header

Implementations§

Source§

impl Psf2Font

Source

pub fn glyph_height(&self) -> usize

Return the height of one glyph in pixels.

Source§

impl Psf2Font

Source

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.

Source

fn parse_char(&self, c: char) -> Option<&'static [u8]>

Return the raw glyph bytes for character c, or None if c has no glyph.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl Freeze for Psf2Font

§

impl RefUnwindSafe for Psf2Font

§

impl Send for Psf2Font

§

impl Sync for Psf2Font

§

impl Unpin for Psf2Font

§

impl UnsafeUnpin for Psf2Font

§

impl UnwindSafe for Psf2Font

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.