Class to render a tiny space 4 bit per pixel font. More...
Classes | |
struct | RGBColorList_t |
struct | State_t |
Public Member Functions | |
const Burger::StaticRTTI * | get_StaticRTTI (void) const noexcept override |
Get the description to the class. | |
Font4Bit (Renderer *pRenderer=0) | |
Constructor. | |
virtual | ~Font4Bit () |
Destructor. | |
uint_t | GetPixelWidth (const char *pInput, uintptr_t uLength) override |
Determine the number of pixels the string will require to render onto the display. | |
void | DrawChar (uint_t uLetter) override |
Draw a single UTF32 character. | |
void | Init (RezFile *pRezFile, uint_t uRezNum, const uint8_t *pPalette, Renderer *pRenderer=0) |
Initialize a font structure. | |
void | Shutdown (void) |
Release a font back to the resource manager. | |
void | SaveState (State_t *pOutput) |
Save the current state of the font manager. | |
void | RestoreState (const State_t *pInput) |
Restore the previous state of the font manager. | |
void | SetColor (uint_t uColorIndex, uint_t uColor) |
Set a color for a font. | |
void | UseZero (void) |
Make color index #0 visible. | |
void | UseMask (void) |
Make color index #0 transparent. | |
void | InstallToPalette (RezFile *pRezFile, uint_t uRezNum, const uint8_t *pPalette) |
Install a font. | |
void | SetColorRGBListToPalette (const RGBColorList_t *pRGBList, const uint8_t *pPalette) |
Set the colors to a font. | |
void | SetToPalette (const uint8_t *pPalette) |
Set the font to use a different palette. | |
Public Member Functions inherited from Burger::Font | |
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. | |
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. | |
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::Font | |
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 | ||
union { | ||
uint8_t Bytes [16] | ||
Color of font for 8 bit rendering. More... | ||
uint16_t Shorts [16] | ||
Color of font for 16 bit rendering. More... | ||
uint32_t Words [16] | ||
Color of font for 32 bit rendering. More... | ||
} | m_ColorTable | |
Storage for the color tables for rendering. | ||
Renderer * | m_pRenderer | |
Software renderer context. | ||
RezFile * | m_pRezFile | |
Resource file manager. | ||
void ** | m_ppData | |
Handle to the active font. | ||
uintptr_t | m_uPixelOffset | |
Offset to the pixel array. | ||
uint_t | m_uRezNum | |
Resource ID of the last font loaded. | ||
uint_t | m_uInvisibleColor | |
Color to ignore for drawing. | ||
Protected Attributes inherited from Burger::Font | ||
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 | |
Font4Bit (const Font4Bit &)=delete | |
Font4Bit & | operator= (const Font4Bit &)=delete |
Font4Bit (Font4Bit &&)=delete | |
Font4Bit & | operator= (Font4Bit &&)=delete |
Class to render a tiny space 4 bit per pixel font.
For systems with tight memory requirements, this font renderer store the font strike at 4 bits per pixel to allow color rendering while occupying only a fraction of the space a full texture based font would take.
Use the font creation tool in MakeRez to create font data for this class
This font type is optimized for software rendering
|
privatedelete |
|
privatedelete |
Burger::Font4Bit::Font4Bit | ( | Renderer * | pRenderer = 0 | ) |
Constructor.
Initializes all shared variables to defaults.
pRenderer | Pointer to a rendering context to use for low level APIs |
|
virtual |
|
overridevirtual |
Draw a single UTF32 character.
Given a valid UTF32 code, draw the single character
uLetter | UTF32 character code to draw |
Reimplemented from Burger::Font.
|
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::Font.
|
overridevirtual |
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 from Burger::Font.
void BURGER_API Burger::Font4Bit::Init | ( | RezFile * | pRezFile, |
uint_t | uRezNum, | ||
const uint8_t * | pPalette, | ||
Renderer * | pRenderer = 0 ) |
Initialize a font structure.
Load a font from a resource file and prepare it for drawing. This will set the font to consider color #0 to be invisible
pRezFile | Pointer to the resource file that the font resides in |
uRezNum | Resource number of the font file |
pPalette | Palette to use for drawing |
pRenderer | Rendering context to use for drawing |
void BURGER_API Burger::Font4Bit::InstallToPalette | ( | Burger::RezFile * | pRezFile, |
uint_t | uRezNum, | ||
const uint8_t * | pPalette ) |
void BURGER_API Burger::Font4Bit::RestoreState | ( | const State_t * | pInput | ) |
Restore the previous state of the font manager.
pInput | Pointer to a initialized structure that contains a previous state. |
void BURGER_API Burger::Font4Bit::SaveState | ( | State_t * | pOutput | ) |
Save the current state of the font manager.
Capture the current state of font manager so it can be restored later Values include the location of the draw cursor and the color rendering modes
pOutput | Pointer to a uninitialized structure to contain the state. |
void BURGER_API Burger::Font4Bit::SetColor | ( | uint_t | uColorIndex, |
uint_t | uColor ) |
Set a color for a font.
uColorIndex | Index into the color table, maximum value is 15 |
uColor | Color in the current color mode to draw with |
void BURGER_API Burger::Font4Bit::SetColorRGBListToPalette | ( | const RGBColorList_t * | pRGBList, |
const uint8_t * | pPalette ) |
Set the colors to a font.
Using a RGB color list, set all the colors to a mounted font.
void BURGER_API Burger::Font4Bit::SetToPalette | ( | const uint8_t * | pPalette | ) |
Set the font to use a different palette.
When a palette is changed, call this function to alert the font manager of the new color scheme. Needed when rendering to 15 bit or higher bit depths since palette changes are manually performed
pPalette | Pointer to a 256 color RGB palette |
void BURGER_API Burger::Font4Bit::Shutdown | ( | void | ) |
Release a font back to the resource manager.
Release all resource allocated by the font
|
inline |
Make color index #0 transparent.
|
inline |
Make color index #0 visible.
uint8_t Burger::Font4Bit::Bytes[16] |
Color of font for 8 bit rendering.
|
static |
union { ... } Burger::Font4Bit::m_ColorTable |
Storage for the color tables for rendering.
|
protected |
Handle to the active font.
|
protected |
Software renderer context.
|
protected |
Resource file manager.
|
protected |
Color to ignore for drawing.
|
protected |
Offset to the pixel array.
|
protected |
Resource ID of the last font loaded.
uint16_t Burger::Font4Bit::Shorts[16] |
Color of font for 16 bit rendering.
uint32_t Burger::Font4Bit::Words[16] |
Color of font for 32 bit rendering.