Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | List of all members
Burger::Font Class Reference

Base class for font manager. More...

Inheritance diagram for Burger::Font:
Inheritance graph
[legend]
Collaboration diagram for Burger::Font:
Collaboration graph
[legend]

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 Font (Display *pDisplay=0)
 Constructor.
 
virtual ~Font ()
 Destructor.
 
virtual void Draw (const char *pInput, uintptr_t uLength)
 Draws a string of UTF8 text onto the screen.
 
virtual uint_t GetPixelWidth (const char *pInput, uintptr_t uLength)
 Determine the number of pixels the string will require to render onto the display.
 
virtual void DrawChar (uint_t uLetter)
 Draw a single UTF32 character.
 
void SetDisplay (Display *pDisplay)
 Set the Display to use.
 
DisplayGetDisplay (void) const
 Get the Display currently in use.
 
void SetX (int iX)
 Set the draw cursor X coordinate.
 
void SetY (int iY)
 Set the draw cursor Y coordinate.
 
void SetXY (int iX, int iY)
 Set the draw cursor X and Y coordinate.
 
int GetX (void) const
 Get the draw cursor X coordinate.
 
int GetY (void) const
 Get the draw cursor Y coordinate.
 
uint_t GetHeight (void) const
 Get the height of the font in pixels.
 
uint_t GetFirstChar (void) const
 Get the lowest valid character in UTF32 format that resides in the font.
 
uint_t GetCount (void) const
 Get the highest valid character in UTF32 format that resides in the font.
 
uint_t GetPixelWidthChar (uint_t uLetter)
 Given a UTF32 character code, return the width in pixels the typeface will render to.
 
uint_t GetPixelWidthNumber (int32_t iInput)
 Determine the number of pixels needed to draw a numeric string.
 
uint_t GetPixelWidthNumber (uint32_t uInput)
 Determine the number of pixels needed to draw a numeric string.
 
uint_t GetPixelWidthString (const char *pInput)
 Determine the number of pixels needed to draw a UTF8 "C" string.
 
void DrawNumber (int32_t iInput)
 Draw a signed numeric string.
 
void DrawNumber (uint32_t uInput)
 Draw an unsigned numeric string.
 
void DrawString (const char *pInput)
 Draw a UTF8 "C" string.
 
void DrawStringCenterX (int iX, int iY, const char *pInput)
 Draw a centered string.
 
void DrawStringAtXY (int iX, int iY, const char *pInput)
 Draw a string at a specific location.
 
uintptr_t CharsForPixelWidth (const char *pInput, uint_t uWidth)
 Return the number of characters in a string that would fit in a pixel width.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Protected Attributes

Displaym_pDisplay
 Rendering context to draw into.
 
int m_iX
 X coord to draw the font.
 
int m_iY
 Y coord to draw the font.
 
uint_t m_uHeight
 Height of the font in pixels.
 
uint_t m_uFirst
 First allowable UTF32 code that can be drawn.
 
uint_t m_uCount
 Number of characters in the font.
 

Private Member Functions

 Font (const Font &)=delete
 
Fontoperator= (const Font &)=delete
 
 Font (Font &&)=delete
 
Fontoperator= (Font &&)=delete
 

Detailed Description

Base class for font manager.


This is the base class for rendering with a font onto a video display.

When a font is created, it needs to be attached to a Renderer context for actual low level pixel manipulation

Constructor & Destructor Documentation

◆ Font() [1/3]

Burger::Font::Font ( const Font & )
privatedelete

◆ Font() [2/3]

Burger::Font::Font ( Font && )
privatedelete

◆ Font() [3/3]

Burger::Font::Font ( Display * pDisplay = 0)

Constructor.


Initializes all shared variables to defaults.

Parameters
pDisplayPointer to a display context to use for low level APIs

◆ ~Font()

Burger::Font::~Font ( )
virtual

Destructor.


Does absolutely nothing

Member Function Documentation

◆ CharsForPixelWidth()

uintptr_t BURGER_API Burger::Font::CharsForPixelWidth ( const char * pInput,
uint_t uWidth )

Return the number of characters in a string that would fit in a pixel width.


To perform word wrap, this function will scan each "word" by using spaces as delimiters and CR, LF and zero as an end of string. It will perform a test after each word until the clip width is hit. Zero can be returned if the string cannot fit due to word wrap or if the string is empty.

