2 * Copyright (c) 2005 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 * Access to Series 60 font system
21 #ifndef __AKNFONTACCESS_H__
22 #define __AKNFONTACCESS_H__
27 #include <AknFontSpecification.h>
34 * Generic font family enumeration. These can be used in place of the family name descriptors
38 EAknFontFamilyNotSpecified = 0,
39 EAknFontFamilySansSerif,
41 EAknFontFamilyMonospace
47 * Returns a font that matches the metrics supplied. The provider can return a scaled
48 * or bitmap font as long as it meets the provided criteria. If an exact match isn't
49 * found then a null is returned.
51 * @since Series 60 release 2.8
53 * @param aBitmapDevice Device for which the font will be requested
54 * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
55 * @param aFontSize Font size in twips.
56 * @param aFontFamily Font is one of the enumerations in TAknFontFamily
57 * Note that serif and sansSerif are proportional fonts
59 * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
60 * device context when the font is no longer required. If an exact match isn't found NULL is returned
62 IMPORT_C static CFbsFont* GetFont(
63 CBitmapDevice& aBitmapDevice,
64 const TFontStyle aFontStyle,
65 TInt aFontSizeInTwips,
66 TAknFontFamily aFontFamily);
68 * Returns a font that matches the metrics supplied. The provider can return a scaled
69 * or bitmap font as long as it meets the provided criteria. If an exact match isn't
70 * found than a null is returned.
72 * @since Series 60 release 2.8
74 * @param aBitmapDevice Device for which the font will be requested
75 * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
76 * @param aFontSize Font size in twips.
77 * @param aFontFamilyname Font family is the text name of the font family and may be, for example:
78 * "courier", "helvetica", "times roman" etc. Font names are not case-sensitive.
80 * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
81 * device context when the font is no longer required. If an exact match isn't found NULL is returned
83 IMPORT_C static CFbsFont* GetFont(
84 CBitmapDevice& aBitmapDevice,
85 const TFontStyle aFontStyle,
86 TInt aFontSizeInTwips,
87 const TDesC& aFontFamilyName);
89 * Returns a font that matches the metrics supplied. The provider can return a scaled
90 * or bitmap font as long as it meets the provided criteria. A best fit is used that
91 * is prioritized as follows: fontSize, fontStyle, fontFamily
92 * This will succeed as long as there is at least one font on the phone.
93 * @since Series 60 release 2.8
95 * @param aBitmapDevice Device for which the font will be requested
96 * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
97 * @param aFontSize Font size in twips.
98 * @param aFontFamily Font is one of the following emumerations values:
99 * monospace, sansSerif, serif
100 * Note that serif and sansSerif are proportional fonts
102 * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
103 * device context when the font is no longer required. A font is always returned.
105 IMPORT_C static CFbsFont* GetClosestFont(
106 CBitmapDevice& aBitmapDevice,
107 const TFontStyle aFontStyle,
108 TInt aFontSizeInTwips,
109 TAknFontFamily aFontFamily);
111 * Returns a font that matches the metrics supplied. The provider can return a scaled
112 * or bitmap font as long as it meets the provided criteria. A best fit is used that
113 * is prioritized as follows: fontSize, fontStyle, fontFamily
114 * This will succeed as long as there is at least one font on the phone.
115 * @since Series 60 release 2.8
117 * @param aBitmapDevice Device for which the font will be requested
118 * @param aFontStyle of type TFontStyle. Use to set weight and posture of the font
119 * @param aFontSize Font size in twips.
120 * @param aFontFamilyname Font family is the text name of the font family and may be, for example:
121 * "courier", "helvetica", "times roman" etc. Font names are not case-sensitive.
123 * @return A font pointer. CBitmapDevice::ReleaseFont must be called to release the font resource on the
124 * device context when the font is no longer required. A font is always returned.
126 IMPORT_C static CFbsFont* GetClosestFont(
127 CBitmapDevice& aBitmapDevice,
128 const TFontStyle aFontStyle,
129 TInt aFontSizeInTwips,
130 const TDesC& aFontFamilyName);
133 * Return a fully constructed CAknLayoutFont object based upon the specification passed in.
134 * The Avkon font specifiation object uses TAknFontCategory to determine the font.
136 * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
138 * This method can only be used for TAknFontSpecification objects that are stored in Pixels.
139 * (See TAknFontSpecification::Units() )
141 * @since Series 60 release 2.8
142 * @param aBitmapDevice Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used)
143 * @param aSpec Series 60 font specification object
144 * @return pointer to a CAknLayoutFont object, owned by the caller
146 IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
147 CBitmapDevice& aBitmapDevice,
148 const TAknFontSpecification& aSpec );
151 * Return a fully constructed CAknLayoutFont object based upon the typeface and specification passed in.
152 * The TTypeface object contains a typeface name that is used as the primary key to select a font.
153 * The Series 60 font specifiation object is also used, but any value of TAknFontCategory passed in is reset to
154 * EAknFontCategoryUndefined, and is not used to select the font.
156 * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
158 * This method can only be used for TAknFontSpecification objects that are stored in Pixels
159 * (See TAknFontSpecification::Units() )
161 * @since Series 60 release 2.8
162 * @param aBitmapDevice Device for which the font is required (not used in 2.8; CEikonEnv::ScreenDevice() is used)
163 * @param aTypeface Symbian Typface object
164 * @param aSpec Series 60 font specification object
165 * @return pointer to a CAknLayoutFont object, owned by the caller
167 IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
168 CBitmapDevice& aBitmapDevice,
169 const TTypeface& aTypeface,
170 const TAknFontSpecification& aSpec);
175 * Method containing all the real implementation for the GetFontXXX APIs
177 static CFbsFont* DoGetFont(
178 CBitmapDevice& aBitmapDevice,
179 const TFontStyle aFontStyle,
180 TInt aFontSizeInTwips,
181 const TTypeface& aFontFamilyTypeface,
182 TBool aExactMatchRequired);
185 #endif // __AKNFONTACCESS_H__