In the theme plugin properties you can often select the font to use. However, there are a few points to bear in mind when using fonts. Here are the key points:
Fonts
directory, either in the package itself, or from your local project. They will be included once only in the C++ menu file and the variable for the font will be exported.We’ll now discuss each option in turn, and what it means in terms of generated code.
Nearly all display plugins support the default option. This means use whatever font is the default for the library, or if there is not a default, we pick a sensible one that would fit most displays. Only the font size field is relevant and is used as the magnification if supported.
For Adafruit_GFX and LTDC/BSP libraries Adafruit fonts are used.
For this option you provide a font that will be found in the global Adafruit_GFX Fonts
directory, you also provide the magnification factor for this. During code generation we will turn this into a C++ file global include, export the font name for use elsewhere, and set the font definition up.
For Adafruit_GFX and LTDC/BSP libraries Adafruit fonts are used.
For this option you provide a font that will be found within your project in a Fonts
directory, you also provide the magnification factor for this. During code generation we will turn this into a C++ file project local include, export the font name for use elsewhere, and set the font definition up.
In U8G2 the fonts are all included in the library directly, all that is needed is to refer to the variable. This option is suitable when the font is already available and can be referenced by name. It will create a font definition only. For this option provide the name only.
Some displays such as TFT_eSPI keep available fonts in an array, and you refer to them by number. For this option provide the number only. The definition will be created for that font number.
Within the core graphics functions, fonts are pased around as a MenuFontDef
, this structure has the fontData
which is a pointer to the font, and also the fontMag
parameter, which is either the size or font number, depending on the device in use.
To construct a font definition manually:
MenuFontDefinition def(fontDataPtr, fontMagOrSize);
It is a struct, so has trivially simple copy characteristics.