epoc32/include/fntstore.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description: 
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@2
    18
williamr@2
    19
#ifndef FNTSTORE_H__
williamr@2
    20
#define FNTSTORE_H__
williamr@2
    21
williamr@2
    22
#include <e32std.h>
williamr@2
    23
#include <f32file.h>
williamr@2
    24
#include <gdi.h>
williamr@2
    25
#include <openfont.h>
williamr@4
    26
#include <linkedfonts.h>
williamr@4
    27
williamr@4
    28
williamr@4
    29
/** Defines the maximum number of linked typefaces that may be placed in a linked typeface specification 
williamr@4
    30
WARNING: Constant for internal use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
    31
@publishedAll
williamr@4
    32
@released
williamr@4
    33
 */
williamr@4
    34
const TInt KMaxLinkedTypefaces = 12;
williamr@4
    35
/** Defines the maximum number of linked typeface groups that may be placed in a linked typeface specification
williamr@4
    36
WARNING: Constant for internal use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
    37
@publishedAll
williamr@4
    38
@released
williamr@4
    39
 */
williamr@4
    40
const TInt KMaxLinkedTypefaceGroups = 12;
williamr@4
    41
williamr@4
    42
/** Defines the maximun number of threads that may tranverse the COpenFontSessionCacheList (read-only)
williamr@4
    43
 @publishedAll
williamr@4
    44
 @released
williamr@4
    45
 */ 
williamr@4
    46
const TInt KSessionCacheSemaphoreCount = 12;
williamr@4
    47
williamr@4
    48
/** Defines the name of the semaphore which is used to exclude threads that may tranverse 
williamr@4
    49
 * the COpenFontSessionCacheList (read-only) with FBserv.
williamr@4
    50
 @publishedAll
williamr@4
    51
 @released
williamr@4
    52
 */
williamr@4
    53
_LIT(KSessionCacheSemaphoreName,"FBSSessionCacheSemaphore");
williamr@2
    54
williamr@2
    55
class CLinkedTypefaceSpecification;
williamr@4
    56
class TLinkedTypefaceSpecificationArgs;
williamr@2
    57
class CFbClient;
williamr@2
    58
class CFontStoreFile;
williamr@2
    59
class CFontBitmap;
williamr@2
    60
class RReadStream;
williamr@2
    61
class TTypefaceFontBitmap;
williamr@2
    62
class TShapeHeader;
williamr@2
    63
class TShapeMessageParameters;
williamr@2
    64
class CTypefaceSupportInfo;
williamr@4
    65
class COpenFontRasterizer;
williamr@4
    66
class CLinkedTypefaceGroup;
williamr@4
    67
IMPORT_C extern const TInt8 KLinkedFontDrive;
williamr@4
    68
IMPORT_C extern const TUint32 KFontTable_GlyphOutline_CacheMaxMem;
williamr@2
    69
williamr@2
    70
/**
williamr@4
    71
WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
    72
@publishedAll
williamr@4
    73
@released
williamr@4
    74
 */
williamr@2
    75
class TCharacterMetrics
williamr@2
    76
	{
williamr@4
    77
public:
williamr@2
    78
	IMPORT_C TCharacterMetrics();
williamr@2
    79
williamr@4
    80
public:
williamr@2
    81
	TInt16 iAscentInPixels;
williamr@2
    82
	TInt16 iHeightInPixels;
williamr@2
    83
	TInt16 iLeftAdjustInPixels;
williamr@2
    84
	TInt16 iMoveInPixels;
williamr@2
    85
	TInt16 iRightAdjustInPixels;
williamr@2
    86
	};
williamr@2
    87
williamr@2
    88
/** 
williamr@2
    89
An algorithmic style for how a font is drawn.
williamr@2
    90
williamr@2
    91
Holds attributes such as whether the font is bold or italic, and the width 
williamr@2
    92
and height factors. This is used as an input parameter for the GetFontById() method
williamr@2
    93
of some font management classes. See CWsScreenDevice::GetFontById() for more information.
williamr@2
    94
@publishedAll
williamr@2
    95
@released
williamr@2
    96
@see CWsScreenDevice::GetFontById()
williamr@2
    97
@see CFbsTypefaceStore::GetFontById()
williamr@2
    98
@see CFbsDevice::GetFontById()
williamr@2
    99
*/
williamr@4
   100
