2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #ifndef AKNFONTSPECIFICATION_H
21 #define AKNFONTSPECIFICATION_H
24 #include <AknFontCategory.hrh>
25 #include <babitflags.h>
28 * Object representing the series 60 requirements for a font. It contains information
29 * from the layout specification that fonts bound to the given font id should honor.
31 * It formst the basis of the request to font provisioning to provide a suitable font
38 class TAknFontSpecification
42 enum TAknFontSpecificationUnits
50 * Construct font specification from Font ID.
52 *@param aFontId Series 60 font id from which to create a font.
54 IMPORT_C TAknFontSpecification( TInt aFontId );
57 * Construct the font specifiation from Symbian OS TFontSpec and MGraphicsDeviceMap
58 * The Symbian OS TFontSpec must be set in Twips. The MGraphicsDeviceMap is used to convert to
59 * pixels for the text pane height.
61 * Note that the units policy during and in effect at the end of this constructor is EPixels.
63 * Note that the TTypeface part of the TFontSpec is lost in this construction
65 * @param aCategory Series 60 Font category to use
66 * @param aFontSpec Provides the metrics and Style information to use for the match
67 * @param aDeviceMap Device map used to convert the aFontSpec's twips to pixels
70 IMPORT_C TAknFontSpecification(
71 TAknFontCategory aCategory,
72 const TFontSpec& aFontSpec,
73 const MGraphicsDeviceMap* aDeviceMap );
76 * Sets the Series 60 font category.
78 * @param aCategory New category to set.
80 IMPORT_C void SetFontCategory( TAknFontCategory aCategory );
83 * Series 60 Layout Specification font category:
84 * Primary, Secondary, Title etc.
86 * @return Series 60 font category
88 IMPORT_C TAknFontCategory FontCategory() const;
91 * The requested height for a font. This represents the maximum vertical range that can be
92 * guraranteed to draw in the text pane.
94 * Note also that this value is the height requested by layout or the client, and might not correspond to
95 * the design height, ascent + descent, or max height reported by the attached font. See the APIs
96 * CAknLayoutFont::TextPaneTopToBaseline and BaselineToTextPaneBottom.
98 * If TextPaneHeightIsDesignHeight() is EFalse, then the font will be requested to fit entirely within
101 * If TextPaneHeightIsDesignHeight() is set, then this value is passed to the font request as the font
102 * design height, in which case the font may not render entirely within the "text pane height".
104 * @param aNewHeight Text pane height to be used by the font.
106 IMPORT_C void SetTextPaneHeight( TInt aNewHeight );
109 * The requested height of the font. This represents the maximum vertical range that can be
110 * guaranteed to draw in the text pane.
112 * Note also that this value is the height requested by layout or the client, and may not correspond to
113 * the design height, ascent + descent, or max height reported by the attached font. See the APIs
114 * CAknLayoutFont::TextPaneTopToBaseline and BaselineToTextPaneBottom.
116 * If TextPaneHeightIsDesignHeight() is EFalse, then the font is to be requested to fit entirely within
119 * If TextPaneHeightIsDesignHeight() is set, then this value is passed to the font request as the font
120 * design height, in which case the font may not render entirely within the "text pane height".
122 * Depending upon the value of TextPaneHeightIsInTwips(), the value returned is in Pixels or Twips.
123 * Note that calling SetTextPaneHeightIsInTwips() does not perform any conversion of the text pane height;
124 * It retains its set value.
126 * @return Requested text pane height.
128 IMPORT_C TInt TextPaneHeight() const;
131 * Set the stoke weight to request using the Symbian OS stroke weight enumeration.
133 * @aParam aWeight The stroke weight.
135 IMPORT_C void SetWeight( TFontStrokeWeight aWeight );
138 * Sets the posture (e.g. upright, italic) of requested font using the Symbian OS enumeration.
139 * @param aPostore posture to request
141 IMPORT_C void SetPosture( TFontPosture aPosture );
144 * Sets the policy to use in requesting the font height. Fonts may be requested either by "design height" (which is
145 * usually approximately the ascent + descent) or by maximum height.
146 * If false, this setting means the number set by SetTextPaneHeight is intended to match
147 * the font's maximum extent; all characters will fit within the text pane.
148 * If true, then the value passed by SetTextPaneHeight will be used to request design height.
150 * This API has no effect if called on a TAknFontSpecification that has already been bound to a font
152 * The default value upon construction is EFalse.
154 * @param aTextPaneHeightIsDesignHeight If EFalse, ensure that the font fits entirely
155 * within the text pane height
156 * If not EFalse, then the text pane height is treated as the font
159 IMPORT_C void SetTextPaneHeightIsDesignHeight( TBool aTextPaneHeightIsDesignHeight );
162 * Accessor API for the height policy.
164 * @return EFalse if text pane height is to be the maximum font extent.
165 * ETrue if text pane height is to be treated as the font's design height
167 IMPORT_C TBool TextPaneIsDesignHeight() const;
170 * Sets a flag indicating to font requests whether they should insist upon an exact match.
171 * Whether a font match is treated as exact or not depends upon various things, including:
172 * - if a request is made via a generic font family or via a font family enumeration, then typeface is not tested for "exactness"
173 * - fonts may be forced to be rendered at certain sizes (within a small number of pixels). This still counts as an exact match
175 * The default value upon construction is EFalse;
177 * @param aRequiresExactMatch
179 IMPORT_C void SetExactMatchRequired ( TBool aRequiresExactMatch );
182 * Accessor API for whether an exact match is required for the font (See SetExactMatchRequired() )
184 * @return whether an exact match is required or not.
186 IMPORT_C TBool ExactMatchRequired() const;
189 * Sets the units for the Text Pane Height APIs. Note that calling this API does not
190 * result in the numerical value of the text pane height being recalculated.
191 * Upon construction, TAknFontSpecification objects store TextPaneHeight in pixels.
192 * If you then call SetUnits to Twips, you will also have to call SetTextPaneHeight to pass in the new
197 IMPORT_C void SetUnits( TAknFontSpecification::TAknFontSpecificationUnits aUnits );
200 * Accessor API for the units being used.
202 * @return units currently being used.
204 IMPORT_C TAknFontSpecification::TAknFontSpecificationUnits Units() const;
207 * Accessor for the requested weight
209 * @return Symbian OS stroke weight enumeration (e.g. EStrokeWeightBold)
211 IMPORT_C TFontStrokeWeight Weight() const ;
214 * Accessor for the requested posture
216 * @return Symbian OS font posture enumeration (e.g. EPostureItalic)
218 IMPORT_C TFontPosture Posture() const;
221 * Accessor for the requested outline effect
225 * @return ETrue iff outline font effect has been requested
227 IMPORT_C TBool IsOutlineEffectOn() const;
230 void LoadAnyCDLFontInstanceL();
233 TAknFontCategory iBaseFontCategory;
234 TInt iTextPaneHeight;
235 // Symbian OS Font Style object convenient for holding style info
236 TFontStyle iRequiredStyle;