|
MTek-GDL 0.100.4-muffintrap
|
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. | |
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.
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
| [in] | image | gdl::Image object of a font sheet. |
| [in] | charw | Width of characters in pixels. |
| [in] | charh | Height of characters in pixels. |
| [in] | firstCharacter | The first character in the image |
| 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().
| [in] | *text | Text to draw. |
| [in] | x | X coordinate of text (can be gdl::Centered to center text). |
| [in] | y | Y coordinate of text. |
| [in] | scale | Scale factor (1.0 is original size). |
| [in] | col | Color value (see gdl::Color::ColorValues or Color Handling Macros). |
| short gdl::FFont::GetCharacterWidth | ( | ) |
Returns the width of this font in pixels.
| short gdl::FFont::GetHeight | ( | ) |
Returns the height of this font in pixels.
| short gdl::FFont::GetStringWidth | ( | const char * | str | ) |
Returns the width of the given string in pixels.
| [in] | str | The string to be measured |
| gdl::wii::TEX2f32 gdl::FFont::GetTextureCoordinate | ( | char | character, |
| char | subIndex | ||
| ) |
Returns the texture coordinate of a character.
| [in] | character | The character |
| [in] | subIndex | Which coordinate: 0-3 |
| 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.
| [in] | x | X coordinate of text (can be gdl::Centered to center text). |
| [in] | y | Y coordinate of text. |
| [in] | scale | Scale factor (1.0 is original size). |
| [in] | col | Color of text (see gdl::Color::ColorValues or Color Handling Macros). |
| [in] | *format | Text to draw supporting printf specifiers and formatting parameters. |
| [in] | ... | Print arguments. |