sl@0: /* sl@0: * Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * A header for the open font system, which allows SymbianOS sl@0: * to use fonts of arbitrary types, including TrueType/OpenType sl@0: * and other outline font formats. sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __OPENFONT_H__ sl@0: #define __OPENFONT_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #endif sl@0: sl@0: class CFont; sl@0: class COpenFontFile; sl@0: class COpenFontGlyph; sl@0: class COpenFontGlyphCache; sl@0: class COpenFontPositioner; sl@0: class COpenFontSessionCache; sl@0: class COpenFontSessionCacheList; sl@0: class RFs; sl@0: class TCharacterMetrics; sl@0: class TFontSpec; sl@0: class TOpenFontFaceAttrib; sl@0: class CFontStore; sl@0: class TOpenFontFileData; sl@0: class TShapeHeader; sl@0: class CBitmapFont; sl@0: class CShaperFactory; sl@0: class CShaper; sl@0: class TShapeHeader; sl@0: class TFontShapeFunctionParameters; sl@0: class TFontShapeDeleteFunctionParameters; sl@0: class RShapeInfo; sl@0: class TShapeMessageParameters; sl@0: class CRasterizerLinkedTypefaceSpecification; sl@0: class TLinkedTypefaceSpecificationArgs; sl@0: sl@0: /** sl@0: Supplied to COpenFont::ExtendedInterface() to access the extended sl@0: API interface MOpenFontShapingExtension. sl@0: sl@0: @see COpenFont::ExtendedInterface() sl@0: @see MOpenFontShapingExtension sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TUid KUidOpenFontShapingExtension = {0x10274DB9}; sl@0: sl@0: /** sl@0: Supplied to COpenFont::ExtendedInterface() to access the extended sl@0: API interface MOpenFontTrueTypeExtension. sl@0: sl@0: @see COpenFont::ExtendedInterface() sl@0: @see MOpenFontTrueTypeExtension sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TUid KUidOpenFontTrueTypeExtension = {0x1027553E}; sl@0: const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE}; sl@0: sl@0: /** sl@0: Supplied to CShaper::ExtendedInterface() to get the language and script sl@0: code with which the current shaper is instatsiated. sl@0: @see CShaper::ExtendedInterface() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TUid KUidShaperGetScript = {0x20009966}; sl@0: const TUid KUidShaperGetLang = {0x20009967}; sl@0: sl@0: /** sl@0: Font metrics. sl@0: sl@0: @see CFbsFont::GetFontMetrics() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontMetrics sl@0: { sl@0: public: sl@0: inline TOpenFontMetrics(); sl@0: IMPORT_C TOpenFontMetrics(const CFont* aFont); sl@0: inline TInt Size() const; sl@0: inline TInt Ascent() const; sl@0: inline TInt Descent() const; sl@0: inline TInt MaxHeight() const; sl@0: inline TInt MaxDepth() const; sl@0: inline TInt MaxWidth() const; sl@0: inline void SetSize(TInt aSize); sl@0: inline void SetAscent(TInt aAscent); sl@0: inline void SetDescent(TInt aDescent); sl@0: inline void SetMaxHeight(TInt aMaxHeight); sl@0: inline void SetMaxDepth(TInt aMaxDepth); sl@0: inline void SetMaxWidth(TInt aMaxWidth); sl@0: /** WARNING: Function for internal and partner use ONLY. Compatibility is not guaranteed in future releases.*/ sl@0: IMPORT_C void SetBaselineCorrection(TInt aBaselineCorrection); sl@0: IMPORT_C TInt BaselineCorrection(); sl@0: private: sl@0: TInt16 iDesignHeight; // size of the font ('pointsize' in pixels) sl@0: TInt16 iAscent; // typographic ascent sl@0: TInt16 iDescent; // typographic descent sl@0: TInt16 iMaxHeight; // maximum height of a character; may be greater than iAscent sl@0: TInt16 iMaxDepth; // maximum depth of a character; may be greater than iDescent sl@0: TInt16 iMaxWidth; // maximum width of a character sl@0: TInt16 iBaselineCorrection; sl@0: TInt16 iReserved; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Character metrics includes more information than TCharacterMetrics. sl@0: sl@0: Character metrics allow characters to be placed horizontally or vertically. sl@0: The character metrics encapsulated by this class are: Height, Width, Horizontal sl@0: Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X, sl@0: Vertical Bearing Y, and Vertical Advance. Their meanings are described in the sl@0: associated setter and getter functions. sl@0: sl@0: Note : sl@0: sl@0: Vertical drawing (in the sense of characters drawn with horizontal baselines, sl@0: but in a vertical line) is not yet supported by Symbian OS. sl@0: sl@0: @see CFont::GetCharacterData() sl@0: @see CFbsFont::GetCharacterData() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontCharMetrics sl@0: { sl@0: public: sl@0: enum TUninitialized { EUninitialized }; sl@0: public: sl@0: /** Default constructor initializes all members to 0. */ sl@0: inline TOpenFontCharMetrics(); sl@0: sl@0: /** Constructor that does not initialize any members. */ sl@0: TOpenFontCharMetrics(TUninitialized) {} sl@0: IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics); sl@0: IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const; sl@0: inline TInt Width() const; sl@0: inline TInt Height() const; sl@0: inline TInt HorizBearingX() const; sl@0: inline TInt HorizBearingY() const; sl@0: inline TInt HorizAdvance() const; sl@0: inline TInt VertBearingX() const; sl@0: inline TInt VertBearingY() const; sl@0: inline TInt VertAdvance() const; sl@0: inline void GetHorizBounds(TRect& aBounds) const; sl@0: inline void GetVertBounds(TRect& aBounds) const; sl@0: inline void SetWidth(TInt aWidth); sl@0: inline void SetHeight(TInt aHeight); sl@0: inline void SetHorizBearingX(TInt aHorizBearingX); sl@0: inline void SetHorizBearingY(TInt aHorizBearingY); sl@0: inline void SetHorizAdvance(TInt aHorizAdvance); sl@0: inline void SetVertBearingX(TInt aVertBearingX); sl@0: inline void SetVertBearingY(TInt aVertBearingY); sl@0: inline void SetVertAdvance(TInt aVertAdvance); sl@0: IMPORT_C void SetGlyphType(TGlyphBitmapType); sl@0: IMPORT_C TGlyphBitmapType GlyphType() const; sl@0: private: sl@0: TInt16 iWidth; // width of the glyph sl@0: TInt16 iHeight; // height of the glyph sl@0: TInt16 iHorizBearingX; // x component of horizontal bearing sl@0: TInt16 iHorizBearingY; // y component of horizontal bearing sl@0: TInt16 iHorizAdvance; // horizontal advance sl@0: TInt16 iVertBearingX; // x component of vertical bearing sl@0: TInt16 iVertBearingY; // y component of vertical bearing sl@0: TInt16 iVertAdvance; // vertical advance sl@0: TUint16 iGlyphBitmapType;// Glyph bitmap type; TGlyphBitmapType sl@0: TInt16 iReserved; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Font glyph data. sl@0: sl@0: Objects of this type are used by rasterizers to supply glyph data to font sl@0: and bitmap server clients. Unless you are writing a rasterizer you will not sl@0: need to use an object of this type. sl@0: sl@0: The object cannot be constructed and destroyed by normal means. It resides sl@0: on a specified heap. It is created by New() and deleted by RHeap::Free(). sl@0: sl@0: @see COpenFont::RasterizeL() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontGlyphData sl@0: { sl@0: public: sl@0: IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize); sl@0: inline TBool Overflow() const; sl@0: inline TInt BytesNeeded() const; sl@0: inline TPtrC8 Bitmap() const; sl@0: inline const TUint8* BitmapPointer() const; sl@0: inline const TOpenFontCharMetrics* Metrics() const; sl@0: inline TInt GlyphIndex() const; sl@0: inline TUint8* BufferStart(); sl@0: inline TUint8* BufferEnd(); sl@0: inline void SetBytesNeeded(TInt aBytes); sl@0: inline void SetBitmapPointer(const TUint8* aBitmap); sl@0: inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics); sl@0: inline void SetPointersToInternalBuffers(); sl@0: inline void SetMetrics(TOpenFontCharMetrics& aMetrics); sl@0: inline void SetGlyphIndex(TInt aGlyphIndex); sl@0: private: sl@0: /* sl@0: Prevent construction and destruction by normal means; the object resides sl@0: on a specified heap and is created by New and deleted by RHeap::Free. sl@0: */ sl@0: TOpenFontGlyphData(); sl@0: ~TOpenFontGlyphData(); sl@0: private: sl@0: TInt iBitmapBufferSize; // size of the buffer in bytes sl@0: TInt iBytesNeeded; // bytes needed for the bitmap sl@0: TOpenFontCharMetrics iMetricsBuffer; // the metrics sl@0: const TUint8* iBitmap; // pointer to the bitmap; points either to iBitmapBuffer or to sl@0: // the cache if the character was already rasterized sl@0: const TOpenFontCharMetrics* iMetrics; // pointer to the metrics; points either to iMetricsBuffer or to sl@0: // the cache if the character was already rasterized sl@0: TInt iGlyphIndex; // the glyph index sl@0: TAny* iReserved; // unused; for future expansion sl@0: TUint8 iBitmapBuffer[1]; // buffer used to write the bitmap when it is first rasterized; this sl@0: // is actually of size iBitmapBufferSize. sl@0: }; sl@0: sl@0: /** sl@0: Open Font System font abstract base class. sl@0: sl@0: Derive a class from this class to represent an instance of a typeface at a sl@0: particular size, provide bitmaps of the glyphs, and determine whether sl@0: characters exist in the typeface. sl@0: sl@0: Writing derived classes construction: sl@0: sl@0: You must call the constructor of this class when creating your derived object, sl@0: passing the arguments aHeap and aSessionCacheList supplied to sl@0: COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile sl@0: object that creates the object as aFile. sl@0: sl@0: The derived object must be created on the shared heap aHeap because it is sl@0: shared by several processes: the font and bitmap server and its clients. sl@0: To do this, use aHeap->AllocL() to obtain memory, then construct in place sl@0: using a placement argument to new. sl@0: sl@0: Derived classes must implement the pure virtual function RasterizeL(). sl@0: Information about this function is provided in the function definition below. sl@0: sl@0: Information about deriving from this class is also provided in the API guide. sl@0: sl@0: @see COpenFontFile::GetNearestFontInPixelsL() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class COpenFont: public CBase sl@0: { sl@0: public: sl@0: /** Creates a bitmap for the specified Unicode character. sl@0: sl@0: Implementations of this function should put the bitmap in sl@0: aGlyphData->iBitmapBuffer, and the character metrics are placed in sl@0: aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left sl@0: alone. sl@0: sl@0: There are a number of strategies for achieving this, e.g. pass the sl@0: rasterization task all the way up to the rasterizer engine. These are sl@0: discussed in the API guide. sl@0: sl@0: At present you must write the bitmap in the Symbian platform's sl@0: run-length-encoded format. This is a packed binary format starting on a sl@0: byte boundary and made up of a number of sections. Each section starts sl@0: with a five-bit header. If the first bit of the header is 0 the next four sl@0: bits are a repeat count, starting with the least significant bit, and a sl@0: single row of bits (the number of bits in a row is specified by sl@0: aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header sl@0: is 1 the next four bits are a count of non-repeating rows, again starting sl@0: with the least significant bit, and that many rows of bits follow. sl@0: sl@0: @param aCode The character code of the Unicode character for which the sl@0: bitmap is required. sl@0: @param aGlyphData On return, contains a pointer to a TOpenFontGlyphData sl@0: containing the character's bitmap and metrics. */ sl@0: virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0; sl@0: IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam); sl@0: IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile); sl@0: IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex); sl@0: IMPORT_C ~COpenFont(); sl@0: IMPORT_C void operator delete(TAny*); sl@0: inline const TOpenFontMetrics& Metrics() const; sl@0: inline const TOpenFontFaceAttrib* FaceAttrib() const; sl@0: inline COpenFontFile* File() const; sl@0: inline TInt FaceIndex() const; sl@0: inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const; sl@0: void SetShaper(CShaper* aShaper); sl@0: CShaper* GetShaper(); sl@0: TBool HasShaper() const; sl@0: TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams); sl@0: TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader); sl@0: TInt FreeShaperCacheMemory(TInt aBytesNeeded); sl@0: TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse); sl@0: TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData); sl@0: TBool HasCharacterL(TInt aCode) const; sl@0: TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const; sl@0: void OnFileDeleted(); sl@0: COpenFontGlyphCache* GetGlyphCache() const; sl@0: inline TInt FontCapitalAscent() const; sl@0: inline TInt FontMaxAscent() const; sl@0: inline TInt FontStandardDescent() const; sl@0: inline TInt FontMaxDescent() const; sl@0: inline TInt FontLineGap() const; sl@0: inline TInt FontMaxHeight() const; sl@0: void DeleteShaper() const; sl@0: TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength); sl@0: TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength); sl@0: sl@0: protected: sl@0: RHeap* iHeap; sl@0: TOpenFontMetrics iMetrics; sl@0: private: sl@0: /** The shaper for performing complex character positioning and sl@0: substitution, if available. Null otherwise. sl@0: sl@0: WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only. sl@0: */ sl@0: CShaper* iShaper; sl@0: sl@0: protected: sl@0: /** The positive distance in pixels from the baseline to sl@0: the top of an ANSI capital (whether or not there are sl@0: ANSI capitals in the font) */ sl@0: TInt iFontCapitalAscent; sl@0: /** The positive distance in pixels from the baseline to sl@0: the top of the highest pre-composed glyph in the font */ sl@0: TInt iFontMaxAscent; sl@0: /** The positive distance in pixels from the baseline to sl@0: the bottom of the lowest ANSI descender (whether or sl@0: not there are ANSI chars in the font)*/ sl@0: TInt iFontStandardDescent; sl@0: /** The positive distance in pixels from the baseline to sl@0: the bottom of the lowest pre-composed glyph in the font */ sl@0: TInt iFontMaxDescent; sl@0: /** The recommended baseline to baseline gap for successive sl@0: lines of text in the font */ sl@0: TInt iFontLineGap; sl@0: private: sl@0: const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const; sl@0: sl@0: const COpenFontGlyph* FontCacheGlyph(TInt aCode) const; sl@0: sl@0: void SetGlyphCache(COpenFontGlyphCache* aGlyphCache); sl@0: sl@0: const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode, sl@0: COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const; sl@0: void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData); sl@0: sl@0: COpenFontSessionCacheList* SessionCacheList()const; sl@0: sl@0: void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList); sl@0: sl@0: void SetFile(COpenFontFile* aFile); sl@0: private: sl@0: sl@0: // Offset from the address of the file used by this font. sl@0: // If the file has been deleted or cannot be used, the offest will be zero. sl@0: TInt iFileOffset; sl@0: sl@0: TInt iFaceIndex; // index of the face in the font file sl@0: sl@0: // Offset from the address of this font of the per-font glyph cache which is owned by the font sl@0: TInt iGlyphCacheOffset; sl@0: sl@0: // Offset from the address of this font of the list of per-session glyph sl@0: // caches which are owned by CFontStore sl@0: TInt iSessionCacheListOffset; sl@0: sl@0: TAny* iReserved; // unused; for future expansion sl@0: }; sl@0: sl@0: /** Open Font System Extension Interface abstract base class. sl@0: sl@0: COpenFont derivers should also derive from this interface to enable complex sl@0: font "shaping". sl@0: sl@0: This interface should be returned by the overridden sl@0: COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is sl@0: supplied as the UID. sl@0: sl@0: @see COpenFont sl@0: @see KUidOpenFontShapingExtension sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MOpenFontShapingExtension sl@0: { sl@0: public: sl@0: /** Various font metrics. */ sl@0: class TExtensionFontMetrics sl@0: { sl@0: public: sl@0: /** The number of font design units per em. */ sl@0: TInt iUnitsPerEm; sl@0: /** The width of the font's em square in pixels. */ sl@0: TReal iXPixelsPerEm; sl@0: /** The height of the font's em square in pixels. */ sl@0: TReal iYPixelsPerEm; sl@0: /** The horizontal scaling factor from the font's transform; sl@0: the number of horizontal pixels per font unit. */ sl@0: TReal iXScaleFactor; sl@0: /** The vertical scaling factor from the font's transform; sl@0: the number of vertical pixels per font unit. */ sl@0: TReal iYScaleFactor; sl@0: private: sl@0: /** Reserved for future expansion. */ sl@0: TInt iReserved[4]; sl@0: }; sl@0: sl@0: /** Creates a bitmap for the specified Glyph code. sl@0: sl@0: Implementations of this function should put the bitmap in sl@0: aGlyphData->iBitmapBuffer, and the character metrics are placed in sl@0: aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left sl@0: alone. sl@0: sl@0: This function provides the same functionality as the sl@0: COpenFont::RasterizeL() except that the glyph code is supplied rather than sl@0: the unicode. sl@0: sl@0: For more information: sl@0: @see COpenFont::RasterizeL() sl@0: sl@0: @param aCode The glyph code of the character for which the bitmap is required. sl@0: @param aGlyphData The function puts its output here. sl@0: */ sl@0: virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0; sl@0: sl@0: /** Maps a character to a glyph index. sl@0: @param aUnicodeCharacter Unicode character code to be mapped. sl@0: @return Glyph code corresponding to aUnicodeCharacter. */ sl@0: virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0; sl@0: sl@0: /** Returns the hinted pixel coordinates of a particular point in the sl@0: outline of the given glyph. sl@0: @param aGlyphPoint The glyph index. sl@0: @param aPointNumber The number of the point. sl@0: @param aX Returns the point's X pixel value. sl@0: @param aY Returns the point's Y pixel value. sl@0: @return True on success, false otherwise. */ sl@0: virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber, sl@0: TReal& aX, TReal& aY) const = 0; sl@0: sl@0: /** Returns the coordinates of a particular (unhinted) point in the outline sl@0: of the given glyph in font units. sl@0: @param aGlyphPoint The glyph index. sl@0: @param aPointNumber The number of the point. sl@0: @param aX Returns the point's X co-ordinate in font units. sl@0: @param aY Returns the point's Y co-ordinate in font units. sl@0: @return True on success, false otherwise. */ sl@0: virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber, sl@0: TInt& aX, TInt& aY) const = 0; sl@0: sl@0: /** Returns font metrics. sl@0: @param aOut Font metrics returned. */ sl@0: virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0; sl@0: }; sl@0: sl@0: /** TrueType extension for Open Fonts. sl@0: sl@0: If an open font is able to load TrueType or OpenType tables it should derive sl@0: from this class. sl@0: sl@0: This class will be used by sl@0: sl@0: This interface should be returned by the overridden sl@0: COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is sl@0: supplied as the UID. sl@0: @see KUidOpenFontTrueTypeExtension sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MOpenFontTrueTypeExtension sl@0: { sl@0: public: sl@0: /** Returns the specified table. The table need not be released by the sl@0: caller, so the deriver is responsible for ensuring that any memory sl@0: allocated is ultimately cleaned up. The caller must not delete or modify sl@0: the data returned. sl@0: @param aError sl@0: Returns KErrNone if successful or one of the system-wide error codes if sl@0: unsuccessful. Returns KErrNotSupported if the table does not exist in sl@0: the font file. sl@0: @param aTag sl@0: The tag of the table, with the first character in the most significant sl@0: byte. For example, the "vhea" table is obtained by passing in 'v'<<24 | sl@0: 'h'<<16 | 'e'<<8 | 'a'. sl@0: @param aLength sl@0: The length of the table in bytes that has been returned or 0 if sl@0: unsuccessful. sl@0: @return The table, if successful. sl@0: @see ReleaseTrueTypeTable */ sl@0: virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0; sl@0: /** Releases a table obtained by GetTrueTypeTable. The caller must not sl@0: use the table after this call. sl@0: @param aTable The table to be released. sl@0: @see GetTrueTypeTable */ sl@0: virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0; sl@0: /** Determines if the font file has a particular table. sl@0: @param aTag The tag of the table as for GetTrueTypeTable. sl@0: @return True if the table exists in the font file, false otherwise. sl@0: @see GetTrueTypeTable */ sl@0: virtual TBool HasTrueTypeTable(TUint32 aTag) = 0; sl@0: }; sl@0: sl@0: class MOpenFontGlyphOutlineExtension sl@0: { sl@0: public: sl@0: virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId, sl@0: TBool aHinted, TAny*& aOutline, TInt& aLength) = 0; sl@0: }; sl@0: /** sl@0: Font attribute base class. sl@0: sl@0: This class is not intended for user derivation. sl@0: sl@0: @see TOpenFontFaceAttrib sl@0: @see TOpenFontSpec sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontFaceAttribBase sl@0: { sl@0: public: sl@0: inline TOpenFontFaceAttribBase(); sl@0: inline TBool HasLatin() const; sl@0: inline TBool HasGreek() const; sl@0: inline TBool HasCyrillic() const; sl@0: inline TBool HasKana() const; sl@0: inline TBool HasHangul() const; sl@0: inline TBool HasCJK() const; sl@0: inline TBool IsSymbol() const; sl@0: inline TBool IsBold() const; sl@0: inline TBool IsItalic() const; sl@0: inline TBool IsSerif() const; sl@0: inline TBool IsMonoWidth() const; sl@0: inline TPtrC Name() const; sl@0: inline const TUint* Coverage() const; sl@0: inline void SetName(const TDesC& aName); sl@0: inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0); sl@0: inline void SetBold(TBool aBold); sl@0: inline void SetItalic(TBool aItalic); sl@0: inline void SetSerif(TBool aSerif); sl@0: inline void SetMonoWidth(TBool aMonoWidth); sl@0: inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const; sl@0: sl@0: // Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included) sl@0: enum sl@0: { sl@0: ELatinSet = 0x1, // 0000-007F sl@0: EGreekSet = 0x80, // 0370-03FF sl@0: ECyrillicSet = 0x200, // 0400-04FF sl@0: EArmenianSet = 0x400, // 0530-058F sl@0: EHebrewSet = 0x800, // 0590-05FF sl@0: EArabicSet = 0x2000, // 0600-06FF sl@0: EDevanagariSet = 0x8000, // 0900-097F sl@0: EBengaliSet = 0x10000, // 0980-09FF sl@0: EGurmukhiSet = 0x20000, // 0A00-0A7F sl@0: EGujuratiSet = 0x40000, // 0A80-0AFF sl@0: EOriyaSet = 0x80000, // 0B00-0B7F sl@0: ETamilSet = 0x100000, // 0B80-0BFF sl@0: ETeluguSet = 0x200000, // 0C00-0C7F sl@0: EKannadaSet = 0x400000, // 0C80-0CFF sl@0: EMalayalamSet = 0x800000, // 0D00-0D7F sl@0: EThaiSet = 0x1000000, // 0E00-0E7F sl@0: ELaoSet = 0x2000000, // 0E80-0EFF sl@0: EGeorgianSet = 0x8000000, // 10A0-10FF sl@0: EHangulJamoSet = 0x10000000,// 1100-11FF sl@0: }; sl@0: sl@0: // Unicode ranges for iCoverage[1] sl@0: enum sl@0: { sl@0: ESymbolSets = 0xFFFE, sl@0: EKanaSets = 0x60000, sl@0: EHangulSet = 0x100000, sl@0: ECJKSet = 0x8000000 sl@0: }; sl@0: sl@0: // Attribute flags sl@0: enum sl@0: { sl@0: EBold = 0x1, // weight > 500 in Windows terms sl@0: EItalic = 0x2, // italic or oblique - any forward slant counts sl@0: ESerif = 0x4, // characters have serifs sl@0: EMonoWidth = 0x8 // all characters are the same width sl@0: }; sl@0: sl@0: // Other constants sl@0: enum sl@0: { sl@0: ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24 sl@0: }; sl@0: protected: sl@0: TBufC iName; // the name of the typeface; whether this is the full name or family name sl@0: // or is in English or another language depends on the context sl@0: TUint iCoverage[4]; // bitmap of the character sets supported by the typeface; sl@0: // these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4 sl@0: // in the OS/2 table in TrueType fonts sl@0: TInt iStyle; // bold, italic serif, and mono-width sl@0: TInt32 iReserved; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Typeface attributes. sl@0: sl@0: These attributes include the name, family name, and supported scripts. sl@0: sl@0: @see CFbsFont::GetFaceAttrib() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase sl@0: { sl@0: public: sl@0: inline TOpenFontFaceAttrib(); sl@0: inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const; sl@0: inline TPtrC FullName() const; sl@0: inline TPtrC FamilyName() const; sl@0: inline TPtrC LocalFullName() const; sl@0: inline TPtrC LocalFamilyName() const; sl@0: inline TPtrC ShortFullName() const; sl@0: inline TPtrC ShortFamilyName() const; sl@0: inline TPtrC ShortLocalFullName() const; sl@0: inline TPtrC ShortLocalFamilyName() const; sl@0: inline void SetFullName(const TDesC& aName); sl@0: inline void SetFamilyName(const TDesC& aName); sl@0: inline void SetLocalFullName(const TDesC& aName); sl@0: inline void SetLocalFamilyName(const TDesC& aName); sl@0: inline TInt MinSizeInPixels() const; sl@0: inline void SetMinSizeInPixels(TInt aSize); sl@0: private: sl@0: TBufC iFamilyName; // the name without any style suffixes; usually a truncation of iFullName sl@0: TBufC iLocalFullName; // the full name in the language of the current locale sl@0: TBufC iLocalFamilyName; // the family name in the language of the current locale sl@0: TInt iMinSizeInPixels; // minimum supported size, (or readable size if scalable) in pixels sl@0: TInt32 iReserved2; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Font specification allowing more attributes to be specified than TFontSpec. sl@0: sl@0: In addition to the attributes specified by TFontSpec, this font specification sl@0: allows stretching and slanting in the x dimension, and other algorithmic effects. sl@0: This is used to correct for non-square pixels, and to allow algorithmic slanting sl@0: and bold. The width factor and slant factor transform any point (x,y) to (x sl@0: * iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16 sl@0: fixed-point numbers. sl@0: sl@0: The font specification also provides access to information about the scripts sl@0: which are supported by the font. This information is not always reliable, sl@0: because it may be incorrectly specified, or not specified at all, by some sl@0: font manufacturers. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TOpenFontSpec : public TOpenFontFaceAttribBase sl@0: { sl@0: public: sl@0: IMPORT_C TOpenFontSpec(); sl@0: IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec); sl@0: IMPORT_C void operator=(const TFontSpec& aFontSpec); sl@0: inline TBool operator==(const TOpenFontSpec& aFontSpec) const; sl@0: TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const; sl@0: IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib); sl@0: IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const; sl@0: IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight); sl@0: IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap); sl@0: inline TInt Height() const; sl@0: inline TInt32 WidthFactor() const; sl@0: inline TInt32 SlantFactor() const; sl@0: inline TGlyphBitmapType BitmapType() const; sl@0: inline TUint32 Effects() const; sl@0: inline TFontPrintPosition PrintPosition() const; sl@0: inline void SetHeight(TInt aHeight); sl@0: inline void SetWidthFactor(TInt32 aWidthFactor); sl@0: inline void SetSlantFactor(TInt32 aSlantFactor); sl@0: inline void SetBitmapType(TGlyphBitmapType aBitmapType); sl@0: inline void SetEffects(TUint32 aEffects); sl@0: IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn); sl@0: IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const; sl@0: IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage); sl@0: IMPORT_C TInt ScriptTypeForMetrics() const; sl@0: static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight); sl@0: static TInt ApplyRatio(TInt& aValue,TInt aNumerator,TInt aDenominator); sl@0: static TInt ApplyRatio(TInt32& aValue,TInt aNumerator,TInt aDenominator); sl@0: public: sl@0: /** Algorithmic effects flags. sl@0: sl@0: These can be combined using an OR operation. sl@0: sl@0: WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases. sl@0: sl@0: @deprecated Use FontEffect::TEffect instead. sl@0: */ sl@0: enum sl@0: { sl@0: /** Font is algorithmic bold. */ sl@0: EAlgorithmicBold = 1, sl@0: /** Font has a drop shadow. */ sl@0: EDropShadow = 2, sl@0: /** Font is an outline font. */ sl@0: EOutline = 4 sl@0: }; sl@0: private: sl@0: void SetScriptTypeForMetrics(TInt aScript); sl@0: void SetSymbol(TBool aSymbol); sl@0: TBool Symbol() const; sl@0: IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const; sl@0: IMPORT_C TUint32 DoEffects() const; sl@0: IMPORT_C void DoSetEffects(TUint32 aEffects); sl@0: private: sl@0: TInt iHeight; // em height sl@0: TInt32 iWidthFactor; // algorithmic width factor as a 16.16 fixed-point number sl@0: TInt32 iSlantFactor; // algorithmic slant factor as a 16.16 fixed-point number sl@0: TInt iBitmapType; // non-anti-aliased, standard anti-aliased, etc.; zero means 'default' sl@0: TUint32 iEffects; // bit flags for font effects sl@0: TInt iSymbol; // a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5) sl@0: // The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec sl@0: TFontPrintPosition iPrintPosition; // normal, superscript or subscript sl@0: sl@0: TInt iReserved2; sl@0: }; sl@0: sl@0: /** sl@0: Font file abstract base class. sl@0: sl@0: Write a class derived from COpenFontFile to manage a file with the font format sl@0: supported by your DLL. The derived class must implement the virtual sl@0: GetNearestFontInPixelsL() function. This function takes a font description sl@0: and creates a COpenFont derived object if the description matches a typeface sl@0: contained in the font file. sl@0: sl@0: Derived classes must also load typeface attributes from the file into the sl@0: protected typeface attribute array during construction. This array is what sl@0: is searched when getting font attribute information see AddFaceL(), sl@0: GetNearestFontHelper(). sl@0: sl@0: Writing derived classes construction: sl@0: sl@0: Call the COpenFontFile constructor in the constructor for your derived object, sl@0: passing it aUid and aFileName arguments. These values are the arguments passed sl@0: when the constructor is called by COpenFontRasterizer::NewFontFileL(). sl@0: sl@0: A file may contain one or more typefaces. During construction the derived sl@0: object should extract the information for each typeface and add it to this sl@0: object's protected typeface attribute array see AddFaceL(). This process sl@0: will probably leave under some conditions. It should therefore be implemented sl@0: in a second phase constructor. sl@0: sl@0: Writing derived classes implement the pure virtual functions: sl@0: sl@0: Derived classes must also implement the two pure virtual functions sl@0: GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about sl@0: these functions is provided in the definitions below. Information about sl@0: deriving from this class is also provided in the API guide. sl@0: sl@0: @see COpenFontRasterizer::NewFontFileL() sl@0: @see CWsScreenDevice::AddFile() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class COpenFontFile : public CBase sl@0: { sl@0: public: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: Implementations of this pure virtual function should create the COpenFont sl@0: derived object that most closely matches aDesiredFontSpec, while fitting within sl@0: aMaxHeight, and place a pointer to it in aFont. If this cannot be done, sl@0: e.g. if the font name doesn't match, aFont should be set to NULL. sl@0: sl@0: The other two arguments, aHeap and aSessionCacheList, should be passed to sl@0: the COpenFont constructor. sl@0: sl@0: Implementations may use the utility function GetNearestFontHelper() sl@0: to get the attributes of the closest matching font. sl@0: sl@0: @param aHeap Shared heap. This value should be passed to the sl@0: COpenFont derived classes' constructor. sl@0: @param aSessionCacheList The session cache list. This value should be passed sl@0: to the COpenFont derived classes' constructor. sl@0: @param aDesiredFontSpec The desired font specification. sl@0: @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aFont On return, contains a pointer to the newly created COpenFont sl@0: derived object, or NULL if no font matching aDesiredFontSpec exists. sl@0: @param aActualFontSpec The actual font specification of the font retrieved into aFont. sl@0: @see GetNearestFontHelper() sl@0: */ sl@0: virtual void GetNearestFontInPixelsL( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: Implementations of this pure virtual function should create the COpenFont sl@0: derived object that most closely matches aDesiredFontSpec, while fitting within sl@0: aMaxHeight, and place a pointer to it in aFont. If this cannot be done, sl@0: e.g. if the font name doesn't match, aFont should be set to NULL. sl@0: sl@0: The other two arguments, aHeap and aSessionCacheList, should be passed to sl@0: the COpenFont constructor. sl@0: sl@0: Implementations may use the utility function GetNearestFontHelper() sl@0: to get the attributes of the closest matching font. sl@0: sl@0: @param aHeap Shared heap. This value should be passed to the COpenFont sl@0: derived classes' constructor. sl@0: @param aSessionCacheList The session cache list. This value should be passed sl@0: to the COpenFont derived classes' constructor. sl@0: @param aDesiredFontSpec The desired font specification. sl@0: @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aFont On return, contains a pointer to the newly created COpenFont sl@0: derived object, or NULL if no font matching aDesiredFontSpec exists. sl@0: @param aActualFontSpec The actual font specification of the font retrieved into aFont. sl@0: @see GetNearestFontHelper() sl@0: */ sl@0: virtual void GetNearestFontToDesignHeightInPixelsL( sl@0: RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/, sl@0: const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/, sl@0: COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {} sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: Implementations of this pure virtual function should create the COpenFont sl@0: derived object that most closely matches aDesiredFontSpec, while fitting within sl@0: aMaxHeight, and place a pointer to it in aFont. If this cannot be done, sl@0: e.g. if the font name doesn't match, aFont should be set to NULL. sl@0: sl@0: The other two arguments, aHeap and aSessionCacheList, should be passed to sl@0: the COpenFont constructor. sl@0: sl@0: Implementations may use the utility function GetNearestFontHelper() sl@0: to get the attributes of the closest matching font. sl@0: sl@0: @param aHeap Shared heap. This value should be passed to the COpenFont sl@0: derived classes' constructor. sl@0: @param aSessionCacheList The session cache list. This value should be passed sl@0: to the COpenFont derived classes' constructor. sl@0: @param aDesiredFontSpec The desired font specification. sl@0: @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating sl@0: the algorithmic slant of the typeface. sl@0: @param aFont On return, contains a pointer to the newly created COpenFont sl@0: derived object, or NULL if no font matching aDesiredFontSpec exists. sl@0: @param aActualFontSpec The actual font specification of the font retrieved into aFont. sl@0: @param aMaxHeight The maximum height (vertical extent) within which the font must fit. sl@0: @see GetNearestFontHelper() sl@0: */ sl@0: virtual void GetNearestFontToMaxHeightInPixelsL( sl@0: RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/, sl@0: const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/, sl@0: COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {} sl@0: sl@0: /** Tests whether a specified typeface contains a particular character. sl@0: sl@0: @param aFaceIndex The index of the typeface to be tested. sl@0: @param aCode The Unicode character code for the character to be tested. sl@0: @return ETrue if the typeface contains aCode, otherwise EFalse. */ sl@0: virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0; sl@0: IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam); sl@0: IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName); sl@0: IMPORT_C ~COpenFontFile(); sl@0: IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const; sl@0: IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib); sl@0: inline TUid Uid() const; sl@0: inline const TDesC& FileName() const; sl@0: inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const; sl@0: inline TInt FaceCount() const; sl@0: inline void IncRefCount(); sl@0: inline TBool DecRefCount(); sl@0: TInt GetNearestFontInPixels( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec); sl@0: TInt GetNearestFontToDesignHeightInPixels( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec); sl@0: TInt GetNearestFontToMaxHeightInPixels( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight); sl@0: void RemoveFontFromList(const COpenFont* aFont); sl@0: void SetFontStoreL(CFontStore* aFontStore); sl@0: CFontStore* GetFontStore(); sl@0: CArrayPtrFlat* GetOpenFontList(); sl@0: protected: sl@0: IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, sl@0: TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const; sl@0: private: sl@0: // A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.) sl@0: class TAttrib: public TOpenFontFaceAttrib sl@0: { sl@0: public: sl@0: COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface sl@0: }; sl@0: static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib); sl@0: static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib); sl@0: void GetNearestFontToDesignHeightInPixelsAndAddToListL( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec); sl@0: void GetNearestFontToMaxHeightInPixelsAndAddToListL( sl@0: RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList, sl@0: const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight, sl@0: COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight); sl@0: sl@0: private: sl@0: CArrayFixFlat iFaceAttrib; sl@0: TUid iUid; sl@0: TBuf iFileName; sl@0: TInt iRefCount; sl@0: CArrayPtrFlat iFontList; sl@0: TOpenFontFileData* iData; sl@0: }; sl@0: sl@0: /** sl@0: Convenience class from which rasterizer contexts may be derived. sl@0: sl@0: A rasterizer context object may (optionally) be created to provide the link sl@0: between the rasterizer DLL code supported by the Open Font System, and the sl@0: rasterizer engine code. A rasterizer context object class should get the sl@0: requested bitmap from the associated rasterizer engine. It should then convert sl@0: this into Symbian run-length-encoded format. This class contains convenience sl@0: functions to make the conversion easier. sl@0: sl@0: Deriving from this class is described in greater detail in the API guide. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class COpenFontRasterizerContext: public CBase sl@0: { sl@0: public: sl@0: inline COpenFontRasterizerContext(); sl@0: inline void StartGlyph(TOpenFontGlyphData* aGlyphData); sl@0: inline void WriteGlyphBit(TInt aBit); sl@0: inline void WriteGlyphByte(TInt aByte); sl@0: inline void EndGlyph(); sl@0: private: sl@0: TOpenFontGlyphData* iGlyphData; sl@0: TUint8* iGlyphDataStart; sl@0: TUint8* iGlyphDataPtr; sl@0: TUint8* iGlyphDataEnd; sl@0: TInt iGlyphBit; sl@0: TInt iBytesNeeded; sl@0: TBool iOverflow; sl@0: TAny* iReserved; // unused; for future expansion sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Shaper abstract class. All shaper implementations derive from this sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CShaper : public CBase sl@0: { sl@0: public: sl@0: class TInput sl@0: { sl@0: public: sl@0: /** The text to be shaped possibly including context. */ sl@0: const TDesC* iText; sl@0: /** The index of the first character in iText to be shaped. */ sl@0: TInt iStart; sl@0: /** (One past) the end of the text in iText to be shaped. */ sl@0: TInt iEnd; sl@0: /** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a' sl@0: for Devanagari. */ sl@0: TInt iScript; sl@0: /** Language code. 0 implies "default" */ sl@0: TUint32 iLanguage; sl@0: /** Maximum advance in pixels. Shaping beyond this sl@0: advance is not required (but is not harmful). */ sl@0: TInt iMaximumAdvance; sl@0: /** Flags. Currently none is defined. */ sl@0: TInt iFlags; sl@0: /** Session handle. To be used if rasterization is needed. */ sl@0: TInt iSessionHandle; sl@0: /** Reserved for future expansion. Must be set to 0. */ sl@0: TInt iReserved1; sl@0: }; sl@0: /** Constructor */ sl@0: IMPORT_C CShaper(); sl@0: sl@0: /** Destructor */ sl@0: IMPORT_C virtual ~CShaper(); sl@0: sl@0: /** construct a shaper object sl@0: @param aBitmapFont The font to be shaped. sl@0: @param aHeap The heap to be used by the shaper. sl@0: @return KErrNone if this font can be shaper or system wide error code*/ sl@0: virtual TInt ConstructL(CBitmapFont* aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0; sl@0: sl@0: /** If possible, shape the text described by aInput, placing the output on aHeapForOutput. sl@0: @param aOutput The output, as a newly allocate object on aHeapForOutput. sl@0: @param aInput The input text and other parameters. sl@0: @param aHeapForOutput On success, aOutput should be allocated from this and nothing else. sl@0: On failure, nothing should be allocated from it. sl@0: @return Error value from one of the system-wide error codes on failure, KErrNone on success. sl@0: @see TShapeHeader */ sl@0: virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0; sl@0: sl@0: /** For future expansion. Any overriders must base-call sl@0: if aInterface is unrecognized. sl@0: sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: sl@0: @param aInterfaceId The ID of the interface to return. sl@0: @return A pointer to the extension interface. sl@0: */ sl@0: IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId); sl@0: }; sl@0: sl@0: /** ECOM plug-in base class for shaper factories. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CShaperFactory : public CBase sl@0: { sl@0: public: sl@0: /** Create a shaper if possible, for typeface aFaceIndex sl@0: within file aFileName. sl@0: @param aFont The font to be shaped. sl@0: @param iHeap The heap to use for constructing the shaper. sl@0: @return 0 If the font is not understood or inappropriate for any shaper that might be constructed sl@0: by this class, otherwise returns the newly-constructed shaper on iHeap. */ sl@0: virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0; sl@0: sl@0: inline static CShaperFactory* NewL(TUid aInterfaceImplUid); sl@0: inline virtual ~CShaperFactory(); sl@0: sl@0: /** For future expansion. Any overriders must base-call if aInterface is unrecognized. sl@0: sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: sl@0: @param aInterfaceId The ID of the interface to return. sl@0: @return A pointer to the extension interface. sl@0: */ sl@0: virtual void* ExtendedInterface(TUid aInterfaceId); sl@0: sl@0: private: sl@0: TUid iDtor_ID_Key;//ECOM identifier used during destruction sl@0: }; sl@0: sl@0: // Inline functions start here. sl@0: /** Default C++ constructor. sl@0: sl@0: This creates then zero fills the object. */ sl@0: inline TOpenFontMetrics::TOpenFontMetrics() sl@0: { sl@0: Mem::FillZ(this,sizeof(*this)); sl@0: } sl@0: sl@0: /** Gets the font's size. sl@0: sl@0: @return The font's size. sl@0: @see SetSize() */ sl@0: inline TInt TOpenFontMetrics::Size() const sl@0: { sl@0: return iDesignHeight; sl@0: } sl@0: sl@0: /** Gets the font's ascent. sl@0: sl@0: This is the ascent for the Latin character which is highest above the baseline. sl@0: sl@0: @return The font's ascent, in pixels. sl@0: @see SetAscent() */ sl@0: inline TInt TOpenFontMetrics::Ascent() const sl@0: { sl@0: return iAscent; sl@0: } sl@0: sl@0: /** Gets the font's descent. sl@0: sl@0: This is the descent for the Latin character in the font which falls furthest below the baseline. sl@0: sl@0: @return The font's descent, in pixels. sl@0: @see SetDescent() */ sl@0: inline TInt TOpenFontMetrics::Descent() const sl@0: { sl@0: return iDescent; sl@0: } sl@0: sl@0: /** Sets the font's maximum height. sl@0: sl@0: Note that if this object was initialised from the CFont this will be the same sl@0: as the ascent. sl@0: sl@0: This is the ascent for the character which is highest above the baseline. sl@0: In many fonts this will be the height of an accented character like Â, sl@0: including the accent. sl@0: sl@0: @return The maximum height of the font, in pixels. sl@0: @see SetMaxDepth() */ sl@0: inline TInt TOpenFontMetrics::MaxHeight() const sl@0: { sl@0: return iMaxHeight; sl@0: } sl@0: sl@0: /** Gets the font's maximum depth. sl@0: sl@0: Note: If this object was initialised from the CFont this will be the same as the sl@0: descent. sl@0: sl@0: This is the descent for the character in the font which falls furthest below sl@0: the baseline. sl@0: sl@0: @return The font's maximum depth. sl@0: @see SetMaxDepth() */ sl@0: inline TInt TOpenFontMetrics::MaxDepth() const sl@0: { sl@0: return iMaxDepth; sl@0: } sl@0: sl@0: /** Gets the maximum character width, in pixels. sl@0: sl@0: @return The maximum character width, in pixels. sl@0: @see SetMaxWidth() */ sl@0: inline TInt TOpenFontMetrics::MaxWidth() const sl@0: { sl@0: return iMaxWidth; sl@0: } sl@0: sl@0: /** Sets the font's size. sl@0: sl@0: @param aSize The font's size. sl@0: @see Size() */ sl@0: inline void TOpenFontMetrics::SetSize(TInt aSize) sl@0: { sl@0: iDesignHeight = static_cast(aSize); sl@0: } sl@0: sl@0: /** Sets the ascent. sl@0: sl@0: @param aAscent The ascent, in pixels. sl@0: @see Ascent() */ sl@0: inline void TOpenFontMetrics::SetAscent(TInt aAscent) sl@0: { sl@0: iAscent = static_cast(aAscent); sl@0: } sl@0: sl@0: /** Sets the descent. sl@0: sl@0: @param aDescent The descent, in pixels. sl@0: @see Descent() */ sl@0: inline void TOpenFontMetrics::SetDescent(TInt aDescent) sl@0: { sl@0: iDescent = static_cast(aDescent); sl@0: } sl@0: sl@0: /** Sets the font's maximum height. sl@0: sl@0: @param aMaxHeight The font's maximum height, in pixels. sl@0: @see MaxHeight() */ sl@0: inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight) sl@0: { sl@0: iMaxHeight = static_cast(aMaxHeight); sl@0: } sl@0: sl@0: /** Sets the font's maximum depth. sl@0: sl@0: @param aMaxDepth The font's maximum depth, in pixels. sl@0: @see MaxDepth() */ sl@0: inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth) sl@0: { sl@0: iMaxDepth = static_cast(aMaxDepth); sl@0: } sl@0: sl@0: /** Sets the maximum character width, in pixels. sl@0: sl@0: @param aMaxWidth The maximum character width, in pixels. sl@0: @see MaxWidth() */ sl@0: inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth) sl@0: { sl@0: iMaxWidth = static_cast(aMaxWidth); sl@0: } sl@0: sl@0: /** Default C++ constructor. sl@0: sl@0: The constructor initialises all data members to zero. As for other T classes, sl@0: there is no need to explicitly cleanup TOpenFontCharMetrics objects. */ sl@0: inline TOpenFontCharMetrics::TOpenFontCharMetrics() sl@0: { sl@0: Mem::FillZ(this,sizeof(*this)); sl@0: } sl@0: sl@0: /** Gets the width of the character's bitmap. sl@0: sl@0: @return The width of the bitmap in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::Width() const sl@0: { sl@0: return iWidth; sl@0: } sl@0: sl@0: /** Gets the height of the character's bitmap. sl@0: sl@0: @return The character's height in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::Height() const sl@0: { sl@0: return iHeight; sl@0: } sl@0: sl@0: /** Gets the horizontal bearing X. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the left edge of the bitmap, when drawing horizontally. sl@0: A positive value means that the left edge of the bitmap is right of the origin. sl@0: sl@0: @return The horizontal bearing X in pixels */ sl@0: inline TInt TOpenFontCharMetrics::HorizBearingX() const sl@0: { sl@0: return iHorizBearingX; sl@0: } sl@0: sl@0: /** Gets horizontal bearing Y. sl@0: sl@0: This is the vertical distance in pixels from the pen point before the character sl@0: is drawn (the origin) to the top edge of the bitmap, when drawing horizontally. sl@0: A positive value means that the top edge of the bitmap is above the origin sl@0: sl@0: @return The horizontal bearing Y in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::HorizBearingY() const sl@0: { sl@0: return iHorizBearingY; sl@0: } sl@0: sl@0: /** Gets the horizontal advance. sl@0: sl@0: This is the amount added to the x co-ordinate of the origin after the character sl@0: is drawn what most people understand by the width or escapement of a character. sl@0: The origin here is the pen point before the character is drawn. sl@0: sl@0: @return The horizontal advance in pixels */ sl@0: inline TInt TOpenFontCharMetrics::HorizAdvance() const sl@0: { sl@0: return iHorizAdvance; sl@0: } sl@0: sl@0: /** Gets the vertical bearing X. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the left edge of the bitmap, when drawing vertically. sl@0: A positive value means that the left edge of the bitmap is right of the origin. sl@0: sl@0: @return The vertical bearing X in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::VertBearingX() const sl@0: { sl@0: return iVertBearingX; sl@0: } sl@0: sl@0: /** Gets the vertical bearing Y. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the top edge of the bitmap, when drawing vertically. sl@0: A positive value means that the top edge of the bitmap is above the origin. sl@0: sl@0: @return The vertical bearing Y in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::VertBearingY() const sl@0: { sl@0: return iVertBearingY; sl@0: } sl@0: sl@0: /** Gets the vertical advance. sl@0: sl@0: When drawing vertically, this is the amount added to the y co-ordinate of sl@0: the origin after the character is drawn what most people understand by sl@0: the height of a character. The origin here is the pen point before the character sl@0: is drawn. sl@0: sl@0: Note: Vertical drawing is not supported in v5. sl@0: sl@0: @return The vertical advance in pixels. */ sl@0: inline TInt TOpenFontCharMetrics::VertAdvance() const sl@0: { sl@0: return iVertAdvance; sl@0: } sl@0: sl@0: /** Gets the bounds of the character relative to its origin when setting text sl@0: horizontally. sl@0: sl@0: The origin here is the pen point before the character is drawn. sl@0: sl@0: @param aBounds The character's bounds. */ sl@0: inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const sl@0: { sl@0: aBounds.iTl.iX = iHorizBearingX; sl@0: aBounds.iTl.iY = -iHorizBearingY; sl@0: aBounds.iBr.iX = aBounds.iTl.iX + iWidth; sl@0: aBounds.iBr.iY = aBounds.iTl.iY + iHeight; sl@0: } sl@0: sl@0: /** Gets the bounds of the character relative to its origin when setting text sl@0: vertically. sl@0: sl@0: The origin here is the pen point before the character is drawn. sl@0: sl@0: @param aBounds The character's bounds. */ sl@0: inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const sl@0: { sl@0: aBounds.iTl.iX = -iVertBearingX; sl@0: aBounds.iTl.iY = iVertBearingY; sl@0: aBounds.iBr.iX = aBounds.iTl.iX + iWidth; sl@0: aBounds.iBr.iY = aBounds.iTl.iY + iHeight; sl@0: } sl@0: sl@0: /** Sets the width of the character's bitmap. sl@0: sl@0: @param aWidth The width of the bitmap in pixels. */ sl@0: inline void TOpenFontCharMetrics::SetWidth(TInt aWidth) sl@0: { sl@0: iWidth = (TInt16)aWidth; sl@0: } sl@0: sl@0: /** Sets the height of the character's bitmap. sl@0: sl@0: @param aHeight The character height (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetHeight(TInt aHeight) sl@0: { sl@0: iHeight = (TInt16)aHeight; sl@0: } sl@0: sl@0: /** Sets the horizontal bearing X. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the left edge of the bitmap, when drawing horizontally. sl@0: A positive value means that the left edge of the bitmap is right of the origin. sl@0: sl@0: @param aHorizBearingX The horizontal bearing X (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX) sl@0: { sl@0: iHorizBearingX = (TInt16)aHorizBearingX; sl@0: } sl@0: sl@0: /** Sets the horizontal bearing Y. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the top edge of the bitmap, when drawing horizontally. sl@0: A positive value means that the top edge of the bitmap is above the origin. sl@0: sl@0: @param aHorizBearingY The horizontal bearing Y (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY) sl@0: { sl@0: iHorizBearingY = (TInt16)aHorizBearingY; sl@0: } sl@0: sl@0: /** Sets the horizontal advance. sl@0: sl@0: This is the amount added to the x co-ordinate of the origin after the character sl@0: is drawn, what most people understand by the width or escapement of a character. sl@0: The origin here is the pen point before the character is drawn. sl@0: sl@0: @param aHorizAdvance The horizontal advance (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance) sl@0: { sl@0: iHorizAdvance = (TInt16)aHorizAdvance; sl@0: } sl@0: sl@0: /** Set vertical bearing X. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the left edge of the bitmap, when drawing vertically. sl@0: A positive value means that the left edge of the bitmap is right of the origin. sl@0: sl@0: @param aVertBearingX The vertical bearing X (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX) sl@0: { sl@0: iVertBearingX = (TInt16)aVertBearingX; sl@0: } sl@0: sl@0: /** Sets the vertical bearing Y. sl@0: sl@0: This is the distance in pixels from the pen point before the character is sl@0: drawn (the origin) to the top edge of the bitmap, when drawing vertically. sl@0: A positive value means that the top edge of the bitmap is above the origin. sl@0: sl@0: @param aVertBearingY The vertical bearing Y (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY) sl@0: { sl@0: iVertBearingY = (TInt16)aVertBearingY; sl@0: } sl@0: sl@0: /** Sets the vertical advance. sl@0: sl@0: When drawing vertically, this is the amount added to the y co-ordinate of sl@0: the origin after the character is drawn what most people understand by sl@0: the height of a character. The origin here is the pen point before the character sl@0: is drawn. sl@0: sl@0: Note: Vertical drawing is not supported in v5. sl@0: sl@0: @param aVertAdvance The vertical advance (in pixels). */ sl@0: inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance) sl@0: { sl@0: iVertAdvance = (TInt16)aVertAdvance; sl@0: } sl@0: sl@0: /** Gets the character metrics for this font. sl@0: sl@0: @return The character metrics for this font. */ sl@0: inline const TOpenFontMetrics& COpenFont::Metrics() const sl@0: { sl@0: return iMetrics; sl@0: } sl@0: sl@0: /** Gets the glyph index. sl@0: sl@0: This is the index of a particular glyph within the font file. sl@0: sl@0: Note: This makes it possible to gain access to glyphs which are not referenced sl@0: by the Unicode character set. However, this feature is not yet supported by sl@0: Symbian OS. sl@0: sl@0: @return The glyph index. sl@0: @see SetGlyphIndex() */ sl@0: inline TInt TOpenFontGlyphData::GlyphIndex() const sl@0: { sl@0: return iGlyphIndex; sl@0: } sl@0: sl@0: /** Gets the typeface attributes. sl@0: sl@0: These are the attributes of the font represented by this object. sl@0: sl@0: @return The typeface attributes. */ sl@0: inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const sl@0: { sl@0: return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex); sl@0: } sl@0: sl@0: /** Gets a pointer to the COpenFontFile which created this object. sl@0: sl@0: This is the COpenFontFile which owns the file that contains the definition sl@0: of the typeface. It can be used to get information about the typeface, or sl@0: to access the rasterizer context (engine). sl@0: sl@0: @return The COpenFontFile which created this object. */ sl@0: inline COpenFontFile* COpenFont::File() const sl@0: { sl@0: return iFileOffset == 0 ? NULL : reinterpret_cast(const_cast(PtrAdd(this, iFileOffset))); sl@0: } sl@0: sl@0: /** Gets the index of this typeface within the font file. sl@0: sl@0: @return The index of this typeface within the font file. */ sl@0: inline TInt COpenFont::FaceIndex() const sl@0: { sl@0: return iFaceIndex; sl@0: } sl@0: sl@0: /** Tests whether or not a character needs to be rasterized. sl@0: sl@0: Characters that have been rasterized are cached there is no need to regenerate sl@0: the character bitmap. This function should only be called by the Font and sl@0: Bitmap server. sl@0: sl@0: @param aSessionHandle A handle to the font and bitmap server session. sl@0: @param aCode The code for the Unicode character. sl@0: @return ETrue if the character needs to be rasterized, otherwise EFalse. */ sl@0: inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const sl@0: { sl@0: return Glyph(aSessionHandle,aCode) == NULL; sl@0: } sl@0: sl@0: /** Gets the ascent of an ANSI capital letter in the font whether or not sl@0: there are any ANSI capitals in the font. sl@0: @return The positive distance from the font baseline to the top of a sl@0: standard ANSI capital letter sl@0: @publishedAll sl@0: @released sl@0: @see AscentInPixels() sl@0: */ sl@0: inline TInt COpenFont::FontCapitalAscent() const sl@0: { sl@0: return iFontCapitalAscent; sl@0: } sl@0: sl@0: /** Gets the max ascent of any pre-composed glyph in the font. This will sl@0: include accents or diacritics that form part of pre-composed glyphs. It is sl@0: not guaranteed to cover the max ascent of composite glyphs that have to be sl@0: created by a layout engine. This is also the recommended distance between sl@0: the top of a text box and the baseline of the first line of text. sl@0: sl@0: The value may be affected by the TLanguage value set by SetScriptTypeForMetrics(). sl@0: sl@0: @return The positive distance from the font baseline to the top of the sl@0: highest pre-composed glyph (including accents) above the baseline. sl@0: @publishedAll sl@0: @released sl@0: @see AscentInPixels() sl@0: @see SetScriptTypeForMetrics() sl@0: */ sl@0: inline TInt COpenFont::FontMaxAscent() const sl@0: { sl@0: return iFontMaxAscent; sl@0: } sl@0: sl@0: /** Gets the descent of an ANSI descending character in the font. sl@0: Whether or not there are any ANSI descenders in the font. sl@0: sl@0: The value may be affected by the TLanguage value set by SetScriptTypeForMetrics(). sl@0: sl@0: @return The positive distance from the font baseline to the bottom of the sl@0: lowest ANSI descender. sl@0: @publishedAll sl@0: @released sl@0: @see DescentInPixels() sl@0: @see SetScriptTypeForMetrics() sl@0: */ sl@0: inline TInt COpenFont::FontStandardDescent() const sl@0: { sl@0: return iFontStandardDescent; sl@0: } sl@0: sl@0: /** Gets the max descent of any pre-composed glyph in the font. This will sl@0: include accents or diacritics that form part of pre-composed glyphs. It is sl@0: not guaranteed to cover the max descent of composite glyphs that have to be sl@0: created by a layout engine. sl@0: sl@0: The value may be affected by the TLanguage value set by SetScriptTypeForMetrics(). sl@0: sl@0: @return The positive distance from the font baseline to the bottom of the sl@0: lowest pre-composed glyph (including accents) below the baseline sl@0: @publishedAll sl@0: @released sl@0: @see DescentInPixels() sl@0: @see SetScriptTypeForMetrics() sl@0: */ sl@0: inline TInt COpenFont::FontMaxDescent() const sl@0: { sl@0: return iFontMaxDescent; sl@0: } sl@0: sl@0: /** Gets the suggested line gap for the font. This is the recommended sl@0: baseline to baseline distance between successive lines of text in the font. sl@0: @return The positive recommended gap between successive lines sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: inline TInt COpenFont::FontLineGap() const sl@0: { sl@0: return iFontLineGap; sl@0: } sl@0: sl@0: /** Gets the maximum height for the font. This is the sum of the max ascent sl@0: of the font and the max descent of the font. sl@0: sl@0: The value may be affected by the TLanguage value set by SetScriptTypeForMetrics(). sl@0: sl@0: @return The positive maximum height of the font sl@0: @publishedAll sl@0: @released sl@0: @see HeightInPixels() sl@0: @see SetScriptTypeForMetrics() sl@0: */ sl@0: inline TInt COpenFont::FontMaxHeight() const sl@0: { sl@0: return iFontMaxAscent + iFontMaxDescent; sl@0: } sl@0: sl@0: /** Default C++ constructor. sl@0: sl@0: This sets all attribute fields to zero. As for other T classes, there is no sl@0: need to explicitly clean-up objects derived from this class. */ sl@0: inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase() sl@0: { sl@0: Mem::FillZ(this,sizeof(*this)); sl@0: } sl@0: sl@0: /** Default C++ constructor. sl@0: sl@0: The function initialises the minimum typeface size to zero, the names to NULL, sl@0: and the coverage and style flags to zero. */ sl@0: inline TOpenFontFaceAttrib::TOpenFontFaceAttrib(): sl@0: iMinSizeInPixels(0), sl@0: iReserved2(0) sl@0: { sl@0: } sl@0: sl@0: /** Tests for support of Latin characters. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Latin characters are supported */ sl@0: inline TBool TOpenFontFaceAttribBase::HasLatin() const sl@0: { sl@0: return iCoverage[0] & ELatinSet; sl@0: } sl@0: sl@0: /** Tests for support of Greek characters. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Greek characters are supported. */ sl@0: inline TBool TOpenFontFaceAttribBase::HasGreek() const sl@0: { sl@0: return iCoverage[0] & EGreekSet; sl@0: } sl@0: sl@0: /** Tests for support of Cyrillic characters. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Cyrillic characters are supported. */ sl@0: inline TBool TOpenFontFaceAttribBase::HasCyrillic() const sl@0: { sl@0: return iCoverage[0] & ECyrillicSet; sl@0: } sl@0: sl@0: /** Tests for support of Japanese syllabic characters. sl@0: sl@0: This function tests for the presence of Hiragana and Katakana syllabic sl@0: characters in the font, collectively called kana. These characters are not sl@0: sufficient for the Japanese language, which also makes use of Chinese characters. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Japanese characters are supported sl@0: @see HasCJK() */ sl@0: inline TBool TOpenFontFaceAttribBase::HasKana() const sl@0: { sl@0: return iCoverage[1] & EKanaSets; sl@0: } sl@0: sl@0: /** Tests for support of Korean Hangul characters. sl@0: sl@0: Korean may also make use of Chinese characters. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Korean characters are supported sl@0: @see HasCJK() */ sl@0: inline TBool TOpenFontFaceAttribBase::HasHangul() const sl@0: { sl@0: return iCoverage[1] & EHangulSet; sl@0: } sl@0: sl@0: /** Tests for support of Chinese ideographic characters. sl@0: sl@0: These are used in Chinese, Japanese and Korean. sl@0: sl@0: Note: A return value of ETrue implies that the font has a usable set of sl@0: characters. It does not imply exhaustive coverage. sl@0: sl@0: @return ETrue if Chinese ideographs are supported. */ sl@0: inline TBool TOpenFontFaceAttribBase::HasCJK() const sl@0: { sl@0: return iCoverage[1] & ECJKSet; sl@0: } sl@0: sl@0: /** Tests if the typeface contains symbols only. sl@0: sl@0: @return ETrue if the typeface contains symbols only. */ sl@0: inline TBool TOpenFontFaceAttribBase::IsSymbol() const sl@0: { sl@0: return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 && sl@0: iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets); sl@0: } sl@0: sl@0: /** Tests if the typeface is inherently bold. sl@0: sl@0: @return ETrue if the typeface is inherently bold. */ sl@0: inline TBool TOpenFontFaceAttribBase::IsBold() const sl@0: { sl@0: return iStyle & EBold; sl@0: } sl@0: sl@0: /** Tests if the typeface is inherently italic. sl@0: sl@0: @return ETrue if the typeface is inherently italic. */ sl@0: inline TBool TOpenFontFaceAttribBase::IsItalic() const sl@0: { sl@0: return iStyle & EItalic; sl@0: } sl@0: sl@0: /** Tests if the typeface has serifs. sl@0: sl@0: @return ETrue if the typeface has serifs. */ sl@0: inline TBool TOpenFontFaceAttribBase::IsSerif() const sl@0: { sl@0: return iStyle & ESerif; sl@0: } sl@0: sl@0: /** Tests if all the characters have the same width. sl@0: sl@0: @return ETrue if all the characters have the same width. */ sl@0: inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const sl@0: { sl@0: return iStyle & EMonoWidth; sl@0: } sl@0: sl@0: /** Gets the typeface's name. sl@0: sl@0: @return Descriptor containing typeface name. */ sl@0: inline TPtrC TOpenFontFaceAttribBase::Name() const sl@0: { sl@0: return iName; sl@0: } sl@0: sl@0: /** Gets the full name. sl@0: sl@0: The full name of the typeface includes style attributes like Italic, Bold, sl@0: and Cursive. sl@0: sl@0: @return The full name of the typeface. sl@0: @see FamilyName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::FullName() const sl@0: { sl@0: return Name(); sl@0: } sl@0: sl@0: /** Gets the family name. sl@0: sl@0: Note: The family name of the typeface does not include style attributes like sl@0: "Italic". sl@0: sl@0: @return The family name of the typeface. sl@0: @see FullName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::FamilyName() const sl@0: { sl@0: return iFamilyName; sl@0: } sl@0: sl@0: /** Gets the local full name. sl@0: sl@0: The local full name of the typeface includes style attributes like Italic, sl@0: Bold, and Cursive. sl@0: sl@0: The local name of the typeface is the name in the language of the current sl@0: locale, where this is provided by the font file. If the local name is not sl@0: available then the local name will be the same as the ordinary name. sl@0: sl@0: @return The local full name of the typeface. */ sl@0: inline TPtrC TOpenFontFaceAttrib::LocalFullName() const sl@0: { sl@0: return iLocalFullName; sl@0: } sl@0: sl@0: /** Gets the local family name. sl@0: sl@0: The local name of the typeface is the name in the language of the current sl@0: locale, where this is provided by the font file. If the local name is not sl@0: available then the local name will be the same as the ordinary name. sl@0: sl@0: Note: The family name of the typeface does not include style attributes like sl@0: 'Italic'. sl@0: sl@0: @return The local family name of the typeface. */ sl@0: inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const sl@0: { sl@0: return iLocalFamilyName; sl@0: } sl@0: sl@0: /** Gets the short full name. sl@0: sl@0: This is the full name of the typeface, truncated to KMaxTypefaceNameLength, sl@0: if necessary. sl@0: sl@0: Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters sl@0: where necessary so that they can be used in the TTypeFace class. The Open sl@0: Font Framework allows 32 characters as a maximum name length. sl@0: sl@0: @return The short full name of the typeface. sl@0: @see FullName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::ShortFullName() const sl@0: { sl@0: // Can't use TDesC::Left for this because it panics if the desired length is > the existing length! sl@0: return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength)); sl@0: } sl@0: sl@0: /** Gets the short family name. sl@0: sl@0: This is the family name, truncated to KMaxTypefaceNameLength, if necessary. sl@0: sl@0: Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters sl@0: where necessary so that they can be used in the TTypeFace class. The Open sl@0: Font Framework allows 32 characters as a maximum name length. sl@0: sl@0: @return The short family name of the typeface. sl@0: @see FamilyName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const sl@0: { sl@0: return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength)); sl@0: } sl@0: sl@0: /** Gets the short local full name. sl@0: sl@0: This is the local full name of the typeface, truncated to KMaxTypefaceNameLength, sl@0: if necessary. sl@0: sl@0: Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters sl@0: where necessary so that they can be used in the TTypeFace class. The Open sl@0: Font Framework allows 32 characters as a maximum name length. sl@0: sl@0: @return The short local full name of the typeface. sl@0: @see LocalFullName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const sl@0: { sl@0: return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength)); sl@0: } sl@0: sl@0: /** Gets the short local family name. sl@0: sl@0: This is the local family name of the typeface, truncated to KMaxTypefaceNameLength, sl@0: if necessary. sl@0: sl@0: Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters sl@0: where necessary so that they can be used in the TTypeFace class. The Open sl@0: Font Framework allows 32 characters as a maximum name length. sl@0: sl@0: @return The short local family name of the typeface. sl@0: @see LocalFamilyName() */ sl@0: inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const sl@0: { sl@0: return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength)); sl@0: } sl@0: sl@0: /** Gets a pointer to the sets of flags that indicate the font's Unicode coverage. sl@0: sl@0: Each flag that is set represents a supported Unicode range. The mapping is sl@0: defined in the TrueType documentation under the OS/2 table. sl@0: sl@0: Note: Some useful subsets are defined as anonymous enumerated constants at the end sl@0: of this class, see ELatinSet etc. sl@0: sl@0: @return A pointer to the flags that indicate the font's Unicode coverage. sl@0: The flags are stored in an array of four 32-bit integers. When no information sl@0: is available, all four integers are zero. sl@0: @see SetCoverage() */ sl@0: inline const TUint* TOpenFontFaceAttribBase::Coverage() const sl@0: { sl@0: return iCoverage; sl@0: } sl@0: sl@0: /** Gets the minimum typeface size. sl@0: sl@0: This is the smallest size that can be drawn legibly. sl@0: sl@0: @return The minimum typeface size (in pixels). */ sl@0: inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const sl@0: { sl@0: return iMinSizeInPixels; sl@0: } sl@0: sl@0: /** Sets the name attribute. sl@0: sl@0: @param aName Descriptor containing typeface name. */ sl@0: inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName) sl@0: { sl@0: iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength)); sl@0: } sl@0: sl@0: /** Sets the full name. sl@0: sl@0: @param aName The full name of the typeface. sl@0: @see FullName() */ sl@0: inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName) sl@0: { sl@0: SetName(aName); sl@0: } sl@0: sl@0: /** Sets the family name. sl@0: sl@0: @param aName The family name of the typeface. sl@0: @see FamilyName() */ sl@0: inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName) sl@0: { sl@0: iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength)); sl@0: } sl@0: sl@0: /** Sets the local full name. sl@0: sl@0: @param aName The local full name of the typeface. sl@0: @see LocalFullName() */ sl@0: inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName) sl@0: { sl@0: iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength)); sl@0: } sl@0: sl@0: /** Sets the local family name. sl@0: sl@0: @param aName The local family name of the typeface. sl@0: @see LocalFamilyName() */ sl@0: inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName) sl@0: { sl@0: iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength)); sl@0: } sl@0: sl@0: /** Sets the coverage flags. sl@0: sl@0: The flags are held in four 32 bit integers. Each flag that is set represents sl@0: a range of Unicode characters that is supported by the typeface: Latin, sl@0: Greek, Cyrillic etc. The mapping is defined in the TrueType documentation sl@0: under the OS/2 table. sl@0: sl@0: Note: Some useful subsets are defined as anonymous enumerated constants at sl@0: the end of this class, see ELatinSet etc. sl@0: sl@0: @param aCoverage0 The first set of coverage flags (bits 0-31). sl@0: @param aCoverage1 The second set of coverage flags (bits 32-63). sl@0: @param aCoverage2 The third set of coverage flags (bits 64-95). sl@0: @param aCoverage3 The fourth set of coverage flags (bits 96-127). */ sl@0: inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3) sl@0: { sl@0: iCoverage[0] = aCoverage0; sl@0: iCoverage[1] = aCoverage1; sl@0: iCoverage[2] = aCoverage2; sl@0: iCoverage[3] = aCoverage3; sl@0: } sl@0: sl@0: /** Set the minimum typeface size. sl@0: sl@0: This is the smallest size that can be drawn legibly. sl@0: sl@0: @param aSize Sets the minimum typeface size (in pixels). sl@0: @see MinSizeInPixels() */ sl@0: inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize) sl@0: { sl@0: iMinSizeInPixels = aSize; sl@0: } sl@0: sl@0: /** Equality operator. sl@0: sl@0: Compares this and another set of font attributes, including the coverage, sl@0: the family name, the local full name, the local family name, and the minimum sl@0: size in pixels. sl@0: sl@0: @param aAttrib Contains the font attributes and names to compare. sl@0: @return ETrue if all values are equal, EFalse if not. */ sl@0: inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const sl@0: { sl@0: return TOpenFontFaceAttribBase::operator==(aAttrib) && sl@0: iFamilyName == aAttrib.iFamilyName && sl@0: iLocalFullName == aAttrib.iLocalFullName && sl@0: iLocalFamilyName == aAttrib.iLocalFamilyName && sl@0: iMinSizeInPixels == aAttrib.iMinSizeInPixels; sl@0: } sl@0: sl@0: /** Sets the bold attribute. sl@0: sl@0: @param aBold The bold attribute takes this value: ETrue or EFalse. */ sl@0: inline void TOpenFontFaceAttribBase::SetBold(TBool aBold) sl@0: { sl@0: if (aBold) sl@0: iStyle |= EBold; sl@0: else sl@0: iStyle &= ~EBold; sl@0: } sl@0: sl@0: /** Sets the italic attribute. sl@0: sl@0: @param aItalic The italic attribute takes this value ETrue or EFalse. */ sl@0: inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic) sl@0: { sl@0: if (aItalic) sl@0: iStyle |= EItalic; sl@0: else sl@0: iStyle &= ~EItalic; sl@0: } sl@0: sl@0: /** Sets the serif attribute. sl@0: sl@0: @param aSerif The serif attribute takes this value ETrue or EFalse. */ sl@0: inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif) sl@0: { sl@0: if (aSerif) sl@0: iStyle |= ESerif; sl@0: else sl@0: iStyle &= ~ESerif; sl@0: } sl@0: sl@0: /** Sets the mono-width attribute. sl@0: sl@0: @param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */ sl@0: inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth) sl@0: { sl@0: if (aMonoWidth) sl@0: iStyle |= EMonoWidth; sl@0: else sl@0: iStyle &= ~EMonoWidth; sl@0: } sl@0: sl@0: /** Equality operator. sl@0: sl@0: Compares this and a specified set of font attributes, including the coverage sl@0: and the typeface name. sl@0: sl@0: In version 6.1, and earlier, the return value was TInt. sl@0: sl@0: @param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase sl@0: or of a derived class. sl@0: @return ETrue if the values are equal. */ sl@0: inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const sl@0: { sl@0: return iStyle == aAttrib.iStyle && sl@0: iCoverage[0] == aAttrib.iCoverage[0] && sl@0: iCoverage[1] == aAttrib.iCoverage[1] && sl@0: iCoverage[2] == aAttrib.iCoverage[2] && sl@0: iCoverage[3] == aAttrib.iCoverage[3] && sl@0: iName.CompareF(aAttrib.iName) == 0; sl@0: } sl@0: sl@0: /** Compares this and another open font specification. Compares all the properties sl@0: of the two fonts. sl@0: @publishedAll sl@0: @released sl@0: @param aFontSpec The open font specification to compare with this one. sl@0: @return ETrue if all values are equal, EFalse if not. sl@0: */ sl@0: inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const sl@0: { sl@0: return sl@0: iHeight == aOpenFontSpec.iHeight && sl@0: iWidthFactor == aOpenFontSpec.iWidthFactor && sl@0: iSlantFactor == aOpenFontSpec.iSlantFactor && sl@0: iBitmapType == aOpenFontSpec.iBitmapType && sl@0: iEffects == aOpenFontSpec.iEffects && sl@0: iSymbol == aOpenFontSpec.iSymbol && sl@0: iPrintPosition == aOpenFontSpec.iPrintPosition && sl@0: TOpenFontFaceAttribBase::operator==(aOpenFontSpec); sl@0: } sl@0: sl@0: /** Gets the height of the font. sl@0: sl@0: @return The height of the font, in pixels or twips. sl@0: @see SetHeight() */ sl@0: inline TInt TOpenFontSpec::Height() const sl@0: { sl@0: return iHeight; sl@0: } sl@0: sl@0: /** Gets the algorithmic width factor. sl@0: sl@0: @return The algorithmic width factor as a 16.16 fixed-point number. sl@0: @see SetWidthFactor() */ sl@0: inline TInt32 TOpenFontSpec::WidthFactor() const sl@0: { sl@0: return iWidthFactor; sl@0: } sl@0: sl@0: /** Gets the algorithmic slant factor. sl@0: sl@0: @return The algorithmic slant factor as a 16.16 fixed-point number. sl@0: @see SetSlantFactor() */ sl@0: inline TInt32 TOpenFontSpec::SlantFactor() const sl@0: { sl@0: return iSlantFactor; sl@0: } sl@0: sl@0: /** Gets the anti-aliasing setting for the font, as set by SetBitmapType(). sl@0: sl@0: @return Indicates whether or not the font should be drawn using anti-aliasing. */ sl@0: inline TGlyphBitmapType TOpenFontSpec::BitmapType() const sl@0: { sl@0: return (TGlyphBitmapType)iBitmapType; sl@0: } sl@0: sl@0: /** Gets the font effects flags. sl@0: Because the flags encoded in the Effects are anonymous, the return value should only sl@0: be tested for the specific bits that are of interest, and never tested as a whole. sl@0: @publishedAll sl@0: @released sl@0: @return The font effects flags. sl@0: @see TOpenFontSpec::SetEffects() sl@0: */ sl@0: inline TUint32 TOpenFontSpec::Effects() const sl@0: { sl@0: return iEffects; sl@0: } sl@0: sl@0: /** Gets the print position. sl@0: sl@0: @return The print position. */ sl@0: inline TFontPrintPosition TOpenFontSpec::PrintPosition() const sl@0: { sl@0: return iPrintPosition; sl@0: } sl@0: sl@0: /** Sets the font's height. sl@0: sl@0: @param aHeight The font's height, in pixels or twips. sl@0: @see Height() */ sl@0: inline void TOpenFontSpec::SetHeight(TInt aHeight) sl@0: { sl@0: iHeight = aHeight; sl@0: } sl@0: sl@0: /** Sets the algorithmic width factor. sl@0: sl@0: The width factor is multiplied by the pixel's x position to get the new position, sl@0: causing characters to become wider or narrower. A width factor of 1 (65536 sl@0: in 16.16 fixed-point number format) should be used if the character width sl@0: is not to be changed. sl@0: sl@0: @param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number. sl@0: @see WidthFactor() */ sl@0: inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor) sl@0: { sl@0: iWidthFactor = aWidthFactor; sl@0: } sl@0: sl@0: /** Sets the algorithmic slant factor. sl@0: sl@0: Note: The slant factor is used to create an italic effect for characters which sl@0: do not have an italic glyph in the typeface. When slanting is active, pixel x sl@0: co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x sl@0: = x + y x slant factor). sl@0: sl@0: The slant factor is a 32 bit, 16.16 fixed-point number. This means that the sl@0: first 16 bits are treated as a whole number, and the second 16 as the fractional sl@0: part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this sl@0: is equivalent to an integer slant value of 1, which causes a 45 degree slant sl@0: on the character. sl@0: sl@0: @param aSlantFactor The slant factor as a 16.16 fixed-point number. sl@0: @see SlantFactor() */ sl@0: inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor) sl@0: { sl@0: iSlantFactor = aSlantFactor; sl@0: } sl@0: sl@0: /** Sets whether the font should be drawn using anti-aliasing. If set, this value sl@0: overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType()) sl@0: for this font. sl@0: sl@0: Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing sl@0: support for bitmapped fonts. sl@0: sl@0: @param aBitmapType Indicates whether or not the font should be drawn using sl@0: anti-aliasing. */ sl@0: inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType) sl@0: { sl@0: iBitmapType = aBitmapType; sl@0: } sl@0: sl@0: /** Sets the font effects flags. sl@0: Prior to calling this routine, the value from Effects() should be read, sl@0: and its flags modified as required, before passing them back in. sl@0: @publishedAll sl@0: @released sl@0: @param aEffect The font effects flags to be set. sl@0: @see TOpenFontSpec::Effects() sl@0: */ sl@0: inline void TOpenFontSpec::SetEffects(TUint32 aEffects) sl@0: { sl@0: iEffects = aEffects; sl@0: } sl@0: sl@0: /** Gets the font file's UID. sl@0: sl@0: @return The uid of the file. */ sl@0: inline TUid COpenFontFile::Uid() const sl@0: { sl@0: return iUid; sl@0: } sl@0: sl@0: /** Gets the full path and filename of the font file sl@0: sl@0: This is the filename that was passed to the constructor when the object is sl@0: created. sl@0: sl@0: @return The filename of the font file. */ sl@0: inline const TDesC& COpenFontFile::FileName() const sl@0: { sl@0: return iFileName; sl@0: } sl@0: sl@0: /** Gets the typeface at a specified index in the typeface attribute array. sl@0: sl@0: @param aFaceIndex The index of the typeface for which the attributes are required. sl@0: @return The attributes of the typeface with the specified index. sl@0: @see AddFaceL() sl@0: @see FaceCount() */ sl@0: inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const sl@0: { sl@0: return iFaceAttrib[aFaceIndex]; sl@0: } sl@0: sl@0: /** Gets the number of typefaces in the typeface attributes array. sl@0: sl@0: This is the number of typefaces in the font file: the attributes for each sl@0: typeface should be loaded into the array when the derived object is constructed. sl@0: sl@0: @return The number of typefaces in the font file. sl@0: @see AddFaceL() sl@0: @see FaceAttrib() */ sl@0: inline TInt COpenFontFile::FaceCount() const sl@0: { sl@0: return iFaceAttrib.Count(); sl@0: } sl@0: sl@0: /** Increments a reference count by one. sl@0: sl@0: @see DecRefCount() */ sl@0: inline void COpenFontFile::IncRefCount() sl@0: { sl@0: iRefCount++; sl@0: } sl@0: sl@0: /** Decrement a reference count by one. sl@0: sl@0: @return ETrue if the reference count has reached zero (i.e. is less than or sl@0: equal to zero); EFalse if the reference count has not yet reached zero (i.e. sl@0: is positive). sl@0: @see IncRefCount() */ sl@0: inline TBool COpenFontFile::DecRefCount() sl@0: { sl@0: iRefCount--; sl@0: return iRefCount <= 0; sl@0: } sl@0: sl@0: /** Default C++ constructor. */ sl@0: inline COpenFontRasterizerContext::COpenFontRasterizerContext(): sl@0: iGlyphData(NULL) sl@0: { sl@0: } sl@0: sl@0: /** Start writing the glyph data. sl@0: sl@0: Use this function to initialise the buffer to which the glyph bitmap is to sl@0: be written. Call WriteGlyphBit() to add bits to the buffer. sl@0: sl@0: @param aGlyphData A pointer to the glyph data. */ sl@0: inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData) sl@0: { sl@0: aGlyphData->SetPointersToInternalBuffers(); sl@0: iGlyphData = aGlyphData; sl@0: iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart(); sl@0: // Allow 4 extra bytes; BITGDI requires this. sl@0: iGlyphDataEnd = aGlyphData->BufferEnd() - 4; sl@0: iGlyphBit = 1; sl@0: *iGlyphDataPtr = 0; sl@0: iBytesNeeded = 1; sl@0: iOverflow = FALSE; sl@0: } sl@0: sl@0: /** Writes a bit to the glyph buffer. sl@0: sl@0: Before calling this function you should first call StartGlyph(). sl@0: sl@0: @param aBit The bit to be added to the buffer. */ sl@0: inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit) sl@0: { sl@0: if (aBit && !iOverflow) sl@0: *iGlyphDataPtr |= iGlyphBit; sl@0: iGlyphBit <<= 1; sl@0: if (iGlyphBit == 256) sl@0: { sl@0: iGlyphBit = 1; sl@0: iBytesNeeded++; sl@0: if (++iGlyphDataPtr < iGlyphDataEnd) sl@0: *iGlyphDataPtr = 0; sl@0: else sl@0: iOverflow = TRUE; sl@0: } sl@0: } sl@0: sl@0: /** Writes a byte to the glyph buffer. sl@0: sl@0: Before calling this function you should first call StartGlyph(). sl@0: sl@0: @param aByte The byte to be added to the buffer. */ sl@0: inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte) sl@0: { sl@0: if (iGlyphDataPtr < iGlyphDataEnd) sl@0: *iGlyphDataPtr++ = (TUint8)aByte; sl@0: else sl@0: iOverflow = TRUE; sl@0: iBytesNeeded++; sl@0: } sl@0: sl@0: /** Completes writing glyph data. sl@0: sl@0: Use this function to complete writing the glyph bitmap to the buffer. Call sl@0: it after adding all necessary bits using WriteGlyphBit(). */ sl@0: inline void COpenFontRasterizerContext::EndGlyph() sl@0: { sl@0: // Add 4 bytes to the data size; some BITGDI functions require this. sl@0: iGlyphData->SetBytesNeeded(iBytesNeeded + 4); sl@0: iGlyphData = NULL; sl@0: } sl@0: sl@0: /** Tests whether the bitmap buffer is large enough to hold the bitmap. sl@0: sl@0: @return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */ sl@0: inline TBool TOpenFontGlyphData::Overflow() const sl@0: { sl@0: return iBytesNeeded > iBitmapBufferSize; sl@0: } sl@0: sl@0: /** Gets the number of bytes needed to store the glyph bitmap. sl@0: sl@0: @return The number of bytes needed to store the glyph bitmap. sl@0: @see SetBytesNeeded() */ sl@0: inline TInt TOpenFontGlyphData::BytesNeeded() const sl@0: { sl@0: return iBytesNeeded; sl@0: } sl@0: sl@0: /** Gets a constant pointer descriptor containing the bitmap this object sl@0: represents. sl@0: sl@0: @return Pointer descriptor for the glyph. */ sl@0: inline TPtrC8 TOpenFontGlyphData::Bitmap() const sl@0: { sl@0: return TPtrC8(iBitmap,iBytesNeeded); sl@0: } sl@0: sl@0: /** Gets a pointer to the bitmap. sl@0: sl@0: This points either to the buffer used to write the bitmap when it is first sl@0: rasterized, or to the cache if the character was already rasterized. sl@0: sl@0: @return A pointer to the bitmap. */ sl@0: inline const TUint8* TOpenFontGlyphData::BitmapPointer() const sl@0: { sl@0: return iBitmap; sl@0: } sl@0: sl@0: /** Gets the character's metrics. sl@0: sl@0: @return The character's open font metrics. */ sl@0: inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const sl@0: { sl@0: return iMetrics; sl@0: } sl@0: sl@0: /** Gets a pointer to the start of the bitmap buffer. sl@0: sl@0: @return A pointer to the start of the bitmap buffer. */ sl@0: inline TUint8* TOpenFontGlyphData::BufferStart() sl@0: { sl@0: return iBitmapBuffer; sl@0: } sl@0: sl@0: /** Gets a pointer to the end of the bitmap buffer. sl@0: sl@0: @return A pointer to the end of the bitmap buffer. */ sl@0: inline TUint8* TOpenFontGlyphData::BufferEnd() sl@0: { sl@0: return iBitmapBuffer + iBitmapBufferSize; sl@0: } sl@0: sl@0: /** Sets the number of bytes needed to store the glyph bitmap. sl@0: sl@0: @param aBytes The number of bytes needed to store the glyph bitmap. sl@0: @see BytesNeeded() */ sl@0: inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes) sl@0: { sl@0: iBytesNeeded = aBytes; sl@0: } sl@0: sl@0: /** Sets the pointer to the bitmap buffer. sl@0: sl@0: @param aBitmap The pointer to the bitmap buffer. */ sl@0: inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap) sl@0: { sl@0: iBitmap = aBitmap; sl@0: } sl@0: sl@0: /** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object. sl@0: sl@0: @param aMetrics A pointer to the character's open font character metrics. */ sl@0: inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics) sl@0: { sl@0: iMetrics = aMetrics; sl@0: } sl@0: sl@0: /** Sets the bitmap and metrics pointers to point to the internal buffers. sl@0: sl@0: The alternative is that the pointers point to the cache of metrics and bitmaps sl@0: that have already been rasterized. */ sl@0: inline void TOpenFontGlyphData::SetPointersToInternalBuffers() sl@0: { sl@0: iBitmap = iBitmapBuffer; sl@0: iMetrics = &iMetricsBuffer; sl@0: } sl@0: sl@0: /** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics sl@0: object. sl@0: sl@0: @param aMetrics The character's open font character metrics. */ sl@0: inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics) sl@0: { sl@0: iMetricsBuffer = aMetrics; sl@0: iMetrics = &iMetricsBuffer; sl@0: } sl@0: sl@0: /** Sets the glyph index. sl@0: sl@0: @param aGlyphIndex The glyph index. */ sl@0: inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex) sl@0: { sl@0: iGlyphIndex = aGlyphIndex; sl@0: } sl@0: sl@0: /** Uses ECOM plug-in framework to instantiate the shaper factory interface sl@0: implementation given its implementation UID. sl@0: sl@0: @param aInterfaceImplUid The UID of the interface implementation required sl@0: sl@0: @return CShaperFactory* A pointer to a CShaperFactory object. */ sl@0: inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid) sl@0: { sl@0: return reinterpret_cast ( sl@0: REComSession::CreateImplementationL( sl@0: aInterfaceImplUid, sl@0: _FOFF(CShaperFactory, iDtor_ID_Key))); sl@0: } sl@0: sl@0: /** Default destructor */ sl@0: inline CShaperFactory::~CShaperFactory() sl@0: { sl@0: REComSession::DestroyedImplementation(iDtor_ID_Key); sl@0: } sl@0: sl@0: #endif // __OPENFONT_H__