class TAlgStyle
williamr@2
   101
	{
williamr@2
   102
public:
williamr@2
   103
	IMPORT_C TAlgStyle();
williamr@2
   104
	IMPORT_C void SetIsBold(TBool aIsBold);
williamr@2
   105
	IMPORT_C void SetIsItalic(TBool aIsItalic);
williamr@2
   106
	IMPORT_C void SetIsMono(TBool aIsMono);
williamr@2
   107
	IMPORT_C void SetWidthFactor(TInt aWidthFactor);
williamr@2
   108
	IMPORT_C void SetHeightFactor(TInt aHeightFactor);
williamr@2
   109
	IMPORT_C TBool IsBold() const;
williamr@2
   110
	IMPORT_C TBool IsItalic() const;
williamr@2
   111
	IMPORT_C TBool IsMono() const;
williamr@2
   112
	IMPORT_C TInt WidthFactor() const;
williamr@2
   113
	IMPORT_C TInt HeightFactor() const;
williamr@2
   114
	IMPORT_C TBool operator==(const TAlgStyle& aAlgStyle) const;
williamr@2
   115
	TBool operator!=(const TAlgStyle& aAlgStyle) const;
williamr@2
   116
public:
williamr@2
   117
	/** Baseline offset in pixels. */
williamr@2
   118
	TInt iBaselineOffsetInPixels;
williamr@2
   119
private:
williamr@2
   120
	enum
williamr@2
   121
		{
williamr@2
   122
		EBold=1,
williamr@2
   123
		EItalic=2,
williamr@2
   124
		EMono=4,
williamr@2
   125
		};
williamr@2
   126
	/** This member is private and not intended for use. */
williamr@2
   127
	TInt8 iFlags;
williamr@2
   128
	/** This member is private and not intended for use. */
williamr@2
   129
	TInt8 iWidthFactor;
williamr@2
   130
	/** This member is private and not intended for use. */
williamr@2
   131
	TInt8 iHeightFactor;
williamr@2
   132
	};
williamr@2
   133
williamr@2
   134
/** 
williamr@2
   135
Bitmap font class.
williamr@2
   136
An object of this class may either access and use a bitmap font (a CFontBitmap)
williamr@2
   137
or an open font (a COpenFont).
williamr@2
   138
Stored in a CFontStore.
williamr@2
   139
@publishedAll
williamr@2
   140
@released
williamr@2
   141
*/
williamr@2
   142
class CBitmapFont : public CFont
williamr@2
   143
	{
williamr@4
   144
	friend class CFbsFont;
williamr@2
   145
	friend class CFontStore;
williamr@4
   146
	friend class CFbsBitGc;
williamr@2
   147
public:
williamr@2
   148
	// New functions
williamr@2
   149
	TUid Uid() const;
williamr@2
   150
	IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
williamr@2
   151
	IMPORT_C TBool GetCharacterData(TInt aSessionHandle, TInt aCode, TOpenFontCharMetrics& aMetrics, const TUint8*& aBitmap) const;
williamr@2
   152
	IMPORT_C TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData) const;
williamr@2
   153
	IMPORT_C void GetFontMetrics(TOpenFontMetrics& aMetrics) const;
williamr@2
   154
	IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const;
williamr@2
   155
	IMPORT_C TInt BitmapEncoding() const;
williamr@2
   156
	IMPORT_C TBool HasCharacterL(TInt aCode) const;
williamr@2
   157
	IMPORT_C TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
williamr@2
   158
	IMPORT_C TShapeHeader* ShapeTextL(const TDesC16& aText,
williamr@2
   159
		TInt aSessionHandle, const TShapeMessageParameters& aParams);
williamr@2
   160
	IMPORT_C void DeleteShape(TInt aSessionHandle,TShapeHeader* aHeader);
williamr@2
   161
	IMPORT_C void operator delete(TAny*);
williamr@2
   162
	inline TBool IsOpenFont() const;
williamr@2
   163
	inline COpenFont* OpenFont() const;
