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