×
Namespaces

Variants
Actions
(Difference between revisions)

Setting font for CEikLabel

From Nokia Developer Wiki
Jump to: navigation, search
lpvalente (Talk | contribs)
m (Lpvalente -)
lpvalente (Talk | contribs)
m (Lpvalente -)
Line 31: Line 31:
 
==Overview==
 
==Overview==
  
This code snippet demonstrates how to set the font for {{Icode|CEikLabel}}.
+
{{Abstract|This code snippet demonstrates how to set the font for {{Icode|CEikLabel}}.}}
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.

Revision as of 00:07, 4 August 2012

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
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
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.

46 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×