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.
CFbsFont CGraphicsContext::UseFont()
Protected Member Functions | |
---|---|
~CFont () | |
IMPORT_C TInt | DoExtendedFunction ( TUid , TAny *) |
IMPORT_C TCharacterDataAvailability | DoGetCharacterData ( TUint , TOpenFontCharMetrics &, const TUint8 *&, TSize &) |
IMPORT_C TBool | DoGetCharacterPosition ( TPositionParam &) |
Private Member Functions | |
---|---|
TInt | DoAscentInPixels () |
TInt | DoBaselineOffsetInPixels () |
TInt | DoCharWidthInPixels ( TChar ) |
IMPORT_C TInt | DoDescentInPixels () |
TFontSpec | DoFontSpecInTwips () |
TInt | DoHeightInPixels () |
TInt | DoMaxCharWidthInPixels () |
TInt | DoMaxNormalCharWidthInPixels () |
TInt | DoTextCount (const TDesC &, TInt ) |
TInt | DoTextCount (const TDesC &, TInt , TInt &) |
TInt | DoTextWidthInPixels (const TDesC &) |
TUid | DoTypeUid () |
Public Member Enumerations | |
---|---|
enum | TCharacterDataAvailability { ENoCharacterData , ECharacterWidthOnly , EAllCharacterData } |
enum | TTextDirection { EHorizontal , EVertical } |
IMPORT_C TInt | AscentInPixels | ( | ) | const |
Gets the font ascent in pixels. Note that this deprecated function is replaced by the new FontMaxAscent() or in some cases FontCapitalAscent() .
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 | CharWidthInPixels | ( | TChar | aChar | ) | 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.
TChar aChar | The character whose width should be determined. |
IMPORT_C TBool | CharactersJoin | ( | TInt | aLeftCharacter, |
TInt | aRightCharacter | |||
) | [static] |
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 | DescentInPixels | ( | ) | const |
Gets the font descent in pixels. Note that this deprecated function is replaced by the new FontMaxDescent() or in some cases FontStandardDescent() .
TInt | DoAscentInPixels | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoBaselineOffsetInPixels | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoCharWidthInPixels | ( | TChar | aChar | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TChar aChar |
IMPORT_C TInt | DoDescentInPixels | ( | ) | const [private, virtual] |
Gets the font descent in pixels. It is defined to be HeightInPixels() minus AscentInPixels() . Note that this deprecated function is replaced by the new FontMaxDescent() or in some cases FontStandardDescent() .
IMPORT_C TInt | DoExtendedFunction | ( | TUid | aFunctionId, |
TAny * | aParam = NULL | |||
) | const [protected, virtual] |
API extension system that 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.
TFontSpec | DoFontSpecInTwips | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
IMPORT_C TCharacterDataAvailability | DoGetCharacterData | ( | TUint | aCode, |
TOpenFontCharMetrics & | aMetrics, | |||
const TUint8 *& | aBitmap, | |||
TSize & | aBitmapSize | |||
) | const [protected, virtual] |
Gets the character metrics for a character.
TUint aCode | The character code. |
TOpenFontCharMetrics & aMetrics | On return, contains the character bitmap. |
const TUint8 *& aBitmap | On return, this points to NULL. |
TSize & aBitmapSize | On return, this has a size of (0,0). |
IMPORT_C TBool | DoGetCharacterPosition | ( | TPositionParam & | aParam | ) | const [protected, virtual] |
Overridable function innards of GetCharacterPosition and GetCharacterPosition2. It is generally not useful to override this function. GetCharacterPosition GetCharacterPosition2
TPositionParam & aParam |
TInt | DoHeightInPixels | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoMaxCharWidthInPixels | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoMaxNormalCharWidthInPixels | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoTextCount | ( | const TDesC & | aText, |
TInt | aWidthInPixels | |||
) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoTextCount | ( | const TDesC & | aText, |
TInt | aWidthInPixels, | |||
TInt & | aExcessWidthInPixels | |||
) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
TInt | DoTextWidthInPixels | ( | const TDesC & | aText | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
const TDesC & aText |
TUid | DoTypeUid | ( | ) | const [private, pure virtual] |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
IMPORT_C TInt | ExtendedFunction | ( | TUid | aFunctionId, |
TAny * | aParam = NULL | |||
) | 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.
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.
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.
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.
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.
TInt | FontMaxHeight | ( | ) | const [inline] |
Gets the (positive) maximum height in pixels of the font. This may differ from the design height.
IMPORT_C TFontSpec | FontSpecInTwips | ( | ) | const |
Gets the font specification of this font in twips.
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.
IMPORT_C TCharacterDataAvailability | GetCharacterData | ( | TUint | aCode, |
TOpenFontCharMetrics & | aMetrics, | |||
const TUint8 *& | aBitmap, | |||
TSize & | aBitmapSize | |||
) | const |
Gets the character metrics for a character.
TUint aCode | The character code. |
TOpenFontCharMetrics & aMetrics | On return, contains the character bitmap. |
const TUint8 *& aBitmap | On return, this points to NULL. |
TSize & aBitmapSize | On return, this has a size of (0,0). |
IMPORT_C TBool | GetCharacterPosition | ( | TPositionParam & | aParam | ) | const |
Transforms one cluster of characters (base character plus combining marks, ligature or indic syllable) into one cluster of glyphs together with their positions. Repeated calls of this function (for the same input text) are considerably slower than repeated calls of GetCharacterPosition2 for Indic text (such as Hindi), as GetCharacterPosition2 can cache information between calls. GetCharacterPosition2
TPositionParam & aParam | Input and output parameters |
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.
TPositionParam & aParam | The input/output parameter of the text/glyph data for the algorithm. |
RShapeInfo & aShapeInfo | The function will cache "shaped" text (e.g. complex scripts such as Devanagari) here. aShapeInfo must be freshly-constructed or closed for each new piece of text in aParam.iText. If aParam.iText is unchanged between calls, aShapeInfo should be passed back in unchanged as well. |
IMPORT_C TInt | HeightInPixels | ( | ) | const |
Gets the font height in pixels. Note that this deprecated function is replaced by the new FontMaxHeight() .
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 TInt | MeasureText | ( | const TDesC & | aText, |
const TMeasureTextInput * | aInput = NULL, | |||
TMeasureTextOutput * | aOutput = NULL | |||
) | 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.
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 .
const TDesC & aText | The text to be measured. |
const TMeasureTextInput * aInput = NULL | The input block. This may be NULL. |
TMeasureTextOutput * aOutput = NULL | The output block. This may be NULL. |
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 | TextWidthInPixels | ( | const TDesC & | aText | ) | const |
Gets the width in pixels of the specified descriptor when displayed in this font.
const TDesC & aText | The descriptor whose width should be determined. |
IMPORT_C TInt | TextWidthInPixels | ( | const TDesC & | aText, |
const TMeasureTextInput * | aParam | |||
) | const |
Gets the width in pixels of the specified descriptor when displayed in this font.
const TDesC & aText | The descriptor whose width should be determined. |
const TMeasureTextInput * aParam | Parameter block that controls how much of aText is measured |
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 | 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.
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.
ENoCharacterData |
No font information available. |
ECharacterWidthOnly |
Width information only is available. |
EAllCharacterData |
All character data is available. |
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.
EHorizontal |
Text is drawn horizontally. Text is drawn horizontally. |
EVertical |
Text is drawn vertically. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.