|
1 /* |
|
2 * Copyright (c) 2003-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: font interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _GDIFONT_H |
|
20 #define _GDIFONT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "nw_object_dynamic.h" |
|
24 #include "nw_gdi_types.h" |
|
25 #include "NW_GDI_EXPORT.h" |
|
26 #include "BrsrTypes.h" |
|
27 #include "BrsrStatusCodes.h" |
|
28 #include "e32base.h" |
|
29 |
|
30 // DATA TYPES |
|
31 struct TGDIFontInfo |
|
32 { |
|
33 TUint8 height; |
|
34 TUint8 baseline; |
|
35 }; |
|
36 |
|
37 enum TGDIFontStyle |
|
38 { |
|
39 EGDIFontStyleNormal = 1, |
|
40 EGDIFontStyleItalic, |
|
41 EGDIFontStyleOblique |
|
42 }; |
|
43 |
|
44 enum TGDIFontVariant |
|
45 { |
|
46 EGDIFontVariantNormal = 1, |
|
47 EGDIFontVariantSmallCaps |
|
48 }; |
|
49 |
|
50 // CONSTANTS |
|
51 const NW_Text_t* const KGDIFontDefaultFamily = NULL; |
|
52 const TUint8 KGDIFontDefaultStyle = EGDIFontStyleNormal; |
|
53 const NW_Float32 KGDIFontDefaultSizeInPt = 6.0F; // 6pt |
|
54 const TUint8 KGDIFontZeroSize = 0; |
|
55 const TUint16 KGDIFontDefaultWeight = 400; |
|
56 const TUint8 KGDIFontDefaultVariant = EGDIFontVariantNormal; |
|
57 const TUint16 KGDIDefaultFontSizeInTwips = 120; |
|
58 |
|
59 // MACROS |
|
60 |
|
61 // FUNCTION PROTOTYPES |
|
62 |
|
63 // FORWARD DECLARATIONS |
|
64 |
|
65 // CLASS DECLARATION |
|
66 |
|
67 typedef struct |
|
68 { |
|
69 const char* iSpecifiedFontName; |
|
70 const char* iDefaultFontName; |
|
71 }TFontLookupArray; |
|
72 |
|
73 /** |
|
74 * CGDIDeviceContext |
|
75 * |
|
76 * @lib BrowserEngine.dll |
|
77 * @since 2.1 |
|
78 */ |
|
79 class CGDIFont : public CBase |
|
80 { |
|
81 public: // Constructors and destructor |
|
82 |
|
83 /** |
|
84 * Two-phased constructor. |
|
85 * @return CCSSHandler* |
|
86 */ |
|
87 static CGDIFont* NewL( const CGDIDeviceContext* aDeviceContext, |
|
88 const NW_Text_t* aFamily, |
|
89 TGDIFontStyle aStyle, |
|
90 TUint16 aSize, |
|
91 TUint16 aWeight, |
|
92 TGDIFontVariant aVariant ); |
|
93 |
|
94 /** |
|
95 * Destructor. |
|
96 */ |
|
97 virtual ~CGDIFont(); |
|
98 |
|
99 public: // New functions |
|
100 |
|
101 /** |
|
102 * This method |
|
103 * @since 2.1 |
|
104 * @param - this parameter is in twips |
|
105 * @return |
|
106 */ |
|
107 void SetFontSize( TUint16 aFontSize ); |
|
108 |
|
109 /** |
|
110 * This method |
|
111 * @since 2.1 |
|
112 * @param |
|
113 * @return |
|
114 */ |
|
115 inline TDesC* FontFamily() { return iFontFamily; }; |
|
116 |
|
117 /** |
|
118 * This method |
|
119 * @since 2.1 |
|
120 * @param |
|
121 * @return TUint16 - the font size in twips |
|
122 */ |
|
123 inline TUint16 FontSize() { return iFontSize; }; |
|
124 |
|
125 /** |
|
126 * This method |
|
127 * @since 2.x |
|
128 * @param |
|
129 * @return TUint16 - the declared or default font size in twips |
|
130 */ |
|
131 inline TUint16 DeclaredFontSize() { return iDeclaredFontSizeInTwips; }; |
|
132 |
|
133 /** |
|
134 * This method |
|
135 * @since 2.1 |
|
136 * @param |
|
137 * @return |
|
138 */ |
|
139 inline TGDIFontVariant FontVariant() { return iFontVariant; }; |
|
140 |
|
141 /** |
|
142 * This method |
|
143 * @since 2.1 |
|
144 * @param |
|
145 * @return TUint16 |
|
146 */ |
|
147 inline TUint16 FontWeight() { return iFontWeight; }; |
|
148 |
|
149 /** |
|
150 * This method |
|
151 * @since 2.1 |
|
152 * @param |
|
153 * @return |
|
154 */ |
|
155 inline TGDIFontStyle FontStyle() { return iFontStyle; }; |
|
156 |
|
157 /** |
|
158 * This method |
|
159 * @since 2.x |
|
160 * @param TGDIFontInfo* whose height and baseline data will be populated |
|
161 * @return TBrowserStatusCode |
|
162 */ |
|
163 TBrowserStatusCode GetFontInfo( TGDIFontInfo* aFontInfo ); |
|
164 |
|
165 /** |
|
166 * This method |
|
167 * @since 2.x |
|
168 * @param |
|
169 * @return TUint8 width of the average character in pixels (based off of the 'w' character) |
|
170 */ |
|
171 TUint8 GetAverageCharWidthInPixels(); |
|
172 |
|
173 /** |
|
174 * This method |
|
175 * @since 2.1 |
|
176 * @param |
|
177 * @return |
|
178 */ |
|
179 const void* GetEpocNativeFont(); |
|
180 |
|
181 private: // New functions |
|
182 |
|
183 /** |
|
184 * C++ default constructor. |
|
185 */ |
|
186 CGDIFont(); |
|
187 |
|
188 /** |
|
189 * By default Symbian 2nd phase constructor is private. |
|
190 */ |
|
191 void ConstructL( const CGDIDeviceContext* aDeviceContext, |
|
192 const NW_Text_t* aFamily, |
|
193 TGDIFontStyle aStyle, |
|
194 TUint16 aSize, |
|
195 TUint16 aWeight, |
|
196 TGDIFontVariant aVariant ); |
|
197 |
|
198 private: // Data |
|
199 // |
|
200 HBufC* iFontFamily; |
|
201 // The font size value in twips |
|
202 TUint16 iFontSize; |
|
203 // |
|
204 TUint16 iDeclaredFontSizeInTwips; |
|
205 // |
|
206 TGDIFontVariant iFontVariant; |
|
207 // |
|
208 TGDIFontStyle iFontStyle; |
|
209 // |
|
210 TUint16 iFontWeight; |
|
211 // |
|
212 CGDIDeviceContext* iDeviceContext; |
|
213 // |
|
214 TBool iFontFound; |
|
215 }; |
|
216 |
|
217 |
|
218 #endif // _GDIFONT_H |