24#include <avr/pgmspace.h>
38 template<
bool VERTICAL_>
class Font
60 glyph_size_{uint8_t(glyph_rows_ * glyph_cols_)},
141 const uint8_t val = uint8_t(value);
142 if ((val < first_char_) || (val > last_char_))
145 uint16_t index = (val - first_char_) *
glyph_size();
146 return uint16_t(&glyphs_[index]);
165 return pgm_read_byte(glyph_ref + index);
170 const uint8_t first_char_;
171 const uint8_t last_char_;
174 const uint8_t width_;
175 const uint8_t height_;
177 const uint8_t glyph_rows_;
178 const uint8_t glyph_cols_;
179 const uint8_t glyph_size_;
183 const uint8_t* glyphs_ =
nullptr;
Generic font support class.
constexpr Font(char first_char, char last_char, uint8_t width, uint8_t height, const uint8_t *glyphs)
Construct a new Font.
static constexpr bool VERTICAL
true if font is vertical, false if horizontal
uint8_t get_char_glyph_byte(uint16_t glyph_ref, uint8_t index) const
Get one byte of character glyph.
uint8_t last_char() const
Code of last char supported by this Font.
uint8_t glyph_rows() const
Determine the number of rows this font uses for each of its glyphs.
uint16_t get_char_glyph_ref(char value) const
Get a glyph reference for the requested character value.
uint8_t glyph_cols() const
Determine the number of columns this font uses for each of its glyphs.
uint8_t first_char() const
Code of first char supported by this Font.
uint8_t glyph_size() const
Glyph size in bytes.
uint8_t width() const
Width of font glyphs in pixels.
uint8_t height() const
Height of font glyphs in pixels.
Defines generic API for all display devices.