COpenFontFile Class Reference

class COpenFontFile : public CBase

Font file abstract base class.

Write a class derived from COpenFontFile to manage a file with the font format supported by your DLL. The derived class must implement the virtual GetNearestFontInPixelsL() function. This function takes a font description and creates a COpenFont derived object if the description matches a typeface contained in the font file.

Derived classes must also load typeface attributes from the file into the protected typeface attribute array during construction. This array is what is searched when getting font attribute information see AddFaceL() , GetNearestFontHelper() .

Writing derived classes construction:

Call the COpenFontFile constructor in the constructor for your derived object, passing it aUid and aFileName arguments. These values are the arguments passed when the constructor is called by COpenFontRasterizer::NewFontFileL() .

A file may contain one or more typefaces. During construction the derived object should extract the information for each typeface and add it to this object's protected typeface attribute array see AddFaceL() . This process will probably leave under some conditions. It should therefore be implemented in a second phase constructor.

Writing derived classes implement the pure virtual functions:

Derived classes must also implement the two pure virtual functions GetNearestFontInPixelsL() and HasUnicodeCharacterL() . Information about these functions is provided in the definitions below. Information about deriving from this class is also provided in the API guide.

COpenFontRasterizer::NewFontFileL() CWsScreenDevice::AddFile()

Inherits from

Nested Classes and Structures

Public Member Functions
~COpenFontFile ()
TBool DecRefCount ()
IMPORT_C void ExtendedInterface ( TUid , TAny *&)
TInt FaceCount ()
const TDesC & FileName ()
IMPORT_C TBool GetNearestFontHelper (const TOpenFontSpec &, TInt , TInt , TInt &, TOpenFontSpec &)
TInt GetNearestFontInPixels ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &)
void GetNearestFontInPixelsL ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &)
TInt GetNearestFontToDesignHeightInPixels ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &)
void GetNearestFontToDesignHeightInPixelsL ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &)
TInt GetNearestFontToMaxHeightInPixels ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &, TInt )
void GetNearestFontToMaxHeightInPixelsL ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &, TInt )
CArrayPtrFlat < COpenFont > * GetOpenFontList ()
TBool HasUnicodeCharacterL ( TInt , TInt )
void IncRefCount ()
void RemoveFontFromList (const COpenFont *)
void SetFontStoreL ( CFontStore *)
TUid Uid ()
Protected Member Functions
IMPORT_C TBool GetNearestFontHelperOld (const TOpenFontSpec &, TInt , TInt , TInt &, TOpenFontSpec &)
Private Member Functions
void GetNearestFontToDesignHeightInPixelsAndAddToListL ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &)
void GetNearestFontToMaxHeightInPixelsAndAddToListL ( RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt , TInt , COpenFont *&, TOpenFontSpec &, TInt )
TInt ScoreByName (const TOpenFontSpec &, const TAttrib &)
TInt ScoreByStyle (const TOpenFontSpec &, const TAttrib &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
TOpenFontFileData * iData
CArrayFixFlat < TAttrib > iFaceAttrib
TBuf < KMaxFileName > iFileName
CArrayPtrFlat < COpenFont > iFontList
TInt iRefCount
TUid iUid

Constructor & Destructor Documentation

~COpenFontFile()

IMPORT_C ~COpenFontFile ( )

Destructor.

It is not allowed that file is deleted before its fonts and the logic is handled in CFontStore::RemoveFile() .

Member Functions Documentation

DecRefCount()

TBool DecRefCount ( ) [inline]

ExtendedInterface(TUid, TAny *&)

IMPORT_C void ExtendedInterface ( TUid aUid,
TAny *& aParam
) [virtual]

Parameters

TUid aUid
TAny *& aParam

FaceCount()

TInt FaceCount ( ) const [inline]

Gets the number of typefaces in the typeface attributes array.

This is the number of typefaces in the font file: the attributes for each typeface should be loaded into the array when the derived object is constructed.

AddFaceL() FaceAttrib()

FileName()

const TDesC & FileName ( ) const [inline]

GetNearestFontHelper(const TOpenFontSpec &, TInt, TInt, TInt &, TOpenFontSpec &)

IMPORT_C TBool GetNearestFontHelper ( const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
TInt & aFaceIndex,
TOpenFontSpec & aActualFontSpec
) const

Gets the nearest font helper function.

This function may be used by derived classes in their GetNearestFontInPixelsL() implementations. It finds the nearest font in the typeface attribute array, if any, to the provided font specification. If there is a possible match it places the face index in aFaceIndex and the actual specification (including algorithmic effects) in aActualFontSpec.

Parameters

const TOpenFontSpec & aDesiredFontSpec The desired font specification.
TInt aPixelWidth The width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeight The height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
TInt & aFaceIndex The index of the typeface which contains the closest match to aDesiredFontSpec.
TOpenFontSpec & aActualFontSpec The actual font specification of the font with attributes closest to aDesiredFontSpec.

GetNearestFontHelperOld(const TOpenFontSpec &, TInt, TInt, TInt &, TOpenFontSpec &)

IMPORT_C TBool GetNearestFontHelperOld ( const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
TInt & aFaceIndex,
TOpenFontSpec & aActualFontSpec
) const [protected]

Parameters

const TOpenFontSpec & aDesiredFontSpec
TInt aPixelWidth
TInt aPixelHeight
TInt & aFaceIndex
TOpenFontSpec & aActualFontSpec

GetNearestFontInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)

