Base class for font manager. More...
Public Member Functions | |
const Burger::StaticRTTI * | get_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. | |
Display * | GetDisplay (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. | |
![]() | |
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 const Burger::StaticRTTI | g_StaticRTTI |
The global description of the class. | |
Protected Attributes | |
Display * | m_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 | |
Font & | operator= (const Font &)=delete |
Font (Font &&)=delete | |
Font & | operator= (Font &&)=delete |
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
|
privatedelete |
|
privatedelete |
Burger::Font::Font | ( | Display * | pDisplay = 0 | ) |
Constructor.
Initializes all shared variables to defaults.
pDisplay | Pointer to a display context to use for low level APIs |
|
virtual |
Destructor.
Does absolutely nothing
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.
pInput | Pointer to a UTF8 encoded "C" string to parse. |
uWidth | Maximum number of pixels allowed to draw |
|
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
|
virtual |
Draw a single UTF32 character.
Given a valid UTF32 code, draw the single character
uLetter | UTF32 character code to draw |
Reimplemented in Burger::Font4Bit.
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
iInput | Signed input value to convert into a numeric string |
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
uInput | Unsigned input value to convert into a numeric string |
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
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.
iX | X coordinate to draw at |
iY | Y coordinate to draw at |
pInput | Pointer to a valid UTF8 encoded "C" string |
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.
iX | X coordinate to center the string on |
iY | Y coordinate to draw the string at |
pInput | Pointer to a valid "C" string. NULL performs no action. |
|
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.
Reimplemented from Burger::Base.
Reimplemented in Burger::Font4Bit.
|
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
|
inline |
|
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
|
inline |
Get the height of the font in pixels.
Returns the height in pixels of the currently installed font typeface.
|
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.
pInput | Pointer to a UTF8 string. If NULL or an empty string, return zero |
uLength | Length of the string in bytes |
Reimplemented in Burger::Font4Bit.
uint_t BURGER_API Burger::Font::GetPixelWidthChar | ( | uint_t | uLetter | ) |
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
iInput | Signed input value to convert into a numeric string |
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
uInput | Unsigned input value to convert into a numeric string |
uint_t BURGER_API Burger::Font::GetPixelWidthString | ( | const char * | pInput | ) |
Determine the number of pixels needed to draw a UTF8 "C" string.
|
inline |
Get the draw cursor X coordinate.
Returns the x coordinate where the next draw call will operate at
|
inline |
Get the draw cursor Y coordinate.
Returns the y coordinate where the next draw call will operate at
|
inline |
|
inline |
Set the draw cursor X coordinate.
Sets the x coordinate where the next draw call will operate at
iX | New X coordinate to draw at |
|
inline |
|
inline |
Set the draw cursor Y coordinate.
Sets the y coordinate where the next draw call will operate at
iY | New Y coordinate to draw at |
|
static |
|
protected |
X coord to draw the font.
|
protected |
Y coord to draw the font.
|
protected |
Rendering context to draw into.
|
protected |
Number of characters in the font.
|
protected |
Height of the font in pixels.