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: u8Width of each glyph in pixels.
glyph_height: u8Height of each glyph in pixels.
scale: u8Pixel 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
impl BitmapFont
Sourcepub fn scaled_width(&self) -> i32
pub fn scaled_width(&self) -> i32
Scaled glyph width in display pixels.
Sourcepub fn scaled_height(&self) -> i32
pub fn scaled_height(&self) -> i32
Scaled glyph height in display pixels.
Sourcepub fn draw_char(
&self,
renderer: &mut dyn Renderer,
x: i32,
y: i32,
ch: char,
color: Color,
)
pub fn draw_char( &self, renderer: &mut dyn Renderer, x: i32, y: i32, ch: char, color: Color, )
Render a single character at (x, y).
Sourcepub fn draw_str(
&self,
renderer: &mut dyn Renderer,
x: i32,
y: i32,
text: &str,
color: Color,
)
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).
Sourcepub fn draw_str_y(
&self,
renderer: &mut dyn Renderer,
x: i32,
y: i32,
text: &str,
color: Color,
)
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
impl FontMetrics for BitmapFont
Source§fn glyph_metrics(&self, ch: char) -> Option<GlyphInfo>
fn glyph_metrics(&self, ch: char) -> Option<GlyphInfo>
ch.Source§fn line_metrics(&self) -> FontLineMetrics
fn line_metrics(&self) -> FontLineMetrics
Source§fn glyph_coverage_row(
&self,
ch: char,
row: u16,
x_offset: u16,
coverage: &mut [u8],
) -> bool
fn glyph_coverage_row( &self, ch: char, row: u16, x_offset: u16, coverage: &mut [u8], ) -> bool
ch. Read moreSource§fn measure_fp16(&self, text: &str) -> i32
fn measure_fp16(&self, text: &str) -> i32
text in 1/16 pixel units.