williamr@2
   164
	inline TGlyphBitmapType GlyphBitmapType() const;
williamr@4
   165
	IMPORT_C TUint32 UniqueFontId();
williamr@4
   166
	IMPORT_C TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, 
williamr@4
   167
	        TInt& aLength, TInt aSessionHandle);
williamr@4
   168
    IMPORT_C TInt GetGlyphOutline(TUint aCode,  
williamr@4
   169
            TBool aHinted, TAny*& aOutline, TInt& aLength, TInt aSessionHandle);
williamr@4
   170
    IMPORT_C void ReleaseGlyphOutlines(TInt aCount, const TUint* aCodes,  
williamr@4
   171
            TBool aHinted, TInt aSessionHandle);
williamr@4
   172
    IMPORT_C void ReleaseFontTable(TUint32 aTag, TInt aSessionHandle);
williamr@4
   173
    
williamr@2
   174
private:
williamr@2
   175
	// From CFont
williamr@2
   176
	IMPORT_C virtual TUid DoTypeUid() const;
williamr@2
   177
	IMPORT_C virtual TInt DoHeightInPixels() const;
williamr@2
   178
	IMPORT_C virtual TInt DoAscentInPixels() const;
williamr@2
   179
	IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const;
williamr@2
   180
	IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC &aText) const;
williamr@2
   181
	IMPORT_C virtual TInt DoBaselineOffsetInPixels() const;
williamr@2
   182
	IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels) const;
williamr@2
   183
	IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels, TInt &aExcessWidthInPixels) const;
williamr@2
   184
	IMPORT_C virtual TInt DoMaxCharWidthInPixels() const;
williamr@2
   185
	IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const;
williamr@2
   186
	IMPORT_C virtual TFontSpec DoFontSpecInTwips() const;
williamr@2
   187
	IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
williamr@2
   188
williamr@2
   189
private:
williamr@2
   190
	CBitmapFont(RHeap* aHeap,const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, CFontBitmap* aFontBitmap);
williamr@2
   191
	CBitmapFont(RHeap* aHeap,const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, COpenFont* aOpenFont);
williamr@2
   192
	void ConstructL();
williamr@2
   193
	~CBitmapFont();
williamr@2
   194
	static CBitmapFont* NewL(RHeap* aHeap, const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, CFontBitmap* aFontBitmap);
williamr@2
   195
	static CBitmapFont* NewL(RHeap* aHeap, const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, COpenFont* aOpenFont);
williamr@2
   196
	inline void operator delete(TAny*, TAny*) {}
williamr@2
   197
	TInt Width(TInt aNum) const;
williamr@2
   198
	TInt Height(TInt aNum) const;
williamr@2
   199
	CFontBitmap* FontBitmap() const;
williamr@2
   200
	void InstallOpenFontShaper(COpenFont* aOpenFont, CShaper::TInput& aShaperInput);
williamr@4
   201
	TInt DoTextWidthInPixels(const TDesC &aText, const TMeasureTextInput* aParam) const;
williamr@4
   202
	void SetUniqueFontId(TUint32 aUniqueFontId);
williamr@2
   203
williamr@2
   204
private:
williamr@2
   205
	TFontSpec iFontSpecInTwips;
williamr@2
   206
williamr@2
   207
public:
williamr@2
   208
	/** The algorithmic font style. */
williamr@2
   209
	TAlgStyle iAlgStyle;	// must not move this member
williamr@2
   210
williamr@2
   211
private:
williamr@4
   212
    // Binary Compatibility warning - data member iOpenFont is referenced by inline methods
williamr@4
   213
    RHeap* iHeap;
williamr@4
   214
    TInt iFontBitmapOffset;
williamr@4
   215
    
williamr@4
   216
    // In order to be able to work with the flexible memory model, iOpenFont is
williamr@4
   217
    // actually an offset from the address of this class.
williamr@4
   218
    // iOpenFont's type remains unchanged.
williamr@4
   219
    // As Qt code that uses OpenFont() must be able to run on new and old versions
williamr@4
   220
    // of Symbian OS, it must be able to determine whether iOpenFont is a pointer or
williamr@4
   221
    // an offset at run-time.  Therefore an offset will have its lowest significant bit set to 1.
