Update contrib.
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file is a subset of original gdi.h.
16 // IMPORTANT NOTE to maintainer:
17 // If you add new exports, to make sure they are exported by GDI.DLL,
18 // remember to update /graphics/graphicsdeviceinterface/gdi/sgdi/TextBaseStub.cpp.
20 // Text related types/consts are moved from gdi.h to this file, as listed below.
23 // enum TFontStrokeWeight
24 // enum TFontPrintPosition
26 // const KMaxTypefaceNameLength
28 // enum TGlyphBitmapType
32 // class TTypefaceSupport
33 // const KSuperSubScalingPercentage
34 // const KSuperscriptOffsetPercentage
35 // const KSubscriptOffsetPercentage
36 // class CTypefaceStore
37 // const KMaxFontCacheEntries
40 // const KFontCapitalAscent
41 // const KFontMaxAscent
42 // const KFontStandardDescent
43 // const KFontMaxDescent
45 // const KFontGetFontTable
46 // const KFontGetGlyphOutline
47 // const KFontReleaseGlyphOutline
48 // const KFontReleaseFontTable
52 #ifndef __TEXTBASE_H__
53 #define __TEXTBASE_H__
59 class TOpenFontCharMetrics;
63 #ifndef __GLYPHSEL_TEXTBASE_H__
64 #define __GLYPHSEL_TEXTBASE_H__
66 This enumeration holds the possible panic codes that may be raised
67 by the TextBase API on detecting an unrecoverable error. */
71 ETextBasePanic_Unknown = 0,
72 /** One or more of the input parameters to the interface were invalid */
73 ETextBasePanic_InvalidInputParam = 1,
74 /** Insufficient text for successful completion of the method */
75 ETextBasePanic_OutOfText = 2,
76 /** Internal failure. */
77 ETextBasePanic_Invariant = 3,
78 /** Reserved panic codes. Not to be used. */
79 ETextBasePanic_Reserved1 = 4,
80 ETextBasePanic_Reserved2 = 5,
81 /** Setting a typeface name that is too long */
82 ETextBasePanic_TypefaceNameOverflow = 6,
89 Fonts can be either upright or italic.
95 /** Font posture is normal (upright). */
97 /** Font posture is italic. */
103 Font stroke weight flags.
107 enum TFontStrokeWeight
109 /** Font stroke weight is normal. */
111 /** Font stroke weight is bold. */
116 Font print position flags.
117 Fonts can be normal, superscript or subscript.
121 enum TFontPrintPosition
123 /** Font is normal. */
125 /** Font is superscript. */
126 EPrintPosSuperscript,
127 /** Font is subscript. */
133 The maximum length of a typeface name (in characters).
137 const TInt KMaxTypefaceNameLength=0x18;
140 /** Typeface name and attributes.
142 This class identifies a typeface by name, and contains the combination of
143 attributes of the typeface. These attributes define whether it is a symbol
144 typeface, whether the typeface is proportional, and whether it is serif or
147 The combination of attributes for a typeface are stored in a bitmask, with
148 the various bits indicating different attributes. The bitmask is calculated
149 for any particular attribute combination by ORing the enumerated value for
150 each individual attribute.
159 /** Typeface is a proportional typeface (e.g. Swiss)
162 /** Typeface is a serif typeface (e.g. Times)
165 /** Typeface is a symbol typeface (e.g. Symbol)
170 IMPORT_C TTypeface();
171 IMPORT_C TBool operator==(const TTypeface& aTypeface) const;
172 IMPORT_C void InternalizeL(RReadStream& aStream);
173 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
174 IMPORT_C void SetAttributes(TInt aAttributes);
175 IMPORT_C void SetIsProportional(TBool aIsProportional);
176 IMPORT_C void SetIsSerif(TBool aIsSerif);
177 IMPORT_C void SetIsSymbol(TBool aIsSymbol);
178 IMPORT_C TInt Attributes() const;
179 IMPORT_C TBool IsProportional() const;
180 IMPORT_C TBool IsSerif() const;
181 IMPORT_C TBool IsSymbol() const;
182 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
183 IMPORT_C void SetScriptTypeForMetrics(TInt aScript);
184 IMPORT_C TInt ScriptTypeForMetrics() const;
185 IMPORT_C void SetName(const TDesC& aName);
186 IMPORT_C const TDesC& Name() const;
188 void ResetAttributes();
189 void ResetScriptType();
191 /** The typeface name. */
192 TBufC<KMaxTypefaceNameLength> iName;
199 An enumerated type for the format of a glyph bitmap. This type is currently
200 used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased.
201 Additional values may be defined in the future.
203 @see TFontStyle::SetBitmapType()
204 @see CFbsTypefaceStore::SetDefaultBitmapType()
208 enum TGlyphBitmapType
210 /** The font store's default glyph bitmap format is used. */
211 EDefaultGlyphBitmap = 0,
212 /** The standard monochrome format: no anti-aliasing, 1 bit per pixel,
213 run-length encoded. */
214 EMonochromeGlyphBitmap,
215 /** Standard 8-bits-per-pixel with anti-aliasing. */
216 EAntiAliasedGlyphBitmap,
217 /** The format used when sub-pixel font rendering is used. */
218 ESubPixelGlyphBitmap,
219 /** The format used when outline and shadow font rendering is used.
221 If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as
222 EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and
223 when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum.
225 EFourColourBlendGlyphBitmap,
227 This is used for glyphs, and not fonts, and is needed to inform the font drawing routines
228 that the character should be drawn using the overall font setting.
229 For Internal Use Only.
231 EGlyphBitmapTypeNotDefined,
233 This is used to inform the rasterizer that the best match should be
234 found for the bitmap type based upon its knowledge.
235 For Internal Use Only.
237 EAntiAliasedOrMonochromeGlyphBitmap,
241 Defines a set of font effects flags.
245 WARNING: This Class is for use by system/UI software ONLY.
247 NONSHARABLE_CLASS(FontEffect)
252 ENone = 0x0, // No effects.
253 EAlgorithmicBold= 0x10, // Font is algorithmic bold (a.k.a pseudo bold.)
254 EDropShadow = 0x20, // Font has a drop shadow.
255 EOutline = 0x40, // Font is an outline font.
256 EEmbossed = 0x80, // Font is embossed.
257 EEngraved = 0x100, // Font is engraved.
258 ESoftEdge = 0x200, // Font is soft edged.
259 EReserved1 = 0x400, // Reserved for Symbian use.
260 EReserved2 = 0x800, // Reserved for Symbian use.
261 EReserved3 = 0x1000, // Reserved for Symbian use.
262 EReserved4 = 0x2000, // Reserved for Symbian use.
263 EReserved5 = 0x4000, // Reserved for Symbian use.
264 EReserved6 = 0x8000, // Reserved for Symbian use.
267 IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect);
268 IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect);
271 /** Encapsulates a font style.
273 The font style information is comprised of:
275 the posture of the font upright or italic
277 the stroke weight of the font normal or bold
279 the print position of the font normal, subscript or superscript
281 Note that the underline and strike-through attributes are not included in
282 this class, but are set in the graphics context.
284 @see CGraphicsContext::SetUnderlineStyle()
285 @see CGraphicsContext::SetStrikethroughStyle()
292 IMPORT_C TFontStyle();
293 IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos);
294 IMPORT_C void InternalizeL(RReadStream& aStream);
295 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
296 IMPORT_C TFontPosture Posture() const;
297 IMPORT_C TFontStrokeWeight StrokeWeight() const;
298 IMPORT_C TFontPrintPosition PrintPosition() const;
299 IMPORT_C void SetPosture(TFontPosture aPosture);
300 IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
301 IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition);
302 inline TGlyphBitmapType BitmapType() const;
303 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
304 IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const;
305 IMPORT_C TUint32 Effects() const;
306 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
307 IMPORT_C void SetEffects(TUint32 aEffects);
308 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
318 TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low)
326 Specifies the font specification in device independent terms.
333 IMPORT_C TFontSpec();
334 IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight);
335 IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const;
336 IMPORT_C void InternalizeL(RReadStream& aStream);
337 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
338 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
339 IMPORT_C TInt ScriptTypeForMetrics() const;
343 /** The height of the typeface (in twips). */
345 /** The font style of the typeface. */
346 TFontStyle iFontStyle;
351 /** Typeface family support information.
353 This data-only class includes the name and attributes of a typeface, how many
354 font heights are available, its minimum and maximum heights, and whether or
355 not it is scaleable a typeface is scaleable if it supports heights at
356 fixed intervals between the minimum and maximum heights.
360 class TTypefaceSupport
363 /** The name and attributes of the typeface. */
365 /** The number of distinct font heights available in the typeface. */
367 /** The typeface's minimum font height, in twips. */
368 TInt iMinHeightInTwips;
369 /** The typeface's maximum font height, in twips. */
370 TInt iMaxHeightInTwips;
371 /** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise
373 TBool iIsScalable; // supports heights from min to max at fixed interval
377 The percentage used to multiply a normal font height when calculating its
378 superscript or subscript height.
382 const TInt KSuperSubScalingPercentage=67;
385 The percentage of a font height used to calculate its baseline offset for a
386 superscript print position.
390 const TInt KSuperscriptOffsetPercentage=-28;
393 The percentage of a font height used to calculate its baseline offset for a
394 subscript print position.
398 const TInt KSubscriptOffsetPercentage=14;
402 /** Typeface store abstract base interface.
404 This class provides the interface to a store for typefaces.
410 class CTypefaceStore : public CBase
413 IMPORT_C ~CTypefaceStore();
416 Gets the font which is the nearest to the given font specification.
418 When the font is no longer needed, call @c ReleaseFont().
420 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
421 yielding (virtually) the same result. However clients are strongly encouraged to use the new
422 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
423 character within any given text string will fit within the given amount of twips, whereas the design
424 height is an aesthetic unit decided by the font designer without strict physical meaning, which
425 may result in cropped characters.
427 @param aFont On return, contains a pointer to the nearest font.
428 @param aFontSpec The specification of the font to be matched.
429 @return KErrNone if successful; a system-wide error code otherwise.
431 @deprecated Use GetNearestFontToDesignHeightInTwips
433 virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
436 Gets the font which is the nearest to the given font specification.
438 When the font is no longer needed, call @c ReleaseFont().
440 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
441 same result. However clients are strongly encouraged to use the new
442 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
443 character within any given text string will fit within the given amount of twips, whereas the design
444 height is an aesthetic unit decided by the font designer without strict physical meaning, which
445 may result in cropped characters.
447 @param aFont On return, contains a pointer to the nearest font.
448 @param aFontSpec The specification of the font to be matched.
449 @return KErrNone if successful; a system-wide error code otherwise.
453 virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
456 Gets the font which is the nearest to the given font specification.
458 When the font is no longer needed, call @c ReleaseFont().
460 The font and bitmap server returns a pointer to the nearest matching font
461 from those available. Matches to max height of font - this does its best
462 to return a font that will fit within the maximum height specified (but
463 note that variations due to hinting algorithms may rarely result in this
464 height being exceeded by up to one pixel). Problems can also be
465 encountered with bitmap fonts where the typeface exists but doesn't have
468 @param aFont On return, contains a pointer to the nearest font.
469 @param aFontSpec The specification of the font to be matched.
470 @param aMaxHeight The maximum height within which the font must fit.
471 @return KErrNone if successful; a system-wide error code otherwise.
475 virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0;
477 /** Gets the number of typefaces supported by the typeface store.
479 @return The number of supported typefaces. */
480 virtual TInt NumTypefaces() const=0;
482 /** Gets typeface information for a specified typeface index.
484 This information is returned in aTypefaceSupport, and
485 includes the typeface name and typeface attributes, the number of font
486 heights, the maximum and minimum font heights, and whether it is a
489 @param aTypefaceSupport On return, if the function executed successfully,
490 this object contains the typeface information.
491 @param aTypefaceIndex A typeface index number, in the range: zero to
492 (NumTypefaces() - 1). */
493 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
495 /** Gets the height of the font with specified height and typeface indices,
498 The value returned is rounded up or down to the nearest font height in twips.
500 @param aTypefaceIndex A typeface index number, in the range: 0 to
501 (NumTypefaces() - 1).
502 @param aHeightIndex A font height index number.
503 @return The height of the font, in twips. */
504 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
505 IMPORT_C void ReleaseFont(CFont* aFont);
506 IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos);
507 IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos);
509 IMPORT_C CTypefaceStore();
510 IMPORT_C void ConstructL();
511 IMPORT_C void AddFontL(CFont* aFont);
512 IMPORT_C TBool IncrementFontCount(const CFont* aFont);
514 TBool FindFont(const CFont* aFont, TInt& aIdx) const;
515 NONSHARABLE_CLASS(TFontAccess)
517 Pairs a font with a count of how many clients of the typeface store
518 are accessing that font.
522 /** A device specific font. */
524 /** The number of clients accessing the font. */
528 /** A list of fonts accessed by clients of the typeface store, which pairs
529 a font with a count of the number of clients accessing the font.
531 Implemented as an array of TFontAccess objects.
533 An object is added to this array for every font accessed. If the font is
534 released by all clients, and the access count drops to zero, the font is
535 removed from the list. */
536 CArrayFixFlat<TFontAccess>* iFontAccess;
539 /** The maximum number of entries in the font cache.
542 const TInt KMaxFontCacheEntries=32;
546 When a CFont* needs to be found for a particular TFontSpec, the cache can
547 be searched to see if the TFontSpec is already in the cache. If the TFontSpec
548 is in the cache, its corresponding CFont* can be returned. Otherwise
549 GetNearestFontInTwips() must be used to search all of the available fonts for
550 the nearest CFont- a procedure which takes much longer than a simple cache
553 The current font cache should be destroyed and a new cache created whenever
554 the zoom factor or device map changes, as these changes break the relation
555 between CFont and TFontSpec.
559 class CFontCache : public CBase
562 IMPORT_C CFontCache();
563 IMPORT_C CFontCache(TInt aMaxEntries);
564 IMPORT_C ~CFontCache();
565 IMPORT_C CFont* Search(const TFontSpec& aFontSpec);
566 IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec);
567 IMPORT_C CFont* RemoveFirstEntry();
569 /** The number of cache hits since the font cache was created i.e.
570 successful results from CFontCache::Search(). */
572 /** The number of cache misses since the font cache was created i.e.
573 unsuccessful results from CFontCache::Search(). */
576 class CFontCacheEntry : public CBase
579 CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext);
583 CFontCacheEntry* iNext;
588 CFontCacheEntry* iFirst;
592 WARNING: this Class is for internal use ONLY. Compatibility is not guaranteed in future releases.
593 UIDs corresponding to the CFont API extension functions
596 const TUid KFontCapitalAscent = {0x1020498E};
597 const TUid KFontMaxAscent = {0x10204B10};
598 const TUid KFontStandardDescent = {0x10204B11};
599 const TUid KFontMaxDescent = {0x10205AFC};
600 const TUid KFontLineGap = {0x10204B12};
601 const TUid KFontGetFontTable = {0x102872C1};
602 const TUid KFontGetGlyphOutline = {0x102872C2};
603 const TUid KFontReleaseGlyphOutline = {0x2002A1FD};
604 const TUid KFontReleaseFontTable = {0x2002AC24};
607 /** Abstract font interface.
609 The CFont class provides a device-independent interface to a device-dependent
610 font usually obtained from a call to GetNearestFont...() on a graphics device.
611 It is used as a handle in CGraphicsContext::UseFont() and to obtain
612 device-dependent information about the font - notably the pixel width of a text
616 @see CGraphicsContext::UseFont()
620 class CFont : public CBase
622 friend class CTypefaceStore;
625 /** Text direction flags.
627 This enum is used in TMeasureTextInput and determines whether the text is
628 drawn horizontally or vertically. Note: text is drawn vertically in some
629 styles of Japanese, etc.
631 @see TMeasureTextInput */
634 /** Text is drawn horizontally. */
635 /** Text is drawn horizontally. */
637 /** Text is drawn vertically. */
641 /** Complicated parameter block used for contextual glyph selection,
642 ligature creation and diacritic placement when drawing text in complex
645 This class declares a constructor, another scoped class, and several other
646 enums. However this class is unlikely to be useful to third party developers.
648 @see CFont::GetCharacterPosition()
649 @see CFont::GetCharacterPosition2()
656 /** Standard constructor. */
658 iDirection(EHorizontal),
667 EMaxInputChars = 18, // ligatures cannot be made from more than 18 components
668 EMaxOutputGlyphs = 8 // output can consist of up to 8 characters (one base and 7 combining characters)
671 /**Flags for TPositionParam::iFlags. */
674 /** Input text is logically ordered not visually ordered. */
678 /** Input: Orientation (EHorizontal or EVertical) in which to draw
681 /** Input: Flags from TFlags. */
683 /** Input: Text containing the characters to be positioned. */
686 /** Input and output: Position within iText to shape. On exit
687 it will index the first character not positioned */
689 /** Input and output: Pen position. */
692 /** Output of GetCharacterPosition and GetCharacterPosition2.
693 @see CFont::GetCharacterPosition
694 @see CFont::GetCharacterPosition2
700 /** Standard constructor. */
701 TOutput() : iBitmapSize(TSize::EUninitialized),
702 iBounds(TRect::EUninitialized) {}
703 /** Character or glyph code. */
705 /** Bitmap data for the glyph, if available */
706 const TUint8* iBitmap;
707 /** Size of the bitmap before algorithmic bolding, size
708 multiplication, etc. */
710 /** Bitmap bounds relative to the original pen position. */
714 /** Information about the glyphs that were output. */
715 TOutput iOutput[EMaxOutputGlyphs];
716 /** Number of glyphs actually output. */
721 /** Input parameter block.
723 This is optionally used by CFont::MeasureText(), which is the powerful text
724 measurement function underlying all the other text measurement functions.
726 @see CFont::MeasureText()
730 class TMeasureTextInput
735 iEndInputChar(KMaxTInt),
736 iDirection(EHorizontal),
738 iMaxAdvance(KMaxTInt),
739 iMaxBounds(KMaxTInt),
747 /**Flags for TMeasureTextInput::iFlags. */
750 /** Input text is visually ordered left-to-right. */
752 /** Input text is visually ordered right-to-left.
753 Overrides EFVisualOrder. */
754 EFVisualOrderRightToLeft = 2,
755 /** Flag to consider side bearings when checking bounds for line-break */
756 EFIncludePenPositionInBoundsCheck = 4
759 /** Starting index specifying first input character in iText.
761 Together with iEndInputChar, this allows some context before and
762 after the measured text to be supplied so that shaping can work
764 TInt iStartInputChar;
766 /** Index specifying the final input character.
768 Together with iStartInputChar, this allows some context before and
769 after the measured text to be supplied so that shaping can work
773 /** The direction in which to draw the text. */
776 /** Flags from TFlags. */
779 /** The maximum advance. */
782 /** The maximum width (or height if drawing vertically) of bounds. */
785 /** The number of glyph groups to be letter-spaced. */
788 /** The amount of space to be used for letter spacing. */
789 TInt iCharJustExcess;
791 /** The number of spaces to be used for word spacing. */
794 /** The amount of space to be used for word spacing. */
795 TInt iWordJustExcess;
798 /** Output parameter block.
800 This is optionally used by CFont::MeasureText(), which is the powerful text
801 measurement function underlying all the other text measurement functions.
803 @see CFont::MeasureText()
807 class TMeasureTextOutput
810 /** The number of input characters that would be drawn.
812 This may be less than the length of the text if a maximum advance or bounding
813 box size is specified. */
815 /** The number of glyphs that would be drawn. */
817 /** The number of groups that would be drawn.
819 A group is a base glyph plus one or more combining characters. */
821 /** The number of word spaces (U+0020) that would be drawn. */
823 /** The bounding box of all the glyphs that would be drawn. */
825 /** The maximum width and height of any glyph. */
830 Data availability flags.
832 Some fonts like printer fonts may only have width information and can return
833 ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize
834 the rest of the data if necessary.
836 @see GetCharacterData()
840 enum TCharacterDataAvailability
842 /** No font information available. */
844 /** Width information only is available. */
846 /** All character data is available. */
851 // virtual functions have been made protected and public non-virtual ones
852 // added to convert CFont to a handle-body pattern. SC is kept throught the
853 // new functions and BC is kept by keeping the protected functions in the
854 // same place in the class, and therefore in the same place in the vtable
857 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
859 virtual TUid DoTypeUid() const=0;
862 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
864 virtual TInt DoHeightInPixels() const=0;
867 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
869 virtual TInt DoAscentInPixels() const=0;
870 IMPORT_C virtual TInt DoDescentInPixels() const;
873 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
875 virtual TInt DoCharWidthInPixels(TChar aChar) const=0;
878 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
880 virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0;
883 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
885 virtual TInt DoBaselineOffsetInPixels() const=0;
888 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
890 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0;
893 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
895 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0;
898 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
900 virtual TInt DoMaxCharWidthInPixels() const=0;
903 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
905 virtual TInt DoMaxNormalCharWidthInPixels() const=0;
908 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
910 virtual TFontSpec DoFontSpecInTwips() const=0;
913 IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
914 IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const;
915 IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
918 IMPORT_C virtual ~CFont();
921 inline TInt FontCapitalAscent() const;
922 inline TInt FontMaxAscent() const;
923 inline TInt FontStandardDescent() const;
924 inline TInt FontMaxDescent() const;
925 inline TInt FontLineGap() const;
926 inline TInt FontMaxHeight() const;
929 /** Gets run-time identity of the actual font type. This enables safe casting to
932 For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid.
933 You would need to cast to a CFbsFont to get a character bounding box. Similarly,
934 a CBitmapFont returns KCBitmapFontUidVal.
936 @return The font-type identifier. */
937 IMPORT_C TUid TypeUid() const;
939 /** Gets the font height in pixels.
940 Note that this deprecated function is replaced by the new @c FontMaxHeight().
942 @return The font height in pixels.
945 IMPORT_C TInt HeightInPixels() const;
947 /** Gets the font ascent in pixels.
948 Note that this deprecated function is replaced by the new @c FontMaxAscent()
949 or in some cases @c FontCapitalAscent().
951 @return The font ascent in pixels.
952 @see FontCapitalAscent()
955 IMPORT_C TInt AscentInPixels() const;
957 /** Gets the font descent in pixels.
958 Note that this deprecated function is replaced by the new @c FontMaxDescent()
959 or in some cases @c FontStandardDescent().
961 @return The font descent in pixels.
962 @see FontStandardDescent()
963 @see FontMaxDescent()
965 IMPORT_C TInt DescentInPixels() const;
967 /** Gets the width in pixels in this font of the specified character.
969 Note: For OpenType fonts this function returns the horizontal advance of
970 the character, which may be different from the actual width.
972 @param aChar The character whose width should be determined.
973 @return The width in pixels of the specified character in this font. */
974 IMPORT_C TInt CharWidthInPixels(TChar aChar) const;
976 /** Gets the width in pixels of the specified descriptor when displayed in this
979 @param aText The descriptor whose width should be determined.
980 @return The width of the specified descriptor when displayed in this font,
982 IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const;
984 /** Gets the baseline offset in pixels.
986 The baseline offset is how far a font is raised or lowered from its normal
989 @return Offset from normal baseline, in pixels. */
990 IMPORT_C TInt BaselineOffsetInPixels() const;
992 /** Gets how much of the specified descriptor can be displayed in this font without
993 exceeding the specified width.
997 This function does not display any of the descriptor itself - it is used
998 before display, to test whether the whole descriptor can be displayed.
1000 @param aText The descriptor.
1001 @param aWidthInPixels The available width for character display.
1002 @return The number of characters which will be able to be displayed without
1003 exceeding the specified width. The count starts from the beginning of the
1005 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const;
1007 /** Gets how much of the specified descriptor can be displayed in this font without
1008 exceeding the specified width.
1010 It also returns the excess width - defined as the specified available width
1011 minus the width of the portion of the descriptor which can be displayed without
1012 exceeding the available width.
1014 @param aText The descriptor.
1015 @param aWidthInPixels The available width for character display.
1016 @param aExcessWidthInPixels The excess width after displaying the portion of
1017 the descriptor, in pixels.
1018 @return The number of characters which will be able to be displayed without
1019 exceeding the specified width. The count starts from the beginning of the
1021 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
1023 /** Gets the width in pixels of the widest character in this font.
1025 @return The width of the maximum width character, in pixels. */
1026 IMPORT_C TInt MaxCharWidthInPixels() const;
1028 /** Gets the width in pixels of the widest normal character in this font.
1030 Normal characters include all character in a character set except non-alphabetic
1031 characters (e.g. the copyright symbol, or a block graphics symbol, for example).
1033 @return The width of the maximum width normal character, in pixels. */
1034 IMPORT_C TInt MaxNormalCharWidthInPixels() const;
1036 /** Gets the font specification of this font in twips.
1038 @return The font specification of this font (in twips). */
1039 IMPORT_C TFontSpec FontSpecInTwips() const;
1040 IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
1041 IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const;
1042 IMPORT_C TInt WidthZeroInPixels() const;
1043 IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const;
1044 IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
1045 IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1046 IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const;
1048 /** Gets the width in pixels of the specified descriptor when displayed in this
1051 @param aText The descriptor whose width should be determined.
1052 @param aParam Parameter block that controls how much of aText is measured
1053 @return The width of the specified descriptor when displayed in this font,
1055 IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
1059 // inline functions from original gdi.inl
1060 /** Gets the ascent of an ANSI capital letter in the font whether or not
1061 there are any ANSI capitals in the font.
1062 @return The positive distance from the font baseline to the top of a
1063 standard ANSI capital letter
1067 inline TInt CFont::FontCapitalAscent() const
1069 return ExtendedFunction(KFontCapitalAscent);
1072 /** Gets the max ascent of any pre-composed glyph in the font. This will
1073 include accents or diacritics that form part of pre-composed glyphs. It is
1074 not guaranteed to cover the max ascent of composite glyphs that have to be
1075 created by a layout engine. This is also the recommended distance between
1076 the top of a text box and the baseline of the first line of text.
1077 @return The positive distance from the font baseline to the top of the
1078 highest pre-composed glyph (including accents) above the baseline
1082 inline TInt CFont::FontMaxAscent() const
1084 return ExtendedFunction(KFontMaxAscent);
1087 /** Gets the descent of an ANSI descending character in the font.
1088 Whether or not there are any ANSI descenders in the font.
1089 @return The positive distance from the font baseline to the bottom of the
1090 lowest ANSI descender
1094 inline TInt CFont::FontStandardDescent() const
1096 return ExtendedFunction(KFontStandardDescent);
1099 /** Gets the max descent of any pre-composed glyph in the font. This will
1100 include accents or diacritics that form part of pre-composed glyphs. It is
1101 not guaranteed to cover the max descent of composite glyphs that have to be
1102 created by a layout engine.
1103 @return The positive distance from the font baseline to the bottom of the
1104 lowest pre-composed glyph (including accents) below the baseline
1108 inline TInt CFont::FontMaxDescent() const
1110 return ExtendedFunction(KFontMaxDescent);
1113 /** Gets the suggested line gap for the font. This is the recommended
1114 baseline to baseline distance between successive lines of text in the font.
1115 @return The positive recommended gap between successive lines
1119 inline TInt CFont::FontLineGap() const
1121 return ExtendedFunction(KFontLineGap);
1125 Gets the (positive) maximum height in pixels of the font.
1126 This may differ from the design height.
1128 @return The maximum height of the font.
1132 inline TInt CFont::FontMaxHeight() const
1134 return FontMaxAscent() + FontMaxDescent();
1138 // from original gdistruct.h
1140 Structure used to pass input/output parameters between RFontTable and CFbsFont.
1143 class TGetFontTableParam
1152 Structure used to pass input/output parameters between RGlyphOutlineIterator and CFbsFont.
1153 Used when opening an outline iterator.
1156 class TGetGlyphOutlineParam
1160 const TUint *iCodes;
1167 Structure used to pass input/output parameters between RGlyphOutlineIterator and CFbsFont.
1168 Used when closing an outline iterator.
1171 class TReleaseGlyphOutlineParam
1175 const TUint *iCodes;
1180 #endif // __TEXTBASE_H__