TouchGFX  v4.10.0
Font Class Referenceabstract

The font base class. More...

#include <touchgfx/Font.hpp>

Public Member Functions

virtual const GlyphNodegetGlyph (Unicode::UnicodeChar unicode, const uint8_t *&pixelData, uint8_t &bitsPerPixel) const =0
 Gets the glyph data associated with the specified unicode. More...
 
virtual const GlyphNodegetGlyph (Unicode::UnicodeChar unicode) const
 Gets the glyph data associated with the specified unicode. More...
 
virtual Unicode::UnicodeChar getFallbackChar () const
 Gets fallback character. More...
 
virtual Unicode::UnicodeChar getEllipsisChar () const
 Gets ellipsis character. More...
 
virtual uint16_t getStringWidth (const Unicode::UnicodeChar *text,...) const
 Gets the width in pixels of the specified string. More...
 
virtual uint16_t getStringWidth (TextDirection textDirection, const Unicode::UnicodeChar *text,...) const
 Gets the width in pixels of the specified string. More...
 
virtual uint16_t getCharWidth (const Unicode::UnicodeChar c) const
 Gets the width in pixels of the specified character. More...
 
virtual uint8_t getSpacingAbove (const Unicode::UnicodeChar *text,...) const
 Gets the number of blank pixels at the top of the given text. More...
 
virtual uint16_t getMaxTextHeight (const Unicode::UnicodeChar *text,...) const
 Gets the height of the highest character in a given string. More...
 
virtual uint16_t getFontHeight () const
 Returns the height in pixels of this font. More...
 
virtual uint16_t getMinimumTextHeight () const
 Returns the minimum height needed for a text field that uses this font. More...
 
virtual uint8_t getBitsPerPixel () const
 Gets bits per pixel for this font. More...
 
uint8_t getMaxPixelsLeft () const
 Gets maximum pixels left. More...
 
uint8_t getMaxPixelsRight () const
 Gets maximum pixels right. More...
 
virtual int8_t getKerning (Unicode::UnicodeChar prevChar, const GlyphNode *glyph) const
 Gets the kerning distance between two characters. More...
 
virtual uint16_t getNumberOfLines (const Unicode::UnicodeChar *text,...) const
 Gets number of lines. More...
 

Protected Types

typedef uint16_t(Font::* StringWidthFunctionPointer) (TextDirection textDirection, const Unicode::UnicodeChar *text, va_list pArg) const
 Defines an alias representing the constant.
 

Protected Member Functions

uint16_t getStringWidthLTR (TextDirection textDirection, const Unicode::UnicodeChar *text, va_list pArg) const
 Gets the width in pixels of the specified string. More...
 
uint16_t getStringWidthRTL (TextDirection textDirection, const Unicode::UnicodeChar *text, va_list pArg) const
 Gets the width in pixels of the specified string. More...
 
 Font (uint16_t height, uint8_t pixBelowBase, uint8_t bitsPerPixel, uint8_t maxLeft, uint8_t maxRight, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar)
 Constructor. More...
 

Protected Attributes

uint16_t fontHeight
 The font height in pixels.
 
uint8_t pixelsBelowBaseline
 The number of pixels below the base line.
 
uint8_t bPerPixel
 The number of bits per pixel.
 
uint8_t maxPixelsLeft
 The maximum number of pixels a glyph extends to the left.
 
uint8_t maxPixelsRight
 The maximum number of pixels a glyph extends to the right.
 
Unicode::UnicodeChar falllbackCharacter
 The fallback character to use when no glyph exists for the wanted character.
 
Unicode::UnicodeChar ellipsisCharacter
 The ellipsis character used for truncating long texts.
 

Static Protected Attributes

static StringWidthFunctionPointer getStringWidthFunction
 The getStringWidth function, either LTR (supporting LTR only) or RTL (supporting RTL and LTR)
 

Detailed Description

The font base class. This class is abstract and requires the implementation of getGlyph.

It provides utility functions such as obtaining string width and font height.