Game Development Reference
In-Depth Information
13. Then, we deine the internal sFTChar structure which holds the information
about a single character:
struct sFTChar
{
// UCS2 character, suitable for FreeType
FT_UInt FChar;
// Internal character index
FT_UInt FIndex;
// Handle for the rendered glyph
FT_Glyph FGlyph;
// Fixed-point character advance and character size
FT_F26Dot6 FAdvance, FWidth;
// Cache node for this glyph
FTC_Node FCacheNode;
// Default parameters
sFTChar(): FChar(0), FIndex((FT_UInt)(-1)), FGlyph(NULL),
FAdvance(0), FWidth(0), FCacheNode( NULL ) { }
};
14. The text we render is in the UTF-8 encoding, which must be converted to the
UCS-2 multi-byte representation. The simplest UTF-8 decoder reads an input
string and outputs its characters into the FString vector:
bool DecodeUTF8( const char* InStr )
{
FIndex = 0;
FBuffer = InStr;
FLength = ( int )strlen( InStr );
FString.clear();
int R = DecodeNextUTF8Char();
while ( ( R != UTF8_LINE_END ) &&
( R != UTF8_DECODE_ERROR ) )
{
sFTChar Ch;
Ch.FChar = R;
FString.push_back( Ch );
R = DecodeNextUTF8Char();
}
return ( R != UTF8_DECODE_ERROR );
}
 
Search WWH ::




Custom Search