Namespaces
Variants
Actions
Revision as of 00:07, 4 August 2012 by lpvalente (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Setting font for CEikLabel

Jump to: navigation, search
Archived.png
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.


Article Metadata

Tested with
Devices(s): Nokia E61i
Nokia E90 Communicator

Compatibility
Platform(s): S60 3rd Edition
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>  // 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);


Postconditions

The font used by CEikLabel is set.

201 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved