Location:
OPENFONT.H
Link against: fntstr.lib
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.
CBase
- Base class for all classes to be instantiated on the heap
COpenFontFile
- Font file abstract base class
Defined in COpenFontFile
:
AddFaceL()
, COpenFontFile()
, DecRefCount()
, FaceAttrib()
, FaceCount()
, FileName()
, GetNearestFontHelper()
, HasUnicodeCharacterL()
, IncRefCount()
, Uid()
, ~COpenFontFile()
Inherited from CBase
:
Delete()
,
Extension_()
,
operator new()
IMPORT_C 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.
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.
|
IMPORT_C ~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 TBool HasUnicodeCharacterL(TInt aFaceIndex, TInt aCode) const=0;
Tests whether a specified typeface contains a particular character.
|
|
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.
|
|
IMPORT_C void AddFaceL(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()
.
|
inline TUid Uid() const;
Gets the font file's UID.
|
inline 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.
|
inline const TOpenFontFaceAttrib &FaceAttrib(TInt aFaceIndex) const;
Gets the typeface at a specified index in the typeface attribute array.
|
|
inline 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.
|
inline TBool DecRefCount();
Decrement a reference count by one.
|