Creating and loading custom fonts in Symbian

From Nokia Developer Wiki
Jump to: navigation, search

This article contains instructions for creating and loading custom fonts in Symbian.

Needs-update.pngThis article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.

Reasons: hamishwillee (25 Jan 2012)
The article is slightly confusing and out of date.

  • its not clear what the differences are between 2nd and 3rd edition - perhaps the first section is for 2nd edition ... who knows!
  • This creates and uses gdr files. Symbian can use open font files from v9 - ie monotype or ttf depending on plugin support and you'd author those in their own native tools
  • the second example (3rd edition) looks like it is loading a system font - how is this a custom font?
  • the second example should explain what it is trying to do with the custom font
I think this should clarify the above points and also explain the difference between a custom and system fonts on both platforms

Main steps

Here are the steps for creating a custom fonts for your Symbian 2nd edition & 3rd Edition phones.

  1. First get/download the .ttf file of the font which you want to use in your mobile.You can also use the .ttf files of your Windows operation system go to Control Panel > Fonts or C:\WINDOWS\Fonts and select the .ttf file of the font.
  2. Get a copy of Easy GDR creator from www.symbian-freak.com, which is a freeware application used for converting a .ttf to a .gdr.
  3. After creating the .gdr file, you can place the .gdr file at any location in your mobile (say for example c:\system\myfolder\abc.gdr).
  4. Load the font file with the Draw() function.
    CGraphicsDevice* iDevice = iCoeEnv->ScreenDevice();
    TFileName iFileName;
    CWsScreenDevice* iScrDevice =iCoeEnv->ScreenDevice();
    TInt aid =10001;//use any value
    TFontSpec myFontSpec;
  5. Unload the font file.

Custom fonts for Symbian 3rd editon

#include <aknutils.h>
LIBRARY gdi.lib
LIBRARY fbscli.lib
CFont* iFont;
TInt iFontUid;
const CFont* logical_font =
//Using those two lines will loose everything but the height from the system font
//So you would end up with no anti-alias on your custom font for instance
//TFontSpec font_spec = logical_font->FontSpecInTwips();
//TFontSpec myFontSpec(_L("Garamond"),font_spec.iHeight);
//Only customize the typeface, keep things like anti-alias settings for instance
TFontSpec myFontSpec = logical_font->FontSpecInTwips();
  • Unloading the font

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 14 September 2012, at 06:34.
143 page views in the last 30 days.