Update contrib.
2 * Copyright (c) 1996-2009 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.
29 const TInt KFontStoreFileUidVal = 0x10000039;
30 const TInt KCBitmapFontUidVal = 0x10000043;
31 const TInt KFnttranVersion = 42;
32 const TInt KFnttran7650Version = 39;
34 class CDirectFileStore;
35 NONSHARABLE_CLASS(CFontStoreFile) : public CBase
42 void ConstructL(const TParse& aParse, RFs& aFs);
44 static CFontStoreFile* NewL(const TParse& aParse, RFs& aFs);
46 inline const TDesC& FullName() const;
49 TInt iKPixelAspectRatio;
51 CDirectFileStore* iFileStore;
53 TStreamId iDataStreamId;
58 class TBitmapCodeSection : public TCodeSection
65 void InternalizeL(RReadStream& aStream);
66 void InternalizeOffsetsL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter);
67 void InternalizeBitmapL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter);
68 void FixUpComponents(TInt aFileAddress);
69 void DeleteOffsets(RHeap* aHeap);
70 void DeleteBitmap(RHeap* aHeap);
71 TBitmapFontCharacterOffset* CharacterOffsetsList(TBool aIsInRAM) const;
72 TUint8* Bitmap(TBool aIsInRAM) const;
77 TCharacterData() : iOffsetsId(KNullStreamIdValue) {}
79 TInt iCharacterOffsetsListOffset;
81 //iCharacterData is interpreted either as StreamId(casted from TUint32) or as TInt offset;
84 TBitmapData() : iBitmapId(KNullStreamIdValue) {}
88 //iBitmapData is interpreted either as StreamId(casted from TUint32) or as TInt offset;
89 //The size of the original TBitmapCodeSection was 24 bytes.
90 //Using the unions above (and removing RHeap* member) we reduce TBitmapCodeSection size
91 //to be 12 bytes per instance.
92 //It is possible to do that because iCharacterData and iBitmapData are treated as IDs during
93 //initialization stage and as offsets during all the time after initialization.
94 //So we can use the same memory for IDs and for offsets.
97 class TCharacterMetricsTable
99 Class to store the list of Character Metrics used in this font
105 TCharacterMetricsTable(RHeap* aHeap);
106 void InternalizeL(RReadStream& aStream);
107 void InternalizeMetricsL(RReadStream& aStream);
108 void RestoreL(const CStreamStore& aStreamStore);
109 void FixUp(TInt aFileAddress);
111 const TBitmapFontCharacterMetrics* Metric(TInt aIndex) const;
112 TInt NumberOfMetrics() const;
114 TBitmapFontCharacterMetrics* MetricsFromOffset(TInt aIndex) const;
117 TStreamId iMetricsStartId;
118 // Sometimes this address is on the metrics heap and sometimes in a ROM file
119 // If the address is on the heap, then this is actually an offset from
120 // the address of this class.
121 TInt iCharacterMetricsStartPtr;
122 TInt iNumberOfMetrics;
123 TBool iMetricsOnHeap;
126 NONSHARABLE_CLASS(CFontBitmap) : public CBase
132 CFontBitmap(RHeap* aHeap,CFontStoreFile* aFontStoreFile);
133 void InternalizeL(RReadStream &aStream, TInt aFontversion);
136 TBitmapFontCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
137 void operator delete(TAny*);
138 inline void operator delete(TAny*, TAny*) {}
139 void SetPosture(TFontPosture aPosture);
140 TFontPosture Posture() const;
141 void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
142 TFontStrokeWeight StrokeWeight() const;
143 void SetIsProportional(TBool aIsProportional);
144 TBool IsProportional() const;
145 CFontStoreFile* FontStoreFile() const;
146 inline TInt FontCapitalAscent() const;
147 inline TInt FontMaxAscent() const;
148 inline TInt FontStandardDescent() const;
149 inline TInt FontMaxDescent() const;
150 inline TInt FontLineGap() const;
151 inline TInt FontMaxHeight() const;
154 void RestoreComponentsL(); // Has reference to FontStoreFile
155 void DeleteComponents();
156 TBitmapCodeSection* CodeSectionList() const;
157 TCharacterMetricsTable* MetricsTable() const;
160 TInt iFontStoreFileOffset;
165 TInt8 iIsProportional;
169 TInt8 iCellHeightInPixels;
170 TInt8 iAscentInPixels;
171 TInt8 iMaxCharWidthInPixels;
172 TInt8 iMaxNormalCharWidthInPixels;
173 TInt iBitmapEncoding;
174 TInt iNumCodeSections;
175 TInt iCodeSectionListOffset;
177 TCharacterMetricsTable iCharacterMetricsTable;
178 TBool iComponentsRestored;
179 TInt iAllocMemCounter_Offsets;
180 TInt iAllocMemCounter_Bitmaps;
181 TInt iFontCapitalAscent; // The positive distance in pixels from the baseline to
182 // the top of an ANSI capital (whether or not there are
183 // ANSI capitals in the font)
184 TInt iFontMaxAscent; // The positive distance in pixels from the baseline to
185 // the top of the highest pre-composed glyph in the font
186 TInt iFontStandardDescent; // The positive distance in pixels from the baseline to
187 // the bottom of the lowest ANSI descender (whether or
188 // not there are ANSI chars in the font)
189 TInt iFontMaxDescent; // The positive distance in pixels from the baseline to
190 // the bottom of the lowest pre-composed glyph in the font
191 TInt iFontLineGap; // The recommended baseline to baseline gap for successive
192 // lines of text in the font
195 class TTypefaceFontBitmap
201 TTypefaceFontBitmap();
202 TTypefaceFontBitmap(TTypeface* aTypeface,CFontBitmap* aFontBitmap);
203 TInt HeightInPixels() const;
205 TTypeface* iTypeface;
206 CFontBitmap* iFontBitmap;
212 /** Gets the ascent of an ANSI capital letter in the font whether or not
213 there are any ANSI capitals in the font.
214 @return The positive distance from the font baseline to the top of a
215 standard ANSI capital letter
218 @see AscentInPixels()
221 inline TInt CFontBitmap::FontCapitalAscent() const
223 return iFontCapitalAscent;
226 /** Gets the max ascent of any pre-composed glyph in the font. This will
227 include accents or diacritics that form part of pre-composed glyphs. It is
228 not guaranteed to cover the max ascent of composite glyphs that have to be
229 created by a layout engine. This is also the recommended distance between
230 the top of a text box and the baseline of the first line of text.
231 @return The positive distance from the font baseline to the top of the
232 highest pre-composed glyph (including accents) above the baseline
235 @see AscentInPixels()
236 @see FontCapitalAscent()
238 inline TInt CFontBitmap::FontMaxAscent() const
240 return iFontMaxAscent;
243 /** Gets the descent of an ANSI descending character in the font.
244 Whether or not there are any ANSI descenders in the font.
245 @return The positive distance from the font baseline to the bottom of the
246 lowest ANSI descender
249 @see DescentInPixels()
251 inline TInt CFontBitmap::FontStandardDescent() const
253 return iFontStandardDescent;
256 /** Gets the max descent of any pre-composed glyph in the font. This will
257 include accents or diacritics that form part of pre-composed glyphs. It is
258 not guaranteed to cover the max descent of composite glyphs that have to be
259 created by a layout engine.
260 @return The positive distance from the font baseline to the bottom of the
261 lowest pre-composed glyph (including accents) below the baseline
264 @see DescentInPixels()
266 inline TInt CFontBitmap::FontMaxDescent() const
268 return iFontMaxDescent;
271 /** Gets the suggested line gap for the font. This is the recommended
272 baseline to baseline distance between successive lines of text in the font.
273 @return The positive recommended gap between successive lines
277 inline TInt CFontBitmap::FontLineGap() const
282 /** Gets the maximum height for the font. This is the sum of the max ascent
283 of the font and the max descent of the font.
284 @return The positive maximum height of the font
287 @see HeightInPixels()
289 inline TInt CFontBitmap::FontMaxHeight() const
291 return iFontMaxAscent + iFontMaxDescent;
295 /** Full filename that the bitmap font was loaded from.
298 inline const TDesC& CFontStoreFile::FullName() const
304 #endif // __FNTBODY_H__