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