Skip to main content

ConstFont

touchgfx/ConstFont.hpp

A ConstFont is a Font implementation that has its contents defined at compile-time and usually placed in read-only memory.

See: Font

Note: Pure virtual class. Create an application-specific implementation of getPixelData().

Inherits from: Font

Inherited by: InternalFlashFont

Public Functions

ConstFont(const GlyphNode * glyphs, uint16_t numGlyphs, uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar)
Initializes a new instance of the ConstFont class.
const GlyphNode *find(Unicode::UnicodeChar unicode) const
Finds the glyph data associated with the specified unicode.
const GlyphNode *getGlyph(Unicode::UnicodeChar unicode)
Gets the glyph data associated with the specified Unicode.
virtual const GlyphNode *getGlyph(Unicode::UnicodeChar unicode, const uint8_t *& pixelData, uint8_t & bitsPerPixel) const
Gets the glyph data associated with the specified Unicode.
const GlyphNode *getGlyph(Unicode::UnicodeChar unicode, const uint8_t *& pixelData, uint8_t & bitsPerPixel)
Gets the glyph data associated with the specified Unicode.
virtual int8_tgetKerning(Unicode::UnicodeChar prevChar, const GlyphNode * glyph) const =0
Gets the kerning distance between two characters.
virtual const uint8_t *getPixelData(const GlyphNode * glyph) const =0
Gets the pixel date associated with this glyph.

Protected Attributes

const GlyphNode *glyphList
The list of glyphs.
uint16_tlistSize
The size of the list of glyphs.

Additional inherited members

Public Functions inherited from Font

virtual FORCE_INLINE_FUNCTION uint16_tgetBaseline() const
Returns the position of the baseline of this font in pixels from the top of the line.
virtual FORCE_INLINE_FUNCTION uint8_tgetBitsPerPixel() const
Gets bits per pixel for this font.
virtual FORCE_INLINE_FUNCTION uint8_tgetByteAlignRow() const
Are the glyphs saved with each glyph row byte aligned?
virtual uint16_tgetCharWidth(const Unicode::UnicodeChar c) const
Gets the width in pixels of the specified character.
virtual const FontContextualFormsTable *getContextualFormsTable() const
Gets the contextual forms table used in arabic fonts.
virtual Unicode::UnicodeChargetEllipsisChar() const
Gets ellipsis character for the given font.
virtual Unicode::UnicodeChargetFallbackChar() const
Gets fallback character for the given font.
virtual const uint16_t *getGSUBTable() const
Gets GSUB table.
virtual FORCE_INLINE_FUNCTION uint16_tgetHeight() const
Returns the height of a font.
FORCE_INLINE_FUNCTION uint8_tgetMaxPixelsLeft() const
Gets maximum pixels left of any glyph in the font.
FORCE_INLINE_FUNCTION uint8_tgetMaxPixelsRight() const
Gets maximum pixels right of any glyph in the font.
virtual uint16_tgetNumberOfLines(const Unicode::UnicodeChar * text, ... ) const
Count the number of lines in a given text.
FORCE_INLINE_FUNCTION uint16_tgetPixelsAboveTop() const
Gets pixels above top of the normal text height.
FORCE_INLINE_FUNCTION uint16_tgetPixelsBelowBottom() const
Gets number of pixel rows below the bottom of the font.
virtual floatgetScaleFactor() const
Returns the scale factor.
virtual int16_tgetSpacingAbove(const Unicode::UnicodeChar * text, ... ) const
Gets the number of blank pixels at the top of the given text.
virtual uint16_tgetStringWidth(const Unicode::UnicodeChar * text, ... ) const
Gets the width in pixels of the specified string.
virtual uint16_tgetStringWidth(TextDirection textDirection, const Unicode::UnicodeChar * text, ... ) const
Gets the width in pixels of the specified string.
virtual boolisVectorBasedFont() const
Returns true if this Font is vector based.
TOUCHGFX_DEPRECATED("Please use getBaseline() instead." , virtual uint16_t getFontHeight() const )
Returns the height in pixels of this font.
TOUCHGFX_DEPRECATED("Please use getHeight() instead." , virtual uint16_t getMaxTextHeight(const Unicode::UnicodeChar *text,...) const )
Gets the height of the highest character in a given string.
TOUCHGFX_DEPRECATED("Please use getHeight() instead." , virtual uint16_t getMinimumTextHeight() const )
Returns the height of a font.
virtual ~Font()
Finalizes an instance of the Font class.
FORCE_INLINE_FUNCTION boolisInvisibleZeroWidth(Unicode::UnicodeChar character)
Query if 'character' is invisible, zero width.

Protected Functions inherited from Font

Font(uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar)
Initializes a new instance of the Font class.
uint16_tgetStringWidthLTR(TextDirection textDirection, const Unicode::UnicodeChar * text, va_list pArg) const
Gets the width in pixels of the specified string.
uint16_tgetStringWidthRTL(TextDirection textDirection, const Unicode::UnicodeChar * text, va_list pArg) const
Gets the width in pixels of the specified string.

Protected Attributes inherited from Font