williamr@4
   222
    // If iOpenFont is null, this object is not an open font.
williamr@4
   223
    // Assumption: a pointer always has least significant bit value of zero.
williamr@4
   224
    COpenFont* iOpenFont; // if iOpenFont is non-null this is an open font and many functions are forwarded to it
williamr@2
   225
williamr@4
   226
    TUint32 iReserved;
williamr@4
   227
    TUint32 iUniqueFontId; // unique id for this instance of this font
williamr@4
   228
	};
williamr@4
   229
williamr@4
   230
/**
williamr@4
   231
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
   232
@publishedAll
williamr@4
   233
@released
williamr@4
   234
 */
williamr@4
   235
class TLinkedTypefaceGroupArgs
williamr@4
   236
	{
williamr@4
   237
public:
williamr@4
   238
	TInt iGroupId;
williamr@4
   239
	CLinkedTypefaceGroup::TScalingOption iScalingOption;
williamr@4
   240
	CLinkedTypefaceGroup::TBaselineShift iBaselineShift;
williamr@4
   241
	TInt iAntialiasingThreshold;
williamr@4
   242
	TInt iBoldnessPercentage;
williamr@4
   243
	TInt iItalicAngle;
williamr@4
   244
public:
williamr@4
   245
	void operator =(const CLinkedTypefaceGroup* aRhs);
williamr@4
   246
	};
williamr@4
   247
williamr@4
   248
class COpenFontLinkedTypefaceElementSpec;
williamr@4
   249
class COpenFontLinkedTypefaceSpecification;
williamr@4
   250
williamr@4
   251
/**
williamr@4
   252
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
   253
@publishedAll
williamr@4
   254
@released
williamr@4
   255
 */
williamr@4
   256
class TLinkedTypefaceElementSpecArgs
williamr@4
   257
	{
williamr@4
   258
public:
williamr@4
   259
	TBufC<KMaxTypefaceNameLength> iName;
williamr@4
   260
	TBool iIsCanonical;
williamr@4
   261
	TInt iGroupId;
williamr@4
   262
	
williamr@4
   263
	void operator = (const CLinkedTypefaceElementSpec* aRhs);
williamr@4
   264
	void operator = (const COpenFontLinkedTypefaceElementSpec* aRhs);
williamr@4
   265
	};
williamr@4
   266
williamr@4
   267
/**
williamr@4
   268
WARNING: Class for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
   269
@publishedAll
williamr@4
   270
@released
williamr@4
   271
 */
williamr@4
   272
class TLinkedTypefaceSpecificationArgs
williamr@4
   273
	{
williamr@4
   274
public:
williamr@4
   275
	TBufC<KMaxTypefaceNameLength> iName;
williamr@4
   276
	TLinkedTypefaceElementSpecArgs iTypefaces[KMaxLinkedTypefaces];
williamr@4
   277
	TLinkedTypefaceGroupArgs iGroups[KMaxLinkedTypefaceGroups];
williamr@4
   278
	TInt	iSize;
williamr@4
   279
	TInt	iGroupSize;
williamr@4
   280
	TInt	iCanonicalIndex;
williamr@4
   281
	
williamr@4
   282
	IMPORT_C void operator = (const CLinkedTypefaceSpecification& aRhs);
williamr@4
   283
	IMPORT_C void operator = (const COpenFontLinkedTypefaceSpecification& aRhs);
williamr@2
   284
	};
williamr@2
   285
	
williamr@4
   286
williamr@4
   287
williamr@4
   288
class TUnhintedOutlineId;
williamr@4
   289
class THintedOutlineId;
williamr@4
   290
class CFontTableCache;
williamr@4
   291
class CUnhintedOutlineCache;
williamr@4
   292
class CHintedOutlineCache;
williamr@4
   293
class TFontTableGlyphOutlineCacheMemMonitor;
williamr@4
   294
williamr@2
   295
class CFontStore : public CTypefaceStore
williamr@2
   296
