JGBKFont Class Reference

#include <JGBKFont.h>

Collaboration diagram for JGBKFont:

List of all members.

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)


Detailed Description

Chinese bitmap font encoded with GBK encoding. All popurlar font sizes are supported and the following have been tested: 12x12, 16x16, 18x18, 20x20, 24x24, 28x28 and 32x32.

Constructor & Destructor Documentation

JGBKFont::JGBKFont (  ) 

Constructor.


Member Function Documentation

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");

Parameters:
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.

Parameters:
ch - Single byte or word of character code.
Returns:
Index of the character in cache.

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.

Parameters:
str - String to look for cache indexes.
Returns:
dest - Indexes of characters in cache.

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.

Parameters:
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.

Parameters:
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.

Parameters:
scale - Scale for rendering characters.

void JGBKFont::SetRotation ( float  rot  ) 

Set angle for rendering.

Parameters:
rot - Rotation angle in radian.

void JGBKFont::SetColor ( PIXEL_TYPE  color  ) 

Set font color.

Parameters:
color - color of font.

void JGBKFont::SetBgColor ( PIXEL_TYPE  color  ) 

Set background color.

Parameters:
color - Background color.


Generated on Mon Oct 22 00:28:22 2007 for JGE++ by  doxygen 1.5.3