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(TInt, const TDesC &)
~COpenFontFile()
IMPORT_C voidAddFaceL(const TOpenFontFaceAttrib &)
TBool DecRefCount()
IMPORT_C voidExtendedInterface(TUid, TAny *&)
const TOpenFontFaceAttrib &FaceAttrib(TInt)
TInt FaceCount()
const TDesC &FileName()
CFontStore *GetFontStore()
IMPORT_C TBoolGetNearestFontHelper(const TOpenFontSpec &, TInt, TInt, TInt &, TOpenFontSpec &)
TInt GetNearestFontInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
voidGetNearestFontInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
TInt GetNearestFontToDesignHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
voidGetNearestFontToDesignHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
TInt GetNearestFontToMaxHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)
voidGetNearestFontToMaxHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)
CArrayPtrFlat< COpenFont > *GetOpenFontList()
TBool HasUnicodeCharacterL(TInt, TInt)
voidIncRefCount()
voidRemoveFontFromList(const COpenFont *)
voidSetFontStoreL(CFontStore *)
TUid Uid()
Protected Member Functions
IMPORT_C TBoolGetNearestFontHelperOld(const TOpenFontSpec &, TInt, TInt, TInt &, TOpenFontSpec &)
Private Member Functions
voidGetNearestFontToDesignHeightInPixelsAndAddToListL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
voidGetNearestFontToMaxHeightInPixelsAndAddToListL(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(TInt, const TDesC &)

IMPORT_CCOpenFontFile(TIntaUid,
const TDesC &aFileName
)

Parameters

TInt aUid
const TDesC & aFileName

~COpenFontFile()

IMPORT_C~COpenFontFile()

Member Functions Documentation

AddFaceL(const TOpenFontFaceAttrib &)

IMPORT_C voidAddFaceL(const TOpenFontFaceAttrib &aAttrib)

Parameters

const TOpenFontFaceAttrib & aAttrib

DecRefCount()

TBool DecRefCount()[inline]

Decrement a reference count by one.

ETrue if the reference count has reached zero (i.e. is less than or equal to zero); EFalse if the reference count has not yet reached zero (i.e. is positive).

IncRefCount()

ExtendedInterface(TUid, TAny *&)

IMPORT_C voidExtendedInterface(TUidaUid,
TAny *&aParam
)[virtual]

Parameters

TUid aUid
TAny *& aParam

FaceAttrib(TInt)

const TOpenFontFaceAttrib &FaceAttrib(TIntaFaceIndex)const [inline]

Gets the typeface at a specified index in the typeface attribute array.

The attributes of the typeface with the specified index.

AddFaceL()

FaceCount()

Parameters

TInt aFaceIndexThe index of the typeface for which the attributes are required.

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.

The number of typefaces in the font file.

AddFaceL()

FaceAttrib()

FileName()

const TDesC &FileName()const [inline]

Gets the full path and filename of the font file

This is the filename that was passed to the constructor when the object is created.

The filename of the font file.

GetFontStore()

CFontStore *GetFontStore()

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

IMPORT_C TBoolGetNearestFontHelper(const TOpenFontSpec &aDesiredFontSpec,
TIntaPixelWidth,
TIntaPixelHeight,
TInt &aFaceIndex,
TOpenFontSpec &aActualFontSpec
)const

Parameters

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

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

IMPORT_C TBoolGetNearestFontHelperOld(const TOpenFontSpec &aDesiredFontSpec,
TIntaPixelWidth,
TIntaPixelHeight,
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,
TIntaPixelWidth,
TIntaPixelHeight,
COpenFont *&aFont,
TOpenFontSpec &aActualFontSpec
)

Parameters

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

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

voidGetNearestFontInPixelsL(RHeap *aHeap,
COpenFontSessionCacheList *aSessionCacheList,
const TOpenFontSpec &aDesiredFontSpec,
TIntaPixelWidth,
TIntaPixelHeight,
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 * aHeapShared heap. This value should be passed to the COpenFont derived classes' constructor.
COpenFontSessionCacheList * aSessionCacheListThe session cache list. This value should be passed to the COpenFont derived classes' constructor.
const TOpenFontSpec & aDesiredFontSpecThe desired font specification.
TInt aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
TInt aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
COpenFont *& aFontOn return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
TOpenFontSpec & aActualFontSpecThe 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,
TIntaPixelWidth,
TIntaPixelHeight,
COpenFont *&aFont,
TOpenFontSpec &aActualFontSpec
)

Parameters

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

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

voidGetNearestFontToDesignHeightInPixelsAndAddToListL(RHeap *aHeap,
COpenFontSessionCacheList *aSessionCacheList,
const TOpenFontSpec &aDesiredFontSpec,
TIntaPixelWidth,
TIntaPixelHeight,
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 &)

voidGetNearestFontToDesignHeightInPixelsL(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,
TIntaPixelWidth,
TIntaPixelHeight,
COpenFont *&aFont,
TOpenFontSpec &aActualFontSpec,
TIntaMaxHeight
)

Parameters

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

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

voidGetNearestFontToMaxHeightInPixelsAndAddToListL(RHeap *aHeap,
COpenFontSessionCacheList *aSessionCacheList,
const TOpenFontSpec &aDesiredFontSpec,
TIntaPixelWidth,
TIntaPixelHeight,
COpenFont *&aFont,
TOpenFontSpec &aActualFontSpec,
TIntaMaxHeight
)[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)

voidGetNearestFontToMaxHeightInPixelsL(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(TIntaFaceIndex,
TIntaCode
)const [pure virtual]

Tests whether a specified typeface contains a particular character.

ETrue if the typeface contains aCode, otherwise EFalse.

Parameters

TInt aFaceIndexThe index of the typeface to be tested.
TInt aCodeThe Unicode character code for the character to be tested.

IncRefCount()

voidIncRefCount()[inline]

Increments a reference count by one.

DecRefCount()

RemoveFontFromList(const COpenFont *)

voidRemoveFontFromList(const COpenFont *aFont)

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 *)

voidSetFontStoreL(CFontStore *aFontStore)

Parameters

CFontStore * aFontStore

Uid()

TUid Uid()const [inline]

Gets the font file's UID.

The uid of the file.

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]