Setting font for CEikLabel
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}}.
The article is believed to be still valid for the original topic scope.
The article is believed to be still valid for the original topic scope.
Article Metadata
Tested with
Devices(s): Nokia E61i
Nokia E90 Communicator
Nokia E90 Communicator
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP1
Article
Keywords: CEikLabel, TFontSpec, CFont, CGraphicsDevice, CGraphicsDevice::GetNearestFontInTwips(), CEikLabel::SetFont()
Created: tapiolaitinen
(22 Feb 2008)
Last edited: lpvalente
(04 Aug 2012)
Contents |
Overview
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
private:
CEikLabel* iLabel;
Source file
#include <gdi.h> // TFontSpeciLabel = 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
iLabel->SetFont(font);
// Destroy the font
screenDevice->ReleaseFont(font);
Postconditions
The font used by CEikLabel is set.

