COpenFontFile Class Reference

#include <openfont.h>

Link against: fntstr.lib

class COpenFontFile : public CBase

Inherits from

  • COpenFontFile
    Public Member Functions
    COpenFontFile(TInt, const TDesC &)
    ~COpenFontFile()
    IMPORT_C voidAddFaceL(const TOpenFontFaceAttrib &)
    TBool DecRefCount()
    virtual 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 &)
    pure virtual voidGetNearestFontInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
    TInt GetNearestFontToDesignHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
    virtual voidGetNearestFontToDesignHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &)
    TInt GetNearestFontToMaxHeightInPixels(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)
    virtual voidGetNearestFontToMaxHeightInPixelsL(RHeap *, COpenFontSessionCacheList *, const TOpenFontSpec &, TInt, TInt, COpenFont *&, TOpenFontSpec &, TInt)
    CArrayPtrFlat< COpenFont > *GetOpenFontList()
    pure virtual TBool HasUnicodeCharacterL(TInt, TInt)
    voidIncRefCount()
    voidRemoveFontFromList(const COpenFont *)
    voidSetFontStoreL(CFontStore *)
    TUid Uid()
    Protected Member Functions
    IMPORT_C TBoolGetNearestFontHelperOld(const TOpenFontSpec &, TInt, TInt, TInt &, TOpenFontSpec &)
    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()

    Detailed Description

    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.

    See also: COpenFontRasterizer::NewFontFileL() CWsScreenDevice::AddFile()

    Constructor & Destructor Documentation

    COpenFontFile ( TInt, const TDesC & )

    IMPORT_CCOpenFontFile(TIntaUid,
    const TDesC &aFileName
    )

    C++ constructor with UID and filename.

    Call this constructor in the constructor for your derived object, passing it aUid and aFileName arguments.

    Non Symbian-platform-native font files are allocated IDs by the font store. These are passed in by the rasteriser class. UIDs are required by the font framework. However you should not use the ID to access the file, since a new UID will need to be allocated when the file is next loaded, e.g. after a device reboot. Instead use the font file name.

    ParameterDescription
    aUidThe UID of the font file.
    aFileNameThe full filename, including the path, of the font file.

    ~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 Function Documentation

    AddFaceL ( const TOpenFontFaceAttrib & )

    IMPORT_C voidAddFaceL(const TOpenFontFaceAttrib &aAttrib)

    Adds a typeface to this object's typeface array.

    This function should be called during construction to add the attributes for each typeface in the font file to the typeface attribute array.

    Note:

    The typeface array is what is searched for the closest match to a specified font by GetNearestFontHelper().

    See also: FaceAttrib() FaceCount()

    ParameterDescription
    aAttribThe attributes for a typeface to be added to the typeface attribute array.

    DecRefCount ( )

    TBool DecRefCount()[inline]

    Decrement a reference count by one.

    See also: IncRefCount()

    Returns: 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).

    ExtendedInterface ( TUid, TAny *& )

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

    FaceAttrib ( TInt )

    const TOpenFontFaceAttrib &FaceAttrib(TIntaFaceIndex)const [inline]

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

    See also: AddFaceL() FaceCount()

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

    Returns: The attributes of the typeface with the specified index.

    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.

    See also: AddFaceL() FaceAttrib()

    Returns: The number of typefaces in the font file.

    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.

    Returns: 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

    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.

    ParameterDescription
    aDesiredFontSpecThe desired font specification.
    aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
    aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
    aFaceIndexThe index of the typeface which contains the closest match to aDesiredFontSpec.
    aActualFontSpecThe actual font specification of the font with attributes closest to aDesiredFontSpec.

    Returns: ETrue if there is a possible font match, otherwise EFalse.

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

    IMPORT_C TBoolGetNearestFontHelperOld(const TOpenFontSpec &aDesiredFontSpec,
    TIntaPixelWidth,
    TIntaPixelHeight,
    TInt &aFaceIndex,
    TOpenFontSpec &aActualFontSpec
    )const [protected]

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

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

    See also: GetNearestFontHelper()

    Deprecated

    Use GetNearestFontToDesignHeightInPixels

    ParameterDescription
    aHeapShared heap. This value should be passed to the COpenFont derived classes' constructor.
    aSessionCacheListThe session cache list. This value should be passed to the COpenFont derived classes' constructor.
    aDesiredFontSpecThe desired font specification.
    aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
    aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
    aFontOn return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
    aActualFontSpecThe actual font specification of the font retrieved into aFont.

    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.

    See also: GetNearestFontHelper()

    ParameterDescription
    aHeapShared heap. This value should be passed to the COpenFont derived classes' constructor.
    aSessionCacheListThe session cache list. This value should be passed to the COpenFont derived classes' constructor.
    aDesiredFontSpecThe desired font specification.
    aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
    aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
    aFontOn return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
    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
    )

    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.

    See also: GetNearestFontHelper()

    ParameterDescription
    aHeapShared heap. This value should be passed to the COpenFont derived classes' constructor.
    aSessionCacheListThe session cache list. This value should be passed to the COpenFont derived classes' constructor.
    aDesiredFontSpecThe desired font specification.
    aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
    aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
    aFontOn return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
    aActualFontSpecThe actual font specification of the font retrieved into aFont.

    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.

    See also: GetNearestFontHelper()

    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
    )

    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.

    See also: GetNearestFontHelper()

    ParameterDescription
    aHeapShared heap. This value should be passed to the COpenFont derived classes' constructor.
    aSessionCacheListThe session cache list. This value should be passed to the COpenFont derived classes' constructor.
    aDesiredFontSpecThe desired font specification.
    aPixelWidthThe width of a pixel. Used with aPixelHeight for calculating the algorithmic slant of the typeface.
    aPixelHeightThe height of a pixel. Used with aPixelWidth for calculating the algorithmic slant of the typeface.
    aFontOn return, contains a pointer to the newly created COpenFont derived object, or NULL if no font matching aDesiredFontSpec exists.
    aActualFontSpecThe actual font specification of the font retrieved into aFont.
    aMaxHeightThe maximum height within which the font must fit.

    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.

    See also: GetNearestFontHelper()

    GetOpenFontList ( )

    CArrayPtrFlat< COpenFont > *GetOpenFontList()

    HasUnicodeCharacterL ( TInt, TInt )

    TBool HasUnicodeCharacterL(TIntaFaceIndex,
    TIntaCode
    )const [pure virtual]

    Tests whether a specified typeface contains a particular character.

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

    Returns: ETrue if the typeface contains aCode, otherwise EFalse.

    IncRefCount ( )

    voidIncRefCount()[inline]

    Increments a reference count by one.

    See also: DecRefCount()

    RemoveFontFromList ( const COpenFont * )

    voidRemoveFontFromList(const COpenFont *aFont)

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

    SetFontStoreL ( CFontStore * )

    voidSetFontStoreL(CFontStore *aFontStore)

    Uid ( )

    TUid Uid()const [inline]

    Gets the font file's UID.

    Returns: The uid of the file.