2 * Copyright (c) 2004 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.
15 * Interface for Series 60 font type, incorporating principles of series 60 layout
21 #ifndef AKNLAYOUTFONT_H
22 #define AKNLAYOUTFONT_H
26 #include <AknFontSpecification.h>
27 #include <AknTextDecorationMetrics.h>
32 * This abstract class is a CFbsFont that can update itself (re-bind a font) and has standard
33 * Series 60 layout API available.
35 * Concrete classes derived from this implement constructors and Update methods that
36 * supply the specification required for the initially, and newly bound font, respectively.
37 * Derived classes must also implement the CreateFont framework method in order to
38 * implement the font binding itself.
45 NONSHARABLE_CLASS(CAknLayoutFont) : public CFbsFont
52 virtual ~CAknLayoutFont();
54 public: // New functions
56 * Update this object's binding to a CFbsFont, using the member data of the derived class.
57 * This method only needs to be called if the client owns the CAknLayoutFont
58 * object, and there has been a layout switch that may affect the font.
60 * It is functionally equivalent to deleting the CAknLayoutFont object, and
61 * reconstructing it with the same parameters.
63 IMPORT_C void Update();
66 * Return the maximum extent of any pixel in the font upwards from the baseline
67 * Measured up, so therefore it is a positive value.
69 * @return maximum ascent of the font
71 IMPORT_C TInt MaxAscent() const;
74 * Return the maximum extent of any pixel in the font down the baseline
75 * Measured down, so therefore it is usually a positive value.
77 * @return maximum descent of the font
79 IMPORT_C TInt MaxDescent() const;
82 * Position of the baseline measured down from the Series 60 layout text pane top
84 * @return distance from text pane top to baseline
86 IMPORT_C TInt TextPaneTopToBaseline() const;
89 * Position of the text pane bottom measured down from the baseline
91 * @return distance from text pane top to baseline
93 IMPORT_C TInt BaselineToTextPaneBottom() const;
96 * Series 60 text pane height.
97 * Always equal to TextPaneTopToBaseline() + BaselineToTextPaneBottom()
99 * @return text pane height
101 IMPORT_C TInt TextPaneHeight() const;
104 * This provides the baseline relative to the top of the combined font for a specific
105 * character code. This value does not include any TopShortfall.
107 TInt AscentForCharacter( TChar aCharacter ) const;
110 * Returns if a font pointer cast to this type if the actual type conforms to this type.
112 * @returns NULL if the font does not conform to CAknLayoutFont.
114 IMPORT_C static const CAknLayoutFont* AsCAknLayoutFontOrNull( const CFont* aFont );
117 * Returns an object describing how the text with this font is to be decorated
119 * @return text decoration metrics for the font
121 IMPORT_C TAknTextDecorationMetrics TextDecorationMetrics() const;
124 * Returns the Avkon font category (EAknFontCategoryPrimary, EAknFontCategorySecondary...)
125 * that was used to generate this font.
127 * @return font category
129 IMPORT_C TAknFontCategory FontCategory() const;
132 * This API allows the font to provide the metrics under which the font was requested.
134 * @return the font specification for which the font has been supplied
136 IMPORT_C TAknFontSpecification FontSpecification() const;
138 public: // Functions from CFont
140 public:// Functions from CFbsFont
142 TFontSpec DoFontSpecInTwips() const;
148 CAknLayoutFont( CBitmapDevice& aScreenDevice );
149 CBitmapDevice& BitmapDevice() const;
151 protected: // Internal methods
153 void SetExcessAscent( TInt aExcessAscent );
154 void SetExcessDescent( TInt aExcessDescent );
155 void SetBottomShortfall( TInt aBottomShortfall );
156 void SetTextPaneHeight( TInt aTextPaneHeight );
158 private: // New Framework methods
159 virtual CFbsFont* SupplyFont() = 0;
160 virtual TInt DoAscentForCharacter( TChar aCharacter ) const;
161 virtual TAknTextDecorationMetrics DoTextDecorationMetrics() const = 0;
162 virtual TAknFontSpecification DoFontSpecification() const = 0;
163 virtual void CAknLayoutFont_Reserved_1();
171 CFbsFont* iNonDynamicFont;
172 CBitmapDevice& iScreenDevice;
175 TInt iBottomShortfall;
176 TInt iTextPaneHeight;
181 #endif //AKNLAYOUTFONT_H