Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to write a rasterizer DLL


Overview

The steps required to write a rasterizer DLL are:

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.

Note that only one Open Font System rasterizer has so far been released: FreeType. It uses freeware code from the FreeType project (see http://www.freetype.org) to provide a TrueType rasterizer. Fragments of code given in this document are taken from this implementation.


See also

How to derive from COpenFontRasterizer

How to derive from COpenFontFile

How to derive from COpenFont

How to derive from COpenFontRasterizerContext

[Top]


The DLL

A rasterizer DLL is an ordinary Symbian polymorphic DLL. It exports just one function and has no unusual behaviour.

In particular, it must have no writable static data. This is an important constraint on the use of code from outside sources.


See also

Static data

[Top]


The exported function

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(). Thus, 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;
    }

[Top]


Project file

The name of the rasterizer DLL, its type, and its UIDs are all specified in the makmake project file. Note that:


Example

A fragment of the project file for the freetype DLL is given below.

target freetype.dll
targetpath \system\fonts
targettype dll
UID 0x10003B1F 0x100012A7

[Top]


Header files

Rasterizer DLLs must #include the following header files, which are located in the standard include directory \epoc32\include\: