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. Thanks for all your past and future contributions.

Setting font for CEikLabel

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}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia E61i
Nokia E90 Communicator
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Keywords: CEikLabel, TFontSpec, CFont, CGraphicsDevice, CGraphicsDevice::GetNearestFontInTwips(), CEikLabel::SetFont()
Created: tapiolaitinen (22 Feb 2008)
Last edited: hamishwillee (30 May 2013)



This code snippet demonstrates how to set the font for CEikLabel.

This snippet can be self-signed.

MMP file

The following libraries are required:

  • LIBRARY  gdi.lib

Header file

CEikLabel* iLabel;

Source file

#include <gdi.h>  // TFontSpec
iLabel = new(ELeave) CEikLabel;
// Set up a font specification
_LIT(KFontName, "LatinPlain12");
const TInt KFontSize = 180; // Height of the typeface in twips
TFontSpec fontSpec(KFontName, KFontSize);
// Find the nearest available font to the TFontSpec and assign it to CFont
CGraphicsDevice* screenDevice = iEikonEnv->ScreenDevice();
CFont* font;
screenDevice->GetNearestFontInTwips(font, fontSpec);
// Set the font for the label
// Destroy the font


The font used by CEikLabel is set.

This page was last modified on 30 May 2013, at 04:40.
48 page views in the last 30 days.