|
1 /* |
|
2 * Copyright (c) 1997-2009 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 "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: |
|
15 * Header FNTRECRD.H |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __FNTRECRD_H__ |
|
21 #define __FNTRECRD_H__ |
|
22 |
|
23 #include "LEXICAL.H" |
|
24 #include "LST.H" |
|
25 #include "RECORD.H" |
|
26 #include "STRNG.H" |
|
27 #include "UID.H" |
|
28 /** |
|
29 @internalComponent |
|
30 */ |
|
31 const boolean PostureUpright = 0; |
|
32 const boolean PostureItalic = 1; |
|
33 /** |
|
34 @internalComponent |
|
35 */ |
|
36 const boolean StrokeWeightNormal = 0; |
|
37 const boolean StrokeWeightBold = 1; |
|
38 |
|
39 class BitmapOffset |
|
40 /** |
|
41 @internalComponent |
|
42 */ |
|
43 { |
|
44 public: |
|
45 BitmapOffset(uint16 aBitmapOffset); |
|
46 void Externalize(ostream& out); |
|
47 public: |
|
48 uint16 iBitmapOffset; // restricts bitmap to 64k |
|
49 }; |
|
50 |
|
51 class CharacterMetrics |
|
52 /** |
|
53 @internalComponent |
|
54 */ |
|
55 { |
|
56 public: |
|
57 CharacterMetrics(); |
|
58 void Externalize(ostream& out); |
|
59 public: |
|
60 chardim iAscentInPixels; |
|
61 chardim iHeightInPixels; |
|
62 chardim iLeftAdjustInPixels; |
|
63 chardim iMoveInPixels; |
|
64 chardim iRightAdjustInPixels; |
|
65 }; |
|
66 |
|
67 |
|
68 class MetricDistributionMember |
|
69 /** |
|
70 Class which wraps up a given metric with the number of characters that use it |
|
71 @internalComponent |
|
72 */ |
|
73 { |
|
74 public: |
|
75 ~MetricDistributionMember(); |
|
76 MetricDistributionMember(); |
|
77 public: |
|
78 CharacterMetrics* Metric() const; |
|
79 int Frequency() const; |
|
80 void IncrementFrequency(int aIncrementBy = 1); |
|
81 void SetMetric(CharacterMetrics* aMetric); |
|
82 void SetFrequency(int aFrequency); |
|
83 void Externalize(ostream& out); |
|
84 private: |
|
85 int iFrequency; |
|
86 CharacterMetrics* iMetric; |
|
87 }; |
|
88 |
|
89 class MetricDistribution |
|
90 /** |
|
91 Class which maintains a list of metrics and the number of characters using each, |
|
92 along with the ability to sort them into most popular first order. |
|
93 @internalComponent |
|
94 */ |
|
95 { |
|
96 public: |
|
97 ~MetricDistribution(); |
|
98 static MetricDistribution* New(); |
|
99 public: |
|
100 void SortMetricsByFrequency(); |
|
101 void SetIndex(const CharacterMetrics& aMetrics, int aIndex); |
|
102 int Index(const CharacterMetrics& aMetrics); |
|
103 void Externalize(ostream& out); |
|
104 void ExternalizeComponents(ostream& out); |
|
105 void AddOrIncrementMetric(const CharacterMetrics& aMetrics, int aFrequency = 1); |
|
106 const CharacterMetrics& MostPopular(int aStartIndex); |
|
107 private: |
|
108 MetricDistribution(); |
|
109 public: |
|
110 ObjectList<MetricDistributionMember*> iCharacterMetricsList; |
|
111 streampos iStreamId; |
|
112 }; |
|
113 |
|
114 class Characters |
|
115 /** |
|
116 @internalComponent |
|
117 */ |
|
118 { |
|
119 public: |
|
120 void Externalize(ostream& out); |
|
121 ObjectList<BitmapOffset*> iBitmapOffsetList; |
|
122 ~Characters(); |
|
123 public: |
|
124 streampos iStreamId; |
|
125 }; |
|
126 |
|
127 class ByteList |
|
128 /** |
|
129 @internalComponent |
|
130 */ |
|
131 { |
|
132 public: |
|
133 ByteList(); |
|
134 void AddBit(char aBit); |
|
135 void NewByte(); |
|
136 int Length() const; |
|
137 void Externalize(ostream& out); |
|
138 private: |
|
139 String iString; |
|
140 char iOffset; |
|
141 }; |
|
142 |
|
143 class CharactersBitmap : public Record |
|
144 /** |
|
145 @internalComponent |
|
146 */ |
|
147 { |
|
148 public: |
|
149 void AddIndex(int aIndex); |
|
150 void Externalize(ostream& out); |
|
151 public: |
|
152 ByteList iByteList; |
|
153 streampos iStreamId; |
|
154 }; |
|
155 |
|
156 class BitmapCodeSection |
|
157 /** |
|
158 @internalComponent |
|
159 */ |
|
160 { |
|
161 public: |
|
162 void Externalize(ostream& out); |
|
163 void ExternalizeComponents(ostream& out); |
|
164 public: |
|
165 uint16 iStart; |
|
166 uint16 iEnd; |
|
167 Characters iCharacters; |
|
168 CharactersBitmap iCharactersBitmap; |
|
169 }; |
|
170 |
|
171 class FontBitmap : public Record |
|
172 /** |
|
173 @internalComponent |
|
174 */ |
|
175 { |
|
176 public: |
|
177 FontBitmap(); |
|
178 void Externalize(ostream& out); |
|
179 void ExternalizeComponents(ostream& out); |
|
180 ~FontBitmap(); |
|
181 public: |
|
182 uid iUid; |
|
183 boolean iPosture; |
|
184 boolean iStrokeWeight; |
|
185 boolean iIsProportional; |
|
186 chardim iCellHeightInPixels; |
|
187 chardim iAscentInPixels; |
|
188 chardim iMaxCharWidthInPixels; |
|
189 chardim iMaxNormalCharWidthInPixels; |
|
190 int32 iBitmapEncoding; |
|
191 ObjectList<BitmapCodeSection*> iCodeSectionList; |
|
192 MetricDistribution* iCharacterMetrics; |
|
193 }; |
|
194 |
|
195 class TypefaceFontBitmap |
|
196 /** |
|
197 @internalComponent |
|
198 */ |
|
199 { |
|
200 public: |
|
201 TypefaceFontBitmap(FontBitmap* aFontBitmap); |
|
202 TypefaceFontBitmap(uid aFontBitmapUid); |
|
203 void Externalize(ostream& out); |
|
204 public: |
|
205 FontBitmap* iFontBitmap; |
|
206 uid iFontBitmapUid; |
|
207 char iWidthFactor; |
|
208 char iHeightFactor; |
|
209 }; |
|
210 |
|
211 class FntTypeface : public Record, public Typeface |
|
212 /** |
|
213 @internalComponent |
|
214 */ |
|
215 { |
|
216 public: |
|
217 void Externalize(ostream& out); |
|
218 public: |
|
219 ObjectList<TypefaceFontBitmap*> iTypefaceFontBitmapList; |
|
220 }; |
|
221 |
|
222 class FontStoreFile : public Record |
|
223 /** |
|
224 @internalComponent |
|
225 */ |
|
226 { |
|
227 public: |
|
228 FontStoreFile(); |
|
229 void AddTypeface(FntTypeface* aTypeface); |
|
230 void AddFontBitmap(FontBitmap* aFontBitmap); |
|
231 void Externalize(ostream& out); |
|
232 private: |
|
233 void ExternalizeHeader(ostream& out); |
|
234 void ExternalizeComponents(ostream& out); |
|
235 public: |
|
236 uid iCollectionUid; |
|
237 int32 iKPixelAspectRatio; |
|
238 ObjectList<String*> iCopyrightInfo; |
|
239 private: |
|
240 streampos iDataStreamId; |
|
241 RecordList iFontBitmapList; |
|
242 RecordList iTypefaceList; |
|
243 }; |
|
244 |
|
245 class FontStore |
|
246 /** |
|
247 @internalComponent |
|
248 */ |
|
249 { |
|
250 public: |
|
251 boolean Store(const String& aFilename); |
|
252 void AddFontStoreFile(FontStoreFile* aFontStoreFile); |
|
253 void AddFontBitmap(FontBitmap* aFontBitmap); |
|
254 Record* FindFontBitmap(String& aLabel); |
|
255 void AddTypeface(FntTypeface* aTypeface); |
|
256 Record* FindTypeface(String& aLabel); |
|
257 FontStore(); |
|
258 ~FontStore(); |
|
259 private: |
|
260 FontStoreFile* iFontStoreFile; |
|
261 RecordList iFontBitmapList; |
|
262 RecordList iTypefaceList; |
|
263 }; |
|
264 |
|
265 #endif |