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