Location: gdi.h
Link against: gdi.lib
CFont
Supported from 5.0
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.
|
Defined in CFont
:
AscentInPixels()
, BaselineOffsetInPixels()
, CharWidthInPixels()
, CodeSection()
, DescentInPixels()
, EAllCharacterData
, ECharacterWidthOnly
, EHorizontal
, ENoCharacterData
, EVertical
, FontSpecInTwips()
, GetCharacterData()
, GetCharacterPosition()
, HeightInPixels()
, MaxCharWidthInPixels()
, MaxNormalCharWidthInPixels()
, MeasureText()
, NumCodeSections()
, TCharacterDataAvailability
, TMeasureTextInput
, TMeasureTextOutput
, TPositionParam
, TTextDirection
, TextCount()
, TextWidthInPixels()
, TypeUid()
, WidthZeroInPixels()
Inherited from CBase
:
operator new()
virtual TUid TypeUid() const=0;
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
.
|
virtual TFontSpec FontSpecInTwips() const=0;
Gets the font specification of this font in twips.
|
virtual TInt HeightInPixels() const=0;
Gets the height of the font in pixels.
|
virtual TInt AscentInPixels() const=0;
Gets the ascent of the font in pixels.
|
virtual TInt DescentInPixels() const;
Gets the descent of the font in pixels.
|
virtual TInt BaselineOffsetInPixels() const=0;
Gets the baseline offset in pixels.
The baseline offset is how far a font is raised or lowered from its normal baseline.
|
TInt WidthZeroInPixels() const;
Gets the width of the zero character of this font in pixels.
This function is provided as the "0" character is roughly the average width of the characters of any font.
|
virtual TInt CharWidthInPixels(TChar aChar) const=0;
Gets the width in pixels in this font of the specified character.
|
|
virtual TInt MaxCharWidthInPixels() const=0;
Gets the width in pixels of the widest character in this font.
|
virtual TInt MaxNormalCharWidthInPixels() const=0;
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).
|
virtual TInt TextWidthInPixels(const TDesC& aText) const=0;
Gets the width in pixels of the specified descriptor when displayed in this font.
|
|
virtual TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const=0;
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.
|
|
virtual TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0;
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.
|
|
virtual TInt NumCodeSections() const=0;
Withdrawn in 6.0
Gets the number of code sections in the font.
A code section defines the bitmaps for characters in a specified range.
This function was removed in version 6.0 because it deals with implementation details of bitmap fonts — these details could not sensibly be provided for by Open Font System fonts.
|
virtual TCodeSection CodeSection(TInt anIndex) const=0;
Withdrawn in 6.0
Gets the code section at the specified index.
A code section defines the bitmaps for characters in a specified range.
This function was removed in version 6.0 because it deals with implementation details of bitmap fonts — these details could not sensibly be provided for by Open Font System fonts.
|
|
virtual TCharacterDataAvailability GetCharacterData(TUint aCode,
TOpenFontCharMetrics& aMetrics, const TUint8*& aBitmap,TSize& aBitmapSize) const;
Supported from 6.0
Gets the character metrics for a character.
|
|
virtual TBool GetCharacterPosition(TPositionParam& aParam) const;
Supported from 6.0
Gets the character position parameter.
This function is not intended for general use. It is used for contextual glyph selection, ligature creation and diacritic placement when drawing text in complex scripts.
|
|
TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL,TMeasureTextOutput* aOutput = NULL) const;
Text measurement function.
This is the powerful text measurement function underlying all the other text measurement functions. It takes optional input and output parameter blocks — they may be null, and returns the the advance width (change in pen position when drawn) of the text, or advance height if the text is drawn vertically. However, vertical text is not yet supported.
Some of the functions that can be performed using this function are listed below — many of them are used by the Text Views API to do its typographic layout.
Get the advance width (return value). The advance width is the amount by which the pen advances when drawing the text.
Measure some text in context, so that shaping behaviour (e.g., in Arabic) can be affected by what comes before and after the text. Do this using TMeasureTextInput::iStartInputChar
and TMeasureTextInput::iEndInputChar
to tell the function where to start and end in the supplied descriptor.
Determine how much text fits a given size — by setting TMeasureTextInput::iMaxAdvance
or TMeasureTextInput::iMaxBounds
.
Specify letterspacing and word spacing using TMeasureTextInput::iCharJustNum
, TMeasureTextInput::iCharJustExcess
, TMeasureTextInput::iWordJustNum
and TMeasureTextInput::iWordJustExcess
.
Get the number of characters drawn in TMeasureTextOutput::iChars
— when applying the various constraints in TMeasureTextInput
.
Get the number of glyphs drawn in TMeasureTextOutput::iGlyphs
.
Get the number of groups (formed by ligation or diacritic placement) in TMeasureTextOutput::iGroups
. Groups are units of cursor movement: the cursor hops over a character-plus-accent group or an Arabic or other ligature in one go.
Get the number of word spaces in TMeasureTextOutput::iSpaces
.
Get the bounds of the inked-in pixels in TMeasureTextOutput::iBounds
.
Get the size of the biggest glyph that would be drawn in TMeasureTextOutput::iMaxGlyphSize
.
|
|
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.
|
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.
|
TPositionParam
Complicated parameter block used for contextual glyph selection, ligature creation and diacritic placement when drawing text in complex scripts
This class declares a constructor, another scoped class, and several other enums. However this class is not unlikely to be useful to third party developers, and so these have not been fully documented.
TMeasureTextInput
Input parameter block.
This is optionally used by CFont::MeasureText()
, which is the powerful text measurement function underlying all the other text measurement functions.
Defined in CFont::TMeasureTextInput
:
TMeasureTextInput
, iCharJustExcess
, iCharJustNum
, iDirection
, iEndInputChar
, iMaxAdvance
, iMaxBounds
, iStartInputChar
, iWordJustExcess
, iWordJustNum
TMeasureTextInput
TMeasureTextInput
Default constructor.
Initialises all values to zero, except iEndInputChar
and iMaxAdvance
which are set to the maximum value, and
iDirection
which is set to EHorizontal
.
iStartInputChar
TInt iStartInputChar;
Starting index specifying first input character in iText
.
Together with iEndInputChar
, this allows some context before and after the measured text to be supplied
so that shaping can work properly.
iEndInputChar
TInt iEndInputChar;
Index specifying the final input character.
Together with iStartInputChar
, this allows some context before and after the measured text to be supplied
so that shaping can work properly.
iDirection
TTextDirection iDirection;
The direction in which to draw the text.
iMaxAdvance
TInt iMaxAdvance;
The maximum advance.
iMaxBounds
TInt iMaxBounds;
The maximum width (or height if drawing vertically) of bounds.
iCharJustNum
TInt iCharJustNum;
The number of glyph groups to be letterspaced.
iCharJustExcess
TInt iCharJustExcess;
The amount of space to be used for letterspacing.
iWordJustNum
TInt iWordJustNum;
The number of spaces to be used for wordspacing.
iWordJustExcess
TInt iWordJustExcess;
The amount of space to be used for wordspacing.
class TMeasureTextOutput
Output parameter block.
This is optionally used by CFont::MeasureText()
, which is the powerful text measurement function underlying all the other text measurement functions.
Defined in CFont::TMeasureTextOutput
:
iBounds
, iChars
, iGlyphs
, iGroups
, iMaxGlyphSize
, iSpaces
iChars
TInt iChars;
The number of input characters that would be drawn.
This may be less than the length of the text if a maximum advance or bounding box size is specified.
iGlyphs
TInt iGlyphs;
The number of glyphs that would be drawn.
iGroups
TInt iGroups;
The number of groups that would be drawn.
A group is a base glyph plus one or more combining characters.
iSpaces
TInt iSpaces;
The number of word spaces (U+0020) that would be drawn.
iBounds
TRect iBounds;
The bounding box of all the glyphs that would be drawn.
iMaxGlyphSize
TSize iMaxGlyphSize;
The maximum width and height of any glyph.