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