Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
GrFont Class Referenceabstract

Base class used by all Graphical Fonts. More...

#include <GrFont.h>

Inheritance diagram for GrFont:
Monofonto_Regular_140 Monofonto_Regular_180 Monofonto_Regular_20 Monofonto_Regular_32 Monofonto_Regular_64 Monofonto_Regular_90

Public Member Functions

 GrFont (ROM_Image imgLoc, uint16_t lineHeight, uint16_t base)
 Constructs a new GrFont object.
 
void begin (uint16_t color16Bit)
 Initializes the font and sets the font's foreground color.
 
void begin (uint8_t red, uint8_t green, uint8_t blue)
 Initializes the font and sets the font's foreground color.
 
virtual bool charDef (char cc, CharDef_t &results) const =0
 Abstract function. Used by derived classes to define the characteristics of each character.
 
int8_t kerning (uint8_t first, uint8_t second) const
 Returns the amount of kerning that should be used between two characters.
 
uint8_t placeText (Canvas &canvas, char cc, uint16_t x, uint16_t y) const
 Places a character onto the canvas.
 
uint8_t placeText (Canvas &canvas, const char *const text, uint16_t buffSize, uint16_t x, uint16_t y) const
 Places a string onto the canvas.
 
uint16_t textWidth (const char cc) const
 Determines the width of character, cc, in screen pixels.
 
uint16_t textWidth (const char *const text, uint16_t buffSize) const
 Determines the width of string in screen pixels.
 

Public Attributes

const ROM_Image imgLoc
 Location of the font in Flash ROM.
 
const uint16_t LINE_HEIGHT
 Recommended vertical spacing between lines of text.
 
const uint16_t BASE
 Distance between the top of the pixel and its base.
 

Protected Member Functions

virtual int8_t kerning (uint16_t ID) const =0
 Finds the amount of kerning that should be used between two characters.
 

Detailed Description

Base class used by all Graphical Fonts.

Constructor & Destructor Documentation

◆ GrFont()

GrFont::GrFont ( ROM_Image imgLoc,
uint16_t lineHeight,
uint16_t base )
inline

Constructs a new GrFont object.

Parameters
[in]imgLocLocation of the font imagery in ROM
[in]lineHeightRecommended vertical spacing between lines of text
[in]baseDistance between the top of the pixel and its base

Member Function Documentation

◆ begin() [1/2]

void GrFont::begin ( uint16_t color16Bit)

Initializes the font and sets the font's foreground color.

Parameters
[in]color16Bit16-bit color (5:6:5 encoding)

◆ begin() [2/2]

void GrFont::begin ( uint8_t red,
uint8_t green,
uint8_t blue )

Initializes the font and sets the font's foreground color.

Parameters
[in]red
[in]green
[in]blue

◆ charDef()

virtual bool GrFont::charDef ( char cc,
CharDef_t & results ) const
pure virtual

Abstract function. Used by derived classes to define the characteristics of each character.

Parameters
[in]ccCharacter to look up
[out]resultsCharDef_t structure containing information on character, cc
Returns
Returns true if cc was found. Returns false if not

Implemented in Monofonto_Regular_140, Monofonto_Regular_180, Monofonto_Regular_20, Monofonto_Regular_32, Monofonto_Regular_64, and Monofonto_Regular_90.

◆ kerning() [1/2]

virtual int8_t GrFont::kerning ( uint16_t ID) const
protectedpure virtual

Finds the amount of kerning that should be used between two characters.

Parameters
[in]ID16-bit encoded value representing the 2 characters (CHAR1:CHAR2)
Returns
Returns the amount of kerning in screen pixels

Implemented in Monofonto_Regular_140, Monofonto_Regular_180, Monofonto_Regular_20, Monofonto_Regular_32, Monofonto_Regular_64, and Monofonto_Regular_90.

◆ kerning() [2/2]

int8_t GrFont::kerning ( uint8_t first,
uint8_t second ) const
inline

Returns the amount of kerning that should be used between two characters.

Parameters
[in]firstFirst character
[in]secondSecond character
Returns
Amount of kerning in screen pixels

◆ placeText() [1/2]

uint8_t GrFont::placeText ( Canvas & canvas,
char cc,
uint16_t x,
uint16_t y ) const

Places a character onto the canvas.

Parameters
[in]canvasCanvas where the character is placed
[in]ccThe character to be placed
[in]xx-position within canvas where the character is to be placed
[in]yy-position within canvas where the character is to be placed
Returns
Returns the width of the character in screen pixels

The base of the characters will be aligned with the vertical position, y.

◆ placeText() [2/2]

uint8_t GrFont::placeText ( Canvas & canvas,
const char *const text,
uint16_t buffSize,
uint16_t x,
uint16_t y ) const

Places a string onto the canvas.

Parameters
[in]canvasCanvas where the character is placed
[in]textCharacter buffer containing the null-terminated string to be placed
[in]buffSizeThe size of the character buffer, text
[in]xx-position within canvas where the character is to be placed
[in]yy-position within canvas where the character is to be placed
Returns
Returns the width of the character in screen pixels

This method applies character kerning to the displayed characters. The base of the characters will be aligned with the vertical position, y.

◆ textWidth() [1/2]

uint16_t GrFont::textWidth ( const char *const text,
uint16_t buffSize ) const

Determines the width of string in screen pixels.

Parameters
[in]textCharacter buffer containing the null-terminated string to be examined
[in]buffSizeThe size of the character buffer, text
Returns
Width of the string in screen pixels

This method applies accounts for character kerning when calculating the total width of the string.

◆ textWidth() [2/2]

uint16_t GrFont::textWidth ( const char cc) const

Determines the width of character, cc, in screen pixels.

Parameters
[in]ccThe character
Returns
Width of the character in screen pixels

Member Data Documentation

◆ BASE

const uint16_t GrFont::BASE

Distance between the top of the pixel and its base.

◆ imgLoc

const ROM_Image GrFont::imgLoc

Location of the font in Flash ROM.

◆ LINE_HEIGHT

const uint16_t GrFont::LINE_HEIGHT

Recommended vertical spacing between lines of text.


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