epoc32/include/openfont.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) 1998-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
* A header for the open font system, which allows SymbianOS
williamr@4
    16
* to use fonts of arbitrary types, including TrueType/OpenType
williamr@4
    17
* and other outline font formats.
williamr@4
    18
*
williamr@4
    19
*/
williamr@4
    20
williamr@4
    21
williamr@4
    22
#ifndef __OPENFONT_H__
williamr@4
    23
#define __OPENFONT_H__
williamr@2
    24
williamr@2
    25
#include <e32base.h>
williamr@2
    26
#include <gdi.h>
williamr@2
    27
#include <ecom/ecom.h>
williamr@2
    28
williamr@4
    29
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    30
#include <linkedfonts.h>
williamr@4
    31
#include <graphics/openfontconstants.h>
williamr@4
    32
#include <graphics/openfontrasterizer.h>
williamr@4
    33
#include <openfontlinkedtypefaceelementspec.h>
williamr@4
    34
#include <graphics/openfontlinkedtypefacespecification.h>
williamr@4
    35
#include <graphics/openfontlinkedtypefaceextension.h>
williamr@4
    36
#endif
williamr@2
    37
williamr@2
    38
class CFont;
williamr@2
    39
class COpenFontFile;
williamr@2
    40
class COpenFontGlyph;
williamr@2
    41
class COpenFontGlyphCache;
williamr@2
    42
class COpenFontGlyphTreeEntry;
williamr@2
    43
class COpenFontPositioner;
williamr@2
    44
class COpenFontSessionCache;
williamr@2
    45
class COpenFontSessionCacheList;
williamr@2
    46
class RFs;
williamr@2
    47
class TCharacterMetrics;
williamr@2
    48
class TFontSpec;
williamr@2
    49
class TOpenFontFaceAttrib;
williamr@2
    50
class CFontStore;
williamr@2
    51
class TOpenFontFileData;
williamr@2
    52
class TShapeHeader;
williamr@2
    53
class CBitmapFont;
williamr@2
    54
class CShaperFactory;
williamr@2
    55
class CShaper;
williamr@2
    56
class TShapeHeader;
williamr@2
    57
class TFontShapeFunctionParameters;
williamr@2
    58
class TFontShapeDeleteFunctionParameters;
williamr@2
    59
class RShapeInfo;
williamr@2
    60
class TShapeMessageParameters;
williamr@4
    61
class CRasterizerLinkedTypefaceSpecification;
williamr@4
    62
class TLinkedTypefaceSpecificationArgs;
williamr@2
    63
williamr@2
    64
/**
williamr@2
    65
Supplied to COpenFont::ExtendedInterface() to access the extended
williamr@2
    66
API interface MOpenFontShapingExtension.
williamr@2
    67
williamr@4
    68
@see	COpenFont::ExtendedInterface()
williamr@4
    69
@see	MOpenFontShapingExtension
williamr@2
    70
@publishedAll
williamr@2
    71
@released
williamr@2
    72
*/
williamr@2
    73
const TUid KUidOpenFontShapingExtension = {0x10274DB9};
williamr@2
    74
williamr@2
    75
/**
williamr@2
    76
Supplied to COpenFont::ExtendedInterface() to access the extended
williamr@2
    77
API interface MOpenFontTrueTypeExtension.
williamr@2
    78
williamr@4
    79
@see	COpenFont::ExtendedInterface()
williamr@4
    80
@see	MOpenFontTrueTypeExtension
williamr@2
    81
@publishedAll
williamr@2
    82
@released
williamr@2
    83
*/
williamr@2
    84
const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
williamr@4
    85
const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
williamr@2
    86
williamr@2
    87
/**
williamr@2
    88
Supplied to CShaper::ExtendedInterface() to get the language and script
williamr@2
    89
code with which the current shaper is instatsiated.
williamr@4
    90
@see	CShaper::ExtendedInterface()
williamr@2
    91
@publishedAll
williamr@2
    92
@released
williamr@2
    93
*/
williamr@2
    94
const TUid KUidShaperGetScript = {0x20009966};
williamr@2
    95
const TUid KUidShaperGetLang = {0x20009967};
williamr@2
    96
williamr@4
    97
/**
williamr@2
    98
Font metrics.
williamr@2
    99
williamr@4
   100
@see	CFbsFont::GetFontMetrics()
williamr@2
   101
@publishedAll
williamr@2
   102
@released
williamr@2
   103
*/
williamr@2
   104
class TOpenFontMetrics
williamr@2
   105
	{
williamr@2
   106
public:
williamr@2
   107
	inline TOpenFontMetrics();
williamr@2
   108
	IMPORT_C TOpenFontMetrics(const CFont* aFont);
williamr@2
   109
	inline TInt Size() const;
williamr@2
   110
	inline TInt Ascent() const;
williamr@2
   111
	inline TInt Descent() const;
williamr@2
   112
	inline TInt MaxHeight() const;
williamr@2
   113
	inline TInt MaxDepth() const;
williamr@2
   114
	inline TInt MaxWidth() const;
williamr@2
   115
	inline void SetSize(TInt aSize);
williamr@2
   116
	inline void SetAscent(TInt aAscent);
williamr@2
   117
	inline void SetDescent(TInt aDescent);
williamr@2
   118
	inline void SetMaxHeight(TInt aMaxHeight);
williamr@2
   119
	inline void SetMaxDepth(TInt aMaxDepth);
williamr@2
   120
	inline void SetMaxWidth(TInt aMaxWidth);
williamr@4
   121
	/** WARNING: Function for internal and partner use ONLY. Compatibility is not guaranteed in future releases.*/
williamr@4
   122
	IMPORT_C void SetBaselineCorrection(TInt aBaselineCorrection);
williamr@4
   123
	IMPORT_C TInt BaselineCorrection();
williamr@2
   124
private:
williamr@2
   125
	TInt16 iDesignHeight;	// size of the font ('pointsize' in pixels)
williamr@2
   126
	TInt16 iAscent;			// typographic ascent
williamr@2
   127
	TInt16 iDescent;		// typographic descent
williamr@2
   128
	TInt16 iMaxHeight;		// maximum height of a character; may be greater than iAscent
williamr@2
   129
	TInt16 iMaxDepth;		// maximum depth of a character; may be greater than iDescent
williamr@2
   130
	TInt16 iMaxWidth;		// maximum width of a character
williamr@4
   131
	TInt16 iBaselineCorrection;
williamr@4
   132
	TInt16 iReserved;
williamr@2
   133
	};
williamr@2
   134
williamr@4
   135
williamr@4
   136
/**
williamr@2
   137
Character metrics  includes more information than TCharacterMetrics.
williamr@2
   138
williamr@2
   139
Character metrics allow characters to be placed horizontally or vertically. 
williamr@2
   140
The character metrics encapsulated by this class are: Height, Width, Horizontal 
williamr@2
   141
Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X, 
williamr@2
   142
Vertical Bearing Y, and Vertical Advance. Their meanings are described in the 
williamr@2
   143
associated setter and getter functions.
williamr@2
   144
williamr@2
   145
Note : 
williamr@2
   146
williamr@2
   147
Vertical drawing (in the sense of characters drawn with horizontal baselines, 
williamr@2
   148
but in a vertical line) is not yet supported by Symbian OS.
williamr@2
   149
williamr@4
   150
@see	CFont::GetCharacterData()
williamr@4
   151
@see	CFbsFont::GetCharacterData() 
williamr@2
   152
@publishedAll
williamr@2
   153
@released
williamr@2
   154
*/
williamr@2
   155
class TOpenFontCharMetrics
williamr@2
   156
	{
williamr@2
   157
public:
williamr@2
   158
	enum TUninitialized { EUninitialized };
williamr@2
   159
public:
williamr@4
   160
	/** Default constructor initializes all members to 0. */
williamr@2
   161
	inline TOpenFontCharMetrics();
williamr@2
   162
williamr@4
   163
	/** Constructor that does not initialize any members. */
williamr@2
   164
	TOpenFontCharMetrics(TUninitialized) {}
williamr@2
   165
	IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics);
williamr@2
   166
	IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const;
williamr@2
   167
	inline TInt Width() const;
williamr@2
   168
	inline TInt Height() const;
williamr@2
   169
	inline TInt HorizBearingX() const;
williamr@2
   170
	inline TInt HorizBearingY() const;
williamr@2
   171
	inline TInt HorizAdvance() const;
williamr@2
   172
	inline TInt VertBearingX() const;
williamr@2
   173
	inline TInt VertBearingY() const;
williamr@2
   174
	inline TInt VertAdvance() const;
williamr@2
   175
	inline void GetHorizBounds(TRect& aBounds) const;
williamr@2
   176
	inline void GetVertBounds(TRect& aBounds) const;
williamr@2
   177
	inline void SetWidth(TInt aWidth);
williamr@2
   178
	inline void SetHeight(TInt aHeight);
williamr@2
   179
	inline void SetHorizBearingX(TInt aHorizBearingX);
williamr@2
   180
	inline void SetHorizBearingY(TInt aHorizBearingY);
williamr@2
   181
	inline void SetHorizAdvance(TInt aHorizAdvance);
williamr@2
   182
	inline void SetVertBearingX(TInt aVertBearingX);
williamr@2
   183
	inline void SetVertBearingY(TInt aVertBearingY);
williamr@2
   184
	inline void SetVertAdvance(TInt aVertAdvance);
williamr@4
   185
	IMPORT_C void  SetGlyphType(TGlyphBitmapType);
williamr@4
   186
	IMPORT_C TGlyphBitmapType GlyphType() const;
williamr@2
   187
private:
williamr@2
   188
	TInt16 iWidth;			// width of the glyph
williamr@2
   189
	TInt16 iHeight;			// height of the glyph
williamr@2
   190
	TInt16 iHorizBearingX;	// x component of horizontal bearing
williamr@2
   191
	TInt16 iHorizBearingY;	// y component of horizontal bearing
williamr@2
   192
	TInt16 iHorizAdvance;	// horizontal advance
williamr@2
   193
	TInt16 iVertBearingX;	// x component of vertical bearing
williamr@2
   194
	TInt16 iVertBearingY;	// y component of vertical bearing
williamr@2
   195
	TInt16 iVertAdvance;	// vertical advance
williamr@4
   196
	TUint16  iGlyphBitmapType;// Glyph bitmap type; TGlyphBitmapType
williamr@4
   197
	TInt16 iReserved;
williamr@2
   198
	};
williamr@2
   199
williamr@4
   200
williamr@4
   201
/**
williamr@2
   202
Font glyph data.
williamr@2
   203
williamr@2
   204
Objects of this type are used by rasterizers to supply glyph data to font 
williamr@2
   205
and bitmap server clients. Unless you are writing a rasterizer you will not 
williamr@2
   206
need to use an object of this type.
williamr@2
   207
williamr@2
   208
The object cannot be constructed and destroyed by normal means. It resides 
williamr@2
   209
on a specified heap. It is created by New() and deleted by RHeap::Free().
williamr@2
   210
williamr@4
   211
@see	COpenFont::RasterizeL()
williamr@2
   212
@publishedAll
williamr@2
   213
@released
williamr@2
   214
*/
williamr@2
   215
class TOpenFontGlyphData
williamr@2
   216
	{
williamr@2
   217
public:
williamr@2
   218
	IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize);
williamr@2
   219
	inline TBool Overflow() const;
williamr@2
   220
	inline TInt BytesNeeded() const;
williamr@2
   221
	inline TPtrC8 Bitmap() const;
williamr@2
   222
	inline const TUint8* BitmapPointer() const;
williamr@2
   223
	inline const TOpenFontCharMetrics* Metrics() const;
williamr@2
   224
	inline TInt GlyphIndex() const;
williamr@2
   225
	inline TUint8* BufferStart();
williamr@2
   226
	inline TUint8* BufferEnd();
williamr@2
   227
	inline void SetBytesNeeded(TInt aBytes);
williamr@2
   228
	inline void SetBitmapPointer(const TUint8* aBitmap);
williamr@2
   229
	inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics);
williamr@2
   230
	inline void SetPointersToInternalBuffers();
williamr@2
   231
	inline void SetMetrics(TOpenFontCharMetrics& aMetrics);
williamr@2
   232
	inline void SetGlyphIndex(TInt aGlyphIndex);
williamr@2
   233
private:
williamr@2
   234
	/*
williamr@2
   235
	Prevent construction and destruction by normal means; the object resides 
williamr@2
   236
	on a specified heap and is created by New and deleted by RHeap::Free.
williamr@2
   237
	*/
williamr@2
   238
	TOpenFontGlyphData();
williamr@2
   239
	~TOpenFontGlyphData();
williamr@2
   240
private:
williamr@2
   241
	TInt iBitmapBufferSize;					// size of the buffer in bytes
williamr@2
   242
	TInt iBytesNeeded;						// bytes needed for the bitmap
williamr@2
   243
	TOpenFontCharMetrics iMetricsBuffer;	// the metrics
williamr@2
   244
	const TUint8* iBitmap;					// pointer to the bitmap; points either to iBitmapBuffer or to
williamr@2
   245
											// the cache if the character was already rasterized
williamr@2
   246
	const TOpenFontCharMetrics* iMetrics;	// pointer to the metrics; points either to iMetricsBuffer or to
williamr@2
   247
											// the cache if the character was already rasterized
williamr@2
   248
	TInt iGlyphIndex;						// the glyph index
williamr@2
   249
	TAny* iReserved;						// unused; for future expansion
williamr@2
   250
	TUint8 iBitmapBuffer[1];				// buffer used to write the bitmap when it is first rasterized; this
williamr@2
   251
											// is actually of size iBitmapBufferSize.
williamr@2
   252
	};
williamr@2
   253
williamr@2
   254
class COpenFontGlyph;
williamr@4
   255
/**
williamr@2
   256
Open Font System font abstract base class.
williamr@2
   257
williamr@2
   258
Derive a class from this class to represent an instance of a typeface at a 
williamr@2
   259
particular size, provide bitmaps of the glyphs, and determine whether 
williamr@2
   260
characters exist in the typeface.
williamr@2
   261
williamr@2
   262
Writing derived classes construction: 
williamr@2
   263
williamr@2
   264
You must call the constructor of this class when creating your derived object, 
williamr@2
   265
passing the arguments aHeap and aSessionCacheList supplied to 
williamr@2
   266
COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile 
williamr@2
   267
object that creates the object as aFile.
williamr@2
   268
williamr@2
   269
The derived object must be created on the shared heap aHeap because it is 
williamr@2
   270
shared by several processes: the font and bitmap server and its clients. 
williamr@2
   271
To do this, use aHeap->AllocL() to obtain memory, then construct in place 
williamr@2
   272
using a placement argument to new.
williamr@2
   273
williamr@2
   274
Derived classes must implement the pure virtual function RasterizeL(). 
williamr@2
   275
Information about this function is provided in the function definition below. 
williamr@2
   276
williamr@2
   277
Information about deriving from this class is also provided in the API guide.
williamr@2
   278
williamr@4
   279
@see	COpenFontFile::GetNearestFontInPixelsL()
williamr@2
   280
@publishedAll
williamr@2
   281
@released
williamr@2
   282
*/
williamr@2
   283
class COpenFont: public CBase
williamr@2
   284
	{
williamr@2
   285
public:
williamr@2
   286
	/** Creates a bitmap for the specified Unicode character.
williamr@4
   287
williamr@2
   288
	Implementations of this function should put the bitmap in 
williamr@2
   289
	aGlyphData->iBitmapBuffer, and the character metrics are placed in 
williamr@2
   290
	aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left 
williamr@2
   291
	alone. 
williamr@4
   292
williamr@2
   293
	There are a number of strategies for achieving this, e.g. pass the 
williamr@2
   294
	rasterization task all the way up to the rasterizer engine. These are 
williamr@2
   295
	discussed in the API guide.
williamr@4
   296
williamr@2
   297
	At present you must write the bitmap in the Symbian platform's 
williamr@2
   298
	run-length-encoded format. This is a packed binary format starting on a 
williamr@2
   299
	byte boundary and made up of a number of sections. Each section starts 
williamr@2
   300
	with a five-bit header. If the first bit of the header is 0 the next four 
williamr@2
   301
	bits are a repeat count, starting with the least significant bit, and a 
williamr@2
   302
	single row of bits (the number of bits in a row is specified by 
williamr@2
   303
	aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header 
williamr@2
   304
	is 1 the next four bits are a count of non-repeating rows, again starting 
williamr@2
   305
	with the least significant bit, and that many rows of bits follow.
williamr@4
   306
williamr@2
   307
	@param aCode The character code of the Unicode character for which the 
williamr@2
   308
	bitmap is required.
williamr@2
   309
	@param aGlyphData On return, contains a pointer to a TOpenFontGlyphData 
williamr@2
   310
	containing the character's bitmap and metrics. */
williamr@2
   311
	virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
williamr@2
   312
	IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
williamr@2
   313
	IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile);
