pub struct BitmapFont {
pub width: u8,
pub height: u8,
pub advance: u8,
pub line_height: u8,
pub first_char: u8,
pub bytes_per_row: u8,
pub glyphs: &'static [u8],
}Expand description
Flexible monospaced or packed raw bitmap font definition.
Unlike PackedFont (which is fixed to 3x5 5-row bitpacks), BitmapFont
supports arbitrary glyph dimensions (e.g., 8x8, 8x16, 12x16, 16x24),
configurable advance/line-height, and multi-byte row bit-masks.
Fields§
§width: u8Bounding box width in pixels.
height: u8Bounding box height in pixels.
advance: u8Character horizontal advance in pixels.
line_height: u8Vertical line height in pixels.
first_char: u8The ASCII character code of the first glyph in the buffer (usually 32 / space).
bytes_per_row: u8Number of bytes per row for each glyph (e.g. 1 byte for width <= 8, 2 bytes for width <= 16).
glyphs: &'static [u8]Contiguous byte slice containing glyph bitmaps stored row by row (MSB left-to-right).
Implementations§
Source§impl BitmapFont
impl BitmapFont
Sourcepub const fn new_8x8(
first_char: u8,
advance: u8,
line_height: u8,
glyphs: &'static [u8],
) -> Self
pub const fn new_8x8( first_char: u8, advance: u8, line_height: u8, glyphs: &'static [u8], ) -> Self
Creates a new BitmapFont for standard 8x8 glyphs (1 byte per row, 8 rows per glyph).
Sourcepub const fn new_8x16(
first_char: u8,
advance: u8,
line_height: u8,
glyphs: &'static [u8],
) -> Self
pub const fn new_8x16( first_char: u8, advance: u8, line_height: u8, glyphs: &'static [u8], ) -> Self
Creates a new BitmapFont for standard 8x16 glyphs (1 byte per row, 16 rows per glyph).
Sourcepub fn glyph_bytes(&self, ch: char) -> Option<&'static [u8]>
pub fn glyph_bytes(&self, ch: char) -> Option<&'static [u8]>
Get the raw byte slice for a character’s row data.
Trait Implementations§
Source§impl Clone for BitmapFont
impl Clone for BitmapFont
Source§fn clone(&self) -> BitmapFont
fn clone(&self) -> BitmapFont
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more