Skip to content

Fonts as header files

By default, on the Evaluation and Commercial editions, fonts are provided as header files and added to the application at build-time.


On the hV_Configuration.h file,

#define USE_FONT_TERMINAL 1 ///< Use default Terminal fonts
#define USE_FONT_HEADER 2 ///< Use fonts from header files
#define FONT_MODE USE_FONT_HEADER ///< Selected option

FONT_MODE should be set to USE_FONT_HEADER.


uint8_t fontSans;
fontSans = myScreen.addFont(Font_DejaVuSans20);
fontSans -= (fontSans > 0) ? 1 : 0;

addFont() adds a font and returns the number of fonts, corresponding to fontMax().

The index of the font just added is fontMax() - 1. In case of an error, addFont() returns 0.

Because the fonts number starts at 0, the index of the font should be corrected by subtracting one.


selectFont() selects the font based on its index, from range 0 ..fontMax() - 1.


Please refer to the example for Text.