williamr@2
   314
	IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex);
williamr@2
   315
	IMPORT_C ~COpenFont();
williamr@2
   316
	IMPORT_C void operator delete(TAny*);
williamr@2
   317
	inline const TOpenFontMetrics& Metrics() const;
williamr@2
   318
	inline const TOpenFontFaceAttrib* FaceAttrib() const;
williamr@2
   319
	inline COpenFontFile* File() const;
williamr@2
   320
	inline TInt FaceIndex() const;
williamr@2
   321
	inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
williamr@2
   322
	void SetShaper(CShaper* aShaper);
williamr@2
   323
	CShaper* GetShaper();
williamr@2
   324
	TBool HasShaper() const;
williamr@2
   325
	TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams);
williamr@2
   326
	TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader);
williamr@2
   327
	TInt FreeShaperCacheMemory(TInt aBytesNeeded);
williamr@2
   328
	TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse);
williamr@2
   329
	TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData);
williamr@2
   330
	TBool HasCharacterL(TInt aCode) const;
williamr@2
   331
	TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
williamr@2
   332
	void OnFileDeleted();
williamr@2
   333
	COpenFontGlyphCache* GetGlyphCache();
williamr@2
   334
	inline TInt FontCapitalAscent() const;
williamr@2
   335
	inline TInt FontMaxAscent() const;
williamr@2
   336
	inline TInt FontStandardDescent() const;
williamr@2
   337
	inline TInt FontMaxDescent() const;
williamr@2
   338
	inline TInt FontLineGap() const;
williamr@2
   339
	inline TInt FontMaxHeight() const;
williamr@2
   340
	void DeleteShaper() const;
williamr@4
   341
	TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength);
williamr@4
   342
	TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength);
williamr@4
   343
	
williamr@4
   344
protected:	
williamr@4
   345
	/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
williamr@4
   346
	*/
williamr@4
   347
	TInt PointerToThisOffset(const TAny* aAny);
williamr@4
   348
	/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
williamr@4
   349
	*/
williamr@4
   350
	TAny* ThisOffsetToPointer(const TInt aOffset);
williamr@4
   351
		
williamr@2
   352
protected:
williamr@2
   353
	RHeap* iHeap;
williamr@2
   354
	TOpenFontMetrics iMetrics;
williamr@2
   355
private:
williamr@2
   356
	/** The shaper for performing complex character positioning and
williamr@2
   357
	substitution, if available. Null otherwise.
williamr@4
   358
	
williamr@4
   359
	WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only. 
williamr@4
   360
    */
williamr@2
   361
	CShaper* iShaper;
williamr@4
   362
williamr@2
   363
protected:
williamr@2
   364
	/** The positive distance in pixels from the baseline to
williamr@2
   365
		the top of an ANSI capital (whether or not there are
williamr@2
   366
		ANSI capitals in the font) */
williamr@4
   367
	TInt iFontCapitalAscent;
williamr@2
   368
	/** The positive distance in pixels from the baseline to
williamr@2
   369
		the top of the highest pre-composed glyph in the font */
williamr@4
   370
	TInt iFontMaxAscent;
williamr@2
   371
	/** The positive distance in pixels from the baseline to
williamr@2
   372
		the bottom of the lowest ANSI descender (whether or
williamr@2
   373
		not there are ANSI chars in the font)*/
williamr@4
   374
	TInt iFontStandardDescent;
williamr@2
   375
	/** The positive distance in pixels from the baseline to
williamr@2
   376
		the bottom of the lowest pre-composed glyph in the font */
williamr@4
   377
	TInt iFontMaxDescent;
williamr@2
   378
	/** The recommended baseline to baseline gap for successive
williamr@2
   379
		lines of text in the font */
williamr@4
   380
	TInt iFontLineGap;
williamr@2
   381
private:
williamr@2
   382
	const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
williamr@2
   383
protected:
williamr@4
   384
williamr@4
   385
	/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
williamr@2
   386
	*/
williamr@4
   387
	const COpenFontGlyph* FontCacheGlyph(TInt aCode,TInt*& aNode);
williamr@4
   388
	const COpenFontGlyph* FontCacheGlyph(TInt aCode);
williamr@4
   389
	
williamr@4
   390
	void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
williamr@4
   391
	
williamr@4
   392
private:
williamr@2
   393
	const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode,
williamr@2
   394
											COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const;
williamr@2
   395
	void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData);
williamr@4
   396
williamr@4
   397
	COpenFontSessionCacheList* SessionCacheList()const;
williamr@4
   398
	
williamr@4
   399
    void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList);
williamr@4
   400
    
williamr@4
   401
    void SetFile(COpenFontFile* aFile);
williamr@2
   402
private:
williamr@4
   403
    
williamr@4
   404
    // Offset from the address of the file used by this font.
williamr@4
   405
    // If the file has been deleted or cannot be used, the offest will be zero.
williamr@4
   406
    TInt iFileOffset;
williamr@4
   407
    
williamr@2
   408
	TInt iFaceIndex;										// index of the face in the font file
williamr@2
   409
protected:
williamr@4
   410
    /**
williamr@4
   411
    WARNING: Compatibility is not guaranteed in future releases. Please use the provided APIs only.
williamr@4
   412
    Offset from the address of this font of the per-font glyph cache which is owned by the font
williamr@4
   413
    @internalTechnology
williamr@4
   414
    */  
williamr@4
   415
    TInt iGlyphCacheOffset;
williamr@4
   416
private:
williamr@4
   417
    // Offset from the address of this font of the list of per-session glyph
williamr@4
   418
    // caches which are owned by CFontStore
williamr@4
   419
    TInt iSessionCacheListOffset;
williamr@4
   420
williamr@2
   421
	TAny* iReserved; // unused; for future expansion
williamr@2
   422
	};
williamr@2
   423
williamr@2
   424
/** Open Font System Extension Interface abstract base class.
williamr@2
   425
williamr@2
   426
COpenFont derivers should also derive from this interface to enable complex
williamr@2
   427
font "shaping".
williamr@2
   428
williamr@2
   429
This interface should be returned by the overridden
williamr@2
   430
COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
williamr@2
   431
supplied as the UID.
williamr@2
   432
williamr@4
   433
@see	COpenFont
williamr@4
   434
@see	KUidOpenFontShapingExtension 
williamr@2
   435
@publishedAll
williamr@2
   436
@released
williamr@2
   437
*/
williamr@2
   438
class MOpenFontShapingExtension
williamr@2
   439
	{
williamr@2
   440
public:
williamr@2
   441
	/** Various font metrics. */
williamr@2
   442
	class TExtensionFontMetrics
williamr@2
   443
		{
williamr@2
   444
	public:
williamr@2
   445
		/** The number of font design units per em. */
williamr@2
   446
		TInt iUnitsPerEm;
williamr@2
   447
		/** The width of the font's em square in pixels. */
williamr@2
   448
		TReal iXPixelsPerEm;
williamr@2
   449
		/** The height of the font's em square in pixels. */
williamr@2
   450
		TReal iYPixelsPerEm;
williamr@2
   451
		/** The horizontal scaling factor from the font's transform;
williamr@2
   452
		the number of horizontal pixels per font unit. */
williamr@2
   453
		TReal iXScaleFactor;
williamr@2
   454
		/** The vertical scaling factor from the font's transform;
williamr@2
   455
		the number of vertical pixels per font unit. */
williamr@2
   456
		TReal iYScaleFactor;
williamr@2
   457
	private:
williamr@2
   458
		/** Reserved for future expansion. */
williamr@2
   459
		TInt iReserved[4];
williamr@2
   460
		};
williamr@2
   461
williamr@2
   462
	/** Creates a bitmap for the specified Glyph code.
williamr@2
   463
williamr@2
   464
	Implementations of this function should put the bitmap in
williamr@2
   465
	aGlyphData->iBitmapBuffer, and the character metrics are placed in
williamr@2
   466
	aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
williamr@2
   467
	alone.
williamr@2
   468
williamr@2
   469
	This function provides the same functionality as the
williamr@2
   470
	COpenFont::RasterizeL() except that the glyph code is supplied rather than
williamr@2
   471
	the unicode.
williamr@2
   472
williamr@2
   473
	For more information:
williamr@4
   474
	@see	COpenFont::RasterizeL()
williamr@4
   475
williamr@4
   476
	@param	aCode		The glyph code of the character for which the bitmap is required.
williamr@4
   477
	@param	aGlyphData	The function puts its output here.
williamr@2
   478
	*/
williamr@2
   479
	virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
williamr@2
   480
williamr@2
   481
	/** Maps a character to a glyph index.
williamr@2
   482
	@param aUnicodeCharacter Unicode character code to be mapped.
williamr@2
   483
	@return Glyph code corresponding to aUnicodeCharacter. */
williamr@2
   484
	virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0;
williamr@2
   485
williamr@2
   486
	/** Returns the hinted pixel coordinates of a particular point in the
williamr@2
   487
	outline of the given glyph.
williamr@2
   488
	@param aGlyphPoint The glyph index.
williamr@2
   489
	@param aPointNumber The number of the point.
williamr@2
   490
	@param aX Returns the point's X pixel value.
williamr@2
   491
	@param aY Returns the point's Y pixel value.
williamr@2
   492
	@return True on success, false otherwise. */
williamr@2
   493
	virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber,
williamr@2
   494
		TReal& aX, TReal& aY) const = 0;
williamr@2
   495
williamr@2
   496
	/** Returns the coordinates of a particular (unhinted) point in the outline
williamr@2
   497
	of the given glyph in font units.
williamr@2
   498
	@param aGlyphPoint The glyph index.
williamr@2
   499
	@param aPointNumber The number of the point.
williamr@2
   500
	@param aX Returns the point's X co-ordinate in font units.
williamr@2
   501
	@param aY Returns the point's Y co-ordinate in font units.
williamr@2
   502
	@return True on success, false otherwise. */
williamr@2
   503
	virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber,
williamr@2
   504
		TInt& aX, TInt& aY) const = 0;
williamr@2
   505
williamr@2
   506
	/** Returns font metrics.
williamr@2
   507
	@param aOut Font metrics returned. */
williamr@2
   508
	virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
williamr@2
   509
	};
williamr@2
   510
williamr@2
   511
/** TrueType extension for Open Fonts.
williamr@2
   512
williamr@2
   513
If an open font is able to load TrueType or OpenType tables it should derive
williamr@2
   514
from this class.
williamr@2
   515
williamr@2
   516
This class will be used by 
williamr@2
   517
williamr@2
   518
This interface should be returned by the overridden
williamr@2
   519
COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
williamr@2
   520
supplied as the UID.
williamr@4
   521
@see	KUidOpenFontTrueTypeExtension
williamr@2
   522
@publishedAll
williamr@2
   523
@released
williamr@2
   524
*/
williamr@2
   525
class MOpenFontTrueTypeExtension
williamr@2
   526
	{
williamr@2
   527
public:
williamr@2
   528
	/** Returns the specified table. The table need not be released by the
williamr@2
   529
	caller, so the deriver is responsible for ensuring that any memory
williamr@2
   530
	allocated is ultimately cleaned up. The caller must not delete or modify
williamr@2
   531
	the data returned.
williamr@2
   532
	@param aError
williamr@2
   533
		Returns KErrNone if successful or one of the system-wide error codes if
williamr@2
   534
		unsuccessful. Returns KErrNotSupported if the table does not exist in
williamr@2
   535
		the font file.
williamr@2
   536
	@param aTag
williamr@2
   537
		The tag of the table, with the first character in the most significant
williamr@2
   538
		byte. For example, the "vhea" table is obtained by passing in 'v'<<24 |
williamr@2
   539
		'h'<<16 | 'e'<<8 | 'a'.
williamr@2
   540
	@param aLength
williamr@2
   541
		The length of the table in bytes that has been returned or 0 if
williamr@2
   542
		unsuccessful.
williamr@2
   543
	@return The table, if successful.
williamr@2
   544
	@see ReleaseTrueTypeTable */
williamr@2
   545
	virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0;
williamr@2
   546
	/** Releases a table obtained by GetTrueTypeTable. The caller must not
williamr@2
   547
	use the table after this call.
williamr@2
   548
	@param aTable The table to be released.
williamr@2
   549
	@see GetTrueTypeTable */
williamr@2
   550
	virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0;
williamr@2
   551
	/** Determines if the font file has a particular table.
williamr@2
   552
	@param aTag The tag of the table as for GetTrueTypeTable.
williamr@2
   553
	@return True if the table exists in the font file, false otherwise.
williamr@2
   554
	@see GetTrueTypeTable */
williamr@2
   555
	virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
williamr@2
   556
	};
williamr@4
   557
williamr@4
   558
class MOpenFontGlyphOutlineExtension 
williamr@4
   559
    {
williamr@4
   560
public:
williamr@4
   561
    virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId, 
williamr@4
   562
            TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
williamr@4
   563
    };
williamr@2
   564
/** 
williamr@2
   565
Font attribute base class. 
williamr@2
   566
williamr@2
   567
This class is not intended for user derivation.
williamr@2
   568
williamr@4
   569
@see	TOpenFontFaceAttrib
williamr@4
   570
@see	TOpenFontSpec
williamr@2
   571
@publishedAll
williamr@2
   572
@released
williamr@2
   573
*/
williamr@2
   574
class TOpenFontFaceAttribBase
williamr@2
   575
	{
williamr@2
   576
public:
williamr@2
   577
	inline TOpenFontFaceAttribBase();
williamr@2
   578
	inline TBool HasLatin() const;
williamr@2
   579
	inline TBool HasGreek() const;
williamr@2
   580
	inline TBool HasCyrillic() const;
williamr@2
   581
	inline TBool HasKana() const;
williamr@2
   582
	inline TBool HasHangul() const;
williamr@2
   583
	inline TBool HasCJK() const;
williamr@2
   584
	inline TBool IsSymbol() const;
williamr@2
   585
	inline TBool IsBold() const;
williamr@2
   586
	inline TBool IsItalic() const;
williamr@2
   587
	inline TBool IsSerif() const;
williamr@2
   588
	inline TBool IsMonoWidth() const;
williamr@2
   589
	inline TPtrC Name() const;
williamr@2
   590
	inline const TUint* Coverage() const;
williamr@2
   591
	inline void SetName(const TDesC& aName);
williamr@2
   592
	inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0);
williamr@2
   593
	inline void SetBold(TBool aBold);
williamr@2
   594
	inline void SetItalic(TBool aItalic);
williamr@2
   595
	inline void SetSerif(TBool aSerif);
williamr@2
   596
	inline void SetMonoWidth(TBool aMonoWidth);
williamr@2
   597
	inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const;
williamr@2
   598
williamr@4
   599
	// Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included)
williamr@2
   600
	enum
