Skip to content

Font

Struct

Source: Font.h

Description

Descriptor for a bitmap font using 1bpp sprites.

A Font contains an array of Sprite structures, one for each character in the font's character set. Each glyph is rendered as a 1bpp sprite, allowing consistent rendering across platforms.

The font uses fixed-width glyphs for simplicity and performance. All glyphs share the same width and height, with spacing between characters controlled by the spacing field.

Font data should be stored in flash memory (const/constexpr) to minimize RAM usage on embedded systems. Include "Renderer.h" when using Font in implementation files to get the full Sprite definition.

TIP

Font data should be stored in flash memory (const/constexpr) to minimize RAM usage on embedded systems.

TIP

Include "Renderer.h" when using Font in implementation files to get the full Sprite definition.

Properties

NameTypeDescription
SpriteconstArray of sprites, one per character (indexed by character code - firstChar)
firstCharuint8_tFirst character code in the font (e.g., 32 for space ' ')
lastCharuint8_tLast character code in the font (e.g., 126 for '~')
glyphWidthuint8_tFixed width of each glyph in pixels
glyphHeightuint8_tFixed height of each glyph in pixels
spacinguint8_tHorizontal spacing between characters in pixels
lineHeightuint8_tTotal line height including vertical spacing (glyphHeight + vertical spacing)

Released under the MIT License.