Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Font4Bit Class Reference

Class to render a tiny space 4 bit per pixel font. More...

Inheritance diagram for Burger::Font4Bit:
Collaboration diagram for Burger::Font4Bit:

Classes

struct  RGBColorList_t
 
struct  State_t
 

Public Member Functions

const Burger::StaticRTTIget_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.
 
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::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.
 
Rendererm_pRenderer
 Software renderer context.
 
RezFilem_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
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

 Font4Bit (const Font4Bit &)=delete
 
Font4Bitoperator= (const Font4Bit &)=delete
 
 Font4Bit (Font4Bit &&)=delete
 
Font4Bitoperator= (Font4Bit &&)=delete
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Font4Bit() [1/3]

Burger::Font4Bit::Font4Bit ( const Font4Bit & )
privatedelete

◆ Font4Bit() [2/3]

Burger::Font4Bit::Font4Bit ( Font4Bit && )
privatedelete

◆ Font4Bit() [3/3]

Burger::Font4Bit::Font4Bit ( Renderer * pRenderer = 0)

Constructor.


Initializes all shared variables to defaults.

Parameters
pRendererPointer to a rendering context to use for low level APIs

◆ ~Font4Bit()

Burger::Font4Bit::~Font4Bit ( )
virtual

Destructor.


Release all resources allocated by the font manager

See also
Shutdown()

Member Function Documentation

◆ DrawChar()

void Burger::Font4Bit::DrawChar ( uint_t uLetter)
overridevirtual

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 from Burger::Font.

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::Font4Bit::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::Font.

◆ GetPixelWidth()

uint_t Burger::Font4Bit::GetPixelWidth ( const char * pInput,
uintptr_t uLength )
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.

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 from Burger::Font.

◆ Init()

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

Parameters
pRezFilePointer to the resource file that the font resides in
uRezNumResource number of the font file
pPalettePalette to use for drawing
pRendererRendering context to use for drawing
See also
InstallToPalette()

◆ InstallToPalette()

void BURGER_API Burger::Font4Bit::InstallToPalette ( Burger::RezFile * pRezFile,
uint_t uRezNum,
const uint8_t * pPalette )

Install a font.


Load a font from the resource file and use the currently attached Display to determine how to render the image

Parameters
pRezFilePointer to the resource file that the font resides in
uRezNumResource number of the font file
pPalettePalette to use for drawing

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ RestoreState()

void BURGER_API Burger::Font4Bit::RestoreState ( const State_t * pInput)

Restore the previous state of the font manager.


Parameters
pInputPointer to a initialized structure that contains a previous state.
See also
SaveState()

◆ SaveState()

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

Parameters
pOutputPointer to a uninitialized structure to contain the state.
See also
RestoreState()

◆ SetColor()

void BURGER_API Burger::Font4Bit::SetColor ( uint_t uColorIndex,
uint_t uColor )

Set a color for a font.


Parameters
uColorIndexIndex into the color table, maximum value is 15
uColorColor in the current color mode to draw with

◆ SetColorRGBListToPalette()

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.

Note
The palette provided must be the colors needed for rendering

◆ SetToPalette()

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

Parameters
pPalettePointer to a 256 color RGB palette

◆ Shutdown()

void BURGER_API Burger::Font4Bit::Shutdown ( void )

Release a font back to the resource manager.


Release all resource allocated by the font

◆ UseMask()

void Burger::Font4Bit::UseMask ( void )
inline

Make color index #0 transparent.


◆ UseZero()

void Burger::Font4Bit::UseZero ( void )
inline

Make color index #0 visible.


Member Data Documentation

◆ Bytes

uint8_t Burger::Font4Bit::Bytes[16]

Color of font for 8 bit rendering.

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::Font4Bit::g_StaticRTTI
static

◆ [union]

union { ... } Burger::Font4Bit::m_ColorTable

Storage for the color tables for rendering.

◆ m_ppData

void** Burger::Font4Bit::m_ppData
protected

Handle to the active font.

◆ m_pRenderer

Renderer* Burger::Font4Bit::m_pRenderer
protected

Software renderer context.

◆ m_pRezFile

RezFile* Burger::Font4Bit::m_pRezFile
protected

Resource file manager.

◆ m_uInvisibleColor

uint_t Burger::Font4Bit::m_uInvisibleColor
protected

Color to ignore for drawing.

◆ m_uPixelOffset

uintptr_t Burger::Font4Bit::m_uPixelOffset
protected

Offset to the pixel array.

◆ m_uRezNum

uint_t Burger::Font4Bit::m_uRezNum
protected

Resource ID of the last font loaded.

◆ Shorts

uint16_t Burger::Font4Bit::Shorts[16]

Color of font for 16 bit rendering.

◆ Words

uint32_t Burger::Font4Bit::Words[16]

Color of font for 32 bit rendering.