Parameters
pInputPointer to a UTF8 encoded "C" string to parse.
uWidthMaximum number of pixels allowed to draw
Returns
Number of bytes of the string that can be drawn without clipping

◆ Draw()

void Burger::Font::Draw ( const char * pInput,
uintptr_t uLength )
virtual

Draws a string of UTF8 text onto the screen.


Render a string of text from the X/Y origin. No attempt is made to perform word wrap. The string will be clipped to the Renderer class's clip boundaries

Parameters
pInputPointer to a UTF8 string. If NULL or an empty string, perform nothing
uLengthLength of the string in bytes
See also
GetPixelWidth(const char *,uintptr_t)

◆ DrawChar()

void Burger::Font::DrawChar ( uint_t uLetter)
virtual

Draw a single UTF32 character.


Given a valid UTF32 code, draw the single character

Parameters
uLetterUTF32 character code to draw
See also
Draw(const char *,uintptr_t)

Reimplemented in Burger::Font4Bit.

◆ DrawNumber() [1/2]

void BURGER_API Burger::Font::DrawNumber ( int32_t iInput)

Draw a signed numeric string.


Convert the input value into a string and draw it at the current x and y coordinates

Parameters
iInputSigned input value to convert into a numeric string
See also
Draw(const char *,uintptr_t)

◆ DrawNumber() [2/2]

void BURGER_API Burger::Font::DrawNumber ( uint32_t uInput)

Draw an unsigned numeric string.


Convert the input value into a string and draw it at the current x and y coordinates

Parameters
uInputUnsigned input value to convert into a numeric string
See also
Draw(const char *,uintptr_t)

◆ DrawString()

void BURGER_API Burger::Font::DrawString ( const char * pInput)

Draw a UTF8 "C" string.


Take a valid UTF8 coded "C" string and draw it at the current x and y coordinates

Parameters
pInputPointer to a valid UTF8 encoded "C" string. NULL performs no action.
See also
Draw(const char *,uintptr_t)

◆ DrawStringAtXY()

void BURGER_API Burger::Font::DrawStringAtXY ( int iX,
int iY,
const char * pInput )

Draw a string at a specific location.


Draw a UTF8 "C" string at a specific X/Y coordinate.

Parameters
iXX coordinate to draw at
iYY coordinate to draw at
pInputPointer to a valid UTF8 encoded "C" string
See also
Draw(const char *,uintptr_t)

◆ DrawStringCenterX()

void BURGER_API Burger::Font::DrawStringCenterX ( int iX,
int iY,
const char * pInput )

Draw a centered string.


Given a UTF8 encoded "C" string and an X/Y coordinate, determine the width in pixels the string will occupy and render the string with it centered on the x coordinate.

Parameters
iXX coordinate to center the string on
iYY coordinate to draw the string at
pInputPointer to a valid "C" string. NULL performs no action.
See also
Draw(const char *,uintptr_t)

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::Font::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

Reimplemented in Burger::Font4Bit.

◆ GetCount()

Burger::Font::GetCount ( void ) const
inline

Get the highest valid character in UTF32 format that resides in the font.


Returns the highest character code in the font. If both the first and last character are zero, then no characters are valid

Returns
Last valid UTF32 character code in the font typeface
See also
GetFirstChar(void) const and GetHeight(void) const

◆ GetDisplay()

Burger::Font::GetDisplay ( void ) const
inline

Get the Display currently in use.


Returns
Pointer to a Display, can be NULL if no Display has been set
See also
SetDisplay(Display *)

◆ GetFirstChar()

Burger::Font::GetFirstChar ( void ) const
inline

Get the lowest valid character in UTF32 format that resides in the font.


Returns the lowest character code in the font. If both the first and last character are zero, then no characters are valid

Returns
First valid UTF32 character code in the font typeface
See also
GetHeight(void) const and GetCount(void) const

◆ GetHeight()

Burger::Font::GetHeight ( void ) const
inline

Get the height of the font in pixels.


Returns the height in pixels of the currently installed font typeface.

Returns
Height in pixels of the font typeface.
See also
GetFirstChar(void) const and GetCount(void) const

◆ GetPixelWidth()

uint_t Burger::Font::GetPixelWidth ( const char * pInput,
uintptr_t uLength )
virtual

Determine the number of pixels the string will require to render onto the display.