TInt GetNearestFontInPixels ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec
)

Gets the nearest font in pixels.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aFontSpec, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utilitity function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper() Use GetNearestFontToDesignHeightInPixels

Parameters

RHeap * aHeap Shared heap. This value should be passed to the COpenFont derived classes' constructor.
COpenFontSessionCacheList * aSessionCacheList The session cache list. This value should be passed to the COpenFont derived classes' constructor.
const TOpenFontSpec & aDesiredFontSpec The desired font specification.
TInt aPixelWidth The width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeight The height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
COpenFont *& aFont On return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
TOpenFontSpec & aActualFontSpec The actual font specification of the font retrieved into aFont.

GetNearestFontInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)

void GetNearestFontInPixelsL ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec
) [pure virtual]

Gets the font which is the nearest to the given font specification.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aDesiredFontSpec, while fitting within aMaxHeight, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utility function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper()

Parameters

RHeap * aHeap Shared heap. This value should be passed to the COpenFont derived classes' constructor.
COpenFontSessionCacheList * aSessionCacheList The session cache list. This value should be passed to the COpenFont derived classes' constructor.
const TOpenFontSpec & aDesiredFontSpec The desired font specification.
TInt aPixelWidth The width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeight The height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
COpenFont *& aFont On return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
TOpenFontSpec & aActualFontSpec The actual font specification of the font retrieved into aFont.

GetNearestFontToDesignHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)

TInt GetNearestFontToDesignHeightInPixels ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec
)

Gets the nearest font in pixels.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aFontSpec, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utilitity function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper()

Parameters

RHeap * aHeap Shared heap. This value should be passed to the COpenFont derived classes' constructor.
COpenFontSessionCacheList * aSessionCacheList The session cache list. This value should be passed to the COpenFont derived classes' constructor.
const TOpenFontSpec & aDesiredFontSpec The desired font specification.
TInt aPixelWidth The width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeight The height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
COpenFont *& aFont On return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
TOpenFontSpec & aActualFontSpec The actual font specification of the font retrieved into aFont.

GetNearestFontToDesignHeightInPixelsAndAddToListL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)

void GetNearestFontToDesignHeightInPixelsAndAddToListL ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec
) [private]

Parameters

RHeap * aHeap
COpenFontSessionCacheList * aSessionCacheList
const TOpenFontSpec & aDesiredFontSpec
TInt aPixelWidth
TInt aPixelHeight
COpenFont *& aFont
TOpenFontSpec & aActualFontSpec

GetNearestFontToDesignHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)

void GetNearestFontToDesignHeightInPixelsL ( RHeap * ,
COpenFontSessionCacheList * ,
const TOpenFontSpec & ,
TInt ,
TInt ,
COpenFont *& ,
TOpenFontSpec &
) [inline, virtual]

Gets the font which is the nearest to the given font specification.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aDesiredFontSpec, while fitting within aMaxHeight, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utility function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper()

Parameters

RHeap *
COpenFontSessionCacheList *
const TOpenFontSpec &
TInt
TInt
COpenFont *&
TOpenFontSpec &

GetNearestFontToMaxHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)

TInt GetNearestFontToMaxHeightInPixels ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec,
TInt aMaxHeight
)

Gets the nearest font in pixels that fits inside specified max height.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aFontSpec, while fitting within aMaxHeight, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utilitity function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper()

Parameters

