Location:
GDI.H
Link against: gdi.lib
class CFont : public CBase;
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.
CBase
- Base class for all classes to be instantiated on the heap
CFont
- Abstract font interface
Defined in CFont
:
AscentInPixels()
, BaselineOffsetInPixels()
, CharWidthInPixels()
, CharactersJoin()
, DescentInPixels()
, DoDescentInPixels()
, DoGetCharacterData()
, EAllCharacterData
, ECharacterWidthOnly
, EHorizontal
, ENoCharacterData
, EVertical
, ExtendedFunction()
, FontCapitalAscent()
, FontLineGap()
, FontMaxAscent()
, FontMaxDescent()
, FontMaxHeight()
, FontSpecInTwips()
, FontStandardDescent()
, GetCharacterData()
, GetCharacterPosition2()
, HeightInPixels()
, MaxCharWidthInPixels()
, MaxNormalCharWidthInPixels()
, MeasureText()
, TCharacterDataAvailability
, TMeasureTextInput
, TMeasureTextOutput
, TPositionParam
, TTextDirection
, TextCount()
, TextCount()
, TextWidthInPixels()
, TypeUid()
, WidthZeroInPixels()
, ~CFont()
Inherited from CBase
:
Delete()
,
Extension_()
,
operator new()
private: virtual IMPORT_C TInt DoDescentInPixels() const;
Gets the font descent in pixels. It is defined to be HeightInPixels()
minus AscentInPixels()
.
|
protected: virtual IMPORT_C TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics &aMetrics, const
TUint8 *&aBitmap, TSize &aBitmapSize) const;
Gets the character metrics for a character.
|
|
inline TInt FontCapitalAscent() const;
Gets the ascent of an ANSI capital letter in the font whether or not there are any ANSI capitals in the font.
|
inline TInt FontMaxAscent() const;
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.
|
inline TInt FontStandardDescent() const;
Gets the descent of an ANSI descending character in the font. Whether or not there are any ANSI descenders in the font.
|
inline TInt FontMaxDescent() const;
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.
|
inline TInt FontLineGap() const;
Gets the suggested line gap for the font. This is the recommended baseline to baseline distance between successive lines of text in the font.
|
inline TInt FontMaxHeight() const;
Gets the (positive) maximum height in pixels of the font. This may differ from the design height.
|
IMPORT_C TUid TypeUid() 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.
|
IMPORT_C TInt HeightInPixels() const;
Gets the font height in pixels.
|
IMPORT_C TInt AscentInPixels() const;
Gets the font ascent in pixels.
|
IMPORT_C TInt DescentInPixels() const;
Gets the font descent in pixels.
|
IMPORT_C TInt CharWidthInPixels(TChar aChar) const;
Gets the width in pixels in this font of the specified character.
|
|
IMPORT_C TInt TextWidthInPixels(const TDesC &aText) const;
Gets the width in pixels of the specified descriptor when displayed in this font.
|
|
IMPORT_C TInt BaselineOffsetInPixels() const;
Gets the baseline offset in pixels.
The baseline offset is how far a font is raised or lowered from its normal baseline.
|
IMPORT_C TInt TextCount(const TDesC &aText, TInt aWidthInPixels) 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.
|
|
IMPORT_C TInt TextCount(const TDesC &aText, TInt aWidthInPixels, 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.
|
|
IMPORT_C TInt MaxCharWidthInPixels() const;
Gets the width in pixels of the widest character in this font.
|
IMPORT_C TInt MaxNormalCharWidthInPixels() 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).
|
IMPORT_C TFontSpec FontSpecInTwips() const;
Gets the font specification of this font in twips.
|
IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics &aMetrics, const TUint8 *&aBitmap,
TSize &aBitmapSize) const;
Gets the character metrics for a character.
|
|
IMPORT_C 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.
|
IMPORT_C TInt MeasureText(const TDesC &aText, const TMeasureTextInput *aInput=0, TMeasureTextOutput *aOutput=0) const;
Text measurement function.
This is a powerful text measurement function underlying all the other text measurement functions. It takes optional input and output parameter blocks, which may be null, and returns the advance width (change in pen position when drawn horizontally) of the text, or the advance height, if the text is drawn vertically.
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 or advance height (return value). The advance width is the amount by which the pen advances when drawing the text horizontally, while the advance height is the amount by which the pen advances when drawing the text vertically.
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 letter spacing 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
.
|
|
|
static IMPORT_C TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
Determines if aLeftCharacter and aRightCharacter affect each other's contextual glyph form if placed next to each other. If either character is a combining character, EFalse will be returned, which is not generally useful information. Pass in base characters ignoring intervening combining characters.
|
|
IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny *aParam=0) const;
Enables the caller to access a particular API extension function. N.B. Any overload of this function in a derived class should call its immediate parent implementation for any extension function UID that it does not recognize and handle.
|
|
IMPORT_C TBool GetCharacterPosition2(TPositionParam &aParam, RShapeInfo &aShapeInfo) const;
Takes Unicode text and produces the glyph cluster for the first character in that text plus any combining mark characters, or for the first indic syllable. It is responsible for contextual glyph selection, ligature creation and diacritic placement.
|
|
class 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 unlikely to be useful to third party developers.
Defined in CFont::TPositionParam
:
EFLogicalOrder
, EMaxInputChars
, EMaxOutputGlyphs
, TFlags
, TOutput
, TPositionParam()
, anonymous
, iDirection
, iFlags
, iOutput
, iOutputGlyphs
, iPen
, iPosInText
, iText
TPositionParam()
inline TPositionParam();
Standard constructor.
TOutput
class TOutput;
Output of GetCharacterPosition and GetCharacterPosition2.
Defined in CFont::TPositionParam::TOutput
:
TOutput()
, iBitmap
, iBitmapSize
, iBounds
, iCode
TOutput()
inline TOutput();
Standard constructor.
iCode
TUint iCode;
Character or glyph code.
iBitmap
const TUint8 * iBitmap;
Bitmap data for the glyph, if available
iBitmapSize
TSize iBitmapSize;
Size of the bitmap before algorithmic bolding, size multiplication, etc.
iBounds
TRect iBounds;
Bitmap bounds relative to the original pen position.
anonymous
n/a
|
TFlags
TFlags
Flags for TPositionParam::iFlags
.
|
iDirection
TInt16 iDirection;
Input: Orientation (EHorizontal or EVertical) in which to draw the text.
iFlags
TUint16 iFlags;
Input: Flags from TFlags.
iText
TPtrC iText;
Input: Text containing the characters to be positioned.
iPosInText
TInt iPosInText;
Input and output: Position within iText to shape. On exit it will index the first character not positioned
iPen
TPoint iPen;
Input and output: Pen position.
iOutput
TOutput iOutput;
Information about the glyphs that were output.
iOutputGlyphs
TInt iOutputGlyphs;
Number of glyphs actually output.
class 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
:
EFIncludePenPositionInBoundsCheck
, EFVisualOrder
, EFVisualOrderRightToLeft
, TFlags
, TMeasureTextInput()
, iCharJustExcess
, iCharJustNum
, iDirection
, iEndInputChar
, iFlags
, iMaxAdvance
, iMaxBounds
, iStartInputChar
, iWordJustExcess
, iWordJustNum
TMeasureTextInput()
inline TMeasureTextInput();
TFlags
TFlags
Flags for TMeasureTextInput::iFlags
.
|
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
TUint16 iDirection;
The direction in which to draw the text.
iFlags
TUint16 iFlags;
Flags from TFlags.
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 letter-spaced.
iCharJustExcess
TInt iCharJustExcess;
The amount of space to be used for letter spacing.
iWordJustNum
TInt iWordJustNum;
The number of spaces to be used for word spacing.
iWordJustExcess
TInt iWordJustExcess;
The amount of space to be used for word spacing.
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.
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.
|