#include <FreeTypeGX.h>
Public Member Functions | |
| FreeTypeGX (FT_UInt pointSize, uint8_t textureFormat=GX_TF_RGBA8, bool cacheAll=false) | |
| ~FreeTypeGX () | |
| uint16_t | drawText (uint16_t x, uint16_t y, wchar_t *text, GXColor color) |
| uint16_t | drawText (uint16_t x, uint16_t y, wchar_t *text) |
| uint16_t | drawText (uint16_t x, uint16_t y, wchar_t const *text, GXColor color) |
| uint16_t | drawText (uint16_t x, uint16_t y, wchar_t const *text) |
| uint16_t | getWidth (wchar_t *text) |
| uint16_t | getWidth (wchar_t const *text) |
| uint16_t | getHeight (wchar_t *text) |
| uint16_t | getHeight (wchar_t const *text) |
Private Member Functions | |
| uint16_t | cacheAllGlyphData () |
| fontCharData * | cacheGlyphData (wchar_t charCode) |
| void | loadGlyphData (FT_Bitmap *bmp, fontCharData *charData) |
| void | copyTextureToFramebuffer (GXTexObj *texObj, uint16_t texWidth, uint16_t texHeight, uint16_t screenX, uint16_t screenY, GXColor color) |
Static Private Member Functions | |
| static uint16_t | adjustTextureWidth (uint16_t textureWidth, uint8_t textureFormat) |
| static uint16_t | adjustTextureHeight (uint16_t textureHeight, uint8_t textureFormat) |
Private Attributes | |
| FT_Library | ftLibrary |
| FT_Face | ftFace |
| FT_GlyphSlot | ftSlot |
| uint8_t | textureFormat |
| std::map< wchar_t, fontCharData > | fontData |
| FreeTypeGX::FreeTypeGX | ( | FT_UInt | pointSize, | |
| uint8_t | textureFormat = GX_TF_RGBA8, |
|||
| bool | cacheAll = false | |||
| ) |
Default constructor for the FreeTypeGX class.
| pointSize | The desired point size this wrapper's configured font face. | |
| textureFormat | Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8. | |
| cacheAll | Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false. |
| FreeTypeGX::~FreeTypeGX | ( | ) |
Default destructor for the FreeTypeGX class.
| uint16_t FreeTypeGX::adjustTextureWidth | ( | uint16_t | textureWidth, | |
| uint8_t | textureFormat | |||
| ) | [static, private] |
Adjusts the texture data buffer to necessary width for a given texture format.
This routine determines adjusts the given texture width into the required width to hold the necessary texture data for proper alignment.
| textureWidth | The initial guess for the texture width. | |
| textureFormat | The texture format to which the data is to be converted. |
| uint16_t FreeTypeGX::adjustTextureHeight | ( | uint16_t | textureHeight, | |
| uint8_t | textureFormat | |||
| ) | [static, private] |
Adjusts the texture data buffer to necessary height for a given texture format.
This routine determines adjusts the given texture height into the required height to hold the necessary texture data for proper alignment.
| textureHeight | The initial guess for the texture height. | |
| textureFormat | The texture format to which the data is to be converted. |
| uint16_t FreeTypeGX::cacheAllGlyphData | ( | ) | [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.
| fontCharData * FreeTypeGX::cacheGlyphData | ( | wchar_t | charCode | ) | [private] |
Caches the given font glyph in the instance font texture buffer.
This routine renders and stores the requested glyph's bitmap and relevant information into its own quickly addressible structure within an instance-specific map.
| charCode | The requested glyph's character code. |
| void FreeTypeGX::loadGlyphData | ( | 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 uint32_t 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 FreeTypeGX::copyTextureToFramebuffer | ( | GXTexObj * | texObj, | |
| uint16_t | texWidth, | |||
| uint16_t | texHeight, | |||
| uint16_t | screenX, | |||
| uint16_t | screenY, | |||
| GXColor | color | |||
| ) | [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 | |
| color | Color to apply to the texture. |
| uint16_t FreeTypeGX::drawText | ( | uint16_t | x, | |
| uint16_t | y, | |||
| wchar_t * | text, | |||
| GXColor | color | |||
| ) |
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.
| x | Screen X coordinate at which to output the text. | |
| y | Screen Y coordinate at which to output the text. Note that this value corresponds to the text tring origin and not the top or bottom of the glyphs. | |
| text | NULL terminated string to output. | |
| color | Optional color to apply to the text characters. If not specified default value is (GXColor){0xff, 0xff, 0xff, 0xff} |
| uint16_t FreeTypeGX::drawText | ( | uint16_t | x, | |
| uint16_t | y, | |||
| wchar_t * | text | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| uint16_t FreeTypeGX::drawText | ( | uint16_t | x, | |
| uint16_t | y, | |||
| wchar_t const * | text, | |||
| GXColor | color | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| uint16_t FreeTypeGX::drawText | ( | uint16_t | x, | |
| uint16_t | y, | |||
| wchar_t const * | text | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| uint16_t FreeTypeGX::getWidth | ( | wchar_t * | text | ) |
Processes the supplied string and return the width of the string in pixels.
This routine processes each character of the supplied text string and calculates the width of the entire string. Note that if precaching of the entire font set is not enabled any uncached glyph will be cached after the call to this function.
| text | NULL terminated string to calculate. |
| uint16_t FreeTypeGX::getWidth | ( | wchar_t const * | text | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| uint16_t FreeTypeGX::getHeight | ( | wchar_t * | text | ) |
Processes the supplied string and return the height of the string in pixels.
This routine processes each character of the supplied text string and calculates the height of the entire string. Note that if precaching of the entire font set is not enabled any uncached glyph will be cached after the call to this function.
| text | NULL terminated string to calculate. |
| uint16_t FreeTypeGX::getHeight | ( | wchar_t const * | text | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
FT_Library FreeTypeGX::ftLibrary [private] |
FreeType FT_Library instance.
FT_Face FreeTypeGX::ftFace [private] |
FreeType reusable FT_Face typographic object.
FT_GlyphSlot FreeTypeGX::ftSlot [private] |
FreeType reusable FT_GlyphSlot glyph container object.
uint8_t FreeTypeGX::textureFormat [private] |
Defined texture format of the target EFB.
std::map<wchar_t, fontCharData> FreeTypeGX::fontData [private] |
Map which holds the glyph data structures for the corresponding characters.
1.5.6