MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Public Member Functions
gdl::FFont Class Reference

Fixed font handling class. More...

#include <mgdl-wii-font.h>

Public Member Functions

 FFont ()
 Class constructor.
 
virtual ~FFont ()
 Class deconstructor.
 
void BindSheet (ImageWii &image, short charw, short charh, char firstCharacter)
 Binds the font handler class to an gdl::Image object of a font sheet.
 
void CreateVertexList ()
 
void CreateTextureCoordList (short rows, short charactersPerRow, short texW, short texH)
 
void SetFirstCharacterIndex (short firstIndex)
 
void SetCharacterDimensions (short characterWidth, short characterHeight)
 
void DrawText (const char *text, short x, short y, float scale, u32 col)
 Draw text.
 
void Printf (short x, short y, float scale, u32 col, const char *format,...)
 Draw text with a printf-like syntax.
 
short GetHeight ()
 Returns the height of this font in pixels.
 
short GetCharacterWidth ()
 Returns the width of this font in pixels.
 
short GetStringWidth (const char *str)
 Returns the width of the given string in pixels.
 
gdl::wii::TEX2f32 GetTextureCoordinate (char character, char subIndex)
 Returns the texture coordinate of a character.
 

Detailed Description

Fixed font handling class.

Used for handling simple fixed-width fonts from a font sheet. A font sheet is essentially just an image with 256 characters arranged in a 16x16 tile grid. The gdl::Font class however supports variable-width characters but is currently limited to supporting only DirectQB font files.

Member Function Documentation

◆ BindSheet()

void gdl::FFont::BindSheet ( ImageWii image,
short  charw,
short  charh,
char  firstCharacter 
)

Binds the font handler class to an gdl::Image object of a font sheet.

A font sheet consists of a simple array of 256 characters arranged in a 16x16 character grid. It is good enough for simple fonts (such as those found in retro inspired games) but will become problematic with dynamic fonts that have variable-width characters. If the sheet does not start from ASCII code 0, the first character on the sheet can be specified

Parameters
[in]imagegdl::Image object of a font sheet.
[in]charwWidth of characters in pixels.
[in]charhHeight of characters in pixels.
[in]firstCharacterThe first character in the image

◆ DrawText()

void gdl::FFont::DrawText ( const char *  text,
short  x,
short  y,
float  scale,
u32  col 
)

Draw text.

Draws a string of text using the currently binded font sheet. Because it only accepts a pre-made string of characters, it is not as flexible as printf() and gdl::FFont::Printf().

Parameters
[in]*textText to draw.
[in]xX coordinate of text (can be gdl::Centered to center text).
[in]yY coordinate of text.
[in]scaleScale factor (1.0 is original size).
[in]colColor value (see gdl::Color::ColorValues or Color Handling Macros).

◆ GetCharacterWidth()

short gdl::FFont::GetCharacterWidth ( )

Returns the width of this font in pixels.

Returns
width of the string in pixels, zero if no font was loaded or the string is blank.

◆ GetHeight()

short gdl::FFont::GetHeight ( )

Returns the height of this font in pixels.

Returns
Height of the font in pixels, zero if no font was loaded or the string is blank.

◆ GetStringWidth()

short gdl::FFont::GetStringWidth ( const char *  str)

Returns the width of the given string in pixels.

Parameters
[in]strThe string to be measured
Returns
width of the string in pixels, zero if no font was loaded or the string is blank.

◆ GetTextureCoordinate()

gdl::wii::TEX2f32 gdl::FFont::GetTextureCoordinate ( char  character,
char  subIndex 
)

Returns the texture coordinate of a character.

Parameters
[in]characterThe character
[in]subIndexWhich coordinate: 0-3
Returns
Texture coordinate

◆ Printf()

void gdl::FFont::Printf ( short  x,
short  y,
float  scale,
u32  col,
const char *  format,
  ... 
)

Draw text with a printf-like syntax.

Similar to gdl::FFont::DrawText() but is much more flexible as it accepts printf-style specifiers and formatting parameters.

Note
The overall length of the string must be no longer than 255 characters.
Parameters
[in]xX coordinate of text (can be gdl::Centered to center text).
[in]yY coordinate of text.
[in]scaleScale factor (1.0 is original size).
[in]colColor of text (see gdl::Color::ColorValues or Color Handling Macros).
[in]*formatText to draw supporting printf specifiers and formatting parameters.
[in]...Print arguments.

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