CFont Class Reference

#include <textbase.h>

class CFont : public CBase

Inherits from

Public Member Enumerations
enumTCharacterDataAvailability { ENoCharacterData, ECharacterWidthOnly, EAllCharacterData }
enumTTextDirection { EHorizontal, EVertical }
Public Member Functions
IMPORT_C TIntAscentInPixels()
IMPORT_C TIntBaselineOffsetInPixels()
IMPORT_C TIntCharWidthInPixels(TChar)
IMPORT_C TBoolCharactersJoin(TInt, TInt)
IMPORT_C TIntDescentInPixels()
IMPORT_C TIntExtendedFunction(TUid, TAny *)
TInt FontCapitalAscent()
TInt FontLineGap()
TInt FontMaxAscent()
TInt FontMaxDescent()
TInt FontMaxHeight()
IMPORT_C TFontSpecFontSpecInTwips()
TInt FontStandardDescent()
IMPORT_C TCharacterDataAvailabilityGetCharacterData(TUint, TOpenFontCharMetrics &, const TUint8 *&, TSize &)
IMPORT_C TBoolGetCharacterPosition(TPositionParam &)
IMPORT_C TBoolGetCharacterPosition2(TPositionParam &, RShapeInfo &)
IMPORT_C TIntHeightInPixels()
IMPORT_C TIntMaxCharWidthInPixels()
IMPORT_C TIntMaxNormalCharWidthInPixels()
IMPORT_C TIntMeasureText(const TDesC &, const TMeasureTextInput *, TMeasureTextOutput *)
IMPORT_C TIntTextCount(const TDesC &, TInt)
IMPORT_C TIntTextCount(const TDesC &, TInt, TInt &)
IMPORT_C TIntTextWidthInPixels(const TDesC &)
IMPORT_C TIntTextWidthInPixels(const TDesC &, const TMeasureTextInput *)
IMPORT_C TUidTypeUid()
IMPORT_C TIntWidthZeroInPixels()
Protected Member Functions
virtual ~CFont()
virtual IMPORT_C TIntDoExtendedFunction(TUid, TAny *)
virtual IMPORT_C TCharacterDataAvailabilityDoGetCharacterData(TUint, TOpenFontCharMetrics &, const TUint8 *&, TSize &)
virtual IMPORT_C TBoolDoGetCharacterPosition(TPositionParam &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()

Detailed Description

Abstract font interface.

The CFont class provides a device-independent interface to a device-dependent font usually obtained from a call to GetNearestFont...() on a graphics device. It is used as a handle in CGraphicsContext::UseFont() and to obtain device-dependent information about the font - notably the pixel width of a text string.

See also: CFbsFont CGraphicsContext::UseFont()

Member Enumeration Documentation

Enum TCharacterDataAvailability

Data availability flags.

Some fonts like printer fonts may only have width information and can return ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize the rest of the data if necessary.

See also: GetCharacterData()

EnumeratorValueDescription
ENoCharacterData

No font information available.

ECharacterWidthOnly

Width information only is available.

EAllCharacterData

All character data is available.

Enum TTextDirection

Text direction flags.

This enum is used in TMeasureTextInput and determines whether the text is drawn horizontally or vertically. Note: text is drawn vertically in some styles of Japanese, etc.

See also: TMeasureTextInput

EnumeratorValueDescription
EHorizontal

Text is drawn horizontally. Text is drawn horizontally.

EVertical

Text is drawn vertically.

Constructor & Destructor Documentation

~CFont ( )

IMPORT_C~CFont()[protected, virtual]

Member Function Documentation

AscentInPixels ( )

IMPORT_C TIntAscentInPixels()const
Deprecated

Gets the font ascent in pixels. Note that this deprecated function is replaced by the new FontMaxAscent() or in some cases FontCapitalAscent().

See also: FontCapitalAscent() FontMaxAscent()

Return Value
The font ascent in pixels.

BaselineOffsetInPixels ( )

IMPORT_C TIntBaselineOffsetInPixels()const

Gets the baseline offset in pixels.

The baseline offset is how far a font is raised or lowered from its normal baseline.

Return Value
Offset from normal baseline, in pixels.

CharWidthInPixels ( TChar )

IMPORT_C TIntCharWidthInPixels(TCharaChar)const

Gets the width in pixels in this font of the specified character.

Note: For OpenType fonts this function returns the horizontal advance of the character, which may be different from the actual width.

Parameters
aCharThe character whose width should be determined.
Return Value
The width in pixels of the specified character in this font.

CharactersJoin ( TInt, TInt )

IMPORT_C TBoolCharactersJoin(TIntaLeftCharacter,
TIntaRightCharacter
)[static]

DescentInPixels ( )

IMPORT_C TIntDescentInPixels()const
Deprecated

Gets the font descent in pixels. Note that this deprecated function is replaced by the new FontMaxDescent() or in some cases FontStandardDescent().

See also: FontStandardDescent() FontMaxDescent()

Return Value
The font descent in pixels.

DoExtendedFunction ( TUid, TAny * )

IMPORT_C TIntDoExtendedFunction(TUidaFunctionId,
TAny *aParam = 0
)const [protected, virtual]

DoGetCharacterData ( TUint, TOpenFontCharMetrics &, const TUint8 *&, TSize & )

IMPORT_C TCharacterDataAvailabilityDoGetCharacterData(TUintaCode,
TOpenFontCharMetrics &aMetrics,
const TUint8 *&aBitmap,
TSize &aBitmapSize
)const [protected, virtual]

DoGetCharacterPosition ( TPositionParam & )

IMPORT_C TBoolDoGetCharacterPosition(TPositionParam &aParam)const [protected, virtual]

ExtendedFunction ( TUid, TAny * )

IMPORT_C TIntExtendedFunction(TUidaFunctionId,
TAny *aParam = 0
)const

FontCapitalAscent ( )

TInt FontCapitalAscent()const [inline]

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

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

FontLineGap ( )

TInt FontLineGap()const [inline]

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
The positive recommended gap between successive lines

FontMaxAscent ( )

TInt FontMaxAscent()const [inline]

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.

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

FontMaxDescent ( )

TInt FontMaxDescent()const [inline]

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.

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

FontMaxHeight ( )

TInt FontMaxHeight()const [inline]

Gets the (positive) maximum height in pixels of the font. This may differ from the design height.

Return Value
The maximum height of the font.

FontSpecInTwips ( )

IMPORT_C TFontSpecFontSpecInTwips()const

Gets the font specification of this font in twips.

Return Value
The font specification of this font (in twips).

FontStandardDescent ( )

TInt FontStandardDescent()const [inline]

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

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

GetCharacterData ( TUint, TOpenFontCharMetrics &, const TUint8 *&, TSize & )

IMPORT_C TCharacterDataAvailabilityGetCharacterData(TUintaCode,
TOpenFontCharMetrics &aMetrics,
const TUint8 *&aBitmap,
TSize &aBitmapSize
)const

GetCharacterPosition ( TPositionParam & )

IMPORT_C TBoolGetCharacterPosition(TPositionParam &aParam)const

GetCharacterPosition2 ( TPositionParam &, RShapeInfo & )

IMPORT_C TBoolGetCharacterPosition2(TPositionParam &aParam,
RShapeInfo &aShapeInfo
)const

HeightInPixels ( )

IMPORT_C TIntHeightInPixels()const
Deprecated

Gets the font height in pixels. Note that this deprecated function is replaced by the new FontMaxHeight().

See also: FontMaxHeight()

Return Value
The font height in pixels.

MaxCharWidthInPixels ( )

IMPORT_C TIntMaxCharWidthInPixels()const

Gets the width in pixels of the widest character in this font.

Return Value
The width of the maximum width character, in pixels.

MaxNormalCharWidthInPixels ( )

IMPORT_C TIntMaxNormalCharWidthInPixels()const

Gets the width in pixels of the widest normal character in this font.

Normal characters include all character in a character set except non-alphabetic characters (e.g. the copyright symbol, or a block graphics symbol, for example).

Return Value
The width of the maximum width normal character, in pixels.

MeasureText ( const TDesC &, const TMeasureTextInput *, TMeasureTextOutput * )

IMPORT_C TIntMeasureText(const TDesC &aText,
const TMeasureTextInput *aInput = 0,
TMeasureTextOutput *aOutput = 0
)const

TextCount ( const TDesC &, TInt )

IMPORT_C TIntTextCount(const TDesC &aText,
TIntaWidthInPixels
)const

Gets how much of the specified descriptor can be displayed in this font without exceeding the specified width.

Note:

This function does not display any of the descriptor itself - it is used before display, to test whether the whole descriptor can be displayed.

Parameters
aTextThe descriptor.
aWidthInPixelsThe available width for character display.
Return Value
The number of characters which will be able to be displayed without exceeding the specified width. The count starts from the beginning of the descriptor.

TextCount ( const TDesC &, TInt, TInt & )

IMPORT_C TIntTextCount(const TDesC &aText,
TIntaWidthInPixels,
TInt &aExcessWidthInPixels
)const

Gets how much of the specified descriptor can be displayed in this font without exceeding the specified width.

It also returns the excess width - defined as the specified available width minus the width of the portion of the descriptor which can be displayed without exceeding the available width.

Parameters
aTextThe descriptor.
aWidthInPixelsThe available width for character display.
aExcessWidthInPixelsThe excess width after displaying the portion of the descriptor, in pixels.
Return Value
The number of characters which will be able to be displayed without exceeding the specified width. The count starts from the beginning of the descriptor.

TextWidthInPixels ( const TDesC & )

IMPORT_C TIntTextWidthInPixels(const TDesC &aText)const

Gets the width in pixels of the specified descriptor when displayed in this font.

Parameters
aTextThe descriptor whose width should be determined.
Return Value
The width of the specified descriptor when displayed in this font, in pixels.

TextWidthInPixels ( const TDesC &, const TMeasureTextInput * )

IMPORT_C TIntTextWidthInPixels(const TDesC &aText,
const TMeasureTextInput *aParam
)const

Gets the width in pixels of the specified descriptor when displayed in this font.

Parameters
aTextThe descriptor whose width should be determined.
aParamParameter block that controls how much of aText is measured
Return Value
The width of the specified descriptor when displayed in this font, in pixels.

TypeUid ( )

IMPORT_C TUidTypeUid()const

Gets run-time identity of the actual font type. This enables safe casting to a derived type.

For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid. You would need to cast to a CFbsFont to get a character bounding box. Similarly, a CBitmapFont returns KCBitmapFontUidVal.

Return Value
The font-type identifier.

WidthZeroInPixels ( )

IMPORT_C TIntWidthZeroInPixels()const