Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: OPENFONT.H
Link against: fntstr.lib

Class COpenFont

class COpenFont : public CBase;

Description

Open Font System font abstract base class.

Derive a class from this class to represent an instance of a typeface at a particular size, provide bitmaps of the glyphs, and determine whether characters exist in the typeface.

Writing derived classes construction:

You must call the constructor of this class when creating your derived object, passing the arguments aHeap and aSessionCacheList supplied to COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile object that creates the object as aFile.

The derived object must be created on the shared heap aHeap because it is shared by several processes: the font and bitmap server and its clients. To do this, use aHeap->AllocL() to obtain memory, then construct in place using a placement argument to new.

Derived classes must implement the pure virtual function RasterizeL(). Information about this function is provided in the function definition below.

Information about deriving from this class is also provided in the API guide.

Derivation

Members

Defined in COpenFont:
COpenFont(), COpenFont(), CharacterNeedsToBeRasterized(), ExtendedInterface(), FaceAttrib(), FaceIndex(), File(), FontCapitalAscent(), FontLineGap(), FontMaxAscent(), FontMaxDescent(), FontMaxHeight(), FontStandardDescent(), Metrics(), RasterizeL(), iFontCapitalAscent, iFontLineGap, iFontMaxAscent, iFontMaxDescent, iFontStandardDescent, iHeap, iMetrics, operator delete(), ~COpenFont()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


COpenFont()

IMPORT_C COpenFont(RHeap *aHeap, COpenFontSessionCacheList *aSessionCacheList, COpenFontFile *aFile);

Description

C++ constructor taking shared heap, session cache list and font file as parameters.

You must either use this, or the other constructor, when creating your derived object. This constructor might be used, in preference to the other, if there is only a single typeface in the font file.

Parameters

RHeap *aHeap

The shared heap.

COpenFontSessionCacheList *aSessionCacheList

The session cache list.

COpenFontFile *aFile

A pointer to the COpenFontFile object creating this COpenFont. e.g. when creating a COpenFont the COpenFontFile derived object would pass it this.


COpenFont()

IMPORT_C COpenFont(RHeap *aHeap, COpenFontSessionCacheList *aSessionCacheList, COpenFontFile *aFile, TInt aFaceIndex);

Description

C++ constructor taking shared heap, session cache list, font file and face index as parameters.

You must either use this, or the other constructor, when creating your derived object. This constructor would be used if the font file contains more than one typeface.

Parameters

RHeap *aHeap

The shared heap.

COpenFontSessionCacheList *aSessionCacheList

The session cache list.

COpenFontFile *aFile

A pointer to the COpenFontFile object creating this COpenFont. e.g. when creating a COpenFont the COpenFontFile derived object would pass it this.

TInt aFaceIndex

The index of the typeface within the font file aFile.


~COpenFont()

IMPORT_C ~COpenFont();

Description

Destructor.

This function frees all memory owned by the object, including the session cache list and the glyph list, prior to its destruction.

[Top]


Member functions


RasterizeL()

virtual void RasterizeL(TInt aCode, TOpenFontGlyphData *aGlyphData)=0;

Description

Creates a bitmap for the specified Unicode character.

Implementations of this function should put the bitmap in aGlyphData->iBitmapBuffer, and the character metrics are placed in aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left alone.

There are a number of strategies for achieving this, e.g. pass the rasterization task all the way up to the rasterizer engine. These are discussed in the API guide.

At present you must write the bitmap in the Symbian platform's run-length-encoded format. This is a packed binary format starting on a byte boundary and made up of a number of sections. Each section starts with a five-bit header. If the first bit of the header is 0 the next four bits are a repeat count, starting with the least significant bit, and a single row of bits (the number of bits in a row is specified by aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header is 1 the next four bits are a count of non-repeating rows, again starting with the least significant bit, and that many rows of bits follow.

Parameters

TInt aCode

The character code of the Unicode character for which the bitmap is required.

TOpenFontGlyphData *aGlyphData

On return, contains a pointer to a TOpenFontGlyphData containing the character's bitmap and metrics.


ExtendedInterface()

virtual IMPORT_C void ExtendedInterface(TUid aUid, TAny *&aParam);

Description

Parameters

TUid aUid

TAny *&aParam


operator delete()

IMPORT_C void operator delete(TAny *);

