|
MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
|
The format of a font, and the way from a char of a string to its glyph. More...
#include <Font.h>
Static Public Member Functions | |
| static MAXMATRIX_NODISCARD Status | CheckFont (span< uint8_t const > font) |
| Returns whether font is a font that fills its bytes exactly. | |
| static MAXMATRIX_NODISCARD Result< Glyph > | GetGlyph (span< uint8_t const > font, char c) |
| Finds the glyph of a char in a font. | |
| static DecodedChar | DecodeChar (span< char const > text) |
| Decodes the next char of a string. | |
The format of a font, and the way from a char of a string to its glyph.
A font is the font format of the MD_MAX72XX library, so that its fonts and its font builder serve here as well: an array of bytes in flash, PROGMEM, that starts with 'F', the version, the code of the first char, that of the last, and the height in rows, and then holds every char from the first to the last as its width and that many columns, bit 0 the top row. A char of width 0 is not in the font. Version 1 gives each code in one byte; version 2, which lets a font go past 255, in two, high byte first.
The format holds no length of its own, so a font is checked against the length of its array, which the span it is handed brings: every char from the first to the last has to fit into it, and the last has to end it. A font that CheckFont() took cannot lead GetGlyph() past its end.
A char is found by walking from the first char to it, as MD_MAX72XX does: in the default font 34 us for an A and 211 us for a u umlaut, 220 chars on, on the Uno (measured in simavr), against an index that would take two bytes of flash per char. A shifting text looks a char up once.
It keeps no font of its own: every function is handed the font, and internal::Text keeps which one is set.
|
static |
Returns whether font is a font that fills its bytes exactly.
A font in RAM fails as well, almost always, as it is read from flash: the bytes found there at its address would have to add up to its length exactly.
| [in] | font | The font, in flash. |
|
static |
Decodes the next char of a string.
A UTF-8 sequence of a latin-1 char, such as an umlaut, becomes that one latin-1 char; every other byte comes back as it is.
| [in] | text | The text from the char to decode on; not at its end, as internal::IsEndOfText() tells it. |
|
static |
Finds the glyph of a char in a font.
| [in] | font | The font, in flash, one that CheckFont() took. |
| [in] | c | The char, latin-1, as DecodeChar() gives it. |