uint8_tbAlignRow
The glyphs are saved with each row byte aligned.
uint16_tbaselineHeight
The baseline.
uint8_tbPerPixel
The number of bits per pixel.
Unicode::UnicodeCharellipsisCharacter
The ellipsis character used for truncating long texts.
Unicode::UnicodeCharfallbackCharacter
The fallback character to use when no glyph exists for the wanted character.
uint16_tfontHeight
The font height in pixels.
uint8_tmaxPixelsLeft
The maximum number of pixels a glyph extends to the left.
uint8_tmaxPixelsRight
The maximum number of pixels a glyph extends to the right.
uint8_tpixelsAboveTop
The number of pixels above the top.
uint8_tpixelsBelowBottom
The number of pixels below the bottom.

Public Functions Documentation

ConstFont

ConstFont(const GlyphNode *glyphs ,
uint16_tnumGlyphs ,
uint16_theight ,
uint16_tbaseline ,
uint8_tpixAboveTop ,
uint8_tpixBelowBottom ,
uint8_tbitsPerPixel ,
uint8_tbyteAlignRow ,
uint8_tmaxLeft ,
uint8_tmaxRight ,
const Unicode::UnicodeCharfallbackChar ,
const Unicode::UnicodeCharellipsisChar
)

Initializes a new instance of the ConstFont class.

Parameters:
glyphsThe array of glyphs known to this font.
numGlyphsThe number of glyphs in list.
heightThe height of the font.
baselineThe pixel position of the baseline.
pixAboveTopThe maximum number of pixels above the top of the text.
pixBelowBottomThe maximum number of pixels that can be drawn below the baseline in this font.
bitsPerPixelThe number of bits per pixel in this font.
byteAlignRowThe glyphs are saved with each row byte aligned.
maxLeftThe maximum a character extends to the left.
maxRightThe maximum a character extends to the right.
fallbackCharThe fallback character for the typography in case no glyph is available.
ellipsisCharThe ellipsis character used for truncating long texts.

find

const GlyphNode * find(Unicode::UnicodeCharunicode)

Finds the glyph data associated with the specified unicode.

Parameters:
unicodeThe character to look up.
Returns:

A pointer to the glyph node or null if the glyph was not found.

getGlyph

const GlyphNode * getGlyph(Unicode::UnicodeCharunicode)

Gets the glyph data associated with the specified Unicode.

Please note that in case of Thai letters and Arabic letters where diacritics can be placed relative to the previous character(s), please use TextProvider::getNextLigature() instead as it will create a temporary GlyphNode that will be adjusted with respect to X/Y position.

Parameters:
unicodeThe character to look up.
Returns:

A pointer to the glyph node or null if the glyph was not found.

See also:

getGlyph

virtual const GlyphNode * getGlyph(Unicode::UnicodeCharunicode ,const
const uint8_t *&pixelData ,const
uint8_t &bitsPerPixelconst
)const

Gets the glyph data associated with the specified Unicode.

Please note that in case of Thai letters and Arabic letters where diacritics can be placed relative to the previous character(s), please use TextProvider::getNextLigature() instead as it will create a temporary GlyphNode that will be adjusted with respect to X/Y position.

Parameters:
unicodeThe character to look up.
pixelDataPointer to the pixel data for the glyph if the glyph is found. This is set by this method.
bitsPerPixelReference where to place the number of bits per pixel.
Returns:

A pointer to the glyph node or null if the glyph was not found.

Reimplements: touchgfx::Font::getGlyph

getGlyph

const GlyphNode * getGlyph(Unicode::UnicodeCharunicode ,
const uint8_t *&pixelData ,
uint8_t &bitsPerPixel
)

Gets the glyph data associated with the specified Unicode.

Please note that in case of Thai letters and Arabic letters where diacritics can be placed relative to the previous character(s), please use TextProvider::getNextLigature() instead as it will create a temporary GlyphNode that will be adjusted with respect to X/Y position.

Parameters:
unicodeThe character to look up.
pixelDataPointer to the pixel data for the glyph if the glyph is found. This is set by this method.
bitsPerPixelReference where to place the number of bits per pixel.
Returns:

A pointer to the glyph node or null if the glyph was not found.

getKerning

virtual int8_t getKerning(Unicode::UnicodeCharprevChar ,const =0
const GlyphNode *glyphconst =0
)const =0

Gets the kerning distance between two characters.

Parameters:
prevCharThe Unicode value of the previous character.
glyphthe glyph object for the current character.
Returns:

The kerning distance between prevChar and glyph char.

Reimplements: touchgfx::Font::getKerning

Reimplemented by: touchgfx::InternalFlashFont::getKerning

getPixelData

virtual const uint8_t * getPixelData(const GlyphNode *glyph)

Gets the pixel date associated with this glyph.

Parameters:
glyphThe glyph to get the pixels data from.
Returns:

Pointer to the pixel data of this glyph.

Reimplemented by: touchgfx::InternalFlashFont::getPixelData

Protected Attributes Documentation

glyphList

const GlyphNode * glyphList

The list of glyphs.

listSize

uint16_t listSize

The size of the list of glyphs.