Archived:Custom font files don't work properly on S60 3rd Edition (Known Issue)
Archived: 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
Tested with
Devices(s): Tested on Nokia N73
Compatibility
Platform(s): S60 3rd Edition
Article
Keywords: CWsScreenDevice::AddFile
Created: User:Symbian expert 0
(17 Sep 2009)
Last edited: hamishwillee
(07 Sep 2012)
Description
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.
CFont* font;
TInt fontId;
CWsScreenDevice* dev = CEikonEnv::Static()->ScreenDevice();
dev->AddFile( _L("c:\\data\\sample.ttf"), fontId );
const CFont* logicalFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont );
TFontSpec fontSpec = logicalFont->FontSpecInTwips();
TFontSpec myFontSpec( _L("MyTypeface"), fontSpec.iHeight );
dev->GetNearestFontToDesignHeightInTwips( font, myFontSpec );
Solution
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.

