Skip to main content

BitmapFont

Struct BitmapFont 

Source
pub struct BitmapFont {
    pub glyph_width: u8,
    pub glyph_height: u8,
    pub scale: u8,
    pub data: &'static [u8],
}
Expand description

A fixed-width bitmap font with 1-bit packed glyph data.

Each glyph occupies glyph_width * glyph_height bits, stored row-major with the MSB of each byte mapping to the leftmost pixel. Glyphs cover ASCII codepoints 0x20 through 0x7E (95 characters).

Fields§

§glyph_width: u8

Width of each glyph in pixels.

§glyph_height: u8

Height of each glyph in pixels.

§scale: u8

Pixel scale factor (1 = native, 2 = double, etc.).

§data: &'static [u8]

Row-major, 1-bit-per-pixel packed glyph data for ASCII 0x20..=0x7E.

Implementations§

Source§

impl BitmapFont

Source

pub fn scaled_width(&self) -> i32

Scaled glyph width in display pixels.

Source

pub fn scaled_height(&self) -> i32

Scaled glyph height in display pixels.

Source

pub fn draw_char( &self, renderer: &mut dyn Renderer, x: i32, y: i32, ch: char, color: Color, )

Render a single character at (x, y).

Source

pub fn draw_str( &self, renderer: &mut dyn Renderer, x: i32, y: i32, text: &str, color: Color, )

Render a string at (x, y) advancing horizontally (increasing x).

Source

pub fn draw_str_y( &self, renderer: &mut dyn Renderer, x: i32, y: i32, text: &str, color: Color, )

Render a string advancing along the Y axis (for rotated displays).

Glyphs remain upright but each character is placed at increasing Y, allowing horizontal text on a display where fb Y = physical horizontal.

Trait Implementations§

Source§

impl FontMetrics for BitmapFont

Source§

fn glyph_metrics(&self, ch: char) -> Option<GlyphInfo>

Return per-glyph advance and extent information for ch.
Source§

fn line_metrics(&self) -> FontLineMetrics

Return font-level vertical metrics.
Source§

fn glyph_coverage_row( &self, ch: char, row: u16, x_offset: u16, coverage: &mut [u8], ) -> bool

Fill one row of glyph coverage for ch. Read more
Source§

fn measure_fp16(&self, text: &str) -> i32

Measure the advance width of text in 1/16 pixel units.
Source§

fn shape(&self, text: &str, origin: (i32, i32)) -> ShapedText<'_>
where Self: Sized,

Shape text into an LTR ShapedText run at origin. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.