Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



Location: FNTSTORE.H
Link against: fntstr.lib

Class CFontStore

class CFontStore : public CTypefaceStore;

Description

A store for fonts.

Stores and handles both open and fixed-size fonts. Open fonts are made from open (scalable) typefaces by Open Font plug-in rasterizers. Fonts of other typefaces are stored in a limited number of fixed sizes. However, which is being used is transparent to the user of this class. For example the GetNearestFont...() functions get a bitmap font which may be retrieved from memory or generated via a rasterizer.

Derivation

Members

Defined in CFontStore:
AddFileL(), DefaultBitmapType(), DeleteSessionCache(), FontHeightInPixels(), FontHeightInTwips(), GetFontById(), GetNearestFontInPixels(), GetNearestFontInPixels(), GetNearestFontInTwips(), GetNearestFontToDesignHeightInPixels(), GetNearestFontToDesignHeightInPixels(), GetNearestFontToDesignHeightInTwips(), GetNearestFontToMaxHeightInPixels(), GetNearestFontToMaxHeightInPixels(), GetNearestFontToMaxHeightInTwips(), InstallRasterizerL(), InstallShaperFactoryL(), NewL(), NumTypefaces(), RemoveFile(), SetDefaultBitmapType(), TypefaceSupport(), iKPixelHeightInTwips, iKPixelWidthInTwips, ~CFontStore()

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

Inherited from CTypefaceStore:
AddFontL(), BaselineOffset(), ConstructL(), IncrementFontCount(), ReleaseFont(), SuperSubHeight(), iFontAccess


Construction and destruction


NewL()

static IMPORT_C CFontStore *NewL(RHeap *aHeap);

Description

Creates a new CFontStore object.

Sets iKPixelWidthInTwips and iKPixelHeightInTwips.

Sets the default bitmap type, used when getting bitmap fonts, to EMonochromeGlyphBitmap.

Also initialises other private member variable values .

Parameters

RHeap *aHeap

A pointer to the heap class used for memory allocation.

Return value

CFontStore *

Leave codes

KErrNoMemory

Insufficient memory available on the heap.


~CFontStore()

IMPORT_C ~CFontStore();

Description

Destructor.

[Top]


Member functions


AddFileL()

IMPORT_C TUid AddFileL(const TDesC &aName);

Description

Finds or creates a font file object to support a font file. The specified font file must be accessible to any process, i.e. not located inside an application's private directory.

If an appropriate font file object exists then no new open font file is created. In this case the reference count of the font file object is incremented.

Notes:

If aName is recognised as an open font file, creates a COpenFontFile, which will manage the font file specified by aName, and adds it to the file store's list of open font files.

The list of open font files is used when getting the nearest font for a font specification (i.e. by the GetNearestFont...() functions of this class) if the font is generated via a rasterizer.

The appropriate rasterizer, which supports the font format of the font file, is used to generate the open font file using COpenFontRasterizer::NewFontFileL().

If aName is not recognised as an open font file then CFontStoreFile tries to open the file as a Symbian Bitmap font.

Parameters

const TDesC &aName

The full path and filename of the font file to be supported.

Return value

TUid

The UID of the font file object supporting aName.

Leave codes

KErrNotSupported

if the file is not recognised at all

KErrCorrupt

if the font file data does not make sense

or

another system-wide error


RemoveFile()

IMPORT_C void RemoveFile(TUid aFileUid);

Description

Releases a hold on one or all font file objects (COpenFontFiles or CFontStoreFiles).

If aFileUid identifies a font file object, then the reference count for this object is decremented. If this brings the reference count down to zero then the font file object is removed from the font store, as well as the fonts and typefaces associated with this file.

If, on the other hand, aFileUid's value is NULL, then all font file objects are removed, along with all fonts and typefaces in the font store. However, in this case the function first checks that no fonts in the font store are being accessed (i.e. iFontAccess is empty); if one or more fonts are being accessed then a panic is raised with the value EFntFontAccessCountNonZero.

(If aFileUid is invalid, then no objects are removed.)

Parameters

TUid aFileUid

UID of a hold on a font file object to be released, or KNullUid if all font file objects are to be removed.


GetNearestFontInPixels()

IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToDesignHeightInPixels()

IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification. Matching to design height gives no guarantees on the actual physical size of the font.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToMaxHeightInPixels()

IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont *&aFont, const TFontSpec &aFontSpec, TInt aMaxHeight);

Description

Gets the font which is the nearest to the given font specification. Matching to maximum height returns a font that will fit within the height specified.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TFontSpec &aFontSpec

The specification of the font to be matched.

TInt aMaxHeight

The maximum height within which the font must fit. If maximum height is greater than 1024 pixels, the function returns KErrTooBig. This overrides the height specified in aFontSpec.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontInTwips()

IMPORT_C TInt GetNearestFontInTwips(CFont *&aFont, const TOpenFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontInPixels()

IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TOpenFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToDesignHeightInTwips()

IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TOpenFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification. Matching to design height gives no guarantees on the actual physical size of the font.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToDesignHeightInPixels()

IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TOpenFontSpec &aFontSpec);

Description

Gets the font which is the nearest to the given font specification. Matching to design height gives no guarantees on the actual physical size of the font.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToMaxHeightInTwips()

IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont *&aFont, const TOpenFontSpec &aFontSpec, TInt aMaxHeight);

Description

Gets the font which is the nearest to the given font specification. Matching to maximum height returns a font that will fit within the height specified.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

TInt aMaxHeight

The maximum height within which the font must fit. If maximum height is greater than 1024 pixels, the function returns KErrTooBig. This overrides the height specified in aFontSpec.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetNearestFontToMaxHeightInPixels()

IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont *&aFont, const TOpenFontSpec &aFontSpec, TInt aMaxHeight);

Description

Gets the font which is the nearest to the given font specification. Matching to maximum height returns a font that will fit within the height specified.

Parameters

CFont *&aFont

On return, contains a pointer to the nearest font.

const TOpenFontSpec &aFontSpec

The specification of the font to be matched.

TInt aMaxHeight

The maximum height within which the font must fit. If maximum height is greater than 1024 pixels, the function returns KErrTooBig. This overrides the height specified in aFontSpec.

Return value

TInt

KErrNone if successful; a system-wide error code otherwise.


GetFontById()

IMPORT_C TInt GetFontById(CFont *&aFont, TUid aUid, const TAlgStyle &aAlgStyle);

Description

Gets a bitmap font using the given font UID and algorithmic style.

Tries to find a bitmap font in the font store with the given UID. If successful, the given algorithmic style is applied to the font and this font (which may be a suitable one already existing in the store, or may be a newly generated font) is stored in aFont. If unsuccessful then no font is stored in aFont.

Parameters

CFont *&aFont

On return, a device-dependent font.

TUid aUid

A bitmap font UID.

const TAlgStyle &aAlgStyle

An algorithmic style to apply to the font.

Return value

TInt

KErrNone if the font is found, KErrNotFound if the font is not found, or another system-wide error code.


NumTypefaces()

virtual IMPORT_C TInt NumTypefaces() const;

Description

Gets the number of typefaces held in the font store.

Note that this includes both open font typefaces and non-scalable typefaces.

Return value

TInt

The number of supported typefaces.


TypefaceSupport()

virtual IMPORT_C void TypefaceSupport(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const;

Description

Gets a typeface support object for the typeface in the font store represented by the given index.

Returns benignly with an empty TTypefaceSupport if the index is too high; this can happen if another process removes a typeface after the first process has already got the number of typefaces. However, if the aTypefaceIndex<0 the function panics with EFntTypefaceIndexOutOfRange.

Parameters

TTypefaceSupport &aTypefaceSupport

On return, a typeface support object.

TInt aTypefaceIndex

An index number representing a typeface, which is valid if in the range 0 to (NumTypefaces() - 1).


FontHeightInTwips()

virtual IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const;

Description

Returns a font height, in twips, for a certain typeface and height index.

The font height is a height allowed for the typeface represented by aTypefaceIndex. The height returned increases with aHeightIndex.

If aTypefaceIndex<0 the function panics with EFntTypefaceIndexOutOfRange. If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0 then the function returns 0. If aHeightIndex is greater than the number of heights then the function returns the biggest height.

Parameters

TInt aTypefaceIndex

An index number representing a typeface, which is valid in the range 0 to (NumTypefaces() - 1).

TInt aHeightIndex

A font height index number, which is valid in the range 0 to (TTypefaceSupport::iNumHeights - 1). Note that the typeface support object for the typeface can be got using TypefaceSupport().

Return value

TInt

The height of a font, in twips.

See also:


FontHeightInPixels()

IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex, TInt aHeightIndex) const;

Description

Returns a font height, in pixels, for a certain typeface and height index.

The font height is a height allowed for the typeface represented by aTypefaceIndex. The height returned increases with aHeightIndex.

If aTypefaceIndex<0 the function panics with EFntTypefaceIndexOutOfRange. If aTypefaceIndex is greater than the number of typefaces or aHeightIndex<0 then the function returns 0. If aHeightIndex is greater than the number of heights then the function returns the biggest height.

Parameters

TInt aTypefaceIndex

An index number representing a typeface, which is valid in the range 0 to (NumTypefaces() - 1).

TInt aHeightIndex

A font height index number, which is valid in the range 0 to (TTypefaceSupport::iNumHeights - 1). Note that the typeface support object for the typeface can be got using TypefaceSupport().

Return value

TInt

The height of a font, in pixels.

See also:


InstallRasterizerL()

IMPORT_C void InstallRasterizerL(COpenFontRasterizer *aRasterizer);

Description

Installs and takes ownership of an Open Font rasterizer.

Parameters

COpenFontRasterizer *aRasterizer

A pointer to an Open Font rasterizer.


DeleteSessionCache()

IMPORT_C void DeleteSessionCache(TInt aSessionHandle);

Description

Deletes the glyph cache belonging to a particular client.

Called by ~CFbClient().

Parameters

TInt aSessionHandle

A session handle.


DefaultBitmapType()

inline TGlyphBitmapType DefaultBitmapType() const;

Description

Returns a default bitmap type.

Return value

TGlyphBitmapType

A default bitmap type.

See also:


SetDefaultBitmapType()

inline void SetDefaultBitmapType(TGlyphBitmapType aType);

Description

Sets a default bitmap type.

Parameters

TGlyphBitmapType aType

A default bitmap type.

See also:


InstallShaperFactoryL()

IMPORT_C void InstallShaperFactoryL(CShaperFactory *aShaperFactory);

Description

Install and takes ownership of the shaper

Parameters

CShaperFactory *aShaperFactory

A pointer to a shaper factory.

[Top]


Member data


iKPixelWidthInTwips

TInt iKPixelWidthInTwips;

Description

The width of 1000 pixels in twips.

This is set in the constructor. If the appropriate HALData attributes are set (EDisplayXPixels and EDisplayXTwips) then the value is calculated using these; otherwise the value is set to 11860.


iKPixelHeightInTwips

TInt iKPixelHeightInTwips;

Description

The height of 1000 pixels in twips.

This is set in the constructor. If the appropriate HALData attributes are set (EDisplayYPixels and EDisplayYTwips) then the value is calculated using these; otherwise the value is set to 11860.