| ID | CS000833 | Creation date | February 28, 2008 |
| Platform | S60 3rd Edition S60 3rd Edition, FP1 | Tested on devices | Nokia E61i Nokia E90 Communicator |
| Category | Symbian C++ | Subcategory | UI |
| Keywords (APIs, classes, methods, functions): CEikLabel, TFontSpec, CFont, CGraphicsDevice, CGraphicsDevice::GetNearestFontInTwips(), CEikLabel::SetFont() |
This code snippet demonstrates how to set the font for CEikLabel.
This snippet can be self-signed.
The following libraries are required:
private:
CEikLabel* iLabel;
#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
iLabel->SetFont(font);
// Destroy the font
screenDevice->ReleaseFont(font);
The font used by CEikLabel is set.
No related wiki articles found