The steps required to write a font rasterizer DLL are:
Implement an exported NewL() factory function to create rasterizer objects (which you derive from COpenFontRasterizer). You may choose to implement this as part of your rasterizer object.
Write a class derived from COpenFontRasterizer. This will need to store any context associated with the rasterization process rather than with individual typefaces. It also implements a function to create your COpenFontFile derived objects.
Write a class derived from COpenFontFile. This class manages a single file representing a typeface.
Write a class derived from COpenFont.
Place all the code into a DLL of the right type and provide an exported function to create the rasterizer object.
Deriving from COpenFontRasterizer, COpenFontFile and COpenFont are discussed in the "See also" topics below. This section describes the operations required to package the code as a polymorphic DLL.
For more information, see:
A font rasterizer DLL is an ordinary Symbian polymorphic DLL. It exports just one function and has no unusual behavior.
In particular, it must have no writable static data. This is an important constraint on the use of code from outside sources. See Static Data for more information.
The exported function is a factory function that creates objects of a class derived from COpenFontRasterizer. It will be called just once — when the Font and Bitmap Server loads the DLL.
Although the name of the function does not matter because it is loaded by ordinal, implementers should follow the practice of making it a static member of the rasterizer class, called NewL(). Therefore, if the rasterizer class is CExampleRasterizer (derived from COpenFontRasterizer), the exported function is:
static COpenFontRasterizer* CExampleRasterizer::NewL()
The function must take no arguments. It must create a COpenFontRasterizer derived object on the heap, returning it to the caller. The caller is responsible for deleting the object. As the name of the example function suggests, it is allowed to leave.
Example
The exported function used in the FreeType rasterizer is given below:
EXPORT_C COpenFontRasterizer* CFreeTypeRasterizer::NewL() { CFreeTypeRasterizer* r = new(ELeave) CFreeTypeRasterizer; CleanupStack::PushL( r ); r->iContext = CFreeTypeContext::NewL(); CleanupStack::Pop(); return r; }
The name of the rasterizer DLL, its type, and its UIDs are all specified in the MMP file. Note that:
All capabilities except TCB (Trusted Computing Base) are required.
The targettype must be PLUGIN .
The UID line identifies the project's UID2 and UID3 values. UID2 must be 0x10009D8D, which identifies the DLL as an ECOM plug-in. UID3 must be 0x100012A7, which identifies the ECOM plug-in as a font rasterizer.
Example
A fragment of the project file for the freetype DLL is given below.
target freetype.dll CAPABILITY All -Tcb targettype PLUGIN UID 0x10003B1F 0x100012A7
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.