/** 
williamr@2
   297
A store for fonts.
williamr@2
   298
williamr@2
   299
Stores and handles both open and fixed-size fonts. Open fonts are made from 
williamr@2
   300
open (scalable) typefaces by Open Font plug-in rasterizers. Fonts of other 
williamr@2
   301
typefaces are stored in a limited number of fixed sizes. However, which is 
williamr@2
   302
being used is transparent to the user of this class. For example the GetNearestFont...() 
williamr@2
   303
functions get a bitmap font which may be retrieved from memory or generated 
williamr@2
   304
via a rasterizer.
williamr@2
   305
@publishedAll
williamr@2
   306
@released
williamr@2
   307
*/
williamr@2
   308
    {
williamr@2
   309
friend class CLinkedFonts;
williamr@2
   310
friend class CLinkedTypefaceSpecification; 
williamr@2
   311
williamr@2
   312
public:
williamr@2
   313
	IMPORT_C static CFontStore* NewL(RHeap* aHeap);
williamr@2
   314
	IMPORT_C ~CFontStore();
williamr@2
   315
	IMPORT_C TUid AddFileL(const TDesC& aName);
williamr@2
   316
	IMPORT_C void RemoveFile(TUid aFileUid);
williamr@2
   317
	IMPORT_C TInt GetNearestFontInTwips(CFont *&aFont, const TFontSpec& aFontSpec);
williamr@2
   318
	IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TFontSpec &aFontSpec);
williamr@2
   319
	IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec& aFontSpec);
williamr@2
   320
	IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TFontSpec& aFontSpec);
williamr@2
   321
	IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   322
	IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   323
	IMPORT_C TInt GetNearestFontInTwips(CFont *&aFont, const TOpenFontSpec& aFontSpec);
williamr@2
   324
	IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TOpenFontSpec &aFontSpec);
williamr@2
   325
	IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TOpenFontSpec& aFontSpec);
williamr@2
   326
	IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TOpenFontSpec& aFontSpec);
williamr@2
   327
	IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   328
	IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   329
	IMPORT_C TInt GetFontById(CFont *&aFont,TUid aUid,const TAlgStyle& aAlgStyle);
williamr@2
   330
	IMPORT_C TInt NumTypefaces() const;
williamr@2
   331
	IMPORT_C void TypefaceSupport(TTypefaceSupport &aTypefaceSupport,TInt aTypefaceIndex) const;
williamr@2
   332
	IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
williamr@2
   333
	IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
williamr@2
   334
	IMPORT_C void InstallRasterizerL(COpenFontRasterizer* aRasterizer);
williamr@2
   335
	IMPORT_C void DeleteSessionCache(TInt aSessionHandle);
williamr@2
   336
	inline TGlyphBitmapType DefaultBitmapType() const;
williamr@2
   337
	inline void SetDefaultBitmapType(TGlyphBitmapType aType);
williamr@2
   338
	IMPORT_C void InstallShaperFactoryL(CShaperFactory* aShaperFactory);
williamr@2
   339
	const CArrayPtrFlat<CShaperFactory>* ShaperFactoryList() const;
williamr@2
   340
	COpenFontSessionCacheList* GetSessionCacheList();
williamr@2
   341
	TInt GetShaperCacheMemUsage();
williamr@2
   342
	void SetShaperCacheMemUsage(TInt aUsage);
williamr@2
   343
	CArrayPtrFlat<COpenFontFile>* GetOpenFontFileList();
williamr@2
   344
	void IncNumShaperCaches();
williamr@2
   345
	void DecNumShaperCaches();
williamr@2
   346
	TInt GetNumShaperCaches();
