#include <JGBKFont.h>
Public Member Functions | |
| JGBKFont () | |
| bool | Init (const char *engFileName, const char *chnFileName, int fontsize=16, bool smallEnglishFont=false) |
| int | PreCacheChar (const BYTE *ch) |
| int | PrepareString (BYTE *str, int *dest) |
| void | RenderEncodedString (const int *text, int count, float x, float y) |
| void | RenderString (BYTE *str, float x, float y, int alignment=JGETEXT_LEFT) |
| void | SetScale (float scale) |
| void | SetRotation (float rot) |
| void | SetColor (PIXEL_TYPE color) |
| void | SetBgColor (PIXEL_TYPE color) |
| JGBKFont::JGBKFont | ( | ) |
Constructor.
| bool JGBKFont::Init | ( | const char * | engFileName, | |
| const char * | chnFileName, | |||
| int | fontsize = 16, |
|||
| bool | smallEnglishFont = false | |||
| ) |
Initialization of the font class. You need to provide both a Chinese font file and an English one as well.
For example:
mChineseFont = new JGBKFont(); mChineseFont->Init("Res/ASC16", "Res/GBK16");
| engFileName | - Name of the English font file. | |
| chnFileName | - Name of the Chinese font file. | |
| fontsize | - Font size. | |
| smallEnglishFont | - Indicate to use half width when rendering English characters. |
| int JGBKFont::PreCacheChar | ( | const BYTE * | ch | ) |
Rendering character into cache.
| ch | - Single byte or word of character code. |
| int JGBKFont::PrepareString | ( | BYTE * | str, | |
| int * | dest | |||
| ) |
Scan through the string and look up the index of each character in the cache and then return all indexes in an array to be rendered later on.
| str | - String to look for cache indexes. |
Number of characters processed.
| void JGBKFont::RenderEncodedString | ( | const int * | text, | |
| int | count, | |||
| float | x, | |||
| float | y | |||
| ) |
Render string by using the indexes returned from PrepareString.
| text | - Cache indexes for rendering. | |
| count | - Number of characters to render. | |
| x | - X screen position for rendering. | |
| y | - Y screen position for rendering. |
| void JGBKFont::RenderString | ( | BYTE * | str, | |
| float | x, | |||
| float | y, | |||
| int | alignment = JGETEXT_LEFT | |||
| ) |
Render string to screen.
| str | - String to render. | |
| x | - X screen position for rendering. | |
| y | - Y screen position for rendering. |
| void JGBKFont::SetScale | ( | float | scale | ) |
Set scale for rendering.
| scale | - Scale for rendering characters. |
| void JGBKFont::SetRotation | ( | float | rot | ) |
Set angle for rendering.
| rot | - Rotation angle in radian. |
| void JGBKFont::SetColor | ( | PIXEL_TYPE | color | ) |
Set font color.
| color | - color of font. |
| void JGBKFont::SetBgColor | ( | PIXEL_TYPE | color | ) |
Set background color.
| color | - Background color. |
1.5.3