FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::display::Font< VERTICAL_ > Class Template Reference

Generic font support class. More...

#include <fastarduino/devices/font.h>

Public Member Functions

constexpr Font (char first_char, char last_char, uint8_t width, uint8_t height, const uint8_t *glyphs)
 Construct a new Font. More...
 
uint8_t width () const
 Width of font glyphs in pixels. More...
 
uint8_t height () const
 Height of font glyphs in pixels. More...
 
uint8_t first_char () const
 Code of first char supported by this Font. More...
 
uint8_t last_char () const
 Code of last char supported by this Font. More...
 
uint8_t glyph_rows () const
 Determine the number of rows this font uses for each of its glyphs. More...
 
uint8_t glyph_cols () const
 Determine the number of columns this font uses for each of its glyphs. More...
 
uint8_t glyph_size () const
 Glyph size in bytes. More...
 
uint16_t get_char_glyph_ref (char value) const
 Get a glyph reference for the requested character value. More...
 
uint8_t get_char_glyph_byte (uint16_t glyph_ref, uint8_t index) const
 Get one byte of character glyph. More...
 

Static Public Attributes

static constexpr bool VERTICAL = VERTICAL_
 true if font is vertical, false if horizontal More...
 

Detailed Description

template<bool VERTICAL_>
class devices::display::Font< VERTICAL_ >

Generic font support class.

Font glyphs are either stored horizontally (1 byte represents a row) or vertically (1 byte represents a columns). Direction selection is based on display devices internal raster organisation and is thus used for optimization purposes.

Template Parameters
VERTICAL_true if font is vertical, false if horizontal

Definition at line 38 of file font.h.

Constructor & Destructor Documentation

◆ Font()

template<bool VERTICAL_>
constexpr devices::display::Font< VERTICAL_ >::Font ( char  first_char,
char  last_char,
uint8_t  width,
uint8_t  height,
const uint8_t *  glyphs 
)
inlineconstexpr

Construct a new Font.

Parameters
first_charcode of first character mapped to a glyph
last_charcode of last character mapped to a glyph
widthwidth of a glyph in pixels
heightheight of a glyph in pixels
glyphspointer to an array of bytes containing all glyphs from first_char and last_char; this array must be stored in MCU flash memory.

Definition at line 55 of file font.h.

Member Function Documentation

◆ width()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::width ( ) const
inline

Width of font glyphs in pixels.

Definition at line 64 of file font.h.

◆ height()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::height ( ) const
inline

Height of font glyphs in pixels.

Definition at line 70 of file font.h.

◆ first_char()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::first_char ( ) const
inline

Code of first char supported by this Font.

Definition at line 76 of file font.h.

◆ last_char()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::last_char ( ) const
inline

Code of last char supported by this Font.

Definition at line 82 of file font.h.

◆ glyph_rows()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::glyph_rows ( ) const
inline

Determine the number of rows this font uses for each of its glyphs.

Result depends on:

  • vertical or horizontal font
  • font height

For a vertical font, one row is already composed of 8 pixels, hence the result will be 1 for fonts which height is 8 or less. For a horizontal font, the result will be exactly the font height.

Returns
uint8_t the number of rows used by glyph of this Font

Definition at line 99 of file font.h.

◆ glyph_cols()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::glyph_cols ( ) const
inline

Determine the number of columns this font uses for each of its glyphs.

Result depends on:

  • vertical or horizontal font
  • font width

For a vertical font, one column is one pixel, hence the result will be exactly the font width. For a horizontal font, one column is 8 pixels (one byte), hence the result will be 1 for fonts which width is 8 or less.

Returns
uint8_t the number of columns used by glyph of this Font

Definition at line 117 of file font.h.

◆ glyph_size()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::glyph_size ( ) const
inline

Glyph size in bytes.

Definition at line 123 of file font.h.

◆ get_char_glyph_ref()

template<bool VERTICAL_>
uint16_t devices::display::Font< VERTICAL_ >::get_char_glyph_ref ( char  value) const
inline

Get a glyph reference for the requested character value.

the char glyph ref object

Parameters
valuecharacter code to retrieve the glyph for
Returns
uint16_t a unique glyph reference that can be used for actual bytes reading with get_char_glyph_byte(); 0 if no glyph exists for value.
See also
get_char_glyph_byte()

Definition at line 139 of file font.h.

◆ get_char_glyph_byte()

template<bool VERTICAL_>
uint8_t devices::display::Font< VERTICAL_ >::get_char_glyph_byte ( uint16_t  glyph_ref,
uint8_t  index 
) const
inline

Get one byte of character glyph.

Parameters
glyph_refunique glyph referenced as returned by get_char_glyph_ref()
indexbyte index to retrieve, from 0 to glyph_size()
Returns
uint8_t the proper byte (pixels row or column, according to VERTICAL) for glyph_ref
See also
get_char_glyph_ref()
glyph_size()
VERTICAL

Definition at line 162 of file font.h.

Member Data Documentation

◆ VERTICAL

template<bool VERTICAL_>
constexpr bool devices::display::Font< VERTICAL_ >::VERTICAL = VERTICAL_
staticconstexpr

true if font is vertical, false if horizontal

Definition at line 42 of file font.h.


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