Game Development Reference
In-Depth Information
2.
Then the list of loaded fonts is declared:
// List of available font faces
std::vector<std::string> FFontFaces;
// Handle for the current font face
FT_Face FFace;
// List of loaded font files to prevent multiple file
reads
std::map<std::string, void*> FAllocatedFonts;
// List of initialized font face handles
std::map<std::string, FT_Face> FFontFaceHandles;
3.
The FMaskMode switch is used to choose between opaque rendering and
alpha-mask creation. It is mentioned later in the glyph rendering code:
bool FMaskMode;
4.
The initialization routine creates the FreeType library instance and initializes
the glyph and image caches:
void InitFreeType()
{
LoadFT();
FT_Init_FreeTypePTR( &FLibrary );
FTC_Manager_NewPTR(FLibrary,0,0,0,
FreeType_Face_Requester, this, &FManager);
FTC_ImageCache_NewPTR( FManager, &FImageCache );
FTC_CMapCache_NewPTR( FManager, &FCMapCache );
}
As usual, we provide the shortest code possible. The complete code should check for
non-zero return codes from the FTC_* functions. The LoadFT() function initializes
the function pointers for the FreeType library. We use the PTR sufix for all of the
FreeType functions in the code for this recipe to allow dynamic library loading on
Windows. If you are only concerned about Android development, the PTR sufix
can be omitted.
5.
The deinitialization routine clears all the internal data and destroys the FreeType
objects:
void StopFreeType()
{
FreeString();
auto p = FAllocatedFonts.begin();
for ( ; p!= FAllocatedFonts.end() ; p++ )
delete[] ( char* )( p->second );
FFontFaces.clear();
FTC_Manager_DonePTR( FManager );
FT_Done_FreeTypePTR( FLibrary );
}
 
Search WWH ::




Custom Search