1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/fontstore/src/FNTBODY.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,304 @@
1.4 +/*
1.5 +* Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef __FNTBODY_H__
1.23 +#define __FNTBODY_H__
1.24 +
1.25 +#include <e32std.h>
1.26 +#include "FNTSTD.H"
1.27 +
1.28 +/**
1.29 +@internalComponent
1.30 +*/
1.31 +
1.32 +const TInt KFontStoreFileUidVal = 0x10000039;
1.33 +const TInt KCBitmapFontUidVal = 0x10000043;
1.34 +const TInt KFnttranVersion = 42;
1.35 +const TInt KFnttran7650Version = 39;
1.36 +
1.37 +class CDirectFileStore;
1.38 +NONSHARABLE_CLASS(CFontStoreFile) : public CBase
1.39 +/**
1.40 +@internalComponent
1.41 +*/
1.42 + {
1.43 +protected:
1.44 + CFontStoreFile();
1.45 + void ConstructL(const TParse& aParse, RFs& aFs);
1.46 +public:
1.47 + static CFontStoreFile* NewL(const TParse& aParse, RFs& aFs);
1.48 + ~CFontStoreFile();
1.49 + inline const TDesC& FullName() const;
1.50 +public:
1.51 + TUid iCollectionUid;
1.52 + TInt iKPixelAspectRatio;
1.53 + TInt iUsageCount;
1.54 + CDirectFileStore* iFileStore;
1.55 + TInt iFileAddress;
1.56 + TStreamId iDataStreamId;
1.57 + TInt iFontVersion;
1.58 + HBufC* iFullName;
1.59 + };
1.60 +
1.61 +class TBitmapCodeSection : public TCodeSection
1.62 +/**
1.63 +@internalComponent
1.64 +*/
1.65 + {
1.66 +public:
1.67 + TBitmapCodeSection();
1.68 + void InternalizeL(RReadStream& aStream);
1.69 + void InternalizeOffsetsL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter);
1.70 + void InternalizeBitmapL(const CStreamStore& aStreamStore, RHeap* aHeap, TInt& aAllocMemCounter);
1.71 + void FixUpComponents(TInt aFileAddress);
1.72 + void DeleteOffsets(RHeap* aHeap);
1.73 + void DeleteBitmap(RHeap* aHeap);
1.74 + TBitmapFontCharacterOffset* CharacterOffsetsList(TBool aIsInRAM) const;
1.75 + TUint8* Bitmap(TBool aIsInRAM) const;
1.76 +
1.77 +private:
1.78 + union TCharacterData
1.79 + {
1.80 + TCharacterData() : iOffsetsId(KNullStreamIdValue) {}
1.81 + TUint32 iOffsetsId;
1.82 + TInt iCharacterOffsetsListOffset;
1.83 + } iCharacterData;
1.84 + //iCharacterData is interpreted either as StreamId(casted from TUint32) or as TInt offset;
1.85 + union TBitmapData
1.86 + {
1.87 + TBitmapData() : iBitmapId(KNullStreamIdValue) {}
1.88 + TUint32 iBitmapId;
1.89 + TInt iBitmapOffset;
1.90 + } iBitmapData;
1.91 + //iBitmapData is interpreted either as StreamId(casted from TUint32) or as TInt offset;
1.92 + //The size of the original TBitmapCodeSection was 24 bytes.
1.93 + //Using the unions above (and removing RHeap* member) we reduce TBitmapCodeSection size
1.94 + //to be 12 bytes per instance.
1.95 + //It is possible to do that because iCharacterData and iBitmapData are treated as IDs during
1.96 + //initialization stage and as offsets during all the time after initialization.
1.97 + //So we can use the same memory for IDs and for offsets.
1.98 + };
1.99 +
1.100 +class TCharacterMetricsTable
1.101 +/**
1.102 +Class to store the list of Character Metrics used in this font
1.103 +@since 7.0s
1.104 +@internalComponent
1.105 +*/
1.106 + {
1.107 +public:
1.108 + TCharacterMetricsTable(RHeap* aHeap);
1.109 + void InternalizeL(RReadStream& aStream);
1.110 + void InternalizeMetricsL(RReadStream& aStream);
1.111 + void RestoreL(const CStreamStore& aStreamStore);
1.112 + void FixUp(TInt aFileAddress);
1.113 + void Delete();
1.114 + const TBitmapFontCharacterMetrics* Metric(TInt aIndex) const;
1.115 + TInt NumberOfMetrics() const;
1.116 +private:
1.117 + TBitmapFontCharacterMetrics* MetricsFromOffset(TInt aIndex) const;
1.118 +private:
1.119 + RHeap* iHeap;
1.120 + TStreamId iMetricsStartId;
1.121 + // Sometimes this address is on the metrics heap and sometimes in a ROM file
1.122 + // If the address is on the heap, then this is actually an offset from
1.123 + // the address of this class.
1.124 + TInt iCharacterMetricsStartPtr;
1.125 + TInt iNumberOfMetrics;
1.126 + TBool iMetricsOnHeap;
1.127 + };
1.128 +
1.129 +NONSHARABLE_CLASS(CFontBitmap) : public CBase
1.130 +/**
1.131 +@internalComponent
1.132 +*/
1.133 + {
1.134 +public:
1.135 + CFontBitmap(RHeap* aHeap,CFontStoreFile* aFontStoreFile);
1.136 + void InternalizeL(RReadStream &aStream, TInt aFontversion);
1.137 + void UseL();
1.138 + void Release();
1.139 + TBitmapFontCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
1.140 + void operator delete(TAny*);
1.141 + inline void operator delete(TAny*, TAny*) {}
1.142 + void SetPosture(TFontPosture aPosture);
1.143 + TFontPosture Posture() const;
1.144 + void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
1.145 + TFontStrokeWeight StrokeWeight() const;
1.146 + void SetIsProportional(TBool aIsProportional);
1.147 + TBool IsProportional() const;
1.148 + CFontStoreFile* FontStoreFile() const;
1.149 + inline TInt FontCapitalAscent() const;
1.150 + inline TInt FontMaxAscent() const;
1.151 + inline TInt FontStandardDescent() const;
1.152 + inline TInt FontMaxDescent() const;
1.153 + inline TInt FontLineGap() const;
1.154 + inline TInt FontMaxHeight() const;
1.155 +protected:
1.156 + ~CFontBitmap();
1.157 + void RestoreComponentsL(); // Has reference to FontStoreFile
1.158 + void DeleteComponents();
1.159 + TBitmapCodeSection* CodeSectionList() const;
1.160 + TCharacterMetricsTable* MetricsTable() const;
1.161 +public:
1.162 + RHeap* iHeap;
1.163 + TInt iFontStoreFileOffset;
1.164 + TUid iUid;
1.165 +protected:
1.166 + TInt8 iPosture;
1.167 + TInt8 iStrokeWeight;
1.168 + TInt8 iIsProportional;
1.169 + TBool iIsInRAM;
1.170 + TInt iUsageCount;
1.171 +public:
1.172 + TInt8 iCellHeightInPixels;
1.173 + TInt8 iAscentInPixels;
1.174 + TInt8 iMaxCharWidthInPixels;
1.175 + TInt8 iMaxNormalCharWidthInPixels;
1.176 + TInt iBitmapEncoding;
1.177 + TInt iNumCodeSections;
1.178 + TInt iCodeSectionListOffset;
1.179 +private:
1.180 + TCharacterMetricsTable iCharacterMetricsTable;
1.181 + TBool iComponentsRestored;
1.182 + TInt iAllocMemCounter_Offsets;
1.183 + TInt iAllocMemCounter_Bitmaps;
1.184 + TInt iFontCapitalAscent; // The positive distance in pixels from the baseline to
1.185 + // the top of an ANSI capital (whether or not there are
1.186 + // ANSI capitals in the font)
1.187 + TInt iFontMaxAscent; // The positive distance in pixels from the baseline to
1.188 + // the top of the highest pre-composed glyph in the font
1.189 + TInt iFontStandardDescent; // The positive distance in pixels from the baseline to
1.190 + // the bottom of the lowest ANSI descender (whether or
1.191 + // not there are ANSI chars in the font)
1.192 + TInt iFontMaxDescent; // The positive distance in pixels from the baseline to
1.193 + // the bottom of the lowest pre-composed glyph in the font
1.194 + TInt iFontLineGap; // The recommended baseline to baseline gap for successive
1.195 + // lines of text in the font
1.196 + };
1.197 +
1.198 +class TTypefaceFontBitmap
1.199 +/**
1.200 +@internalComponent
1.201 +*/
1.202 + {
1.203 +public:
1.204 + TTypefaceFontBitmap();
1.205 + TTypefaceFontBitmap(TTypeface* aTypeface,CFontBitmap* aFontBitmap);
1.206 + TInt HeightInPixels() const;
1.207 +public:
1.208 + TTypeface* iTypeface;
1.209 + CFontBitmap* iFontBitmap;
1.210 + TInt8 iHeightFactor;
1.211 + TInt8 iWidthFactor;
1.212 + };
1.213 +
1.214 +
1.215 +/** Gets the ascent of an ANSI capital letter in the font whether or not
1.216 +there are any ANSI capitals in the font.
1.217 +@return The positive distance from the font baseline to the top of a
1.218 +standard ANSI capital letter
1.219 +@internalComponent
1.220 +@released
1.221 +@see AscentInPixels()
1.222 +@see FontMaxAscent()
1.223 +*/
1.224 +inline TInt CFontBitmap::FontCapitalAscent() const
1.225 + {
1.226 + return iFontCapitalAscent;
1.227 + }
1.228 +
1.229 +/** Gets the max ascent of any pre-composed glyph in the font. This will
1.230 +include accents or diacritics that form part of pre-composed glyphs. It is
1.231 +not guaranteed to cover the max ascent of composite glyphs that have to be
1.232 +created by a layout engine. This is also the recommended distance between
1.233 +the top of a text box and the baseline of the first line of text.
1.234 +@return The positive distance from the font baseline to the top of the
1.235 +highest pre-composed glyph (including accents) above the baseline
1.236 +@internalComponent
1.237 +@released
1.238 +@see AscentInPixels()
1.239 +@see FontCapitalAscent()
1.240 +*/
1.241 +inline TInt CFontBitmap::FontMaxAscent() const
1.242 + {
1.243 + return iFontMaxAscent;
1.244 + }
1.245 +
1.246 +/** Gets the descent of an ANSI descending character in the font.
1.247 +Whether or not there are any ANSI descenders in the font.
1.248 +@return The positive distance from the font baseline to the bottom of the
1.249 +lowest ANSI descender
1.250 +@internalComponent
1.251 +@released
1.252 +@see DescentInPixels()
1.253 +*/
1.254 +inline TInt CFontBitmap::FontStandardDescent() const
1.255 + {
1.256 + return iFontStandardDescent;
1.257 + }
1.258 +
1.259 +/** Gets the max descent of any pre-composed glyph in the font. This will
1.260 +include accents or diacritics that form part of pre-composed glyphs. It is
1.261 +not guaranteed to cover the max descent of composite glyphs that have to be
1.262 +created by a layout engine.
1.263 +@return The positive distance from the font baseline to the bottom of the
1.264 +lowest pre-composed glyph (including accents) below the baseline
1.265 +@internalComponent
1.266 +@released
1.267 +@see DescentInPixels()
1.268 +*/
1.269 +inline TInt CFontBitmap::FontMaxDescent() const
1.270 + {
1.271 + return iFontMaxDescent;
1.272 + }
1.273 +
1.274 +/** Gets the suggested line gap for the font. This is the recommended
1.275 +baseline to baseline distance between successive lines of text in the font.
1.276 +@return The positive recommended gap between successive lines
1.277 +@internalComponent
1.278 +@released
1.279 +*/
1.280 +inline TInt CFontBitmap::FontLineGap() const
1.281 + {
1.282 + return iFontLineGap;
1.283 + }
1.284 +
1.285 +/** Gets the maximum height for the font. This is the sum of the max ascent
1.286 +of the font and the max descent of the font.
1.287 +@return The positive maximum height of the font
1.288 +@internalComponent
1.289 +@released
1.290 +@see HeightInPixels()
1.291 +*/
1.292 +inline TInt CFontBitmap::FontMaxHeight() const
1.293 + {
1.294 + return iFontMaxAscent + iFontMaxDescent;
1.295 + }
1.296 +
1.297 +
1.298 +/** Full filename that the bitmap font was loaded from.
1.299 +@internalComponent
1.300 +*/
1.301 +inline const TDesC& CFontStoreFile::FullName() const
1.302 + {
1.303 + return *iFullName;
1.304 + }
1.305 +
1.306 +
1.307 +#endif // __FNTBODY_H__