williamr@4
   347
	IMPORT_C TInt CreateLinkedTypeface(const TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
williamr@4
   348
	IMPORT_C void GetLinkedTypefaceL(TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec);
williamr@2
   349
	IMPORT_C TBool HaveTypefaceFamilyName(const TDesC& aName);
williamr@4
   350
	IMPORT_C void UpdateLinkedTypefaceL(const TLinkedTypefaceSpecificationArgs& aLinkedTypefaceSpec);
williamr@4
   351
	IMPORT_C void LoadFontsAtStartupL();
williamr@4
   352
	IMPORT_C TBool GetFontFilePath(const TDesC& aFontName, TFileName& aFilePath) const;
williamr@4
   353
    IMPORT_C void CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
williamr@4
   354
	
williamr@4
   355
	TInt CacheFontTable(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt aLength);
williamr@4
   356
	TInt ReleaseFontTable(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
williamr@4
   357
	TInt FindFontTableInCache(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt& aLength);
williamr@4
   358
	TInt IncFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
williamr@4
   359
	TInt DecFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
williamr@4
   360
	TInt CacheUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TAny* aData, 
williamr@4
   361
	        TInt aLength, TAny*& aOutline, TInt& aLen);
williamr@4
   362
	TInt CacheHintedOutline(const THintedOutlineId& aOutlineId, TAny* aData, TInt aLength,
williamr@4
   363
	        TAny*& aOutline, TInt& aLen);
williamr@4
   364
	TInt ReleaseUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
williamr@4
   365
	TInt ReleaseHintedOutline(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
williamr@4
   366
	TInt IncreaseUnhintedOutlineRefCount(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
williamr@4
   367
	TInt IncreaseHintedOutlineRefCount(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
williamr@4
   368
	TInt FindUnhintedOutlineInCache(const TUnhintedOutlineId& aOutlineId, TAny*& aData, 
williamr@4
   369
	        TInt &aLength);
williamr@4
   370
	TInt FindHintedOutlineInCache(const THintedOutlineId& aOutlineId, TAny*& aData, TInt& aLength);
williamr@4
   371
    void CleanupCacheOnOpenFontRemoval(COpenFont* aFont);
williamr@4
   372
    void CleanupCacheOnOpenFontFileRemoval(COpenFontFile* aFontFile);
williamr@4
   373
williamr@2
   374
private:
williamr@2
   375
	CFontStore(RHeap* aHeap);
williamr@2
   376
	void ConstructL();
williamr@2
   377
	void InternalizeFontStoreFileL(CFontStoreFile* aFontStoreFile, TInt aFontVersion);
williamr@2
   378
	TTypeface* GetNearestTypeface(const TTypeface& aTypeface) const;
williamr@2
   379
	TTypefaceFontBitmap GetNearestTypefaceFontBitmap(const TFontSpec& aFontSpecInPixels, TInt aMaxHeight);
williamr@2
   380
	CFontBitmap* GetFontBitmapById(TUid aUid);
williamr@2
   381
	TBool IsFontLoaded(CFont*& aFont, const TAlgStyle& aAlgStyle, const TFontSpec& aFontSpecInPixels, TUid aUid, TInt aMaxHeight = 0) const;
williamr@2
   382
	TBool IsFontLoaded(CFont*& aFont, const TAlgStyle& aAlgStyle, const TOpenFontSpec& aFontSpecInPixels, TInt aMaxHeight) const;
williamr@2
   383
	CBitmapFont* NewFontL(const TFontSpec& aFontSpecInTwips,const TAlgStyle& aAlgStyle,CFontBitmap* aFontBitmap);
williamr@2
   384
	CBitmapFont* NewFontL(const TOpenFontSpec& aFontSpecInTwips,const TAlgStyle& aAlgStyle,COpenFont* aOpenFont);
williamr@2
   385
	TInt VerticalPixelsToTwips(TInt aPixelHeight) const;
williamr@2
   386
	TInt VerticalTwipsToPixels(TInt aTwipsHeight) const;
williamr@2
   387
	void GetNearestBitmapFontInPixelsL(CFont*& aFont, TFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   388
	void GetNearestOpenFontInPixelsL(
williamr@2
   389
	CFont*& aFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
williamr@2
   390
	TInt GetNearestRealFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   391
	TInt GetNearestFontInPixelsL(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
williamr@4
   392
	TInt CreateLinkedTypefaceL(const TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
williamr@2
   393
	TInt GetCanonicalIndex(TInt aTypefaceIndex) const;
williamr@2
   394
	void TypefaceSupportLinked(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const;
williamr@2
   395
	TInt GetNearestFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
williamr@2
   396
	void SanityCheckForTtfL(RFile& aFile, TUint aFontFileSize, TBool aStrictChecking);
williamr@2
   397
	void SanityCheckFontFileL(TParse& aParse);
williamr@2
   398
	TInt GetNearestOpenFontInPixelsByFontName(COpenFont*& aNearestOpenFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
williamr@2
   399
	TInt GetNearestOpenFontInPixelsBySimilarity(COpenFont*& aNearestOpenFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
williamr@2
   400
	TInt AddTypefacesToSupportList(COpenFontFile* aOpenFontFile);
williamr@2
   401
	void RemoveTypefacesFromSupportList(COpenFontFile* aOpenFontFile);
williamr@2
   402
	TInt FindBitmapFontFileIndexByUid(TUid aUid);
williamr@4
   403
	TBool IncRefCountOfLoadedFont(const TParse& aFileName, TUid& aFontUid);
williamr@4
   404
	TBool LoadFileAsOpenFontL(const TParse& aFileName, TUid& aFontUid);
williamr@4
   405
	TUid LoadFileAsBitmapFontL(const TParse& aParse);
williamr@2
   406
	static void CleanupRemoveFontFile(TAny* aCleanupInfo);
williamr@4
   407
	const TAny* FontLinkingInterface() const;
williamr@4
   408
	TInt ValidateLinkedFontSpecificationL(COpenFontLinkedTypefaceSpecification& aSpec, TBool aOverwrite) const;
williamr@4
   409
	void GenerateLinkedFontFileL(COpenFontLinkedTypefaceSpecification& aSpec, const TAny* aExtension, TBool aUpdate);
williamr@4
   410
	void LoadFontsL(const TDesC& aFontsDir);
williamr@4
   411
	void AddSanityCheckedFontL(const TParse& aFileName, TUid& aUid);
williamr@2
   412
public:
williamr@2
   413
	/** The width of 1000 pixels in twips.
williamr@2
   414
	
williamr@2
   415
	This is set in the constructor. If the appropriate HALData attributes are 
williamr@2
   416
	set (EDisplayXPixels and EDisplayXTwips) then the value is calculated using 
williamr@2
   417
	these; otherwise the value is set to 11860. */
williamr@2
   418
	TInt iKPixelWidthInTwips;
williamr@2
   419
	
williamr@2
   420
	/** The height of 1000 pixels in twips.
williamr@2
   421
	
williamr@2
   422
	This is set in the constructor. If the appropriate HALData attributes are 
williamr@2
   423
	set (EDisplayYPixels and EDisplayYTwips) then the value is calculated using 
williamr@2
   424
	these; otherwise the value is set to 11860. */
williamr@2
   425
	TInt iKPixelHeightInTwips;
williamr@2
   426
williamr@2
   427
private:
williamr@2
   428
	// Binary Compatibility warning - data member iDefaultBitmapType is referenced by inline methods
williamr@2
   429
	RFs iFs;
williamr@2
   430
	RHeap* iHeap;
williamr@2
   431
	CArrayPtrFlat<CFontStoreFile> iFontStoreFileList;
williamr@2
   432
	CArrayPtrFlat<TTypeface> iTypefaceList;
williamr@2
   433
	CArrayPtrFlat<CFontBitmap> iFontBitmapList;
williamr@2
   434
	CArrayFixFlat<TTypefaceFontBitmap> iTypefaceFontBitmapList;
williamr@2
   435
	CArrayPtrFlat<COpenFontFile> iOpenFontFileList;
williamr@4
   436
	TInt iReserved[2];		// keep iDefaultBitmapType at the correct offset
williamr@4
   437
    CFontTableCache *iFontTableCache;
williamr@4
   438
    CUnhintedOutlineCache *iUnhintedOutlineCache;
williamr@4
   439
    CHintedOutlineCache *iHintedOutlineCache;
williamr@4
   440
    TFontTableGlyphOutlineCacheMemMonitor *iCacheMemMon;
williamr@2
   441
	CArrayPtrFlat<COpenFontRasterizer> iOpenFontRasterizerList;
williamr@2
   442
	COpenFontSessionCacheList* iOpenFontSessionCacheList;
williamr@2
   443
	TInt iOpenFontUid;
williamr@2
   444
	TGlyphBitmapType iDefaultBitmapType;
williamr@2
   445
	CArrayPtrFlat<CShaperFactory> iShaperFactoryList;
williamr@2
   446
	TInt iOpenFontShaperCacheMemUsage;
williamr@2
   447
	TInt iNumberOfShaperCaches;
williamr@2
   448
	RPointerArray<CTypefaceSupportInfo> iOpenFontTypefaceSupportList;
williamr@4
   449
	RArray<RHandleBase> *iHandleArray;
williamr@4
   450
	TAny* iUnused2;
williamr@4
   451
	TUint32 iUniqueFontIdCount;
williamr@2
   452
	};
williamr@2
   453
williamr@2
   454
// inline functions start here
williamr@2
   455
williamr@2
   456
/** Returns whether the bitmap font object is an open font (a COpenFont) rather 
williamr@2
   457
than a bitmap font (a CFontBitmap).
williamr@2
   458
williamr@2
   459
@return ETrue if the bitmap font object is using an open font (a COpenFont);
williamr@2
   460
EFalse if it is using a bitmap font (a CFontBitmap).
williamr@2
   461
@see OpenFont()
williamr@2
   462
*/
williamr@2
   463
inline TBool CBitmapFont::IsOpenFont() const
williamr@2
   464
	{
williamr@2
   465
	return iOpenFont != NULL;
williamr@2
   466
	}
williamr@2
   467
williamr@4
   468
williamr@2
   469
/** Returns a pointer to the open font being used by the bitmap font object.
williamr@2
   470
williamr@2
   471
@return A pointer to an open font.
williamr@2
   472
@see IsOpenFont()
williamr@2
   473
*/
williamr@2
   474
inline COpenFont* CBitmapFont::OpenFont() const
williamr@2
   475
	{ 
williamr@4
   476
    if (reinterpret_cast<TInt>(iOpenFont) & 1)
williamr@4
   477
        {
williamr@4
   478
        return reinterpret_cast<COpenFont*>(const_cast<CBitmapFont*>(PtrAdd(this, reinterpret_cast<TInt>(iOpenFont) & ~1)));
williamr@4
   479
        }
williamr@4
   480
    else
williamr@4
   481
        {
williamr@4
   482
        return iOpenFont;
williamr@4
   483
        }
williamr@2
   484
	}
williamr@2
   485
williamr@2
   486
/** Gets the anti-aliasing setting for the font, see TGlyphBitmapType for 
williamr@2
   487
the range of values.
williamr@2
   488
williamr@2
   489
This is only applicable to open fonts (COpenFonts) not bitmap fonts (CBitmapFonts).
williamr@2
   490
williamr@2
   491
Note that this setting is stored in the device-independent font specification 
williamr@2
   492
which is set when the bitmap font object is constructed.
williamr@2
   493
williamr@2
   494
@return The anti-aliasing setting for the font.
williamr@2
   495
@see IsOpenFont()
williamr@2
   496
@see TGlyphBitmapType
williamr@2
   497
@see COpenFont
williamr@2
   498
@see CBitmapFont
williamr@2
   499
*/
williamr@2
   500
inline TGlyphBitmapType CBitmapFont::GlyphBitmapType() const
williamr@2
   501
	{
williamr@2
   502
	return iFontSpecInTwips.iFontStyle.BitmapType();
williamr@2
   503
	}
williamr@2
   504
williamr@2
   505
/** Returns a default bitmap type.
williamr@2
   506
williamr@2
   507
@return A default bitmap type.
williamr@2
   508
@see TGlyphBitmapType
williamr@2
   509
*/
williamr@2
   510
inline TGlyphBitmapType CFontStore::DefaultBitmapType() const
williamr@2
   511
	{
williamr@2
   512
	return iDefaultBitmapType;
williamr@2
   513
	}
williamr@2
   514
williamr@2
   515
/** Sets a default bitmap type.
williamr@2
   516
williamr@2
   517
@param aType A default bitmap type.
williamr@2
   518
@see TGlyphBitmapType
williamr@2
   519
*/
williamr@2
   520
inline void CFontStore::SetDefaultBitmapType(TGlyphBitmapType aType)
williamr@2
   521
	{
williamr@2
   522
	iDefaultBitmapType = aType;
williamr@2
   523
	}
williamr@2
   524
williamr@2
   525
#endif
williamr@4
   526