williamr@2
   601
		{
williamr@2
   602
		ELatinSet = 0x1,			// 0000-007F
williamr@2
   603
		EGreekSet = 0x80,			// 0370-03FF
williamr@2
   604
		ECyrillicSet = 0x200,		// 0400-04FF
williamr@2
   605
		EArmenianSet = 0x400,		// 0530-058F
williamr@2
   606
		EHebrewSet = 0x800,			// 0590-05FF
williamr@2
   607
		EArabicSet = 0x2000,		// 0600-06FF
williamr@2
   608
		EDevanagariSet = 0x8000,	// 0900-097F
williamr@2
   609
		EBengaliSet = 0x10000,		// 0980-09FF
williamr@2
   610
		EGurmukhiSet = 0x20000,		// 0A00-0A7F
williamr@2
   611
		EGujuratiSet = 0x40000,		// 0A80-0AFF
williamr@2
   612
		EOriyaSet = 0x80000,		// 0B00-0B7F
williamr@2
   613
		ETamilSet = 0x100000,		// 0B80-0BFF
williamr@2
   614
		ETeluguSet = 0x200000,		// 0C00-0C7F
williamr@2
   615
		EKannadaSet = 0x400000,		// 0C80-0CFF
williamr@2
   616
		EMalayalamSet = 0x800000,	// 0D00-0D7F
williamr@2
   617
		EThaiSet = 0x1000000,		// 0E00-0E7F
williamr@2
   618
		ELaoSet = 0x2000000,		// 0E80-0EFF
williamr@2
   619
		EGeorgianSet = 0x8000000,	// 10A0-10FF
williamr@2
   620
		EHangulJamoSet = 0x10000000,// 1100-11FF
williamr@2
   621
		};
williamr@2
   622
williamr@2
   623
	// Unicode ranges for iCoverage[1]
williamr@2
   624
	enum
williamr@2
   625
		{
williamr@2
   626
		ESymbolSets = 0xFFFE,
williamr@2
   627
		EKanaSets = 0x60000,
williamr@2
   628
		EHangulSet = 0x100000,
williamr@2
   629
		ECJKSet = 0x8000000
williamr@2
   630
		};
williamr@2
   631
williamr@2
   632
	// Attribute flags
williamr@2
   633
	enum
williamr@2
   634
		{
williamr@2
   635
		EBold = 0x1,			// weight > 500 in Windows terms
williamr@2
   636
		EItalic = 0x2,			// italic or oblique - any forward slant counts
williamr@2
   637
		ESerif = 0x4,			// characters have serifs
williamr@2
   638
		EMonoWidth = 0x8		// all characters are the same width
williamr@2
   639
		};
williamr@2
   640
williamr@2
   641
	// Other constants
williamr@2
   642
	enum
williamr@2
   643
		{
williamr@2
   644
		ENameLength = 32		// we allow 32 but names that are compatible with old-style fonts are limited to 24
williamr@2
   645
		};
williamr@2
   646
protected:
williamr@2
   647
	TBufC<ENameLength> iName;				// the name of the typeface; whether this is the full name or family name
williamr@2
   648
											// or is in English or another language depends on the context
williamr@2
   649
	TUint iCoverage[4];						// bitmap of the character sets supported by the typeface;
williamr@2
   650
											// these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4
williamr@2
   651
											// in the OS/2 table in TrueType fonts
williamr@2
   652
	TInt iStyle;							// bold, italic serif, and mono-width
williamr@2
   653
	TInt32 iReserved;
williamr@2
   654
	};
williamr@2
   655
williamr@4
   656
williamr@2
   657
/** 
williamr@2
   658
Typeface attributes.
williamr@2
   659
williamr@2
   660
These attributes include the name, family name, and supported scripts.
williamr@2
   661
williamr@4
   662
@see	CFbsFont::GetFaceAttrib()
williamr@2
   663
@publishedAll
williamr@2
   664
@released
williamr@2
   665
*/
williamr@2
   666
class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
williamr@2
   667
	{
williamr@2
   668
public:
williamr@2
   669
	inline TOpenFontFaceAttrib();
williamr@2
   670
	inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const;
williamr@2
   671
	inline TPtrC FullName() const;
williamr@2
   672
	inline TPtrC FamilyName() const;
williamr@2
   673
	inline TPtrC LocalFullName() const;
williamr@2
   674
	inline TPtrC LocalFamilyName() const;
williamr@2
   675
	inline TPtrC ShortFullName() const;
williamr@2
   676
	inline TPtrC ShortFamilyName() const;
williamr@2
   677
	inline TPtrC ShortLocalFullName() const;
williamr@2
   678
	inline TPtrC ShortLocalFamilyName() const;
williamr@2
   679
	inline void SetFullName(const TDesC& aName);
williamr@2
   680
	inline void SetFamilyName(const TDesC& aName);
williamr@2
   681
	inline void SetLocalFullName(const TDesC& aName);
williamr@2
   682
	inline void SetLocalFamilyName(const TDesC& aName);
williamr@2
   683
	inline TInt MinSizeInPixels() const;
williamr@2
   684
	inline void SetMinSizeInPixels(TInt aSize);
williamr@2
   685
private:
williamr@2
   686
	TBufC<ENameLength> iFamilyName;			// the name without any style suffixes; usually a truncation of iFullName
williamr@2
   687
	TBufC<ENameLength> iLocalFullName;		// the full name in the language of the current locale
williamr@2
   688
	TBufC<ENameLength> iLocalFamilyName;	// the family name in the language of the current locale
williamr@2
   689
	TInt iMinSizeInPixels;					// minimum supported size, (or readable size if scalable) in pixels
williamr@2
   690
	TInt32 iReserved2;
williamr@2
   691
	};
williamr@2
   692
williamr@4
   693
williamr@4
   694
/**
williamr@2
   695
Font specification allowing more attributes to be specified than TFontSpec.
williamr@2
   696
williamr@2
   697
In addition to the attributes specified by TFontSpec, this font specification 
williamr@2
   698
allows stretching and slanting in the x dimension, and other algorithmic effects. 
williamr@2
   699
This is used to correct for non-square pixels, and to allow algorithmic slanting 
williamr@2
   700
and bold. The width factor and slant factor transform any point (x,y) to (x 
williamr@2
   701
* iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16 
williamr@2
   702
fixed-point numbers.
williamr@2
   703
williamr@2
   704
The font specification also provides access to information about the scripts 
williamr@2
   705
which are supported by the font. This information is not always reliable, 
williamr@2
   706
because it may be incorrectly specified, or not specified at all, by some 
williamr@2
   707
font manufacturers. 
williamr@2
   708
@publishedAll
williamr@2
   709
@released
williamr@2
   710
*/
williamr@2
   711
class TOpenFontSpec : public TOpenFontFaceAttribBase
williamr@2
   712
	{
williamr@2
   713
public:
williamr@2
   714
	IMPORT_C TOpenFontSpec();
williamr@2
   715
	IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec);
williamr@2
   716
	IMPORT_C void operator=(const TFontSpec& aFontSpec);
williamr@2
   717
	inline TBool operator==(const TOpenFontSpec& aFontSpec) const;
williamr@2
   718
	TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const;
williamr@2
   719
	IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib);
williamr@2
   720
	IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const;
williamr@2
   721
	IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight);
williamr@2
   722
	IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap);
williamr@2
   723
	inline TInt Height() const;
williamr@2
   724
	inline TInt32 WidthFactor() const;
williamr@2
   725
	inline TInt32 SlantFactor() const;
williamr@2
   726
	inline TGlyphBitmapType BitmapType() const;
williamr@2
   727
	inline TUint32 Effects() const;
williamr@2
   728
	inline TFontPrintPosition PrintPosition() const;
williamr@2
   729
	inline void SetHeight(TInt aHeight);
williamr@2
   730
	inline void SetWidthFactor(TInt32 aWidthFactor);
williamr@2
   731
	inline void SetSlantFactor(TInt32 aSlantFactor);
williamr@2
   732
	inline void SetBitmapType(TGlyphBitmapType aBitmapType);
williamr@2
   733
	inline void SetEffects(TUint32 aEffects);
williamr@2
   734
	IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
williamr@2
   735
	IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
williamr@2
   736
	IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
williamr@2
   737
	IMPORT_C TInt ScriptTypeForMetrics() const;
williamr@4
   738
	static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight);
williamr@4
   739
	static TInt ApplyRatio(TInt& aValue,TInt aNumerator,TInt aDenominator);
williamr@4
   740
	static TInt ApplyRatio(TInt32& aValue,TInt aNumerator,TInt aDenominator);
williamr@2
   741
public:
williamr@2
   742
	/** Algorithmic effects flags.
williamr@2
   743
williamr@4
   744
	These can be combined using an OR operation.
williamr@4
   745
williamr@4
   746
	WARNING: Enum for internal and partner use ONLY.  Compatibility is not guaranteed in future releases.
williamr@4
   747
 
williamr@2
   748
	@deprecated Use FontEffect::TEffect instead.
williamr@2
   749
	*/
williamr@2
   750
	enum
williamr@2
   751
		{
williamr@2
   752
		/** Font is algorithmic bold. */
williamr@2
   753
		EAlgorithmicBold = 1,
williamr@2
   754
		/** Font has a drop shadow. */
williamr@2
   755
		EDropShadow = 2,
williamr@2
   756
		/** Font is an outline font. */
williamr@2
   757
		EOutline = 4
williamr@2
   758
		};
williamr@2
   759
private:
williamr@2
   760
	void SetScriptTypeForMetrics(TInt aScript);
williamr@2
   761
	void SetSymbol(TBool aSymbol);
williamr@2
   762
	TBool Symbol() const;
williamr@2
   763
	IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const;
williamr@2
   764
	IMPORT_C TUint32 DoEffects() const;
williamr@2
   765
	IMPORT_C void DoSetEffects(TUint32 aEffects);
williamr@2
   766
private:
williamr@2
   767
	TInt iHeight;						// em height
williamr@2
   768
	TInt32 iWidthFactor;				// algorithmic width factor as a 16.16 fixed-point number
williamr@2
   769
	TInt32 iSlantFactor;				// algorithmic slant factor as a 16.16 fixed-point number
williamr@2
   770
	TInt iBitmapType;					// non-anti-aliased, standard anti-aliased, etc.; zero means 'default'
williamr@2
   771
	TUint32 iEffects;					// bit flags for font effects
williamr@2
   772
	TInt iSymbol;						// a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5)
williamr@2
   773
	// The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec
williamr@2
   774
	TFontPrintPosition iPrintPosition;	// normal, superscript or subscript
williamr@2
   775
williamr@2
   776
	TInt iReserved2;
williamr@2
   777
	};
williamr@2
   778
williamr@2
   779
/**
williamr@2
   780
Font file abstract base class.
williamr@2
   781
williamr@2
   782
Write a class derived from COpenFontFile to manage a file with the font format 
williamr@2
   783
supported by your DLL. The derived class must implement the virtual 
williamr@2
   784
GetNearestFontInPixelsL() function. This function takes a font description 
williamr@2
   785
and creates a COpenFont derived object if the description matches a typeface 
williamr@2
   786
contained in the font file.
williamr@2
   787
williamr@2
   788
Derived classes must also load typeface attributes from the file into the 
williamr@2
   789
protected typeface attribute array during construction. This array is what 
williamr@2
   790
is searched when getting font attribute information see AddFaceL(), 
williamr@2
   791
GetNearestFontHelper().
williamr@2
   792
williamr@2
   793
Writing derived classes  construction:
williamr@2
   794
williamr@2
   795
Call the COpenFontFile constructor in the constructor for your derived object, 
williamr@2
   796
passing it aUid and aFileName arguments. These values are the arguments passed 
williamr@2
   797
when the constructor is called by COpenFontRasterizer::NewFontFileL().
williamr@2
   798
williamr@2
   799
A file may contain one or more typefaces. During construction the derived 
williamr@2
   800
object should extract the information for each typeface and add it to this 
williamr@2
   801
object's protected typeface attribute array see AddFaceL(). This process 
williamr@2
   802
will probably leave under some conditions. It should therefore be implemented 
williamr@2
   803
in a second phase constructor.
williamr@2
   804
williamr@2
   805
Writing derived classes  implement the pure virtual functions:
williamr@2
   806
williamr@2
   807
Derived classes must also implement the two pure virtual functions 
williamr@2
   808
GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about 
williamr@2
   809
these functions is provided in the definitions below. Information about 
williamr@2
   810
deriving from this class is also provided in the API guide. 
williamr@2
   811
williamr@4
   812
@see	COpenFontRasterizer::NewFontFileL()
williamr@4
   813
@see	CWsScreenDevice::AddFile()
williamr@2
   814
@publishedAll
williamr@2
   815
@released
williamr@2
   816
*/
williamr@2
   817
