Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Using application-specific custom fonts in Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Code Example
Source file:
Tested with
Devices(s): All (S60)
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Keywords: CFbsTypefaceStore
Created: User:Technical writer 1 (05 Dec 2008)
Last edited: hamishwillee (19 Sep 2012)


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:

CFont* font;
TInt fontFileID;
_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();
screenDevice->GetNearestFontInTwips(font, fontSpec);

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.

This page was last modified on 19 September 2012, at 00:30.
54 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.