Location: openfont.h
Link against: fntstr.lib
COpenFontFile
Supported from 5.0
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 AddArrayL()
, 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.
|
Defined in COpenFontFile
:
AddFaceL()
, COpenFontFile()
, DecRefCount()
, FaceAttrib()
, FaceCount()
, FileName()
, GetNearestFontHelper()
, GetNearestFontInPixelsL()
, HasUnicodeCharacterL()
, IncRefCount()
, Uid()
, ~COpenFontFile()
Inherited from CBase
:
operator new()
COpenFontFile(TInt aUid,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.
Note:
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.
|
~COpenFontFile();
Destructor.
The destructor notifies fonts using this file that it has been deleted, allowing a controlled exit if a file is deleted before its fonts.
virtual void GetNearestFontInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList, const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight, COpenFont*& aFont,TOpenFontSpec& aActualFontSpec)=0;
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.
Note:
Implementations may use the utilitity function GetNearestFontHelper()
to get the attributes of the closest matching font.
|
virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const=0;
Tests whether a specified typeface contains a particular character.
|
|
void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
Supported from 5.1
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()
.
|
TBool DecRefCount();
Decrement a reference count by one.
The function will reduce the reference count below zero, but will return EFalse
for values below zero.
|
const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
Gets the typeface at a specified index in the typeface attribute array.
|
|
TInt FaceCount() const;
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.
|
const TDesC& FileName() const;
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.
|
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
.
|
|
TUid Uid() const;
Gets the font file's UID.
|