class COpenFontFile : public CBase
williamr@2
   818
	{
williamr@2
   819
public:
williamr@2
   820
	/**
williamr@2
   821
	Gets the font which is the nearest to the given font specification.
williamr@2
   822
williamr@2
   823
	Implementations of this pure virtual function should create the COpenFont 
williamr@2
   824
	derived object that most closely matches aDesiredFontSpec, while fitting within
williamr@2
   825
	aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
williamr@2
   826
	e.g. if the font name doesn't match, aFont should be set to NULL.
williamr@2
   827
williamr@2
   828
	The other two arguments, aHeap and aSessionCacheList, should be passed to 
williamr@2
   829
	the COpenFont constructor.
williamr@2
   830
williamr@2
   831
	Implementations may use the utility function GetNearestFontHelper()
williamr@2
   832
	to get the attributes of the closest matching font.
williamr@2
   833
williamr@4
   834
	@param	aHeap				Shared heap. This value should be passed to the 
williamr@4
   835
								COpenFont derived classes' constructor.
williamr@4
   836
	@param	aSessionCacheList	The session cache list. This value should be passed 
williamr@4
   837
								to the COpenFont derived classes' constructor.
williamr@4
   838
	@param	aDesiredFontSpec	The desired font specification.
williamr@4
   839
	@param	aPixelWidth			The width of a pixel. Used with aPixelHeight for calculating 
williamr@4
   840
								the algorithmic slant of the typeface.
williamr@4
   841
	@param	aPixelHeight		The height of a pixel. Used with aPixelWidth for calculating 
williamr@4
   842
								the algorithmic slant of the typeface.
williamr@4
   843
	@param	aFont				On return, contains a pointer to the newly created COpenFont 
williamr@4
   844
								derived object, or NULL if no font matching aDesiredFontSpec exists.
williamr@4
   845
	@param	aActualFontSpec		The actual font specification of the font retrieved into aFont.
williamr@4
   846
	@see	GetNearestFontHelper()
williamr@2
   847
	*/
williamr@2
   848
	virtual void GetNearestFontInPixelsL(
williamr@2
   849
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   850
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   851
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
williamr@2
   852
williamr@2
   853
	/**
williamr@2
   854
	Gets the font which is the nearest to the given font specification.
williamr@2
   855
williamr@2
   856
	Implementations of this pure virtual function should create the COpenFont 
williamr@2
   857
	derived object that most closely matches aDesiredFontSpec, while fitting within
williamr@2
   858
	aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
williamr@2
   859
	e.g. if the font name doesn't match, aFont should be set to NULL.
williamr@2
   860
williamr@2
   861
	The other two arguments, aHeap and aSessionCacheList, should be passed to 
williamr@2
   862
	the COpenFont constructor.
williamr@2
   863
williamr@2
   864
	Implementations may use the utility function GetNearestFontHelper()
williamr@2
   865
	to get the attributes of the closest matching font.
williamr@2
   866
williamr@4
   867
	@param	aHeap				Shared heap. This value should be passed to the COpenFont 
williamr@4
   868
								derived classes' constructor.
williamr@4
   869
	@param	aSessionCacheList	The session cache list. This value should be passed 
williamr@4
   870
								to the COpenFont derived classes' constructor.
williamr@4
   871
	@param	aDesiredFontSpec	The desired font specification.
williamr@4
   872
	@param	aPixelWidth			The width of a pixel. Used with aPixelHeight for calculating 
williamr@4
   873
								the algorithmic slant of the typeface.
williamr@4
   874
	@param	aPixelHeight		The height of a pixel. Used with aPixelWidth for calculating 
williamr@4
   875
								the algorithmic slant of the typeface.
williamr@4
   876
	@param	aFont				On return, contains a pointer to the newly created COpenFont 
williamr@4
   877
								derived object, or NULL if no font matching aDesiredFontSpec exists.
williamr@4
   878
	@param	aActualFontSpec		The actual font specification of the font retrieved into aFont.
williamr@4
   879
	@see	GetNearestFontHelper()
williamr@2
   880
	*/
williamr@2
   881
	virtual void GetNearestFontToDesignHeightInPixelsL(
williamr@2
   882
		RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
williamr@2
   883
		const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
williamr@2
   884
		COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
williamr@2
   885
	/**
williamr@2
   886
	Gets the font which is the nearest to the given font specification.
williamr@2
   887
williamr@2
   888
	Implementations of this pure virtual function should create the COpenFont 
williamr@2
   889
	derived object that most closely matches aDesiredFontSpec, while fitting within
williamr@2
   890
	aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
williamr@2
   891
	e.g. if the font name doesn't match, aFont should be set to NULL.
williamr@2
   892
williamr@2
   893
	The other two arguments, aHeap and aSessionCacheList, should be passed to 
williamr@2
   894
	the COpenFont constructor.
williamr@2
   895
williamr@2
   896
	Implementations may use the utility function GetNearestFontHelper()
williamr@2
   897
	to get the attributes of the closest matching font.
williamr@2
   898
williamr@4
   899
	@param	aHeap				Shared heap. This value should be passed to the COpenFont 
williamr@4
   900
								derived classes' constructor.
williamr@4
   901
	@param	aSessionCacheList	The session cache list. This value should be passed 
williamr@4
   902
								to the COpenFont derived classes' constructor.
williamr@4
   903
	@param	aDesiredFontSpec	The desired font specification.
williamr@4
   904
	@param	aPixelWidth			The width of a pixel. Used with aPixelHeight for calculating 
williamr@4
   905
								the algorithmic slant of the typeface.
williamr@4
   906
	@param	aPixelHeight		The height of a pixel. Used with aPixelWidth for calculating 
williamr@4
   907
								the algorithmic slant of the typeface.
williamr@4
   908
	@param	aFont				On return, contains a pointer to the newly created COpenFont 
williamr@4
   909
								derived object, or NULL if no font matching aDesiredFontSpec exists.
williamr@4
   910
	@param	aActualFontSpec		The actual font specification of the font retrieved into aFont.
williamr@4
   911
	@param	aMaxHeight			The maximum height (vertical extent) within which the font must fit.
williamr@4
   912
	@see	GetNearestFontHelper()
williamr@2
   913
	*/
williamr@2
   914
	virtual void GetNearestFontToMaxHeightInPixelsL(
williamr@2
   915
		RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
williamr@2
   916
		const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
williamr@2
   917
		COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
williamr@2
   918
williamr@2
   919
	/** Tests whether a specified typeface contains a particular character.
williamr@4
   920
williamr@4
   921
	@param	aFaceIndex	The index of the typeface to be tested.
williamr@4
   922
	@param	aCode		The Unicode character code for the character to be tested. 
williamr@4
   923
	@return	ETrue if the typeface contains aCode, otherwise EFalse. */
williamr@2
   924
	virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0; 
williamr@2
   925
	IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
williamr@2
   926
	IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName);
williamr@2
   927
	IMPORT_C ~COpenFontFile();
williamr@2
   928
	IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
williamr@2
   929
										TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
williamr@2
   930
	IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
williamr@2
   931
	inline TUid Uid() const;
williamr@2
   932
	inline const TDesC& FileName() const;
williamr@2
   933
	inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
williamr@2
   934
	inline TInt FaceCount() const;
williamr@2
   935
	inline void IncRefCount();
williamr@2
   936
	inline TBool DecRefCount();
williamr@2
   937
	TInt GetNearestFontInPixels(
williamr@2
   938
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   939
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   940
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
williamr@2
   941
	TInt GetNearestFontToDesignHeightInPixels(
williamr@2
   942
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   943
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   944
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
williamr@2
   945
	TInt GetNearestFontToMaxHeightInPixels(
williamr@2
   946
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   947
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   948
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
williamr@2
   949
	void RemoveFontFromList(const COpenFont* aFont);
williamr@2
   950
	void SetFontStoreL(CFontStore* aFontStore);
williamr@2
   951
	CFontStore* GetFontStore();
williamr@2
   952
	CArrayPtrFlat<COpenFont>* GetOpenFontList();
williamr@2
   953
protected:
williamr@2
   954
	IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
williamr@2
   955
										TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
williamr@2
   956
private:
williamr@2
   957
	// A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
williamr@2
   958
	class TAttrib: public TOpenFontFaceAttrib
williamr@2
   959
		{
williamr@4
   960
	public:
williamr@2
   961
		COpenFontPositioner* iPositioner;	// if non-null, positioning information for the typeface
williamr@2
   962
		};
williamr@2
   963
	static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
williamr@2
   964
	static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
williamr@2
   965
	void GetNearestFontToDesignHeightInPixelsAndAddToListL(
williamr@2
   966
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   967
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   968
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
williamr@2
   969
	void GetNearestFontToMaxHeightInPixelsAndAddToListL(
williamr@2
   970
		RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
williamr@2
   971
		const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
williamr@2
   972
		COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
williamr@2
   973
williamr@2
   974
private:
williamr@2
   975
	CArrayFixFlat<TAttrib> iFaceAttrib;
williamr@2
   976
	TUid iUid;
williamr@2
   977
	TBuf<KMaxFileName> iFileName;
williamr@2
   978
	TInt iRefCount;
williamr@2
   979
	CArrayPtrFlat<COpenFont> iFontList;
williamr@2
   980
	TOpenFontFileData* iData;
williamr@2
   981
	};
williamr@2
   982
williamr@4
   983
/**
williamr@2
   984
Convenience class from which rasterizer contexts may be derived.
williamr@2
   985
williamr@2
   986
A rasterizer context object may (optionally) be created to provide the link 
williamr@2
   987
between the rasterizer DLL code supported by the Open Font System, and the 
williamr@2
   988
rasterizer engine code. A rasterizer context object class should get the 
williamr@2
   989
requested bitmap from the associated rasterizer engine. It should then convert 
williamr@2
   990
this into Symbian run-length-encoded format. This class contains convenience 
williamr@2
   991
functions to make the conversion easier.
williamr@2
   992
williamr@2
   993
Deriving from this class is described in greater detail in the API guide.
williamr@2
   994
@publishedAll
williamr@2
   995
@released
williamr@2
   996
*/
williamr@2
   997
class COpenFontRasterizerContext: public CBase
williamr@2
   998
	{
williamr@2
   999
public:
williamr@2
  1000
	inline COpenFontRasterizerContext();
williamr@2
  1001
	inline void StartGlyph(TOpenFontGlyphData* aGlyphData);
williamr@2
  1002
	inline void WriteGlyphBit(TInt aBit);
williamr@2
  1003
	inline void WriteGlyphByte(TInt aByte);
williamr@2
  1004
	inline void EndGlyph();
williamr@2
  1005
private:
williamr@2
  1006
	TOpenFontGlyphData* iGlyphData;
williamr@2
  1007
	TUint8* iGlyphDataStart;
williamr@2
  1008
	TUint8* iGlyphDataPtr;
williamr@2
  1009
	TUint8* iGlyphDataEnd;
williamr@2
  1010
	TInt iGlyphBit;
williamr@2
  1011
	TInt iBytesNeeded;
williamr@2
  1012
	TBool iOverflow;
williamr@2
  1013
	TAny* iReserved; // unused; for future expansion
williamr@2
  1014
	};
williamr@2
  1015
williamr@2
  1016
williamr@2
  1017
/**
williamr@4
  1018
Shaper abstract class.  All shaper implementations derive from this
williamr@4
  1019
@publishedAll 
williamr@4
  1020
@released
williamr@4
  1021
*/
williamr@2
  1022
class CShaper : public CBase
williamr@2
  1023
	{
williamr@2
  1024
public:
williamr@2
  1025
	class TInput
williamr@2
  1026
		{
williamr@2
  1027
	public:
williamr@2
  1028
		/** The text to be shaped possibly including context. */
williamr@2
  1029
		const TDesC* iText;
williamr@2
  1030
		/** The index of the first character in iText to be shaped. */
williamr@2
  1031
		TInt iStart;
williamr@2
  1032
		/** (One past) the end of the text in iText to be shaped. */
williamr@2
  1033
		TInt iEnd;
williamr@2
  1034
		/** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
williamr@2
  1035
		for Devanagari. */
williamr@2
  1036
		TInt iScript;
williamr@2
  1037
		/** Language code. 0 implies "default" */
williamr@2
  1038
		TUint32 iLanguage;
williamr@2
  1039
		/** Maximum advance in pixels. Shaping beyond this
williamr@2
  1040
		advance is not required (but is not harmful). */
williamr@2
  1041
		TInt iMaximumAdvance;
williamr@2
  1042
		/** Flags. Currently none is defined. */
williamr@2
  1043
		TInt iFlags;
williamr@2
  1044
		/** Session handle. To be used if rasterization is needed. */
williamr@2
  1045
		TInt iSessionHandle;
williamr@2
  1046
		/** Reserved for future expansion. Must be set to 0. */
williamr@2
  1047
		TInt iReserved1;
williamr@2
  1048
		};
williamr@2
  1049
	/** Constructor */
williamr@2
  1050
	IMPORT_C CShaper();
williamr@2
  1051
williamr@2
  1052
	/** Destructor */
williamr@2
  1053
	IMPORT_C virtual ~CShaper();
williamr@2
  1054
williamr@2
  1055
	/** construct a shaper object
williamr@4
  1056
	@param	aBitmapFont	The font to be shaped.
williamr@4
  1057
	@param	aHeap		The heap to be used by the shaper.
williamr@4
  1058
	@return	KErrNone if this font can be shaper or system wide error code*/
williamr@2
  1059
	virtual TInt ConstructL(CBitmapFont*  aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
williamr@2
  1060
williamr@4
  1061
	/** If possible, shape the text described by aInput, placing the output on aHeapForOutput.
williamr@4
  1062
	@param	aOutput			The output, as a newly allocate object on aHeapForOutput.
williamr@4
  1063
	@param	aInput			The input text and other parameters.
williamr@4
  1064
	@param	aHeapForOutput	On success, aOutput should be allocated from this and nothing else. 
williamr@4
  1065
							On failure, nothing should be allocated from it.
williamr@4
  1066
	@return	Error value from one of the system-wide error codes on failure, KErrNone on success.
williamr@4
  1067
	@see	TShapeHeader */
williamr@2
  1068
	virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0;
williamr@2
  1069
williamr@2
  1070
	/** For future expansion. Any overriders must base-call
williamr@2
  1071
	if aInterface is unrecognized.
williamr@4
  1072
	
williamr@4
  1073
	WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
williamr@4
  1074
	
williamr@4
  1075
	@param	aInterfaceId	The ID of the interface to return.
williamr@4
  1076
	@return	A pointer to the extension interface.
williamr@2
  1077
	*/
williamr@4
  1078
	IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
williamr@2
  1079
	};
williamr@2
  1080
williamr@2
  1081
/** ECOM plug-in base class for shaper factories.
williamr@4
  1082
@publishedAll
williamr@4
  1083
@released
williamr@4
  1084
*/
williamr@2
  1085
class CShaperFactory : public CBase
williamr@2
  1086
	{
williamr@2
  1087
public:
williamr@2
  1088
	/** Create a shaper if possible, for typeface aFaceIndex
williamr@2
  1089
	within file aFileName.
williamr@4
  1090
	@param	aFont	The font to be shaped.
williamr@4
  1091
	@param	iHeap	The heap to use for constructing the shaper.
williamr@4
  1092
	@return	0 If the font is not understood or inappropriate for any shaper that might be constructed 
williamr@4
  1093
			by this class, otherwise returns the newly-constructed shaper on iHeap. */
williamr@2
  1094
	virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
williamr@2
  1095
williamr@2
  1096
	inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
williamr@2
  1097
	inline virtual ~CShaperFactory();
williamr@2
  1098
williamr@4
  1099
	/** For future expansion. Any overriders must base-call if aInterface is unrecognized.
williamr@4
  1100
williamr@4
  1101
	WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
williamr@4
  1102
williamr@4
  1103
	@param	aInterfaceId	The ID of the interface to return.
williamr@4
  1104
	@return	A pointer to the extension interface.	
williamr@2
  1105
	*/
williamr@2
  1106
	virtual void* ExtendedInterface(TUid aInterfaceId);
williamr@2
  1107
williamr@2
  1108
private:
williamr@2
  1109
	TUid iDtor_ID_Key;//ECOM identifier used during destruction
williamr@2
  1110
	};
williamr@2
  1111
williamr@2
  1112
// Inline functions start here.
williamr@2
  1113
/** Default C++ constructor.
williamr@4
  1114
williamr@2
  1115
This creates then zero fills the object. */
williamr@2
  1116
inline TOpenFontMetrics::TOpenFontMetrics()
williamr@2
  1117
	{
williamr@2
  1118
	Mem::FillZ(this,sizeof(*this));
williamr@2
  1119
	}
williamr@2
  1120
williamr@2
  1121
/** Gets the font's size.
williamr@4
  1122
williamr@4
  1123
@return	The font's size. 
williamr@4
  1124
@see	SetSize() */
williamr@2
  1125
inline TInt TOpenFontMetrics::Size() const
williamr@2
  1126
	{
williamr@2
  1127
	return iDesignHeight;
williamr@2
  1128
	}
williamr@4
  1129
williamr@2
  1130
/** Gets the font's ascent.
williamr@4
  1131
williamr@2
  1132
This is the ascent for the Latin character which is highest above the baseline.
williamr@2
  1133
williamr@2
  1134
@return The font's ascent, in pixels.
williamr@2
  1135
@see SetAscent() */
williamr@2
  1136
inline TInt TOpenFontMetrics::Ascent() const
williamr@2
  1137
	{
williamr@2
  1138
	return iAscent;
williamr@2
  1139
	}
williamr@2
  1140
williamr@2
  1141
/** Gets the font's descent.
williamr@4
  1142
williamr@2
  1143
This is the descent for the Latin character in the font which falls furthest below the baseline.
williamr@4
  1144
williamr@2
  1145
@return The font's descent, in pixels. 
williamr@2
  1146
@see SetDescent() */
williamr@2
  1147
inline TInt TOpenFontMetrics::Descent() const
williamr@2
  1148
	{
williamr@2
  1149
	return iDescent;
williamr@2
  1150
	}
williamr@4
  1151
williamr@2
  1152
/** Sets the font's maximum height.
williamr@2
  1153
williamr@2
  1154
Note that if this object was initialised from the CFont this will be the same 
williamr@2
  1155
as the ascent.
williamr@2
  1156
williamr@2
  1157
This is the ascent for the character which is highest above the baseline. 
williamr@4
  1158
In many fonts this will be the height of an accented character like Â, 
williamr@2
  1159
including the accent.
williamr@4
  1160
williamr@2
  1161
@return The maximum height of the font, in pixels.
williamr@2
  1162
@see SetMaxDepth() */
williamr@2
  1163
inline TInt TOpenFontMetrics::MaxHeight() const
williamr@2
  1164
	{
williamr@2
  1165
	return iMaxHeight;
williamr@2
  1166
	}
williamr@4
  1167
williamr@2
  1168
/** Gets the font's maximum depth.
williamr@2
  1169
williamr@2
  1170
Note: If this object was initialised from the CFont this will be the same as the 
williamr@2
  1171
descent.
williamr@2
  1172
williamr@2
  1173
This is the descent for the character in the font which falls furthest below 
williamr@2
  1174
the baseline.
williamr@4
  1175
williamr@2
  1176
@return The font's maximum depth.
williamr@2
  1177
@see SetMaxDepth() */
williamr@2
  1178
inline TInt TOpenFontMetrics::MaxDepth() const
williamr@2
  1179
	{
williamr@2
  1180
	return iMaxDepth;
williamr@2
  1181
	}
williamr@4
  1182
williamr@2
  1183
/** Gets the maximum character width, in pixels.
williamr@4
  1184
williamr@2
  1185
@return The maximum character width, in pixels.
williamr@2
  1186
@see SetMaxWidth() */
williamr@2
  1187
inline TInt TOpenFontMetrics::MaxWidth() const
williamr@2
  1188
	{
williamr@2
  1189
	return iMaxWidth;
williamr@2
  1190
	}
williamr@4
  1191
williamr@2
  1192
/** Sets the font's size.
williamr@4
  1193
williamr@2
  1194
@param aSize The font's size.
williamr@2
  1195
@see Size() */
williamr@2
  1196
inline void TOpenFontMetrics::SetSize(TInt aSize)
williamr@2
  1197
	{
williamr@2
  1198
	iDesignHeight = static_cast<TInt16>(aSize);
williamr@2
  1199
	}
williamr@2
  1200
williamr@2
  1201
/** Sets the ascent.
williamr@4
  1202
williamr@2
  1203
@param aAscent The ascent, in pixels.
williamr@2
  1204
@see Ascent() */
williamr@2
  1205
inline void TOpenFontMetrics::SetAscent(TInt aAscent)
williamr@2
  1206
	{
williamr@2
  1207
	iAscent = static_cast<TInt16>(aAscent);
williamr@2
  1208
	}
williamr@2
  1209
williamr@2
  1210
/** Sets the descent.
williamr@4
  1211
williamr@2
  1212
@param aDescent The descent, in pixels.
williamr@2
  1213
@see Descent() */
williamr@2
  1214
inline void TOpenFontMetrics::SetDescent(TInt aDescent)
williamr@2
  1215
	{
williamr@2
  1216
	iDescent = static_cast<TInt16>(aDescent);
williamr@2
  1217
	}
williamr@4
  1218
williamr@2
  1219
/** Sets the font's maximum height.
williamr@4
  1220
williamr@2
  1221
@param aMaxHeight The font's maximum height, in pixels. 
williamr@2
  1222
@see MaxHeight() */
williamr@2
  1223
inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
williamr@2
  1224
	{
williamr@2
  1225
	iMaxHeight = static_cast<TInt16>(aMaxHeight);
williamr@2
  1226
	}
williamr@4
  1227
williamr@2
  1228
/** Sets the font's maximum depth.
williamr@4
  1229
williamr@2
  1230
@param aMaxDepth The font's maximum depth, in pixels.
williamr@2
  1231
@see MaxDepth() */
williamr@2
  1232
inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
williamr@2
  1233
	{
williamr@2
  1234
	iMaxDepth = static_cast<TInt16>(aMaxDepth);
williamr@2
  1235
	}
williamr@4
  1236
williamr@2
  1237
/** Sets the maximum character width, in pixels.
williamr@4
  1238
williamr@2
  1239
@param aMaxWidth The maximum character width, in pixels.
williamr@2
  1240
@see MaxWidth() */
williamr@2
  1241
inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
williamr@2
  1242
	{
williamr@2
  1243
	iMaxWidth = static_cast<TInt16>(aMaxWidth);
williamr@2
  1244
	}
williamr@4
  1245
williamr@2
  1246
/** Default C++ constructor. 
williamr@4
  1247
williamr@2
  1248
The constructor initialises all data members to zero. As for other T classes, 
williamr@2
  1249
there is no need to explicitly cleanup TOpenFontCharMetrics objects. */
williamr@2
  1250
inline TOpenFontCharMetrics::TOpenFontCharMetrics()
williamr@2
  1251
	{
williamr@2
  1252
	Mem::FillZ(this,sizeof(*this));
williamr@2
  1253
	}
williamr@4
  1254
williamr@2
  1255
/** Gets the width of the character's bitmap.
williamr@4
  1256
williamr@2
  1257
@return The width of the bitmap in pixels. */
williamr@2
  1258
inline TInt TOpenFontCharMetrics::Width() const
williamr@2
  1259
	{
williamr@2
  1260
	return iWidth;
williamr@2
  1261
	}
williamr@4
  1262
williamr@2
  1263
/** Gets the height of the character's bitmap.
williamr@4
  1264
williamr@2
  1265
@return The character's height in pixels. */
williamr@2
  1266
inline TInt TOpenFontCharMetrics::Height() const
williamr@2
  1267
	{
williamr@2
  1268
	return iHeight;
williamr@2
  1269
	}
williamr@4
  1270
williamr@2
  1271
/** Gets the horizontal bearing X. 
williamr@4
  1272
williamr@2
  1273
This is the distance in pixels from the pen point before the character is 
williamr@2
  1274
drawn (the origin) to the left edge of the bitmap, when drawing horizontally. 
williamr@2
  1275
A positive value means that the left edge of the bitmap is right of the origin.
williamr@4
  1276
williamr@2
  1277
@return The horizontal bearing X in pixels */
williamr@2
  1278
inline TInt TOpenFontCharMetrics::HorizBearingX() const
williamr@2
  1279
	{
williamr@2
  1280
	return iHorizBearingX;
williamr@2
  1281
	}
williamr@4
  1282
williamr@2
  1283
/** Gets horizontal bearing Y.
williamr@4
  1284
williamr@2
  1285
This is the vertical distance in pixels from the pen point before the character 
williamr@2
  1286
is drawn (the origin) to the top edge of the bitmap, when drawing horizontally. 
williamr@2
  1287
A positive value means that the top edge of the bitmap is above the origin
williamr@4
  1288
williamr@2
  1289
@return The horizontal bearing Y in pixels. */
williamr@2
  1290
inline TInt TOpenFontCharMetrics::HorizBearingY() const
williamr@2
  1291
	{
williamr@2
  1292
	return iHorizBearingY;
williamr@2
  1293
	}
williamr@4
  1294
williamr@2
  1295
/** Gets the horizontal advance.
williamr@4
  1296
williamr@2
  1297
This is the amount added to the x co-ordinate of the origin after the character 
williamr@2
  1298
is drawn   what most people understand by the width or escapement of a character. 
williamr@2
  1299
The origin here is the pen point before the character is drawn. 
williamr@4
  1300
williamr@2
  1301
@return The horizontal advance in pixels */
williamr@2
  1302
inline TInt TOpenFontCharMetrics::HorizAdvance() const
williamr@2
  1303
	{
williamr@2
  1304
	return iHorizAdvance;
williamr@2
  1305
	}
williamr@2
  1306
williamr@2
  1307
/** Gets the vertical bearing X.
williamr@4
  1308
williamr@2
  1309
This is the distance in pixels from the pen point before the character is 
williamr@2
  1310
drawn (the origin) to the left edge of the bitmap, when drawing vertically. 
williamr@2
  1311
A positive value means that the left edge of the bitmap is right of the origin.
williamr@4
  1312
williamr@2
  1313
@return The vertical bearing X in pixels. */
williamr@2
  1314
inline TInt TOpenFontCharMetrics::VertBearingX() const
williamr@2
  1315
	{
williamr@2
  1316
	return iVertBearingX;
williamr@2
  1317
	}
williamr@4
  1318
williamr@2
  1319
/** Gets the vertical bearing Y.
williamr@4
  1320
williamr@2
  1321
This is the distance in pixels from the pen point before the character is 
williamr@2
  1322
drawn (the origin) to the top edge of the bitmap, when drawing vertically. 
williamr@2
  1323
A positive value means that the top edge of the bitmap is above the origin.
williamr@4
  1324
williamr@2
  1325
@return The vertical bearing Y in pixels. */
williamr@2
  1326
inline TInt TOpenFontCharMetrics::VertBearingY() const
williamr@2
  1327
	{
williamr@2
  1328
	return iVertBearingY;
williamr@2
  1329
	}
williamr@4
  1330
williamr@2
  1331
/** Gets the vertical advance.
williamr@4
  1332
williamr@2
  1333
When drawing vertically, this is the amount added to the y co-ordinate of 
williamr@2
  1334
the origin after the character is drawn what most people understand by 
williamr@2
  1335
the height of a character. The origin here is the pen point before the character 
williamr@2
  1336
is drawn.
williamr@4
  1337
williamr@2
  1338
Note: Vertical drawing is not supported in v5.
williamr@4
  1339
williamr@2
  1340
@return The vertical advance in pixels. */
williamr@2
  1341
inline TInt TOpenFontCharMetrics::VertAdvance() const
williamr@2
  1342
	{
williamr@2
  1343
	return iVertAdvance;
williamr@2
  1344
	}
williamr@4
  1345
williamr@2
  1346
/** Gets the bounds of the character relative to its origin when setting text 
williamr@2
  1347
horizontally.
williamr@4
  1348
williamr@2
  1349
The origin here is the pen point before the character is drawn. 
williamr@2
  1350
williamr@2
  1351
@param aBounds The character's bounds. */
williamr@2
  1352
inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
williamr@2
  1353
	{
williamr@2
  1354
	aBounds.iTl.iX = iHorizBearingX;
williamr@2
  1355
	aBounds.iTl.iY = -iHorizBearingY;
williamr@2
  1356
	aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
williamr@2
  1357
	aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
williamr@2
  1358
	}
williamr@4
  1359
williamr@2
  1360
/** Gets the bounds of the character relative to its origin when setting text 
williamr@2
  1361
vertically. 
williamr@4
  1362
williamr@2
  1363
The origin here is the pen point before the character is drawn.
williamr@4
  1364
williamr@2
  1365
@param aBounds The character's bounds. */
williamr@2
  1366
inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
williamr@2
  1367
	{
williamr@2
  1368
	aBounds.iTl.iX = -iVertBearingX;
williamr@2
  1369
	aBounds.iTl.iY = iVertBearingY;
williamr@2
  1370
	aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
williamr@2
  1371
	aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
williamr@2
  1372
	}
williamr@4
  1373
williamr@2
  1374
/** Sets the width of the character's bitmap.
williamr@4
  1375
williamr@2
  1376
@param aWidth The width of the bitmap in pixels. */
williamr@2
  1377
inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
williamr@2
  1378
	{
williamr@2
  1379
	iWidth = (TInt16)aWidth;
williamr@2
  1380
	}
williamr@4
  1381
williamr@2
  1382
/** Sets the height of the character's bitmap.
williamr@4
  1383
williamr@2
  1384
@param aHeight The character height (in pixels). */
williamr@2
  1385
inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
williamr@2
  1386
	{
williamr@2
  1387
	iHeight = (TInt16)aHeight;
williamr@2
  1388
	}
williamr@4
  1389
williamr@2
  1390
/** Sets the horizontal bearing X.
williamr@4
  1391
williamr@2
  1392
This is the distance in pixels from the pen point before the character is 
williamr@2
  1393
drawn (the origin) to the left edge of the bitmap, when drawing horizontally. 
williamr@2
  1394
A positive value means that the left edge of the bitmap is right of the origin.
williamr@4
  1395
williamr@2
  1396
@param aHorizBearingX The horizontal bearing X (in pixels). */
williamr@2
  1397
inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
williamr@2
  1398
	{
williamr@2
  1399
	iHorizBearingX = (TInt16)aHorizBearingX;
williamr@2
  1400
	}
williamr@4
  1401
williamr@2
  1402
/** Sets the horizontal bearing Y.
williamr@4
  1403
williamr@2
  1404
This is the distance in pixels from the pen point before the character is 
williamr@2
  1405
drawn (the origin) to the top edge of the bitmap, when drawing horizontally. 
williamr@2
  1406
A positive value means that the top edge of the bitmap is above the origin.
williamr@4
  1407
williamr@2
  1408
@param aHorizBearingY The horizontal bearing Y (in pixels). */
williamr@2
  1409
inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
williamr@2
  1410
	{
williamr@2
  1411
	iHorizBearingY = (TInt16)aHorizBearingY;
williamr@2
  1412
	}
williamr@4
  1413
williamr@2
  1414
/** Sets the horizontal advance.
williamr@4
  1415
williamr@2
  1416
This is the amount added to the x co-ordinate of the origin after the character 
williamr@2
  1417
is drawn, what most people understand by the width or escapement of a character. 
williamr@2
  1418
The origin here is the pen point before the character is drawn.
williamr@4
  1419
williamr@2
  1420
@param aHorizAdvance The horizontal advance (in pixels). */
williamr@2
  1421
inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
williamr@2
  1422
	{
williamr@2
  1423
	iHorizAdvance = (TInt16)aHorizAdvance;
williamr@2
  1424
	}
williamr@4
  1425
williamr@2
  1426
/** Set vertical bearing X.
williamr@4
  1427
williamr@2
  1428
This is the distance in pixels from the pen point before the character is 
williamr@2
  1429
drawn (the origin) to the left edge of the bitmap, when drawing vertically. 
williamr@2
  1430
A positive value means that the left edge of the bitmap is right of the origin.
williamr@4
  1431
williamr@2
  1432
@param aVertBearingX The vertical bearing X (in pixels). */
williamr@2
  1433
inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
williamr@2
  1434
	{
williamr@2
  1435
	iVertBearingX = (TInt16)aVertBearingX;
williamr@2
  1436
	}
williamr@4
  1437
williamr@2
  1438
/** Sets the vertical bearing Y.
williamr@4
  1439
williamr@2
  1440
This is the distance in pixels from the pen point before the character is 
williamr@2
  1441
drawn (the origin) to the top edge of the bitmap, when drawing vertically. 
williamr@2
  1442
A positive value means that the top edge of the bitmap is above the origin.
williamr@4
  1443
williamr@2
  1444
@param aVertBearingY The vertical bearing Y (in pixels). */
williamr@2
  1445
inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
williamr@2
  1446
	{
williamr@2
  1447
	iVertBearingY = (TInt16)aVertBearingY;
williamr@2
  1448
	}
williamr@4
  1449
williamr@2
  1450
/** Sets the vertical advance.
williamr@4
  1451
williamr@2
  1452
When drawing vertically, this is the amount added to the y co-ordinate of 
williamr@2
  1453
the origin after the character is drawn  what most people understand by 
williamr@2
  1454
the height of a character. The origin here is the pen point before the character 
williamr@2
  1455
is drawn.
williamr@4
  1456
williamr@2
  1457
Note: Vertical drawing is not supported in v5.
williamr@4
  1458
williamr@2
  1459
@param aVertAdvance The vertical advance (in pixels). */
williamr@2
  1460
inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
williamr@2
  1461
	{
williamr@2
  1462
	iVertAdvance = (TInt16)aVertAdvance;
williamr@2
  1463
	}
williamr@4
  1464
williamr@2
  1465
/** Gets the character metrics for this font.
williamr@4
  1466
williamr@2
  1467
@return The character metrics for this font. */
williamr@2
  1468
inline const TOpenFontMetrics& COpenFont::Metrics() const
williamr@2
  1469
	{
williamr@2
  1470
	return iMetrics;
williamr@2
  1471
	}
williamr@2
  1472
williamr@2
  1473
/** Gets the glyph index.
williamr@4
  1474
williamr@2
  1475
This is the index of a particular glyph within the font file.
williamr@4
  1476
williamr@2
  1477
Note: This makes it possible to gain access to glyphs which are not referenced 
williamr@2
  1478
by the Unicode character set. However, this feature is not yet supported by 
williamr@2
  1479
Symbian OS.
williamr@4
  1480
williamr@2
  1481
@return The glyph index.
williamr@2
  1482
@see SetGlyphIndex() */
williamr@2
  1483
inline TInt TOpenFontGlyphData::GlyphIndex() const
williamr@2
  1484
	{
williamr@2
  1485
	return iGlyphIndex;
williamr@2
  1486
	}
williamr@4
  1487
williamr@2
  1488
/** Gets the typeface attributes.
williamr@4
  1489
williamr@2
  1490
These are the attributes of the font represented by this object.
williamr@4
  1491
williamr@2
  1492
@return The typeface attributes. */
williamr@2
  1493
inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
williamr@2
  1494
	{
williamr@4
  1495
    return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex);
williamr@2
  1496
	}
williamr@4
  1497
williamr@2
  1498
/** Gets a pointer to the COpenFontFile which created this object.
williamr@4
  1499
williamr@2
  1500
This is the COpenFontFile which owns the file that contains the definition 
williamr@2
  1501
of the typeface. It can be used to get information about the typeface, or 
williamr@2
  1502
to access the rasterizer context (engine).
williamr@4
  1503
williamr@2
  1504
@return The COpenFontFile which created this object. */
williamr@2
  1505
inline COpenFontFile* COpenFont::File() const
williamr@2
  1506
	{
williamr@4
  1507
    return iFileOffset == 0 ? NULL : reinterpret_cast<COpenFontFile*>(const_cast<COpenFont*>(PtrAdd(this, iFileOffset)));
williamr@2
  1508
	}
williamr@4
  1509
williamr@2
  1510
/** Gets the index of this typeface within the font file.
williamr@4
  1511
williamr@2
  1512
@return The index of this typeface within the font file. */
williamr@2
  1513
inline TInt COpenFont::FaceIndex() const
williamr@2
  1514
	{
williamr@2
  1515
	return iFaceIndex;
williamr@2
  1516
	}
williamr@4
  1517
williamr@2
  1518
/** Tests whether or not a character needs to be rasterized.
williamr@4
  1519
williamr@2
  1520
Characters that have been rasterized are cached  there is no need to regenerate 
williamr@2
  1521
the character bitmap. This function should only be called by the Font and 
williamr@2
  1522
Bitmap server.
williamr@4
  1523
williamr@2
  1524
@param aSessionHandle A handle to the font and bitmap server session.
williamr@2
  1525
@param aCode The code for the Unicode character.
williamr@2
  1526
@return ETrue if the character needs to be rasterized, otherwise EFalse. */
williamr@2
  1527
inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const
williamr@2
  1528
	{
williamr@2
  1529
	return Glyph(aSessionHandle,aCode) == NULL;
williamr@2
  1530
	}
williamr@2
  1531
williamr@2
  1532
/** Gets the ascent of an ANSI capital letter in the font whether or not
williamr@2
  1533
there are any ANSI capitals in the font.
williamr@2
  1534
@return The positive distance from the font baseline to the top of a
williamr@2
  1535
standard ANSI capital letter
williamr@2
  1536
@publishedAll
williamr@2
  1537
@released
williamr@2
  1538
@see AscentInPixels()
williamr@2
  1539
*/
williamr@2
  1540
inline TInt COpenFont::FontCapitalAscent() const
williamr@2
  1541
	{
williamr@2
  1542
	return iFontCapitalAscent;
williamr@2
  1543
	}
williamr@2
  1544
williamr@2
  1545
/** Gets the max ascent of any pre-composed glyph in the font. This will
williamr@2
  1546
include accents or diacritics that form part of pre-composed glyphs. It is
williamr@2
  1547
not guaranteed to cover the max ascent of composite glyphs that have to be
williamr@2
  1548
created by a layout engine. This is also the recommended distance between
williamr@2
  1549
the top of a text box and the baseline of the first line of text. 
williamr@2
  1550
williamr@2
  1551
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
williamr@2
  1552
williamr@2
  1553
@return The positive distance from the font baseline to the top of the
williamr@2
  1554
highest pre-composed glyph (including accents) above the baseline.
williamr@2
  1555
@publishedAll
williamr@2
  1556
@released
williamr@2
  1557
@see AscentInPixels()
williamr@2
  1558
@see SetScriptTypeForMetrics()
williamr@2
  1559
*/
williamr@2
  1560
inline TInt COpenFont::FontMaxAscent() const
williamr@2
  1561
	{
williamr@2
  1562
	return iFontMaxAscent;
williamr@2
  1563
	}
williamr@2
  1564
williamr@2
  1565
/** Gets the descent of an ANSI descending character in the font.
williamr@2
  1566
Whether or not there are any ANSI descenders in the font.
williamr@2
  1567
williamr@2
  1568
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
williamr@2
  1569
williamr@2
  1570
@return The positive distance from the font baseline to the bottom of the
williamr@2
  1571
lowest ANSI descender.
williamr@2
  1572
@publishedAll
williamr@2
  1573
@released
williamr@2
  1574
@see DescentInPixels()
williamr@2
  1575
@see SetScriptTypeForMetrics()
williamr@2
  1576
*/
williamr@2
  1577
inline TInt COpenFont::FontStandardDescent() const
williamr@2
  1578
	{
williamr@2
  1579
	return iFontStandardDescent;
williamr@2
  1580
	}
williamr@2
  1581
williamr@2
  1582
/** Gets the max descent of any pre-composed glyph in the font. This will
williamr@2
  1583
include accents or diacritics that form part of pre-composed glyphs. It is
williamr@2
  1584
not guaranteed to cover the max descent of composite glyphs that have to be
williamr@2
  1585
created by a layout engine.
williamr@2
  1586
williamr@2
  1587
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
williamr@2
  1588
williamr@2
  1589
@return The positive distance from the font baseline to the bottom of the
williamr@2
  1590
lowest pre-composed glyph (including accents) below the baseline
williamr@2
  1591
@publishedAll
williamr@2
  1592
@released
williamr@2
  1593
@see DescentInPixels()
williamr@2
  1594
@see SetScriptTypeForMetrics()
williamr@2
  1595
*/
williamr@2
  1596
inline TInt COpenFont::FontMaxDescent() const
williamr@2
  1597
	{
williamr@2
  1598
	return iFontMaxDescent;
williamr@2
  1599
	}
williamr@2
  1600
williamr@2
  1601
/** Gets the suggested line gap for the font. This is the recommended
williamr@2
  1602
baseline to baseline distance between successive lines of text in the font.
williamr@2
  1603
@return The positive recommended gap between successive lines
williamr@2
  1604
@publishedAll
williamr@2
  1605
@released
williamr@2
  1606
*/
williamr@2
  1607
inline TInt COpenFont::FontLineGap() const
williamr@2
  1608
	{
williamr@2
  1609
	return iFontLineGap;
williamr@2
  1610
	}
williamr@2
  1611
williamr@2
  1612
/** Gets the maximum height for the font. This is the sum of the max ascent 
williamr@2
  1613
of the font and the max descent of the font.
williamr@2
  1614
williamr@2
  1615
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
williamr@2
  1616
williamr@2
  1617
@return The positive maximum height of the font
williamr@2
  1618
@publishedAll
williamr@2
  1619
@released
williamr@2
  1620
@see HeightInPixels()
williamr@2
  1621
@see SetScriptTypeForMetrics()
williamr@2
  1622
*/
williamr@2
  1623
inline TInt COpenFont::FontMaxHeight() const
williamr@2
  1624
	{
williamr@2
  1625
	return iFontMaxAscent + iFontMaxDescent;
williamr@2
  1626
	}
williamr@2
  1627
williamr@2
  1628
/** Default C++ constructor.
williamr@4
  1629
williamr@2
  1630
This sets all attribute fields to zero. As for other T classes, there is no 
williamr@2
  1631
need to explicitly clean-up objects derived from this class. */
williamr@2
  1632
inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
williamr@2
  1633
	{
williamr@2
  1634
	Mem::FillZ(this,sizeof(*this));
williamr@2
  1635
	}
williamr@4
  1636
williamr@2
  1637
/** Default C++ constructor.
williamr@4
  1638
williamr@2
  1639
The function initialises the minimum typeface size to zero, the names to NULL, 
williamr@2
  1640
and the coverage and style flags to zero. */
williamr@2
  1641
inline TOpenFontFaceAttrib::TOpenFontFaceAttrib():
williamr@2
  1642
	iMinSizeInPixels(0),
williamr@2
  1643
	iReserved2(0)
williamr@2
  1644
	{
williamr@2
  1645
	}
williamr@4
  1646
williamr@2
  1647
/** Tests for support of Latin characters.
williamr@4
  1648
williamr@2
  1649
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1650
characters. It does not imply exhaustive coverage.
williamr@4
  1651
williamr@2
  1652
@return ETrue if Latin characters are supported */
williamr@2
  1653
inline TBool TOpenFontFaceAttribBase::HasLatin() const
williamr@2
  1654
	{
williamr@2
  1655
	return iCoverage[0] & ELatinSet;
williamr@2
  1656
	}
williamr@4
  1657
williamr@2
  1658
/** Tests for support of Greek characters.
williamr@4
  1659
williamr@2
  1660
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1661
characters. It does not imply exhaustive coverage.
williamr@4
  1662
williamr@2
  1663
@return ETrue if Greek characters are supported. */
williamr@2
  1664
inline TBool TOpenFontFaceAttribBase::HasGreek() const
williamr@2
  1665
	{
williamr@2
  1666
	return iCoverage[0] & EGreekSet;
williamr@2
  1667
	}
williamr@4
  1668
williamr@2
  1669
/** Tests for support of Cyrillic characters.
williamr@4
  1670
williamr@2
  1671
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1672
characters. It does not imply exhaustive coverage.
williamr@4
  1673
williamr@2
  1674
@return ETrue if Cyrillic characters are supported. */
williamr@2
  1675
inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
williamr@2
  1676
	{
williamr@2
  1677
	return iCoverage[0] & ECyrillicSet;
williamr@2
  1678
	}
williamr@4
  1679
williamr@2
  1680
/** Tests for support of Japanese syllabic characters.
williamr@4
  1681
williamr@2
  1682
This function tests for the presence of Hiragana and Katakana syllabic 
williamr@2
  1683
characters in the font, collectively called kana. These characters are not 
williamr@2
  1684
sufficient for the Japanese language, which also makes use of Chinese characters.
williamr@4
  1685
williamr@2
  1686
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1687
characters. It does not imply exhaustive coverage.
williamr@4
  1688
williamr@2
  1689
@return ETrue if Japanese characters are supported 
williamr@2
  1690
@see HasCJK() */
williamr@2
  1691
inline TBool TOpenFontFaceAttribBase::HasKana() const
williamr@2
  1692
	{
williamr@2
  1693
	return iCoverage[1] & EKanaSets;
williamr@2
  1694
	}
williamr@4
  1695
williamr@2
  1696
/** Tests for support of Korean Hangul characters.
williamr@4
  1697
williamr@2
  1698
Korean may also make use of Chinese characters.
williamr@4
  1699
williamr@2
  1700
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1701
characters. It does not imply exhaustive coverage.
williamr@4
  1702
williamr@2
  1703
@return ETrue if Korean characters are supported 
williamr@2
  1704
@see HasCJK() */
williamr@2
  1705
inline TBool TOpenFontFaceAttribBase::HasHangul() const
williamr@2
  1706
	{
williamr@2
  1707
	return iCoverage[1] & EHangulSet;
williamr@2
  1708
	}
williamr@4
  1709
williamr@2
  1710
/** Tests for support of Chinese ideographic characters.
williamr@4
  1711
williamr@2
  1712
These are used in Chinese, Japanese and Korean.
williamr@4
  1713
williamr@2
  1714
Note: A return value of ETrue implies that the font has a usable set of 
williamr@2
  1715
characters. It does not imply exhaustive coverage.
williamr@4
  1716
williamr@2
  1717
@return ETrue if Chinese ideographs are supported. */
williamr@2
  1718
inline TBool TOpenFontFaceAttribBase::HasCJK() const
williamr@2
  1719
	{
williamr@2
  1720
	return iCoverage[1] & ECJKSet;
williamr@2
  1721
	}
williamr@4
  1722
williamr@2
  1723
/** Tests if the typeface contains symbols only.
williamr@4
  1724
williamr@2
  1725
@return ETrue if the typeface contains symbols only. */
williamr@2
  1726
inline TBool TOpenFontFaceAttribBase::IsSymbol() const
williamr@2
  1727
	{
williamr@2
  1728
	return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
williamr@2
  1729
		   iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
williamr@2
  1730
	}
williamr@4
  1731
williamr@2
  1732
/** Tests if the typeface is inherently bold.
williamr@4
  1733
williamr@2
  1734
@return ETrue if the typeface is inherently bold. */
williamr@2
  1735
inline TBool TOpenFontFaceAttribBase::IsBold() const
williamr@2
  1736
	{
williamr@2
  1737
	return iStyle & EBold;
williamr@2
  1738
	}
williamr@4
  1739
williamr@2
  1740
/** Tests if the typeface is inherently italic.
williamr@4
  1741
williamr@2
  1742
@return ETrue if the typeface is inherently italic. */
williamr@2
  1743
inline TBool TOpenFontFaceAttribBase::IsItalic() const
williamr@2
  1744
	{
williamr@2
  1745
	return iStyle & EItalic;
williamr@2
  1746
	}
williamr@4
  1747
williamr@2
  1748
/** Tests if the typeface has serifs.
williamr@4
  1749
williamr@2
  1750
@return ETrue if the typeface has serifs. */
williamr@2
  1751
inline TBool TOpenFontFaceAttribBase::IsSerif() const
williamr@2
  1752
	{
williamr@2
  1753
	return iStyle & ESerif;
williamr@2
  1754
	}
williamr@4
  1755
williamr@2
  1756
/** Tests if all the characters have the same width.
williamr@4
  1757
williamr@2
  1758
@return ETrue if all the characters have the same width. */
williamr@2
  1759
inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
williamr@2
  1760
	{
williamr@2
  1761
	return iStyle & EMonoWidth;
williamr@2
  1762
	}
williamr@4
  1763
williamr@2
  1764
/** Gets the typeface's name.
williamr@4
  1765
williamr@2
  1766
@return Descriptor containing typeface name. */
williamr@2
  1767
inline TPtrC TOpenFontFaceAttribBase::Name() const
williamr@2
  1768
	{
williamr@2
  1769
	return iName;
williamr@2
  1770
	}
williamr@4
  1771
williamr@2
  1772
/** Gets the full name.
williamr@4
  1773
williamr@2
  1774
The full name of the typeface includes style attributes like Italic, Bold, 
williamr@2
  1775
and Cursive.
williamr@4
  1776
williamr@2
  1777
@return The full name of the typeface.
williamr@2
  1778
@see FamilyName() */
williamr@2
  1779
inline TPtrC TOpenFontFaceAttrib::FullName() const
williamr@2
  1780
	{
williamr@2
  1781
	return Name();
williamr@2
  1782
	}
williamr@4
  1783
williamr@2
  1784
/** Gets the family name.
williamr@4
  1785
williamr@2
  1786
Note: The family name of the typeface does not include style attributes like 
williamr@2
  1787
"Italic".
williamr@4
  1788
williamr@2
  1789
@return The family name of the typeface. 
williamr@2
  1790
@see FullName() */
williamr@2
  1791
inline TPtrC TOpenFontFaceAttrib::FamilyName() const
williamr@2
  1792
	{
williamr@2
  1793
	return iFamilyName;
williamr@2
  1794
	}
williamr@4
  1795
williamr@2
  1796
/** Gets the local full name.
williamr@4
  1797
williamr@2
  1798
The local full name of the typeface includes style attributes like Italic, 
williamr@2
  1799
Bold, and Cursive.
williamr@4
  1800
williamr@2
  1801
The local name of the typeface is the name in the language of the current 
williamr@2
  1802
locale, where this is provided by the font file. If the local name is not 
williamr@2
  1803
available then the local name will be the same as the ordinary name.
williamr@4
  1804
williamr@2
  1805
@return The local full name of the typeface. */
williamr@2
  1806
inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
williamr@2
  1807
	{
williamr@2
  1808
	return iLocalFullName;
williamr@2
  1809
	}
williamr@4
  1810
williamr@2
  1811
/** Gets the local family name.
williamr@4
  1812
williamr@2
  1813
The local name of the typeface is the name in the language of the current 
williamr@2
  1814
locale, where this is provided by the font file. If the local name is not 
williamr@2
  1815
available then the local name will be the same as the ordinary name.
williamr@4
  1816
williamr@2
  1817
Note: The family name of the typeface does not include style attributes like 
williamr@2
  1818
'Italic'.
williamr@4
  1819
williamr@2
  1820
@return The local family name of the typeface. */
williamr@2
  1821
inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
williamr@2
  1822
	{
williamr@2
  1823
	return iLocalFamilyName;
williamr@2
  1824
	}
williamr@4
  1825
williamr@2
  1826
/** Gets the short full name.
williamr@4
  1827
williamr@2
  1828
This is the full name of the typeface, truncated to KMaxTypefaceNameLength, 
williamr@2
  1829
if necessary.
williamr@4
  1830
williamr@2
  1831
Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters 
williamr@2
  1832
where necessary so that they can be used in the TTypeFace class. The Open 
williamr@2
  1833
Font Framework allows 32 characters as a maximum name length.
williamr@4
  1834
williamr@2
  1835
@return The short full name of the typeface.
williamr@2
  1836
@see FullName() */
williamr@2
  1837
inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
williamr@2
  1838
	{
williamr@2
  1839
	// Can't use TDesC::Left for this because it panics if the desired length is > the existing length!
williamr@2
  1840
	return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength));
williamr@2
  1841
	}
williamr@4
  1842
williamr@2
  1843
/** Gets the short family name.
williamr@4
  1844
williamr@2
  1845
This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
williamr@4
  1846
williamr@2
  1847
Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters 
williamr@2
  1848
where necessary so that they can be used in the TTypeFace class. The Open 
williamr@2
  1849
Font Framework allows 32 characters as a maximum name length.
williamr@4
  1850
williamr@2
  1851
@return The short family name of the typeface. 
williamr@2
  1852
@see FamilyName() */
williamr@2
  1853
inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
williamr@2
  1854
	{
williamr@2
  1855
	return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
williamr@2
  1856
	}
williamr@4
  1857
williamr@2
  1858
/** Gets the short local full name.
williamr@4
  1859
williamr@2
  1860
This is the local full name of the typeface, truncated to KMaxTypefaceNameLength, 
williamr@2
  1861
if necessary.
williamr@4
  1862
williamr@2
  1863
Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters 
williamr@2
  1864
where necessary so that they can be used in the TTypeFace class. The Open 
williamr@2
  1865
Font Framework allows 32 characters as a maximum name length.
williamr@4
  1866
williamr@2
  1867
@return The short local full name of the typeface. 
williamr@2
  1868
@see LocalFullName() */
williamr@2
  1869
inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
williamr@2
  1870
	{
williamr@2
  1871
	return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
williamr@2
  1872
	}
williamr@4
  1873
williamr@2
  1874
/** Gets the short local family name.
williamr@4
  1875
williamr@2
  1876
This is the local family name of the typeface, truncated to KMaxTypefaceNameLength, 
williamr@2
  1877
if necessary.
williamr@4
  1878
williamr@2
  1879
Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters 
williamr@2
  1880
where necessary so that they can be used in the TTypeFace class. The Open 
williamr@2
  1881
Font Framework allows 32 characters as a maximum name length.
williamr@4
  1882
williamr@2
  1883
@return The short local family name of the typeface.
williamr@2
  1884
@see LocalFamilyName() */
williamr@2
  1885
inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
williamr@2
  1886
	{
williamr@2
  1887
	return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
williamr@2
  1888
	}
williamr@4
  1889
williamr@2
  1890
/** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
williamr@4
  1891
williamr@2
  1892
Each flag that is set represents a supported Unicode range. The mapping is 
williamr@2
  1893
defined in the TrueType documentation under the OS/2 table. 
williamr@4
  1894
williamr@2
  1895
Note: Some useful subsets are defined as anonymous enumerated constants at the end 
williamr@2
  1896
of this class, see ELatinSet etc.
williamr@4
  1897
williamr@2
  1898
@return A pointer to the flags that indicate the font's Unicode coverage. 
williamr@2
  1899
The flags are stored in an array of four 32-bit integers. When no information 
williamr@2
  1900
is available, all four integers are zero.
williamr@2
  1901
@see SetCoverage() */
williamr@2
  1902
inline const TUint* TOpenFontFaceAttribBase::Coverage() const
williamr@2
  1903
	{
williamr@2
  1904
	return iCoverage;
williamr@2
  1905
	}
williamr@4
  1906
williamr@2
  1907
/** Gets the minimum typeface size.
williamr@4
  1908
williamr@2
  1909
This is the smallest size that can be drawn legibly.
williamr@4
  1910
williamr@2
  1911
@return The minimum typeface size (in pixels). */
williamr@2
  1912
inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
williamr@2
  1913
	{
williamr@2
  1914
	return iMinSizeInPixels;
williamr@2
  1915
	}
williamr@4
  1916
williamr@2
  1917
/** Sets the name attribute.
williamr@4
  1918
williamr@2
  1919
@param aName Descriptor containing typeface name. */
williamr@2
  1920
inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
williamr@2
  1921
	{
williamr@2
  1922
	iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
williamr@2
  1923
	}
williamr@4
  1924
williamr@2
  1925
/** Sets the full name.
williamr@4
  1926
williamr@2
  1927
@param aName The full name of the typeface.
williamr@2
  1928
@see FullName() */
williamr@2
  1929
inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
williamr@2
  1930
	{
williamr@2
  1931
	SetName(aName);
williamr@2
  1932
	}
williamr@4
  1933
williamr@2
  1934
/** Sets the family name.
williamr@4
  1935
williamr@2
  1936
@param aName The family name of the typeface. 
williamr@2
  1937
@see FamilyName() */
williamr@2
  1938
inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
williamr@2
  1939
	{
williamr@2
  1940
	iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
williamr@2
  1941
	}
williamr@4
  1942
williamr@2
  1943
/** Sets the local full name.
williamr@4
  1944
williamr@2
  1945
@param aName The local full name of the typeface. 
williamr@2
  1946
@see LocalFullName() */
williamr@2
  1947
inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
williamr@2
  1948
	{
williamr@2
  1949
	iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
williamr@2
  1950
	}
williamr@4
  1951
williamr@2
  1952
/** Sets the local family name.
williamr@4
  1953
williamr@2
  1954
@param aName The local family name of the typeface. 
williamr@2
  1955
@see LocalFamilyName() */
williamr@2
  1956
inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
williamr@2
  1957
	{
williamr@2
  1958
	iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
williamr@2
  1959
	}
williamr@2
  1960
williamr@2
  1961
/** Sets the coverage flags.
williamr@2
  1962
williamr@2
  1963
The flags are held in four 32 bit integers. Each flag that is set represents 
williamr@2
  1964
a range of Unicode characters that is supported by the typeface: Latin, 
williamr@2
  1965
Greek, Cyrillic etc. The mapping is defined in the TrueType documentation 
williamr@2
  1966
under the OS/2 table.
williamr@2
  1967
williamr@2
  1968
Note: Some useful subsets are defined as anonymous enumerated constants at 
williamr@2
  1969
the end of this class, see ELatinSet etc.
williamr@2
  1970
williamr@2
  1971
@param aCoverage0 The first set of coverage flags (bits 0-31).
williamr@2
  1972
@param aCoverage1 The second set of coverage flags (bits 32-63).
williamr@2
  1973
@param aCoverage2 The third set of coverage flags (bits 64-95). 
williamr@2
  1974
@param aCoverage3 The fourth set of coverage flags (bits 96-127). */
williamr@2
  1975
inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3)
williamr@2
  1976
	{
williamr@2
  1977
	iCoverage[0] = aCoverage0;
williamr@2
  1978
	iCoverage[1] = aCoverage1;
williamr@2
  1979
	iCoverage[2] = aCoverage2;
williamr@2
  1980
	iCoverage[3] = aCoverage3;
williamr@2
  1981
	}
williamr@4
  1982
williamr@2
  1983
/** Set the minimum typeface size.
williamr@4
  1984
williamr@2
  1985
This is the smallest size that can be drawn legibly.
williamr@4
  1986
williamr@2
  1987
@param aSize Sets the minimum typeface size (in pixels). 
williamr@2
  1988
@see MinSizeInPixels() */
williamr@2
  1989
inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
williamr@2
  1990
	{
williamr@2
  1991
	iMinSizeInPixels = aSize;
williamr@2
  1992
	}
williamr@4
  1993
williamr@2
  1994
/** Equality operator.
williamr@4
  1995
williamr@2
  1996
Compares this and another set of font attributes, including the coverage, 
williamr@2
  1997
the family name, the local full name, the local family name, and the minimum 
williamr@2
  1998
size in pixels.
williamr@4
  1999
williamr@2
  2000
@param aAttrib Contains the font attributes and names to compare.
williamr@2
  2001
@return ETrue if all values are equal, EFalse if not. */
williamr@2
  2002
inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const
williamr@2
  2003
	{
williamr@2
  2004
	return TOpenFontFaceAttribBase::operator==(aAttrib) &&
williamr@2
  2005
		   iFamilyName == aAttrib.iFamilyName &&
williamr@2
  2006
		   iLocalFullName == aAttrib.iLocalFullName &&
williamr@2
  2007
		   iLocalFamilyName == aAttrib.iLocalFamilyName &&
williamr@2
  2008
		   iMinSizeInPixels == aAttrib.iMinSizeInPixels;
williamr@2
  2009
	}
williamr@2
  2010
williamr@2
  2011
/** Sets the bold attribute.
williamr@2
  2012
williamr@2
  2013
@param aBold The bold attribute takes this value: ETrue or EFalse. */
williamr@2
  2014
inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
williamr@2
  2015
	{
williamr@2
  2016
	if (aBold)
williamr@2
  2017
		iStyle |= EBold;
williamr@2
  2018
	else
williamr@2
  2019
		iStyle &= ~EBold;
williamr@2
  2020
	}
williamr@2
  2021
williamr@2
  2022
/** Sets the italic attribute.
williamr@4
  2023
williamr@2
  2024
@param aItalic The italic attribute takes this value   ETrue or EFalse. */
williamr@2
  2025
inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
williamr@2
  2026
	{
williamr@2
  2027
	if (aItalic)
williamr@2
  2028
		iStyle |= EItalic;
williamr@2
  2029
	else
williamr@2
  2030
		iStyle &= ~EItalic;
williamr@2
  2031
	}
williamr@4
  2032
williamr@2
  2033
/** Sets the serif attribute.
williamr@4
  2034
williamr@2
  2035
@param aSerif The serif attribute takes this value  ETrue or EFalse. */
williamr@2
  2036
inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
williamr@2
  2037
	{
williamr@2
  2038
	if (aSerif)
williamr@2
  2039
		iStyle |= ESerif;
williamr@2
  2040
	else
williamr@2
  2041
		iStyle &= ~ESerif;
williamr@2
  2042
	}
williamr@2
  2043
williamr@2
  2044
/** Sets the mono-width attribute.
williamr@2
  2045
williamr@2
  2046
@param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
williamr@2
  2047
inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
williamr@2
  2048
	{
williamr@2
  2049
	if (aMonoWidth)
williamr@2
  2050
		iStyle |= EMonoWidth;
williamr@2
  2051
	else
williamr@2
  2052
		iStyle &= ~EMonoWidth;
williamr@2
  2053
	}
williamr@2
  2054
williamr@2
  2055
/** Equality operator. 
williamr@4
  2056
williamr@2
  2057
Compares this and a specified set of font attributes, including the coverage 
williamr@2
  2058
and the typeface name.
williamr@4
  2059
williamr@2
  2060
In version 6.1, and earlier, the return value was TInt.
williamr@4
  2061
williamr@2
  2062
@param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase 
williamr@2
  2063
or of a derived class. 
williamr@2
  2064
@return ETrue if the values are equal. */
williamr@2
  2065
inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const
williamr@2
  2066
	{
williamr@2
  2067
	return iStyle == aAttrib.iStyle &&
williamr@2
  2068
		   iCoverage[0] == aAttrib.iCoverage[0] &&
williamr@2
  2069
		   iCoverage[1] == aAttrib.iCoverage[1] &&
williamr@2
  2070
		   iCoverage[2] == aAttrib.iCoverage[2] &&
williamr@2
  2071
		   iCoverage[3] == aAttrib.iCoverage[3] &&
williamr@2
  2072
		   iName.CompareF(aAttrib.iName) == 0;
williamr@2
  2073
	}
williamr@2
  2074
williamr@2
  2075
/** Compares this and another open font specification. Compares all the properties 
williamr@2
  2076
of the two fonts.
williamr@2
  2077
@publishedAll
williamr@2
  2078
@released
williamr@2
  2079
@param aFontSpec The open font specification to compare with this one.
williamr@2
  2080
@return ETrue if all values are equal, EFalse if not.
williamr@2
  2081
*/
williamr@2
  2082
inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
williamr@2
  2083
	{
williamr@2
  2084
	return
williamr@2
  2085
		iHeight			== aOpenFontSpec.iHeight &&
williamr@2
  2086
		iWidthFactor	== aOpenFontSpec.iWidthFactor &&
williamr@2
  2087
		iSlantFactor	== aOpenFontSpec.iSlantFactor &&
williamr@2
  2088
		iBitmapType		== aOpenFontSpec.iBitmapType &&
williamr@2
  2089
		iEffects		== aOpenFontSpec.iEffects &&
williamr@2
  2090
		iSymbol			== aOpenFontSpec.iSymbol &&
williamr@2
  2091
		iPrintPosition	== aOpenFontSpec.iPrintPosition &&
williamr@2
  2092
		TOpenFontFaceAttribBase::operator==(aOpenFontSpec);
williamr@2
  2093
	}
williamr@2
  2094
williamr@2
  2095
/** Gets the height of the font.
williamr@4
  2096
williamr@2
  2097
@return The height of the font, in pixels or twips. 
williamr@2
  2098
@see SetHeight() */
williamr@2
  2099
inline TInt TOpenFontSpec::Height() const
williamr@2
  2100
	{
williamr@2
  2101
	return iHeight;
williamr@2
  2102
	}
williamr@4
  2103
williamr@2
  2104
/** Gets the algorithmic width factor.
williamr@4
  2105
williamr@2
  2106
@return The algorithmic width factor as a 16.16 fixed-point number.
williamr@2
  2107
@see SetWidthFactor() */
williamr@2
  2108
inline TInt32 TOpenFontSpec::WidthFactor() const
williamr@2
  2109
	{
williamr@2
  2110
	return iWidthFactor;
williamr@2
  2111
	}
williamr@4
  2112
williamr@2
  2113
/** Gets the algorithmic slant factor.
williamr@4
  2114
williamr@2
  2115
@return The algorithmic slant factor as a 16.16 fixed-point number.
williamr@2
  2116
@see SetSlantFactor() */
williamr@2
  2117
inline TInt32 TOpenFontSpec::SlantFactor() const
williamr@2
  2118
	{
williamr@2
  2119
	return iSlantFactor;
williamr@2
  2120
	}
williamr@4
  2121
williamr@2
  2122
/** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
williamr@4
  2123
williamr@2
  2124
@return Indicates whether or not the font should be drawn using anti-aliasing. */
williamr@2
  2125
inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
williamr@2
  2126
	{
williamr@2
  2127
	return (TGlyphBitmapType)iBitmapType;
williamr@2
  2128
	}
williamr@2
  2129
williamr@2
  2130
/** Gets the font effects flags.
williamr@2
  2131
Because the flags encoded in the Effects are anonymous, the return value should only
williamr@2
  2132
 be tested for the specific bits that are of interest, and never tested as a whole.
williamr@2
  2133
@publishedAll
williamr@2
  2134
@released
williamr@2
  2135
@return The font effects flags.
williamr@2
  2136
@see TOpenFontSpec::SetEffects()
williamr@2
  2137
*/
williamr@2
  2138
inline TUint32 TOpenFontSpec::Effects() const
williamr@2
  2139
	{
williamr@2
  2140
	return iEffects;
williamr@2
  2141
	}
williamr@2
  2142
williamr@2
  2143
/** Gets the print position.
williamr@4
  2144
williamr@2
  2145
@return The print position. */
williamr@2
  2146
inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
williamr@2
  2147
	{
williamr@2
  2148
	return iPrintPosition;
williamr@2
  2149
	}
williamr@4
  2150
williamr@2
  2151
/** Sets the font's height.
williamr@4
  2152
williamr@2
  2153
@param aHeight The font's height, in pixels or twips.
williamr@2
  2154
@see Height() */
williamr@2
  2155
inline void TOpenFontSpec::SetHeight(TInt aHeight)
williamr@2
  2156
	{
williamr@2
  2157
	iHeight = aHeight;
williamr@2
  2158
	}
williamr@2
  2159
williamr@2
  2160
/** Sets the algorithmic width factor.
williamr@4
  2161
williamr@2
  2162
The width factor is multiplied by the pixel's x position to get the new position, 
williamr@2
  2163
causing characters to become wider or narrower. A width factor of 1 (65536 
williamr@2
  2164
in 16.16 fixed-point number format) should be used if the character width 
williamr@2
  2165
is not to be changed.
williamr@4
  2166
williamr@2
  2167
@param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
williamr@2
  2168
@see WidthFactor() */
williamr@2
  2169
inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
williamr@2
  2170
	{
williamr@2
  2171
	iWidthFactor = aWidthFactor;
williamr@2
  2172
	}
williamr@4
  2173
williamr@2
  2174
/** Sets the algorithmic slant factor.
williamr@4
  2175
williamr@2
  2176
Note: The slant factor is used to create an italic effect for characters which 
williamr@2
  2177
do not have an italic glyph in the typeface. When slanting is active, pixel x 
williamr@2
  2178
co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x 
williamr@2
  2179
= x + y x slant factor).
williamr@4
  2180
williamr@2
  2181
The slant factor is a 32 bit, 16.16 fixed-point number. This means that the 
williamr@2
  2182
first 16 bits are treated as a whole number, and the second 16 as the fractional 
williamr@2
  2183
part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this 
williamr@2
  2184
is equivalent to an integer slant value of 1, which causes a 45 degree slant 
williamr@2
  2185
on the character.
williamr@4
  2186
williamr@2
  2187
@param aSlantFactor The slant factor as a 16.16 fixed-point number.
williamr@2
  2188
@see SlantFactor() */
williamr@2
  2189
inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
williamr@2
  2190
	{
williamr@2
  2191
	iSlantFactor = aSlantFactor;
williamr@2
  2192
	}
williamr@4
  2193
williamr@2
  2194
/** Sets whether the font should be drawn using anti-aliasing. If set, this value 
williamr@2
  2195
overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType()) 
williamr@2
  2196
for this font.
williamr@4
  2197
williamr@2
  2198
Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing 
williamr@2
  2199
support for bitmapped fonts.
williamr@4
  2200
williamr@2
  2201
@param aBitmapType Indicates whether or not the font should be drawn using 
williamr@2
  2202
anti-aliasing. */
williamr@2
  2203
inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
williamr@2
  2204
	{
williamr@2
  2205
	iBitmapType = aBitmapType;
williamr@2
  2206
	}
williamr@2
  2207
williamr@2
  2208
/** Sets the font effects flags.
williamr@2
  2209
Prior to calling this routine, the value from Effects() should be read,
williamr@2
  2210
 and its flags modified as required, before passing them back in.
williamr@2
  2211
@publishedAll
williamr@2
  2212
@released
williamr@2
  2213
@param aEffect The font effects flags to be set.
williamr@2
  2214
@see TOpenFontSpec::Effects()
williamr@2
  2215
*/
williamr@2
  2216
inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
williamr@2
  2217
	{
williamr@2
  2218
	iEffects = aEffects;
williamr@2
  2219
	}
williamr@2
  2220
williamr@2
  2221
/** Gets the font file's UID.
williamr@4
  2222
williamr@2
  2223
@return The uid of the file. */
williamr@2
  2224
inline TUid COpenFontFile::Uid() const
williamr@2
  2225
	{
williamr@2
  2226
	return iUid;
williamr@2
  2227
	}
williamr@4
  2228
williamr@2
  2229
/** Gets the full path and filename of the font file
williamr@4
  2230
williamr@2
  2231
This is the filename that was passed to the constructor when the object is 
williamr@2
  2232
created.
williamr@4
  2233
williamr@2
  2234
@return The filename of the font file. */
williamr@2
  2235
inline const TDesC& COpenFontFile::FileName() const
williamr@2
  2236
	{
williamr@2
  2237
	return iFileName;
williamr@2
  2238
	}
williamr@4
  2239
williamr@2
  2240
/** Gets the typeface at a specified index in the typeface attribute array.
williamr@4
  2241
williamr@2
  2242
@param aFaceIndex The index of the typeface for which the attributes are required.
williamr@2
  2243
@return The attributes of the typeface with the specified index.
williamr@2
  2244
@see AddFaceL()
williamr@2
  2245
@see FaceCount() */
williamr@2
  2246
inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
williamr@2
  2247
	{
williamr@2
  2248
	return iFaceAttrib[aFaceIndex];
williamr@2
  2249
	}
williamr@4
  2250
williamr@2
  2251
/** Gets the number of typefaces in the typeface attributes array.
williamr@2
  2252
williamr@2
  2253
This is the number of typefaces in the font file: the attributes for each 
williamr@2
  2254
typeface should be loaded into the array when the derived object is constructed.
williamr@2
  2255
williamr@2
  2256
@return The number of typefaces in the font file.
williamr@2
  2257
@see AddFaceL()
williamr@2
  2258
@see FaceAttrib() */
williamr@2
  2259
inline TInt COpenFontFile::FaceCount() const
williamr@2
  2260
	{
williamr@2
  2261
	return iFaceAttrib.Count();
williamr@2
  2262
	}
williamr@4
  2263
williamr@2
  2264
/** Increments a reference count by one.
williamr@4
  2265
williamr@2
  2266
@see DecRefCount() */
williamr@2
  2267
inline void COpenFontFile::IncRefCount()
williamr@2
  2268
	{
williamr@2
  2269
	iRefCount++;
williamr@2
  2270
	}
williamr@4
  2271
williamr@2
  2272
/** Decrement a reference count by one.
williamr@4
  2273
williamr@2
  2274
@return ETrue if the reference count has reached zero (i.e. is less than or 
williamr@2
  2275
equal to zero); EFalse if the reference count has not yet reached zero (i.e. 
williamr@2
  2276
is positive).
williamr@2
  2277
@see IncRefCount() */
williamr@2
  2278
inline TBool COpenFontFile::DecRefCount()
williamr@2
  2279
	{
williamr@2
  2280
	iRefCount--;
williamr@2
  2281
	return iRefCount <= 0;
williamr@2
  2282
	}
williamr@4
  2283
williamr@2
  2284
/** Default C++ constructor. */
williamr@2
  2285
inline COpenFontRasterizerContext::COpenFontRasterizerContext():
williamr@2
  2286
	iGlyphData(NULL)
williamr@2
  2287
	{
williamr@2
  2288
	}
williamr@4
  2289
williamr@2
  2290
/** Start writing the glyph data.
williamr@4
  2291
williamr@2
  2292
Use this function to initialise the buffer to which the glyph bitmap is to 
williamr@2
  2293
be written. Call WriteGlyphBit() to add bits to the buffer.
williamr@4
  2294
williamr@2
  2295
@param aGlyphData A pointer to the glyph data. */
williamr@2
  2296
inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
williamr@2
  2297
	{
williamr@2
  2298
	aGlyphData->SetPointersToInternalBuffers();
williamr@2
  2299
	iGlyphData = aGlyphData;
williamr@2
  2300
	iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
williamr@2
  2301
	// Allow 4 extra bytes; BITGDI requires this.
williamr@2
  2302
	iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
williamr@2
  2303
	iGlyphBit = 1;
williamr@2
  2304
	*iGlyphDataPtr = 0;
williamr@2
  2305
	iBytesNeeded = 1;
williamr@2
  2306
	iOverflow = FALSE;
williamr@2
  2307
	}
williamr@4
  2308
williamr@2
  2309
/** Writes a bit to the glyph buffer.
williamr@4
  2310
williamr@2
  2311
Before calling this function you should first call StartGlyph().
williamr@4
  2312
williamr@2
  2313
@param aBit The bit to be added to the buffer. */
williamr@2
  2314
inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
williamr@2
  2315
	{
williamr@2
  2316
	if (aBit && !iOverflow)
williamr@2
  2317
		*iGlyphDataPtr |= iGlyphBit;
williamr@2
  2318
	iGlyphBit <<= 1;
williamr@2
  2319
	if (iGlyphBit == 256)
williamr@2
  2320
		{
williamr@2
  2321
		iGlyphBit = 1;
williamr@2
  2322
		iBytesNeeded++;
williamr@2
  2323
		if (++iGlyphDataPtr < iGlyphDataEnd)
williamr@2
  2324
			*iGlyphDataPtr = 0;
williamr@2
  2325
		else
williamr@2
  2326
			iOverflow = TRUE;
williamr@2
  2327
		}
williamr@2
  2328
	}
williamr@2
  2329
williamr@2
  2330
/** Writes a byte to the glyph buffer.
williamr@2
  2331
williamr@2
  2332
Before calling this function you should first call StartGlyph().
williamr@2
  2333
williamr@2
  2334
@param aByte The byte to be added to the buffer. */	
williamr@2
  2335
inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
williamr@2
  2336
 	{
williamr@2
  2337
	if (iGlyphDataPtr < iGlyphDataEnd)
williamr@2
  2338
		*iGlyphDataPtr++ = (TUint8)aByte;
williamr@2
  2339
	else
williamr@2
  2340
		iOverflow = TRUE;
williamr@2
  2341
	iBytesNeeded++;
williamr@2
  2342
	}
williamr@4
  2343
williamr@2
  2344
/** Completes writing glyph data.
williamr@4
  2345
williamr@2
  2346
Use this function to complete writing the glyph bitmap to the buffer. Call 
williamr@2
  2347
it after adding all necessary bits using WriteGlyphBit(). */
williamr@2
  2348
inline void COpenFontRasterizerContext::EndGlyph()
williamr@2
  2349
	{
williamr@2
  2350
	// Add 4 bytes to the data size; some BITGDI functions require this.
williamr@2
  2351
	iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
williamr@2
  2352
	iGlyphData = NULL;
williamr@2
  2353
	}
williamr@4
  2354
williamr@2
  2355
/** Tests whether the bitmap buffer is large enough to hold the bitmap.
williamr@4
  2356
williamr@2
  2357
@return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
williamr@2
  2358
inline TBool TOpenFontGlyphData::Overflow() const
williamr@2
  2359
	{
williamr@2
  2360
	return iBytesNeeded > iBitmapBufferSize;
williamr@2
  2361
	}
williamr@4
  2362
williamr@2
  2363
/** Gets the number of bytes needed to store the glyph bitmap.
williamr@4
  2364
williamr@2
  2365
@return The number of bytes needed to store the glyph bitmap.
williamr@2
  2366
@see SetBytesNeeded() */
williamr@2
  2367
inline TInt TOpenFontGlyphData::BytesNeeded() const
williamr@2
  2368
	{
williamr@2
  2369
	return iBytesNeeded;
williamr@2
  2370
	}
williamr@4
  2371
williamr@2
  2372
/** Gets a constant pointer descriptor containing the bitmap this object 
williamr@2
  2373
represents. 
williamr@4
  2374
williamr@2
  2375
@return Pointer descriptor for the glyph. */
williamr@2
  2376
inline TPtrC8 TOpenFontGlyphData::Bitmap() const
williamr@2
  2377
	{
williamr@2
  2378
	return TPtrC8(iBitmap,iBytesNeeded);
williamr@2
  2379
	}
williamr@4
  2380
williamr@2
  2381
/** Gets a pointer to the bitmap.
williamr@4
  2382
williamr@2
  2383
This points either to the buffer used to write the bitmap when it is first 
williamr@2
  2384
rasterized, or to the cache if the character was already rasterized.
williamr@4
  2385
williamr@2
  2386
@return A pointer to the bitmap. */
williamr@2
  2387
inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
williamr@2
  2388
	{
williamr@2
  2389
	return iBitmap;
williamr@2
  2390
	}
williamr@4
  2391
williamr@2
  2392
/** Gets the character's metrics.
williamr@4
  2393
williamr@2
  2394
@return The character's open font metrics. */
williamr@2
  2395
inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
williamr@2
  2396
	{
williamr@2
  2397
	return iMetrics;
williamr@2
  2398
	}
williamr@4
  2399
williamr@2
  2400
/** Gets a pointer to the start of the bitmap buffer.
williamr@4
  2401
williamr@2
  2402
@return A pointer to the start of the bitmap buffer. */
williamr@2
  2403
inline TUint8* TOpenFontGlyphData::BufferStart()
williamr@2
  2404
	{
williamr@2
  2405
	return iBitmapBuffer;
williamr@2
  2406
	}
williamr@4
  2407
williamr@2
  2408
/** Gets a pointer to the end of the bitmap buffer.
williamr@4
  2409
williamr@2
  2410
@return A pointer to the end of the bitmap buffer. */
williamr@2
  2411
inline TUint8* TOpenFontGlyphData::BufferEnd()
williamr@2
  2412
	{
williamr@2
  2413
	return iBitmapBuffer + iBitmapBufferSize;
williamr@2
  2414
	}
williamr@4
  2415
williamr@2
  2416
/** Sets the number of bytes needed to store the glyph bitmap.
williamr@4
  2417
williamr@2
  2418
@param aBytes The number of bytes needed to store the glyph bitmap.
williamr@2
  2419
@see BytesNeeded() */
williamr@2
  2420
inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
williamr@2
  2421
	{
williamr@2
  2422
	iBytesNeeded = aBytes;
williamr@2
  2423
	}
williamr@4
  2424
williamr@2
  2425
/** Sets the pointer to the bitmap buffer.
williamr@4
  2426
williamr@2
  2427
@param aBitmap The pointer to the bitmap buffer. */
williamr@2
  2428
inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
williamr@2
  2429
	{
williamr@2
  2430
	iBitmap = aBitmap;
williamr@2
  2431
	}
williamr@4
  2432
williamr@2
  2433
/** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
williamr@4
  2434
williamr@2
  2435
@param aMetrics A pointer to the character's open font character metrics. */
williamr@2
  2436
inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
williamr@2
  2437
	{
williamr@2
  2438
	iMetrics = aMetrics;
williamr@2
  2439
	}
williamr@4
  2440
williamr@2
  2441
/** Sets the bitmap and metrics pointers to point to the internal buffers.
williamr@4
  2442
williamr@2
  2443
The alternative is that the pointers point to the cache of metrics and bitmaps 
williamr@2
  2444
that have already been rasterized. */
williamr@2
  2445
inline void TOpenFontGlyphData::SetPointersToInternalBuffers()
williamr@2
  2446
	{
williamr@2
  2447
	iBitmap = iBitmapBuffer;
williamr@2
  2448
	iMetrics = &iMetricsBuffer;
williamr@2
  2449
	}
williamr@4
  2450
williamr@2
  2451
/** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics 
williamr@2
  2452
object.
williamr@4
  2453
williamr@4
  2454
@param	aMetrics	The character's open font character metrics. */
williamr@2
  2455
inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
williamr@2
  2456
	{
williamr@2
  2457
	iMetricsBuffer = aMetrics;
williamr@2
  2458
	iMetrics = &iMetricsBuffer;
williamr@2
  2459
	}
williamr@4
  2460
williamr@2
  2461
/** Sets the glyph index.
williamr@4
  2462
williamr@4
  2463
@param	aGlyphIndex	The glyph index. */
williamr@2
  2464
inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
williamr@2
  2465
	{
williamr@2
  2466
	iGlyphIndex = aGlyphIndex;
williamr@2
  2467
	}
williamr@2
  2468
williamr@2
  2469
/** Uses ECOM plug-in framework to instantiate the shaper factory interface 
williamr@2
  2470
implementation given its implementation UID. 
williamr@2
  2471
williamr@4
  2472
@param	aInterfaceImplUid	The UID of the interface implementation required
williamr@4
  2473
williamr@4
  2474
@return	CShaperFactory*	A pointer to a CShaperFactory object. */
williamr@2
  2475
inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
williamr@2
  2476
	{
williamr@2
  2477
	return reinterpret_cast <CShaperFactory*> (
williamr@2
  2478
		REComSession::CreateImplementationL( 
williamr@2
  2479
			aInterfaceImplUid,
williamr@2
  2480
			_FOFF(CShaperFactory, iDtor_ID_Key))); 
williamr@2
  2481
	}
williamr@2
  2482
williamr@2
  2483
/** Default destructor */
williamr@2
  2484
inline CShaperFactory::~CShaperFactory()
williamr@2
  2485
{
williamr@2
  2486
	REComSession::DestroyedImplementation(iDtor_ID_Key);
williamr@2
  2487
}
williamr@2
  2488
williamr@4
  2489
#endif	// __OPENFONT_H__