#include <JTTFont.h>
Public Types | |
enum | FONT_LOADING_MODE { MODE_NORMAL, MODE_PRECACHE_ASCII, MODE_PRECACHE_ASCII_EX } |
enum | CACHE_IMAGE_SIZE { CACHE_IMAGE_64x64, CACHE_IMAGE_128x128, CACHE_IMAGE_256x256, CACHE_IMAGE_512x512 } |
Public Member Functions | |
JTTFont (int cacheImageSize=CACHE_IMAGE_256x256) | |
void | SetColor (PIXEL_TYPE color) |
void | SetAngle (float angle) |
bool | SetSize (int size) |
bool | Load (const char *filename, int size=12, int mode=MODE_NORMAL) |
bool | Load (JTTFont *fontSource, int size=12, int mode=MODE_NORMAL) |
void | Unload (void) |
void | RenderString (const u16 *text, float x, float y, int alignment=JGETEXT_LEFT) |
void | RenderString (const char *text, float x, float y, int alignment=JGETEXT_LEFT) |
void | RenderString (const u8 *text, float x, float y, int alignment=JGETEXT_LEFT) |
void | PreCacheString (const u16 *text) |
void | PreCacheString (const char *text) |
void | PreCacheString (const u8 *text) |
int | GetWidth (const u16 *text) |
int | GetWidth (const char *text) |
int | GetWidth (const u8 *text) |
bool | PreCacheASCII () |
bool | PreCacheExtendedASCII () |
// in Create() mTTFont = new JTTFont(); mTTFont->Load("arial.ttf", 32); // size 32 if (mTTFont->PreCacheASCII()) mTTFont->Unload(); ... // in Render() mTTFont->RenderString("Hello World!", 240, 80, JGETEXT_CENTER);
JTTFont::JTTFont | ( | int | cacheImageSize = CACHE_IMAGE_256x256 |
) |
Constructor.
cacheImageSize | - Size of the texture used for caching. This can be 64x64, 128x128(default), 256x256 or 512x512. |
void JTTFont::SetColor | ( | PIXEL_TYPE | color | ) |
Set color of font.
color | - Font color. |
void JTTFont::SetAngle | ( | float | angle | ) |
Set angle of the font for rendering.
angle | - Angle in radians. |
bool JTTFont::SetSize | ( | int | size | ) |
Set font size.
size | - Font size. |
bool JTTFont::Load | ( | const char * | filename, | |
int | size = 12 , |
|||
int | mode = MODE_NORMAL | |||
) |
Load font file.
filename | - Name of True Type font. | |
size | - Initial font size. Default is 12. | |
mode | - Loading mode. |
bool JTTFont::Load | ( | JTTFont * | fontSource, | |
int | size = 12 , |
|||
int | mode = MODE_NORMAL | |||
) |
Create font using font data from another JTTFont instance.
fontSource | - Source of font data. | |
size | - Initial font size. Default is 12. | |
mode | - Loading mode. |
void JTTFont::Unload | ( | void | ) |
Unload font file and related Freetype objects from memory.
void JTTFont::RenderString | ( | const u16 * | text, | |
float | x, | |||
float | y, | |||
int | alignment = JGETEXT_LEFT | |||
) |
Render Unicode string to screen.
text | - NULL terminated Unicode-16 string. | |
x | - X position. | |
y | - Y position. | |
alignment | - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER |
void JTTFont::RenderString | ( | const char * | text, | |
float | x, | |||
float | y, | |||
int | alignment = JGETEXT_LEFT | |||
) |
Render ASCII string to screen.
text | - NULL terminated ASCII string. | |
x | - X position. | |
y | - Y position. | |
alignment | - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER |
void JTTFont::RenderString | ( | const u8 * | text, | |
float | x, | |||
float | y, | |||
int | alignment = JGETEXT_LEFT | |||
) |
Render Chinese (GBK) string to screen.
text | - NULL terminated GBK encoded string. | |
x | - X position. | |
y | - Y position. | |
alignment | - Text alignment: JGETEXT_LEFT, JGETEXT_RIGHT, JGETEXT_CENTER |
void JTTFont::PreCacheString | ( | const u16 * | text | ) |
Put characters of an Unicode string into cache
text | - NULL terminated Unicode-16 string. |
void JTTFont::PreCacheString | ( | const char * | text | ) |
Put characters of an ASCII string into cache.
text | - NULL terminated ASCII string. |
void JTTFont::PreCacheString | ( | const u8 * | text | ) |
Put characters of a Chinese (GBK) string into cache.
text | - NULL terminated GBK encoded string. |
int JTTFont::GetWidth | ( | const u16 * | text | ) |
Get width of Unicode string on screen.
text | - NULL terminated Unicode-16 string. |
int JTTFont::GetWidth | ( | const char * | text | ) |
Get width of ASCII string on screen.
text | - NULL terminated ASCII string. |
int JTTFont::GetWidth | ( | const u8 * | text | ) |
Get width of Chinese (GBK) string on screen.
text | - NULL terminated GBK encoded string. |
bool JTTFont::PreCacheASCII | ( | ) |
Put all standard ASCII characters (0x20-0x7F) into cache.
bool JTTFont::PreCacheExtendedASCII | ( | ) |
Put all ASCII characters (0x20-0xFF) into cache.