Archived:Using application-specific custom fonts in Symbian C++
Custom fonts can be added with CFbsTypefaceStore or through the screen device (CWsScreenDevice) instance provided by the application framework control environment. The installation path for the font files must be selected carefully if the fonts are not meant to be shared.
Application-specific fonts (such as TTF or GDR files) can be installed to the screen device typeface store as follows:
_LIT( fontFullName, "C:\\system\\fonts\\VodafoneRg.ttf"); // Default font path has been set.
CWsScreenDevice* device = CEikonEnv::Static()->ScreenDevice();
CFbsTypefaceStore* fontStore = CFbsTypefaceStore::NewL( device );
TInt error = fontStore->AddFile( fontFullName, fontFileID);
_LIT(KFontName, "Vodafone Rg"); //Proper font name needs to be passed
const TInt KFontSize = 1000; // Height of the typeface in twips
TFontSpec fontSpec(KFontName, KFontSize);
CGraphicsDevice* screenDevice = CEikonEnv::Static()->ScreenDevice();
Unload the font file in destructor:
Note that AddFile() will use a reference-counted list of fonts - the reference count is decremented automatically when a client is destroyed and the typeface is removed when the count is zero. Alternatively, a client can remove a font file explicitly by calling RemoveFile() with the font file ID as a parameter.
After successfully adding a font file, new fonts can be found with GetNearestFont...() functions from CFbsTypefaceStore.