RHeap * aHeap Shared heap. This value should be passed to the COpenFont derived classes' constructor.
COpenFontSessionCacheList * aSessionCacheList The session cache list. This value should be passed to the COpenFont derived classes' constructor.
const TOpenFontSpec & aDesiredFontSpec The desired font specification.
TInt aPixelWidth The width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeight The height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
COpenFont *& aFont On return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
TOpenFontSpec & aActualFontSpec The actual font specification of the font retrieved into aFont.
TInt aMaxHeight The maximum height within which the font must fit.

GetNearestFontToMaxHeightInPixelsAndAddToListL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)

void GetNearestFontToMaxHeightInPixelsAndAddToListL ( RHeap * aHeap,
COpenFontSessionCacheList * aSessionCacheList,
const TOpenFontSpec & aDesiredFontSpec,
TInt aPixelWidth,
TInt aPixelHeight,
COpenFont *& aFont,
TOpenFontSpec & aActualFontSpec,
TInt aMaxHeight
) [private]

Parameters

RHeap * aHeap
COpenFontSessionCacheList * aSessionCacheList
const TOpenFontSpec & aDesiredFontSpec
TInt aPixelWidth
TInt aPixelHeight
COpenFont *& aFont
TOpenFontSpec & aActualFontSpec
TInt aMaxHeight

GetNearestFontToMaxHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)

void GetNearestFontToMaxHeightInPixelsL ( RHeap * ,
COpenFontSessionCacheList * ,
const TOpenFontSpec & ,
TInt ,
TInt ,
COpenFont *& ,
TOpenFontSpec & ,
TInt
) [inline, virtual]

Gets the font which is the nearest to the given font specification.

Implementations of this pure virtual function should create the COpenFont derived object that most closely matches aDesiredFontSpec, while fitting within aMaxHeight, and place a pointer to it in aFont. If this cannot be done, e.g. if the font name doesn't match, aFont should be set to NULL.

The other two arguments, aHeap and aSessionCacheList, should be passed to the COpenFont constructor.

Implementations may use the utility function GetNearestFontHelper() to get the attributes of the closest matching font.

GetNearestFontHelper()

Parameters

RHeap *
COpenFontSessionCacheList *
const TOpenFontSpec &
TInt
TInt
COpenFont *&
TOpenFontSpec &
TInt

GetOpenFontList()

CArrayPtrFlat < COpenFont > * GetOpenFontList ( )

HasUnicodeCharacterL(TInt, TInt)

TBool HasUnicodeCharacterL ( TInt aFaceIndex,
TInt aCode
) const [pure virtual]

Tests whether a specified typeface contains a particular character.

Parameters

TInt aFaceIndex The index of the typeface to be tested.
TInt aCode The Unicode character code for the character to be tested.

IncRefCount()

void IncRefCount ( ) [inline]

Increments a reference count by one.

DecRefCount()

RemoveFontFromList(const COpenFont *)

void RemoveFontFromList ( const COpenFont * aFont )

This function is called (via iFile) by a COpenFont when it is destroyed.

Parameters

const COpenFont * aFont

ScoreByName(const TOpenFontSpec &, const TAttrib &)

TInt ScoreByName ( const TOpenFontSpec & aDesiredFontSpec,
const TAttrib & aAttrib
) [private, static]

Parameters

const TOpenFontSpec & aDesiredFontSpec
const TAttrib & aAttrib

ScoreByStyle(const TOpenFontSpec &, const TAttrib &)

TInt ScoreByStyle ( const TOpenFontSpec & aDesiredFontSpec,
const TAttrib & aAttrib
) [private, static]

Parameters

const TOpenFontSpec & aDesiredFontSpec
const TAttrib & aAttrib

SetFontStoreL(CFontStore *)

void SetFontStoreL ( CFontStore * aFontStore )

Parameters

CFontStore * aFontStore

Uid()

TUid Uid ( ) const [inline]

Gets the font file's UID.

Member Data Documentation

TOpenFontFileData * iData

TOpenFontFileData * iData [private]

CArrayFixFlat< TAttrib > iFaceAttrib

CArrayFixFlat < TAttrib > iFaceAttrib [private]

TBuf< KMaxFileName > iFileName

TBuf < KMaxFileName > iFileName [private]

CArrayPtrFlat< COpenFont > iFontList

CArrayPtrFlat < COpenFont > iFontList [private]

TInt iRefCount

TInt iRefCount [private]

TUid iUid

TUid iUid [private]