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:Custom font files don't work properly on S60 3rd Edition (Known Issue)
S60 3rd Edition (initial release)
Custom (TTF of GDR) fonts can be used in an application by loading the font file using the CWsScreenDevice::AddFile() function. In S60 3rd Edition devices, adding a new font file works only the first time. Once the application is restarted, adding the custom font fails (a system font is selected instead).
How to reproduce
The issue can be reproduced using the following code snippet.
CWsScreenDevice* dev = CEikonEnv::Static()->ScreenDevice();<br>
dev->AddFile( _L("c:\\data\\sample.ttf"), fontId );<br>
const CFont* logicalFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont );<br>
TFontSpec fontSpec = logicalFont->FontSpecInTwips();
TFontSpec myFontSpec( _L("MyTypeface"), fontSpec.iHeight );<br>
dev->GetNearestFontToDesignHeightInTwips( font, myFontSpec );<br>
This issue is fixed in S60 3rd Edition, Feature Pack 1 devices (and onwards).
Workaround for affected devices:
As a workaround, implement a check at application startup for whether the font file is already added to the typeface store; ie. only call AddFile() once.