Given a string of UTF8 text, determine the number of pixels will be needed to render the string. Return the value. Clipping is not considered in the calculation. Any invalid UTF8 characters or characters that are not present in the font are skipped.

Parameters
pInputPointer to a UTF8 string. If NULL or an empty string, return zero
uLengthLength of the string in bytes
See also
Draw(const char *,uintptr_t)

Reimplemented in Burger::Font4Bit.

◆ GetPixelWidthChar()

uint_t BURGER_API Burger::Font::GetPixelWidthChar ( uint_t uLetter)

Given a UTF32 character code, return the width in pixels the typeface will render to.


Invalid UTF32 character codes will return a width of zero

Parameters
uLetterUTF32 character code
Returns
Number of pixels wide this character strike
See also
GetPixelWidth(const char *,uintptr_t)

◆ GetPixelWidthNumber() [1/2]

uint_t BURGER_API Burger::Font::GetPixelWidthNumber ( int32_t iInput)

Determine the number of pixels needed to draw a numeric string.


Convert the input value into a string and determine the number of pixels needed to render the string

Parameters
iInputSigned input value to convert into a numeric string
See also
GetPixelWidth(const char *,uintptr_t)

◆ GetPixelWidthNumber() [2/2]

uint_t BURGER_API Burger::Font::GetPixelWidthNumber ( uint32_t uInput)

Determine the number of pixels needed to draw a numeric string.


Convert the input value into a string and determine the number of pixels needed to render the string

Parameters
uInputUnsigned input value to convert into a numeric string
See also
GetPixelWidth(const char *,uintptr_t)

◆ GetPixelWidthString()

uint_t BURGER_API Burger::Font::GetPixelWidthString ( const char * pInput)

Determine the number of pixels needed to draw a UTF8 "C" string.


Parameters
pInputPointer to a UTF8 "C" string or NULL to get zero
Returns
The string's width in pixels
See also
GetPixelWidth(const char *,uintptr_t)

◆ GetX()

Burger::Font::GetX ( void ) const
inline

Get the draw cursor X coordinate.


Returns the x coordinate where the next draw call will operate at

Returns
Current X coordinate to draw at
See also
GetY(void) const, SetX(int)

◆ GetY()

Burger::Font::GetY ( void ) const
inline

Get the draw cursor Y coordinate.


Returns the y coordinate where the next draw call will operate at

Returns
Current Y coordinate to draw at
See also
GetX(void) const, SetY(int)

◆ operator=() [1/2]

Font & Burger::Font::operator= ( const Font & )
privatedelete

◆ operator=() [2/2]

Font & Burger::Font::operator= ( Font && )
privatedelete

◆ SetDisplay()

Burger::Font::SetDisplay ( Display * pDisplay)
inline

Set the Display to use.


Parameters
pDisplayPointer to a Display
See also
GetDisplay(void) const

◆ SetX()

Burger::Font::SetX ( int iX)
inline

Set the draw cursor X coordinate.


Sets the x coordinate where the next draw call will operate at

Parameters
iXNew X coordinate to draw at
See also
GetX(void) const, SetY(int) or SetXY(int,int)

◆ SetXY()

Burger::Font::SetXY ( int iX,
int iY )
inline

Set the draw cursor X and Y coordinate.


Sets the x and y coordinates where the next draw call will operate at

Parameters
iXNew X coordinate to draw at
iYNew Y coordinate to draw at
See also
SetX(int) or SetY(int)

◆ SetY()

Burger::Font::SetY ( int iY)
inline

Set the draw cursor Y coordinate.


Sets the y coordinate where the next draw call will operate at

Parameters
iYNew Y coordinate to draw at
See also
GetY(void) const, SetX(int) or SetXY(int,int)

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::Font::g_StaticRTTI
static

◆ m_iX

int Burger::Font::m_iX
protected

X coord to draw the font.

◆ m_iY

int Burger::Font::m_iY
protected

Y coord to draw the font.

◆ m_pDisplay

Display* Burger::Font::m_pDisplay
protected

Rendering context to draw into.

◆ m_uCount

uint_t Burger::Font::m_uCount
protected

Number of characters in the font.

◆ m_uFirst

uint_t Burger::Font::m_uFirst
protected

First allowable UTF32 code that can be drawn.

◆ m_uHeight

uint_t Burger::Font::m_uHeight
protected

Height of the font in pixels.