idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::font::mono_font Struct Reference

A fixed-cell monochrome bitmap font. More...

Public Member Functions

constexpr size_t bytes_per_row () const noexcept
 Returns the number of bytes in one glyph row.
 
constexpr size_t bytes_per_glyph () const noexcept
 Returns the number of bytes in one glyph.
 
constexpr bool contains (char c) const noexcept
 Returns true if the font has a glyph for c.
 
constexpr const uint8_t * glyph (char c) const noexcept
 Returns a pointer to the glyph bitmap for c.
 
constexpr bool ink_at (char c, size_t col, size_t row) const noexcept
 Returns true if the glyph for c has ink at (col, row).
 
constexpr size_t advance (char) const noexcept
 Returns the horizontal distance the cursor moves after c.
 

Public Attributes

uint8_t width
 Glyph cell width in pixels.
 
uint8_t height
 Glyph cell height in pixels.
 
char first_char
 First character in the glyph range.
 
char last_char
 Last character in the glyph range (inclusive).
 
const uint8_t * bitmap
 Glyph data (see struct description for layout).
 

Detailed Description

A fixed-cell monochrome bitmap font.

Glyphs cover a contiguous character range and share one cell size. The bitmap stores glyphs consecutively, each as height rows of ceil(width / 8) bytes, MSB = leftmost pixel.

Definition at line 41 of file font.hpp.

Member Function Documentation

◆ advance()

constexpr size_t idfxx::font::mono_font::advance ( char  ) const
inlineconstexprnoexcept

Returns the horizontal distance the cursor moves after c.

In a fixed-cell font every character advances one cell width, including characters outside the glyph range (rendered blank).

Parameters
cThe character.
Returns
The advance in pixels.

Definition at line 90 of file font.hpp.

References width.

Referenced by idfxx::gfx::draw_text(), and idfxx::font::text_width().

◆ bytes_per_glyph()

constexpr size_t idfxx::font::mono_font::bytes_per_glyph ( ) const
inlineconstexprnoexcept

Returns the number of bytes in one glyph.

Definition at line 52 of file font.hpp.

References bytes_per_row(), and height.

Referenced by glyph().

◆ bytes_per_row()

constexpr size_t idfxx::font::mono_font::bytes_per_row ( ) const
inlineconstexprnoexcept

Returns the number of bytes in one glyph row.

Definition at line 49 of file font.hpp.

References width.

Referenced by bytes_per_glyph(), idfxx::gfx::draw_text(), and ink_at().

◆ contains()

constexpr bool idfxx::font::mono_font::contains ( char  c) const
inlineconstexprnoexcept

Returns true if the font has a glyph for c.

Definition at line 55 of file font.hpp.

References first_char, and last_char.

Referenced by idfxx::gfx::draw_text().

◆ glyph()

constexpr const uint8_t * idfxx::font::mono_font::glyph ( char  c) const
inlineconstexprnoexcept

Returns a pointer to the glyph bitmap for c.

Parameters
cA character satisfying contains.
Returns
The first byte of the glyph's rows.

Definition at line 62 of file font.hpp.

References bitmap, bytes_per_glyph(), and first_char.

Referenced by idfxx::gfx::draw_text(), and ink_at().

◆ ink_at()

constexpr bool idfxx::font::mono_font::ink_at ( char  c,
size_t  col,
size_t  row 
) const
inlineconstexprnoexcept

Returns true if the glyph for c has ink at (col, row).

Per-pixel accessor decoding the glyph bitmap layout, so consumers need not address the packed bytes themselves.

Parameters
cA character satisfying contains.
colColumn within the glyph cell, in [0, width).
rowRow within the glyph cell, in [0, height).
Returns
true if the pixel is inked.

Definition at line 77 of file font.hpp.

References bytes_per_row(), and glyph().

Member Data Documentation

◆ bitmap

const uint8_t* idfxx::font::mono_font::bitmap

Glyph data (see struct description for layout).

Definition at line 46 of file font.hpp.

Referenced by glyph().

◆ first_char

char idfxx::font::mono_font::first_char

First character in the glyph range.

Definition at line 44 of file font.hpp.

Referenced by contains(), and glyph().

◆ height

uint8_t idfxx::font::mono_font::height

Glyph cell height in pixels.

Definition at line 43 of file font.hpp.

Referenced by bytes_per_glyph(), and idfxx::gfx::draw_text().

◆ last_char

char idfxx::font::mono_font::last_char

Last character in the glyph range (inclusive).

Definition at line 45 of file font.hpp.

Referenced by contains().

◆ width

uint8_t idfxx::font::mono_font::width

Glyph cell width in pixels.

Definition at line 42 of file font.hpp.

Referenced by advance(), bytes_per_row(), and idfxx::gfx::draw_text().


The documentation for this struct was generated from the following file: