#include <freetype.h>
Public Member Functions | |
| FontSystem (FT_UInt pointSize, u8 textureFormat=GX_TF_RGBA8) | |
| ~FontSystem () | |
| u16 | drawText (u16 x, u16 y, char *text) |
| u16 | drawText (u16 x, u16 y, char const *text) |
| u16 | drawText (u16 x, u16 y, char *text, u32 *videoBuffer, u16 videoBufferWidth) |
| u16 | drawText (u16 x, u16 y, char const *text, u32 *videoBuffer, u16 videoBufferWidth) |
Private Member Functions | |
| void | cacheFontData () |
| void | loadFontData (FT_Bitmap *bmp, fontCharData *charData) |
| void | converBufferToRGBA8 (u32 *glyphData, fontCharData *charData) |
| void | copyTextureToFramebuffer (GXTexObj *texObj, u16 texWidth, u16 texHeight, u16 screenX, u16 screenY) |
| void | drawCharacter (u16 x, u16 y, fontCharData *charData, u32 *videoBuffer, u16 videoBufferWidth) |
Private Attributes | |
| FT_Library | ftLibrary |
| FT_Face | ftFace |
| FT_GlyphSlot | ftSlot |
| u8 | textureFormat |
| std::map< char, fontCharData > | fontData |
| FontSystem::FontSystem | ( | FT_UInt | pointSize, | |
| u8 | textureFormat = GX_TF_RGBA8 | |||
| ) |
Default constructor for the FontSystem class.
| pointSize | The desired point size this wrapper's configured font face. | |
| textureFormat | The format (GX_TF_*) of the texture as defined by the libogc gx.h header file. Default value is GX_TF_RGBA8. |
| FontSystem::~FontSystem | ( | ) |
Default destructor for the FontSystem class.
| void FontSystem::cacheFontData | ( | ) | [private] |
Locates each character in this wrapper's configured font face and proccess them.
This routine locates each character in the configured font face and renders the glyph's bitmap. Each bitmap and relevant information is loaded into its own quickly addressible structure within an instance-specific map.
| void FontSystem::loadFontData | ( | FT_Bitmap * | bmp, | |
| fontCharData * | charData | |||
| ) | [private] |
Loads the rendered bitmap into the relevant structure's data buffer.
This routine does a simple byte-wise copy of the glyph's rendered 8-bit grayscale bitmap into the structure's buffer. Each byte is converted from the bitmap's intensity value into the a u32 RGBA value.
| bmp | A pointer to the most recently rendered glyph's bitmap. | |
| charData | A pointer to an allocated fontCharData structure whose data represent that of the last rendered glyph. |
| void FontSystem::converBufferToRGBA8 | ( | u32 * | glyphData, | |
| fontCharData * | charData | |||
| ) | [private] |
Convert the specified glyph data buffer into the RGBA8 texture format
This routine converts the temporary RGBA data buffer into the RGBA8 texture format within the character storage structure. Although many RGBA->RGBA8 routines were tested the only that finally worked came from the GRRLIB Wii library and is fully attributed to its author NoNameNo.
| glyphData | Buffer containing the temporarily rendered RGBA data for the current glyph. | |
| charData | A pointer to an allocated fontCharData structure whose data represent that of the desired character |
| void FontSystem::copyTextureToFramebuffer | ( | GXTexObj * | texObj, | |
| u16 | texWidth, | |||
| u16 | texHeight, | |||
| u16 | screenX, | |||
| u16 | screenY | |||
| ) | [private] |
Copies the supplied texture quad to the EFB.
This routine uses the in-built GX quad builder functions to define the texture bounds and location on the EFB target.
| texObj | A pointer to the glyph's initialized texture object. | |
| texWidth | The pixel width of the texture object. | |
| texHeight | The pixel height of the texture object. | |
| screenX | The screen X coordinate at which to output the rendered texture. | |
| screenY | The screen Y coordinate at which to output the rendered texture |
| void FontSystem::drawCharacter | ( | u16 | x, | |
| u16 | y, | |||
| fontCharData * | charData, | |||
| u32 * | videoBuffer, | |||
| u16 | videoBufferWidth | |||
| ) | [private] |
Renders the bitmap buffer from the supplied structure directly into the supplied XFB.
This routine performs a u32-wise copy from the glyphs bitmap buffer directly into the supplied XFB. Note that since this routine must process the entire buffer each time it is called on larger fonts peformance will be highly degraded and its use overall lacks an optimal flair. At most this routine should only be used for debugging purposes.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. | |
| charData | A pointer to an allocated fontCharData structure whose data represent that of the desired character. | |
| videoBuffer | The XFB in which to render the glyph's bitmap. | |
| videoBufferWidth | The pixel width of the XFB referenced by videoBuffer. |
| u16 FontSystem::drawText | ( | u16 | x, | |
| u16 | y, | |||
| char * | text | |||
| ) |
Processes the supplied text string and prints the results at the specified coordinates.
This routine processes each character of the supplied text string, loads the relevant preprocessed bitmap buffer, a texture from said buffer, and loads the resultant texture into the EFB. Since this routine utilizes a preprocess methodology and in-built GX texture functions rendering performance should be very high.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. | |
| text | NULL terminated string to output. |
| u16 FontSystem::drawText | ( | u16 | x, | |
| u16 | y, | |||
| char const * | text | |||
| ) |
Processes the supplied text string and prints the results at the specified coordinates.
Overloaded utility version of the performant drawText function which accepts a char const text string.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. | |
| text | NULL terminated string to output. |
| u16 FontSystem::drawText | ( | u16 | x, | |
| u16 | y, | |||
| char * | text, | |||
| u32 * | videoBuffer, | |||
| u16 | videoBufferWidth | |||
| ) |
Processes the supplied text string and prints the results at the specified coordinates.
This routine processes each character of the supplied text string, loads the relevant preprocessed bitmap buffer and renders the bitmap buffer directly into the supplied XFB using a much slower pixel-based copy function.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. | |
| text | NULL terminated string to output. | |
| videoBuffer | The XFB in which to render the glyph's bitmap. | |
| videoBufferWidth | The pixel width of the XFB referenced by videoBuffer. |
| u16 FontSystem::drawText | ( | u16 | x, | |
| u16 | y, | |||
| char const * | text, | |||
| u32 * | videoBuffer, | |||
| u16 | videoBufferWidth | |||
| ) |
Processes the supplied text string and prints the results at the specified coordinates.
Overloaded utility version of the non-performant drawText function which accepts a char const text string.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. | |
| text | NULL terminated string to output. | |
| videoBuffer | The XFB in which to render the glyph's bitmap. | |
| videoBufferWidth | The pixel width of the XFB referenced by videoBuffer. |
FT_Library FontSystem::ftLibrary [private] |
FreeType FT_Library instance.
FT_Face FontSystem::ftFace [private] |
FreeType reusable FT_Face typographic object.
FT_GlyphSlot FontSystem::ftSlot [private] |
FreeType reusable FT_GlyphSlot glyph container object.
u8 FontSystem::textureFormat [private] |
Defined texture format of the target EFB.
std::map<char, fontCharData> FontSystem::fontData [private] |
Map which holds the glyph data structures for the corresponding characters.
1.5.6