diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-1CF78E25-8C83-5812-AE6F-8612B3F9CDA9.dita --- a/Symbian3/PDK/Source/GUID-1CF78E25-8C83-5812-AE6F-8612B3F9CDA9.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-1CF78E25-8C83-5812-AE6F-8612B3F9CDA9.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,80 +1,80 @@ - - - - - -Deriving -from COpenFontRasterizer -
Overview

Classes derived from COpenFontRasterizer are -used to recognize font files and create objects to manage them. To derive -from COpenFontRasterizer you need only provide an implementation -of its pure virtual function NewFontFileL(). The implementation -of this function is discussed in the following section.

The derived -class should also define the DLL's single exported function. This function -is discussed further in the previous topic: The -exported function.

In addition, font rasterizer classes often -need to store an 'engine context'. For example, FreeType relies on a TT_Engine object; -this is kept in the CFreeTypeRasterizer, in a CFreeTypeRasterizerContext. -The context is derived from COpenFontRasterizerContext, a -utility base class that provides functions that make it easier to write the -glyph bitmap during rasterization.

-
Implementing NewFontFileL()

The implementation -must examine a specified file and, if it is of the correct type, attempt to -create a COpenFontFile derived object to open it. The function -must return NULL if it cannot recognize the file. It may also leave if there -is an error. The caller is responsible for deleting the COpenFontFile object.

The -function prototype is given below:

virtual COpenFontFile* NewFontFileL(TInt aUid, - const TDesC& aFileName, RFs& aFileSession) = 0;

aUid is -an ID to be used for the font file — the application framework requires that -each typeface have a UID, so one is dynamically allocated for font files that -are not Symbian-native. The ID must be passed to the COpenFontFile derived -class's constructor.

aFileName is the full path -and filename of the file that the font rasterizer is attempting to open. This -filename must also be passed to the COpenFontFile derived -class's constructor.

aFileSession is the file session -owned by the Font and Bitmap server. This reference should be used for any -file access. If COpenFontFile derived objects need to keep -files open, aFileSession should be stored in a place that -is accessible to them.

-

The FreeType implementation of NewFontFileL() is -given below. It recognizes the file only by its extension, relying on the -construction of the font file object to perform stricter checking.

COpenFontFile* CFreeTypeRasterizer::NewFontFileL(TInt aUid, - const TDesC& aFileName,RFs& aFileSession) - { - TBool is_ttf = EFalse; - - //Tests if the filename extension is ".ttf" or ".ttc". - if (aFileName.Length() > 4) - { - _LIT(KExtensionTTF,".ttf"); // Extension for truetype font file. - _LIT(KExtensionTTC,".ttc"); // Extension for truetype collection file. - TPtrC ext = aFileName.Right(4); - if ((ext.CompareF(KExtensionTTF) == 0) | (ext.CompareF(KExtensionTTC)==0)) - is_ttf = ETrue; - } - // If the extension is not .ttf or .ttc then we can't read the file. - if (!is_ttf) - return NULL; - - //If extension is .ttf then attempt to create the font file reader. - //return it to the caller. - return CFreeTypeFontFile::NewL(iContext,aUid, - aFileName,aFileSession); - } -
-
-Creating -a Font Rasterizer Plug-in -Deriving -from COpenFontFile -Deriving -from COpenFont -Deriving -from COpenFontRasterizerContext + + + + + +Deriving +from COpenFontRasterizer +
Overview

Classes derived from COpenFontRasterizer are +used to recognize font files and create objects to manage them. To derive +from COpenFontRasterizer you need only provide an implementation +of its pure virtual function NewFontFileL(). The implementation +of this function is discussed in the following section.

The derived +class should also define the DLL's single exported function. This function +is discussed further in the previous topic: The +exported function.

In addition, font rasterizer classes often +need to store an 'engine context'. For example, FreeType relies on a TT_Engine object; +this is kept in the CFreeTypeRasterizer, in a CFreeTypeRasterizerContext. +The context is derived from COpenFontRasterizerContext, a +utility base class that provides functions that make it easier to write the +glyph bitmap during rasterization.

+
Implementing NewFontFileL()

The implementation +must examine a specified file and, if it is of the correct type, attempt to +create a COpenFontFile derived object to open it. The function +must return NULL if it cannot recognize the file. It may also leave if there +is an error. The caller is responsible for deleting the COpenFontFile object.

The +function prototype is given below:

virtual COpenFontFile* NewFontFileL(TInt aUid, + const TDesC& aFileName, RFs& aFileSession) = 0;

aUid is +an ID to be used for the font file — the application framework requires that +each typeface have a UID, so one is dynamically allocated for font files that +are not Symbian-native. The ID must be passed to the COpenFontFile derived +class's constructor.

aFileName is the full path +and filename of the file that the font rasterizer is attempting to open. This +filename must also be passed to the COpenFontFile derived +class's constructor.

aFileSession is the file session +owned by the Font and Bitmap server. This reference should be used for any +file access. If COpenFontFile derived objects need to keep +files open, aFileSession should be stored in a place that +is accessible to them.

+

The FreeType implementation of NewFontFileL() is +given below. It recognizes the file only by its extension, relying on the +construction of the font file object to perform stricter checking.

COpenFontFile* CFreeTypeRasterizer::NewFontFileL(TInt aUid, + const TDesC& aFileName,RFs& aFileSession) + { + TBool is_ttf = EFalse; + + //Tests if the filename extension is ".ttf" or ".ttc". + if (aFileName.Length() > 4) + { + _LIT(KExtensionTTF,".ttf"); // Extension for truetype font file. + _LIT(KExtensionTTC,".ttc"); // Extension for truetype collection file. + TPtrC ext = aFileName.Right(4); + if ((ext.CompareF(KExtensionTTF) == 0) | (ext.CompareF(KExtensionTTC)==0)) + is_ttf = ETrue; + } + // If the extension is not .ttf or .ttc then we can't read the file. + if (!is_ttf) + return NULL; + + //If extension is .ttf then attempt to create the font file reader. + //return it to the caller. + return CFreeTypeFontFile::NewL(iContext,aUid, + aFileName,aFileSession); + } +
+
+Creating +a Font Rasterizer Plug-in +Deriving +from COpenFontFile +Deriving +from COpenFont +Deriving +from COpenFontRasterizerContext
\ No newline at end of file