Description

Parameters

TAny *


Metrics()

inline const TOpenFontMetrics &Metrics() const;

Description

Gets the character metrics for this font.

Return value

const TOpenFontMetrics &

The character metrics for this font.


FaceAttrib()

inline const TOpenFontFaceAttrib *FaceAttrib() const;

Description

Gets the typeface attributes.

These are the attributes of the font represented by this object.

Return value

const TOpenFontFaceAttrib *

The typeface attributes.


File()

inline COpenFontFile *File() const;

Description

Gets a pointer to the COpenFontFile which created this object.

This is the COpenFontFile which owns the file that contains the definition of the typeface. It can be used to get information about the typeface, or to access the rasterizer context (engine).

Return value

COpenFontFile *

The COpenFontFile which created this object.


FaceIndex()

inline TInt FaceIndex() const;

Description

Gets the index of this typeface within the font file.

Return value

TInt

The index of this typeface within the font file.


CharacterNeedsToBeRasterized()

inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle, TInt aCode) const;

Description

Tests whether or not a character needs to be rasterized.

Characters that have been rasterized are cached there is no need to regenerate the character bitmap. This function should only be called by the Font and Bitmap server.

Parameters

TInt aSessionHandle

A handle to the font and bitmap server session.

TInt aCode

The code for the Unicode character.

Return value

TBool

ETrue if the character needs to be rasterized, otherwise EFalse.


FontCapitalAscent()

inline TInt FontCapitalAscent() const;

Description

Gets the ascent of an ANSI capital letter in the font whether or not there are any ANSI capitals in the font.

Return value

TInt

The positive distance from the font baseline to the top of a standard ANSI capital letter


FontMaxAscent()

inline TInt FontMaxAscent() const;

Description

Gets the max ascent of any pre-composed glyph in the font. This will include accents or diacritics that form part of pre-composed glyphs. It is not guaranteed to cover the max ascent of composite glyphs that have to be created by a layout engine. This is also the recommended distance between the top of a text box and the baseline of the first line of text.

The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().

Return value

TInt

The positive distance from the font baseline to the top of the highest pre-composed glyph (including accents) above the baseline.


FontStandardDescent()

inline TInt FontStandardDescent() const;

Description

Gets the descent of an ANSI descending character in the font. Whether or not there are any ANSI descenders in the font.

The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().

Return value

TInt

The positive distance from the font baseline to the bottom of the lowest ANSI descender.


FontMaxDescent()

inline TInt FontMaxDescent() const;

Description

Gets the max descent of any pre-composed glyph in the font. This will include accents or diacritics that form part of pre-composed glyphs. It is not guaranteed to cover the max descent of composite glyphs that have to be created by a layout engine.

The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().

Return value

TInt

The positive distance from the font baseline to the bottom of the lowest pre-composed glyph (including accents) below the baseline


FontLineGap()

inline TInt FontLineGap() const;

Description

Gets the suggested line gap for the font. This is the recommended baseline to baseline distance between successive lines of text in the font.

Return value

TInt

The positive recommended gap between successive lines


FontMaxHeight()

inline TInt FontMaxHeight() const;

Description

Gets the maximum height for the font. This is the sum of the max ascent of the font and the max descent of the font.

The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().

Return value

TInt

The positive maximum height of the font

[Top]


Member data


iHeap

protected: RHeap * iHeap;

Description


iMetrics

protected: TOpenFontMetrics iMetrics;

Description


iFontCapitalAscent

protected: TInt iFontCapitalAscent;

Description

The positive distance in pixels from the baseline to the top of an ANSI capital (whether or not there are ANSI capitals in the font)


iFontMaxAscent

protected: TInt iFontMaxAscent;

Description

The positive distance in pixels from the baseline to the top of the highest pre-composed glyph in the font


iFontStandardDescent

protected: TInt iFontStandardDescent;

Description

The positive distance in pixels from the baseline to the bottom of the lowest ANSI descender (whether or not there are ANSI chars in the font)


iFontMaxDescent

protected: TInt iFontMaxDescent;

Description

The positive distance in pixels from the baseline to the bottom of the lowest pre-composed glyph in the font


iFontLineGap

protected: TInt iFontLineGap;

Description

The recommended baseline to baseline gap for successive lines of text in the font