510 EStrikethroughOff, |
473 EStrikethroughOff, |
511 /** Font is struck-through. */ |
474 /** Font is struck-through. */ |
512 EStrikethroughOn |
475 EStrikethroughOn |
513 }; |
476 }; |
514 |
477 |
515 /** |
478 |
516 The maximum length of a typeface name (in characters). |
479 // These types are moved from Gdi.h to TextBase.h. |
517 @publishedAll |
480 // const KMaxTypefaceNameLength |
518 @released |
481 // class TTypeface |
519 */ |
482 // enum TGlyphBitmapType |
520 const TInt KMaxTypefaceNameLength=0x18; |
483 // class FontEffect |
521 |
484 // class TFontStyle |
522 |
485 // class TFontSpec |
523 /** Typeface name and attributes. |
486 // class TTypefaceSupport |
524 |
487 // const KSuperSubScalingPercentage |
525 This class identifies a typeface by name, and contains the combination of |
488 // const KSuperscriptOffsetPercentage |
526 attributes of the typeface. These attributes define whether it is a symbol |
489 // const KSubscriptOffsetPercentage |
527 typeface, whether the typeface is proportional, and whether it is serif or |
490 // class CTypefaceStore |
528 sans-serif. |
491 // const KMaxFontCacheEntries |
529 |
492 // class CFontCache |
530 The combination of attributes for a typeface are stored in a bitmask, with |
493 |
531 the various bits indicating different attributes. The bitmask is calculated |
|
532 for any particular attribute combination by ORing the enumerated value for |
|
533 each individual attribute. |
|
534 @publishedAll |
|
535 @released |
|
536 */ |
|
537 class TTypeface |
|
538 { |
|
539 public: |
|
540 enum |
|
541 { |
|
542 /** Typeface is a proportional typeface (e.g. Swiss) |
|
543 */ |
|
544 EProportional = 1, |
|
545 /** Typeface is a serif typeface (e.g. Times) |
|
546 */ |
|
547 ESerif = 2, |
|
548 /** Typeface is a symbol typeface (e.g. Symbol) |
|
549 */ |
|
550 ESymbol = 4, |
|
551 }; |
|
552 public: |
|
553 IMPORT_C TTypeface(); |
|
554 IMPORT_C TBool operator==(const TTypeface& aTypeface) const; |
|
555 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
556 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
557 IMPORT_C void SetAttributes(TInt aAttributes); |
|
558 IMPORT_C void SetIsProportional(TBool aIsProportional); |
|
559 IMPORT_C void SetIsSerif(TBool aIsSerif); |
|
560 IMPORT_C void SetIsSymbol(TBool aIsSymbol); |
|
561 IMPORT_C TInt Attributes() const; |
|
562 IMPORT_C TBool IsProportional() const; |
|
563 IMPORT_C TBool IsSerif() const; |
|
564 IMPORT_C TBool IsSymbol() const; |
|
565 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage); |
|
566 IMPORT_C void SetScriptTypeForMetrics(TInt aScript); |
|
567 IMPORT_C TInt ScriptTypeForMetrics() const; |
|
568 IMPORT_C void SetName(const TDesC& aName); |
|
569 IMPORT_C const TDesC& Name() const; |
|
570 private: |
|
571 void ResetAttributes(); |
|
572 void ResetScriptType(); |
|
573 public: |
|
574 /** The typeface name. */ |
|
575 TBufC<KMaxTypefaceNameLength> iName; |
|
576 private: |
|
577 TUint32 iFlags; |
|
578 }; |
|
579 |
|
580 |
|
581 /** |
|
582 An enumerated type for the format of a glyph bitmap. This type is currently |
|
583 used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased. |
|
584 Additional values may be defined in the future. |
|
585 |
|
586 @see TFontStyle::SetBitmapType() |
|
587 @see CFbsTypefaceStore::SetDefaultBitmapType() |
|
588 @publishedAll |
|
589 @released |
|
590 */ |
|
591 enum TGlyphBitmapType |
|
592 { |
|
593 /** The font store's default glyph bitmap format is used. */ |
|
594 EDefaultGlyphBitmap = 0, |
|
595 /** The standard monochrome format: no anti-aliasing, 1 bit per pixel, |
|
596 run-length encoded. */ |
|
597 EMonochromeGlyphBitmap, |
|
598 /** Standard 8-bits-per-pixel with anti-aliasing. */ |
|
599 EAntiAliasedGlyphBitmap, |
|
600 /** The format used when sub-pixel font rendering is used. */ |
|
601 ESubPixelGlyphBitmap, |
|
602 /** The format used when outline and shadow font rendering is used. |
|
603 |
|
604 If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as |
|
605 EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and |
|
606 when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum. |
|
607 */ |
|
608 EFourColourBlendGlyphBitmap, |
|
609 /** |
|
610 This is used for glyphs, and not fonts, and is needed to inform the font drawing routines |
|
611 that the character should be drawn using the overall font setting. |
|
612 For Internal Use Only. |
|
613 */ |
|
614 EGlyphBitmapTypeNotDefined, |
|
615 /** |
|
616 This is used to inform the rasterizer that the best match should be |
|
617 found for the bitmap type based upon its knowledge. |
|
618 For Internal Use Only. |
|
619 */ |
|
620 EAntiAliasedOrMonochromeGlyphBitmap, |
|
621 }; |
|
622 |
|
623 /** |
|
624 Defines a set of font effects flags. |
|
625 |
|
626 @publishedAll |
|
627 @released |
|
628 WARNING: This Class is for use by system/UI software ONLY. |
|
629 */ |
|
630 NONSHARABLE_CLASS(FontEffect) |
|
631 { |
|
632 public: |
|
633 enum TEffect |
|
634 { |
|
635 ENone = 0x0, // No effects. |
|
636 EAlgorithmicBold= 0x10, // Font is algorithmic bold (a.k.a pseudo bold.) |
|
637 EDropShadow = 0x20, // Font has a drop shadow. |
|
638 EOutline = 0x40, // Font is an outline font. |
|
639 EEmbossed = 0x80, // Font is embossed. |
|
640 EEngraved = 0x100, // Font is engraved. |
|
641 ESoftEdge = 0x200, // Font is soft edged. |
|
642 EReserved1 = 0x400, // Reserved for Symbian use. |
|
643 EReserved2 = 0x800, // Reserved for Symbian use. |
|
644 EReserved3 = 0x1000, // Reserved for Symbian use. |
|
645 EReserved4 = 0x2000, // Reserved for Symbian use. |
|
646 EReserved5 = 0x4000, // Reserved for Symbian use. |
|
647 EReserved6 = 0x8000, // Reserved for Symbian use. |
|
648 }; |
|
649 public: |
|
650 IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect); |
|
651 IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect); |
|
652 }; |
|
653 |
|
654 /** Encapsulates a font style. |
|
655 |
|
656 The font style information is comprised of: |
|
657 |
|
658 the posture of the font upright or italic |
|
659 |
|
660 the stroke weight of the font normal or bold |
|
661 |
|
662 the print position of the font normal, subscript or superscript |
|
663 |
|
664 Note that the underline and strike-through attributes are not included in |
|
665 this class, but are set in the graphics context. |
|
666 |
|
667 @see CGraphicsContext::SetUnderlineStyle() |
|
668 @see CGraphicsContext::SetStrikethroughStyle() |
|
669 @publishedAll |
|
670 @released |
|
671 */ |
|
672 class TFontStyle |
|
673 { |
|
674 public: |
|
675 IMPORT_C TFontStyle(); |
|
676 IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos); |
|
677 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
678 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
679 IMPORT_C TFontPosture Posture() const; |
|
680 IMPORT_C TFontStrokeWeight StrokeWeight() const; |
|
681 IMPORT_C TFontPrintPosition PrintPosition() const; |
|
682 IMPORT_C void SetPosture(TFontPosture aPosture); |
|
683 IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight); |
|
684 IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition); |
|
685 inline TGlyphBitmapType BitmapType() const; |
|
686 inline void SetBitmapType(TGlyphBitmapType aBitmapType); |
|
687 IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const; |
|
688 IMPORT_C TUint32 Effects() const; |
|
689 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const; |
|
690 IMPORT_C void SetEffects(TUint32 aEffects); |
|
691 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn); |
|
692 private: |
|
693 enum |
|
694 { |
|
695 EItalic=0x1, |
|
696 EBold=0x2, |
|
697 ESuper=0x4, |
|
698 ESub=0x8 |
|
699 }; |
|
700 private: |
|
701 TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low) |
|
702 TAny* iReserved1; |
|
703 TAny* iReserved2; |
|
704 }; |
|
705 |
|
706 |
|
707 |
|
708 /** |
|
709 Specifies the font specification in device independent terms. |
|
710 @publishedAll |
|
711 @released |
|
712 */ |
|
713 class TFontSpec |
|
714 { |
|
715 public: |
|
716 IMPORT_C TFontSpec(); |
|
717 IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight); |
|
718 IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const; |
|
719 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
720 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
721 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage); |
|
722 IMPORT_C TInt ScriptTypeForMetrics() const; |
|
723 public: |
|
724 /** The typeface. */ |
|
725 TTypeface iTypeface; |
|
726 /** The height of the typeface (in twips). */ |
|
727 TInt iHeight; |
|
728 /** The font style of the typeface. */ |
|
729 TFontStyle iFontStyle; |
|
730 }; |
|
731 |
|
732 |
|
733 |
|
734 /** Typeface family support information. |
|
735 |
|
736 This data-only class includes the name and attributes of a typeface, how many |
|
737 font heights are available, its minimum and maximum heights, and whether or |
|
738 not it is scaleable a typeface is scaleable if it supports heights at |
|
739 fixed intervals between the minimum and maximum heights. |
|
740 @publishedAll |
|
741 @released |
|
742 */ |
|
743 class TTypefaceSupport |
|
744 { |
|
745 public: |
|
746 /** The name and attributes of the typeface. */ |
|
747 TTypeface iTypeface; |
|
748 /** The number of distinct font heights available in the typeface. */ |
|
749 TInt iNumHeights; |
|
750 /** The typeface's minimum font height, in twips. */ |
|
751 TInt iMinHeightInTwips; |
|
752 /** The typeface's maximum font height, in twips. */ |
|
753 TInt iMaxHeightInTwips; |
|
754 /** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise |
|
755 EFalse. */ |
|
756 TBool iIsScalable; // supports heights from min to max at fixed interval |
|
757 }; |
|
758 |
|
759 /** |
|
760 The percentage used to multiply a normal font height when calculating its |
|
761 superscript or subscript height. |
|
762 @publishedAll |
|
763 @released |
|
764 */ |
|
765 const TInt KSuperSubScalingPercentage=67; |
|
766 |
|
767 /** |
|
768 The percentage of a font height used to calculate its baseline offset for a |
|
769 superscript print position. |
|
770 @publishedAll |
|
771 @released |
|
772 */ |
|
773 const TInt KSuperscriptOffsetPercentage=-28; |
|
774 |
|
775 /** |
|
776 The percentage of a font height used to calculate its baseline offset for a |
|
777 subscript print position. |
|
778 @publishedAll |
|
779 @released |
|
780 */ |
|
781 const TInt KSubscriptOffsetPercentage=14; |
|
782 |
|
783 class CFont; |
|
784 |
|
785 /** Typeface store abstract base interface. |
|
786 |
|
787 This class provides the interface to a store for typefaces. |
|
788 |
|
789 See also CFontStore. |
|
790 @publishedAll |
|
791 @released |
|
792 */ |
|
793 class CTypefaceStore : public CBase |
|
794 { |
|
795 public: |
|
796 IMPORT_C ~CTypefaceStore(); |
|
797 |
|
798 /** |
|
799 Gets the font which is the nearest to the given font specification. |
|
800 |
|
801 When the font is no longer needed, call @c ReleaseFont(). |
|
802 |
|
803 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() |
|
804 yielding (virtually) the same result. However clients are strongly encouraged to use the new |
|
805 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every |
|
806 character within any given text string will fit within the given amount of twips, whereas the design |
|
807 height is an aesthetic unit decided by the font designer without strict physical meaning, which |
|
808 may result in cropped characters. |
|
809 |
|
810 @param aFont On return, contains a pointer to the nearest font. |
|
811 @param aFontSpec The specification of the font to be matched. |
|
812 @return KErrNone if successful; a system-wide error code otherwise. |
|
813 @publishedAll |
|
814 @deprecated Use GetNearestFontToDesignHeightInTwips |
|
815 */ |
|
816 virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0; |
|
817 |
|
818 /** |
|
819 Gets the font which is the nearest to the given font specification. |
|
820 |
|
821 When the font is no longer needed, call @c ReleaseFont(). |
|
822 |
|
823 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the |
|
824 same result. However clients are strongly encouraged to use the new |
|
825 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every |
|
826 character within any given text string will fit within the given amount of twips, whereas the design |
|
827 height is an aesthetic unit decided by the font designer without strict physical meaning, which |
|
828 may result in cropped characters. |
|
829 |
|
830 @param aFont On return, contains a pointer to the nearest font. |
|
831 @param aFontSpec The specification of the font to be matched. |
|
832 @return KErrNone if successful; a system-wide error code otherwise. |
|
833 @publishedAll |
|
834 @released |
|
835 */ |
|
836 virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0; |
|
837 |
|
838 /** |
|
839 Gets the font which is the nearest to the given font specification. |
|
840 |
|
841 When the font is no longer needed, call @c ReleaseFont(). |
|
842 |
|
843 The font and bitmap server returns a pointer to the nearest matching font |
|
844 from those available. Matches to max height of font - this does its best |
|
845 to return a font that will fit within the maximum height specified (but |
|
846 note that variations due to hinting algorithms may rarely result in this |
|
847 height being exceeded by up to one pixel). Problems can also be |
|
848 encountered with bitmap fonts where the typeface exists but doesn't have |
|
849 a font small enough. |
|
850 |
|
851 @param aFont On return, contains a pointer to the nearest font. |
|
852 @param aFontSpec The specification of the font to be matched. |
|
853 @param aMaxHeight The maximum height within which the font must fit. |
|
854 @return KErrNone if successful; a system-wide error code otherwise. |
|
855 @publishedAll |
|
856 @released |
|
857 */ |
|
858 virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0; |
|
859 |
|
860 /** Gets the number of typefaces supported by the typeface store. |
|
861 |
|
862 @return The number of supported typefaces. */ |
|
863 virtual TInt NumTypefaces() const=0; |
|
864 |
|
865 /** Gets typeface information for a specified typeface index. |
|
866 |
|
867 This information is returned in aTypefaceSupport, and |
|
868 includes the typeface name and typeface attributes, the number of font |
|
869 heights, the maximum and minimum font heights, and whether it is a |
|
870 scaleable typeface. |
|
871 |
|
872 @param aTypefaceSupport On return, if the function executed successfully, |
|
873 this object contains the typeface information. |
|
874 @param aTypefaceIndex A typeface index number, in the range: zero to |
|
875 (NumTypefaces() - 1). */ |
|
876 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0; |
|
877 |
|
878 /** Gets the height of the font with specified height and typeface indices, |
|
879 in twips. |
|
880 |
|
881 The value returned is rounded up or down to the nearest font height in twips. |
|
882 |
|
883 @param aTypefaceIndex A typeface index number, in the range: 0 to |
|
884 (NumTypefaces() - 1). |
|
885 @param aHeightIndex A font height index number. |
|
886 @return The height of the font, in twips. */ |
|
887 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0; |
|
888 IMPORT_C void ReleaseFont(CFont* aFont); |
|
889 IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos); |
|
890 IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos); |
|
891 protected: |
|
892 IMPORT_C CTypefaceStore(); |
|
893 IMPORT_C void ConstructL(); |
|
894 IMPORT_C void AddFontL(CFont* aFont); |
|
895 IMPORT_C TBool IncrementFontCount(const CFont* aFont); |
|
896 private: |
|
897 TBool FindFont(const CFont* aFont, TInt& aIdx) const; |
|
898 NONSHARABLE_CLASS(TFontAccess) |
|
899 /** |
|
900 Pairs a font with a count of how many clients of the typeface store |
|
901 are accessing that font. |
|
902 */ |
|
903 { |
|
904 public: |
|
905 /** A device specific font. */ |
|
906 CFont* iFont; |
|
907 /** The number of clients accessing the font. */ |
|
908 TInt iAccessCount; |
|
909 }; |
|
910 protected: |
|
911 /** A list of fonts accessed by clients of the typeface store, which pairs |
|
912 a font with a count of the number of clients accessing the font. |
|
913 |
|
914 Implemented as an array of TFontAccess objects. |
|
915 |
|
916 An object is added to this array for every font accessed. If the font is |
|
917 released by all clients, and the access count drops to zero, the font is |
|
918 removed from the list. */ |
|
919 CArrayFixFlat<TFontAccess>* iFontAccess; |
|
920 }; |
|
921 |
|
922 /** The maximum number of entries in the font cache. |
|
923 |
|
924 @see CFontCache */ |
|
925 const TInt KMaxFontCacheEntries=32; |
|
926 |
|
927 /** Font cache. |
|
928 |
|
929 When a CFont* needs to be found for a particular TFontSpec, the cache can |
|
930 be searched to see if the TFontSpec is already in the cache. If the TFontSpec |
|
931 is in the cache, its corresponding CFont* can be returned. Otherwise |
|
932 GetNearestFontInTwips() must be used to search all of the available fonts for |
|
933 the nearest CFont- a procedure which takes much longer than a simple cache |
|
934 search. |
|
935 |
|
936 The current font cache should be destroyed and a new cache created whenever |
|
937 the zoom factor or device map changes, as these changes break the relation |
|
938 between CFont and TFontSpec. |
|
939 @publishedAll |
|
940 @released |
|
941 */ |
|
942 class CFontCache : public CBase |
|
943 { |
|
944 public: |
|
945 IMPORT_C CFontCache(); |
|
946 IMPORT_C CFontCache(TInt aMaxEntries); |
|
947 IMPORT_C ~CFontCache(); |
|
948 IMPORT_C CFont* Search(const TFontSpec& aFontSpec); |
|
949 IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec); |
|
950 IMPORT_C CFont* RemoveFirstEntry(); |
|
951 public: |
|
952 /** The number of cache hits since the font cache was created i.e. |
|
953 successful results from CFontCache::Search(). */ |
|
954 TInt iNumHits; |
|
955 /** The number of cache misses since the font cache was created i.e. |
|
956 unsuccessful results from CFontCache::Search(). */ |
|
957 TInt iNumMisses; |
|
958 private: |
|
959 class CFontCacheEntry : public CBase |
|
960 { |
|
961 public: |
|
962 CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext); |
|
963 public: |
|
964 CFont* iFont; |
|
965 TFontSpec iSpec; |
|
966 CFontCacheEntry* iNext; |
|
967 }; |
|
968 private: |
|
969 TInt iNumEntries; |
|
970 TInt iMaxEntries; |
|
971 CFontCacheEntry* iFirst; |
|
972 }; |
|
973 |
494 |
974 /** Interface class for mapping between twips and device-specific units (pixels). |
495 /** Interface class for mapping between twips and device-specific units (pixels). |
975 |
496 |
976 TZoomFactor is derived from MGraphicsDeviceMap. |
497 TZoomFactor is derived from MGraphicsDeviceMap. |
977 |
498 |
1217 TInt iStart; |
738 TInt iStart; |
1218 /** The end of the range. */ |
739 /** The end of the range. */ |
1219 TInt iEnd; |
740 TInt iEnd; |
1220 }; |
741 }; |
1221 |
742 |
1222 /** |
743 // These types/consts are moved from Gdi.h to TextBase.h. |
1223 WARNING: this Class is for internal use ONLY. Compatibility is not guaranteed in future releases. |
744 // const TUid KFontCapitalAscent |
1224 UIDs corresponding to the CFont API extension functions |
745 // const TUid KFontMaxAscent |
1225 @internalTechnology |
746 // const TUid KFontStandardDescent |
1226 */ |
747 // const TUid KFontMaxDescent |
1227 const TUid KFontCapitalAscent = {0x1020498E}; |
748 // const TUid KFontLineGap |
1228 const TUid KFontMaxAscent = {0x10204B10}; |
749 // const TUid KFontGetFontTable |
1229 const TUid KFontStandardDescent = {0x10204B11}; |
750 // const TUid KFontGetGlyphOutline |
1230 const TUid KFontMaxDescent = {0x10205AFC}; |
751 // const TUid KFontReleaseGlyphOutline |
1231 const TUid KFontLineGap = {0x10204B12}; |
752 // const TUid KFontReleaseFontTable |
1232 const TUid KFontGetFontTable = {0x102872C1}; |
753 // class CFont |
1233 const TUid KFontGetGlyphOutline = {0x102872C2}; |
|
1234 const TUid KFontReleaseGlyphOutline = {0x2002A1FD}; |
|
1235 const TUid KFontReleaseFontTable = {0x2002AC24}; |
|
1236 |
|
1237 |
|
1238 /** Abstract font interface. |
|
1239 |
|
1240 The CFont class provides a device-independent interface to a device-dependent |
|
1241 font usually obtained from a call to GetNearestFont...() on a graphics device. |
|
1242 It is used as a handle in CGraphicsContext::UseFont() and to obtain |
|
1243 device-dependent information about the font - notably the pixel width of a text |
|
1244 string. |
|
1245 |
|
1246 @see CFbsFont |
|
1247 @see CGraphicsContext::UseFont() |
|
1248 @publishedAll |
|
1249 @released |
|
1250 */ |
|
1251 class CFont : public CBase |
|
1252 { |
|
1253 friend class CTypefaceStore; |
|
1254 public: |
|
1255 |
|
1256 /** Text direction flags. |
|
1257 |
|
1258 This enum is used in TMeasureTextInput and determines whether the text is |
|
1259 drawn horizontally or vertically. Note: text is drawn vertically in some |
|
1260 styles of Japanese, etc. |
|
1261 |
|
1262 @see TMeasureTextInput */ |
|
1263 enum TTextDirection |
|
1264 { |
|
1265 /** Text is drawn horizontally. */ |
|
1266 /** Text is drawn horizontally. */ |
|
1267 EHorizontal, |
|
1268 /** Text is drawn vertically. */ |
|
1269 EVertical |
|
1270 }; |
|
1271 |
|
1272 /** Complicated parameter block used for contextual glyph selection, |
|
1273 ligature creation and diacritic placement when drawing text in complex |
|
1274 scripts |
|
1275 |
|
1276 This class declares a constructor, another scoped class, and several other |
|
1277 enums. However this class is unlikely to be useful to third party developers. |
|
1278 |
|
1279 @see CFont::GetCharacterPosition() |
|
1280 @see CFont::GetCharacterPosition2() |
|
1281 @publishedAll |
|
1282 @released |
|
1283 */ |
|
1284 class TPositionParam |
|
1285 { |
|
1286 public: |
|
1287 /** Standard constructor. */ |
|
1288 TPositionParam(): |
|
1289 iDirection(EHorizontal), |
|
1290 iFlags(0), |
|
1291 iPosInText(0), |
|
1292 iOutputGlyphs(0) |
|
1293 { |
|
1294 } |
|
1295 |
|
1296 enum |
|
1297 { |
|
1298 EMaxInputChars = 18, // ligatures cannot be made from more than 18 components |
|
1299 EMaxOutputGlyphs = 8 // output can consist of up to 8 characters (one base and 7 combining characters) |
|
1300 }; |
|
1301 |
|
1302 /**Flags for TPositionParam::iFlags. */ |
|
1303 enum TFlags |
|
1304 { |
|
1305 /** Input text is logically ordered not visually ordered. */ |
|
1306 EFLogicalOrder = 1 |
|
1307 }; |
|
1308 |
|
1309 /** Input: Orientation (EHorizontal or EVertical) in which to draw |
|
1310 the text. */ |
|
1311 TInt16 iDirection; |
|
1312 /** Input: Flags from TFlags. */ |
|
1313 TUint16 iFlags; |
|
1314 /** Input: Text containing the characters to be positioned. */ |
|
1315 TPtrC iText; |
|
1316 |
|
1317 /** Input and output: Position within iText to shape. On exit |
|
1318 it will index the first character not positioned */ |
|
1319 TInt iPosInText; |
|
1320 /** Input and output: Pen position. */ |
|
1321 TPoint iPen; |
|
1322 |
|
1323 /** Output of GetCharacterPosition and GetCharacterPosition2. |
|
1324 @see CFont::GetCharacterPosition |
|
1325 @see CFont::GetCharacterPosition2 |
|
1326 @publishedAll |
|
1327 @released */ |
|
1328 class TOutput |
|
1329 { |
|
1330 public: |
|
1331 /** Standard constructor. */ |
|
1332 TOutput() : iBitmapSize(TSize::EUninitialized), |
|
1333 iBounds(TRect::EUninitialized) {} |
|
1334 /** Character or glyph code. */ |
|
1335 TUint iCode; |
|
1336 /** Bitmap data for the glyph, if available */ |
|
1337 const TUint8* iBitmap; |
|
1338 /** Size of the bitmap before algorithmic bolding, size |
|
1339 multiplication, etc. */ |
|
1340 TSize iBitmapSize; |
|
1341 /** Bitmap bounds relative to the original pen position. */ |
|
1342 TRect iBounds; |
|
1343 }; |
|
1344 |
|
1345 /** Information about the glyphs that were output. */ |
|
1346 TOutput iOutput[EMaxOutputGlyphs]; |
|
1347 /** Number of glyphs actually output. */ |
|
1348 TInt iOutputGlyphs; |
|
1349 }; |
|
1350 |
|
1351 |
|
1352 /** Input parameter block. |
|
1353 |
|
1354 This is optionally used by CFont::MeasureText(), which is the powerful text |
|
1355 measurement function underlying all the other text measurement functions. |
|
1356 |
|
1357 @see CFont::MeasureText() |
|
1358 @publishedAll |
|
1359 @released |
|
1360 */ |
|
1361 class TMeasureTextInput |
|
1362 { |
|
1363 public: |
|
1364 TMeasureTextInput(): |
|
1365 iStartInputChar(0), |
|
1366 iEndInputChar(KMaxTInt), |
|
1367 iDirection(EHorizontal), |
|
1368 iFlags(0), |
|
1369 iMaxAdvance(KMaxTInt), |
|
1370 iMaxBounds(KMaxTInt), |
|
1371 iCharJustNum(0), |
|
1372 iCharJustExcess(0), |
|
1373 iWordJustNum(0), |
|
1374 iWordJustExcess(0) |
|
1375 { |
|
1376 } |
|
1377 |
|
1378 /**Flags for TMeasureTextInput::iFlags. */ |
|
1379 enum TFlags |
|
1380 { |
|
1381 /** Input text is visually ordered left-to-right. */ |
|
1382 EFVisualOrder = 1, |
|
1383 /** Input text is visually ordered right-to-left. |
|
1384 Overrides EFVisualOrder. */ |
|
1385 EFVisualOrderRightToLeft = 2, |
|
1386 /** Flag to consider side bearings when checking bounds for line-break */ |
|
1387 EFIncludePenPositionInBoundsCheck = 4 |
|
1388 }; |
|
1389 |
|
1390 /** Starting index specifying first input character in iText. |
|
1391 |
|
1392 Together with iEndInputChar, this allows some context before and |
|
1393 after the measured text to be supplied so that shaping can work |
|
1394 properly. */ |
|
1395 TInt iStartInputChar; |
|
1396 |
|
1397 /** Index specifying the final input character. |
|
1398 |
|
1399 Together with iStartInputChar, this allows some context before and |
|
1400 after the measured text to be supplied so that shaping can work |
|
1401 properly. */ |
|
1402 TInt iEndInputChar; |
|
1403 |
|
1404 /** The direction in which to draw the text. */ |
|
1405 TUint16 iDirection; |
|
1406 |
|
1407 /** Flags from TFlags. */ |
|
1408 TUint16 iFlags; |
|
1409 |
|
1410 /** The maximum advance. */ |
|
1411 TInt iMaxAdvance; |
|
1412 |
|
1413 /** The maximum width (or height if drawing vertically) of bounds. */ |
|
1414 TInt iMaxBounds; |
|
1415 |
|
1416 /** The number of glyph groups to be letter-spaced. */ |
|
1417 TInt iCharJustNum; |
|
1418 |
|
1419 /** The amount of space to be used for letter spacing. */ |
|
1420 TInt iCharJustExcess; |
|
1421 |
|
1422 /** The number of spaces to be used for word spacing. */ |
|
1423 TInt iWordJustNum; |
|
1424 |
|
1425 /** The amount of space to be used for word spacing. */ |
|
1426 TInt iWordJustExcess; |
|
1427 }; |
|
1428 |
|
1429 /** Output parameter block. |
|
1430 |
|
1431 This is optionally used by CFont::MeasureText(), which is the powerful text |
|
1432 measurement function underlying all the other text measurement functions. |
|
1433 |
|
1434 @see CFont::MeasureText() |
|
1435 @publishedAll |
|
1436 @released |
|
1437 */ |
|
1438 class TMeasureTextOutput |
|
1439 { |
|
1440 public: |
|
1441 /** The number of input characters that would be drawn. |
|
1442 |
|
1443 This may be less than the length of the text if a maximum advance or bounding |
|
1444 box size is specified. */ |
|
1445 TInt iChars; |
|
1446 /** The number of glyphs that would be drawn. */ |
|
1447 TInt iGlyphs; |
|
1448 /** The number of groups that would be drawn. |
|
1449 |
|
1450 A group is a base glyph plus one or more combining characters. */ |
|
1451 TInt iGroups; |
|
1452 /** The number of word spaces (U+0020) that would be drawn. */ |
|
1453 TInt iSpaces; |
|
1454 /** The bounding box of all the glyphs that would be drawn. */ |
|
1455 TRect iBounds; |
|
1456 /** The maximum width and height of any glyph. */ |
|
1457 TSize iMaxGlyphSize; |
|
1458 }; |
|
1459 |
|
1460 /** |
|
1461 Data availability flags. |
|
1462 |
|
1463 Some fonts like printer fonts may only have width information and can return |
|
1464 ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize |
|
1465 the rest of the data if necessary. |
|
1466 |
|
1467 @see GetCharacterData() |
|
1468 @publishedAll |
|
1469 @released |
|
1470 */ |
|
1471 enum TCharacterDataAvailability |
|
1472 { |
|
1473 /** No font information available. */ |
|
1474 ENoCharacterData, |
|
1475 /** Width information only is available. */ |
|
1476 ECharacterWidthOnly, |
|
1477 /** All character data is available. */ |
|
1478 EAllCharacterData |
|
1479 }; |
|
1480 |
|
1481 private: |
|
1482 // virtual functions have been made protected and public non-virtual ones |
|
1483 // added to convert CFont to a handle-body pattern. SC is kept throught the |
|
1484 // new functions and BC is kept by keeping the protected functions in the |
|
1485 // same place in the class, and therefore in the same place in the vtable |
|
1486 /** |
|
1487 @publishedAll |
|
1488 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1489 */ |
|
1490 virtual TUid DoTypeUid() const=0; |
|
1491 /** |
|
1492 @publishedAll |
|
1493 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1494 */ |
|
1495 virtual TInt DoHeightInPixels() const=0; |
|
1496 /** |
|
1497 @publishedAll |
|
1498 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1499 */ |
|
1500 virtual TInt DoAscentInPixels() const=0; |
|
1501 IMPORT_C virtual TInt DoDescentInPixels() const; |
|
1502 /** |
|
1503 @publishedAll |
|
1504 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1505 */ |
|
1506 virtual TInt DoCharWidthInPixels(TChar aChar) const=0; |
|
1507 /** |
|
1508 @publishedAll |
|
1509 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1510 */ |
|
1511 virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0; |
|
1512 /** |
|
1513 @publishedAll |
|
1514 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1515 */ |
|
1516 virtual TInt DoBaselineOffsetInPixels() const=0; |
|
1517 /** |
|
1518 @publishedAll |
|
1519 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1520 */ |
|
1521 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0; |
|
1522 /** |
|
1523 @publishedAll |
|
1524 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1525 */ |
|
1526 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0; |
|
1527 /** |
|
1528 @publishedAll |
|
1529 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1530 */ |
|
1531 virtual TInt DoMaxCharWidthInPixels() const=0; |
|
1532 /** |
|
1533 @publishedAll |
|
1534 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1535 */ |
|
1536 virtual TInt DoMaxNormalCharWidthInPixels() const=0; |
|
1537 /** |
|
1538 @publishedAll |
|
1539 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. |
|
1540 */ |
|
1541 virtual TFontSpec DoFontSpecInTwips() const=0; |
|
1542 |
|
1543 protected: |
|
1544 IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const; |
|
1545 IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const; |
|
1546 IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const; |
|
1547 |
|
1548 protected: |
|
1549 IMPORT_C virtual ~CFont(); |
|
1550 |
|
1551 public: |
|
1552 inline TInt FontCapitalAscent() const; |
|
1553 inline TInt FontMaxAscent() const; |
|
1554 inline TInt FontStandardDescent() const; |
|
1555 inline TInt FontMaxDescent() const; |
|
1556 inline TInt FontLineGap() const; |
|
1557 inline TInt FontMaxHeight() const; |
|
1558 |
|
1559 public: |
|
1560 /** Gets run-time identity of the actual font type. This enables safe casting to |
|
1561 a derived type. |
|
1562 |
|
1563 For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid. |
|
1564 You would need to cast to a CFbsFont to get a character bounding box. Similarly, |
|
1565 a CBitmapFont returns KCBitmapFontUidVal. |
|
1566 |
|
1567 @return The font-type identifier. */ |
|
1568 IMPORT_C TUid TypeUid() const; |
|
1569 |
|
1570 /** Gets the font height in pixels. |
|
1571 Note that this deprecated function is replaced by the new @c FontMaxHeight(). |
|
1572 |
|
1573 @return The font height in pixels. |
|
1574 @see FontMaxHeight() |
|
1575 @deprecated */ |
|
1576 IMPORT_C TInt HeightInPixels() const; |
|
1577 |
|
1578 /** Gets the font ascent in pixels. |
|
1579 Note that this deprecated function is replaced by the new @c FontMaxAscent() |
|
1580 or in some cases @c FontCapitalAscent(). |
|
1581 |
|
1582 @return The font ascent in pixels. |
|
1583 @see FontCapitalAscent() |
|
1584 @see FontMaxAscent() |
|
1585 @deprecated */ |
|
1586 IMPORT_C TInt AscentInPixels() const; |
|
1587 |
|
1588 /** Gets the font descent in pixels. |
|
1589 Note that this deprecated function is replaced by the new @c FontMaxDescent() |
|
1590 or in some cases @c FontStandardDescent(). |
|
1591 |
|
1592 @return The font descent in pixels. |
|
1593 @see FontStandardDescent() |
|
1594 @see FontMaxDescent() |
|
1595 @deprecated */ |
|
1596 IMPORT_C TInt DescentInPixels() const; |
|
1597 |
|
1598 /** Gets the width in pixels in this font of the specified character. |
|
1599 |
|
1600 Note: For OpenType fonts this function returns the horizontal advance of |
|
1601 the character, which may be different from the actual width. |
|
1602 |
|
1603 @param aChar The character whose width should be determined. |
|
1604 @return The width in pixels of the specified character in this font. */ |
|
1605 IMPORT_C TInt CharWidthInPixels(TChar aChar) const; |
|
1606 |
|
1607 /** Gets the width in pixels of the specified descriptor when displayed in this |
|
1608 font. |
|
1609 |
|
1610 @param aText The descriptor whose width should be determined. |
|
1611 @return The width of the specified descriptor when displayed in this font, |
|
1612 in pixels. */ |
|
1613 IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const; |
|
1614 |
|
1615 /** Gets the baseline offset in pixels. |
|
1616 |
|
1617 The baseline offset is how far a font is raised or lowered from its normal |
|
1618 baseline. |
|
1619 |
|
1620 @return Offset from normal baseline, in pixels. */ |
|
1621 IMPORT_C TInt BaselineOffsetInPixels() const; |
|
1622 |
|
1623 /** Gets how much of the specified descriptor can be displayed in this font without |
|
1624 exceeding the specified width. |
|
1625 |
|
1626 Note: |
|
1627 |
|
1628 This function does not display any of the descriptor itself - it is used |
|
1629 before display, to test whether the whole descriptor can be displayed. |
|
1630 |
|
1631 @param aText The descriptor. |
|
1632 @param aWidthInPixels The available width for character display. |
|
1633 @return The number of characters which will be able to be displayed without |
|
1634 exceeding the specified width. The count starts from the beginning of the |
|
1635 descriptor. */ |
|
1636 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const; |
|
1637 |
|
1638 /** Gets how much of the specified descriptor can be displayed in this font without |
|
1639 exceeding the specified width. |
|
1640 |
|
1641 It also returns the excess width - defined as the specified available width |
|
1642 minus the width of the portion of the descriptor which can be displayed without |
|
1643 exceeding the available width. |
|
1644 |
|
1645 @param aText The descriptor. |
|
1646 @param aWidthInPixels The available width for character display. |
|
1647 @param aExcessWidthInPixels The excess width after displaying the portion of |
|
1648 the descriptor, in pixels. |
|
1649 @return The number of characters which will be able to be displayed without |
|
1650 exceeding the specified width. The count starts from the beginning of the |
|
1651 descriptor. */ |
|
1652 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const; |
|
1653 |
|
1654 /** Gets the width in pixels of the widest character in this font. |
|
1655 |
|
1656 @return The width of the maximum width character, in pixels. */ |
|
1657 IMPORT_C TInt MaxCharWidthInPixels() const; |
|
1658 |
|
1659 /** Gets the width in pixels of the widest normal character in this font. |
|
1660 |
|
1661 Normal characters include all character in a character set except non-alphabetic |
|
1662 characters (e.g. the copyright symbol, or a block graphics symbol, for example). |
|
1663 |
|
1664 @return The width of the maximum width normal character, in pixels. */ |
|
1665 IMPORT_C TInt MaxNormalCharWidthInPixels() const; |
|
1666 |
|
1667 /** Gets the font specification of this font in twips. |
|
1668 |
|
1669 @return The font specification of this font (in twips). */ |
|
1670 IMPORT_C TFontSpec FontSpecInTwips() const; |
|
1671 IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const; |
|
1672 IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const; |
|
1673 IMPORT_C TInt WidthZeroInPixels() const; |
|
1674 IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const; |
|
1675 IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter); |
|
1676 IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const; |
|
1677 IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const; |
|
1678 |
|
1679 /** Gets the width in pixels of the specified descriptor when displayed in this |
|
1680 font. |
|
1681 |
|
1682 @param aText The descriptor whose width should be determined. |
|
1683 @param aParam Parameter block that controls how much of aText is measured |
|
1684 @return The width of the specified descriptor when displayed in this font, |
|
1685 in pixels. */ |
|
1686 IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const; |
|
1687 }; |
|
1688 |
754 |
1689 class CFbsBitmap; |
755 class CFbsBitmap; |
1690 class CWsBitmap; |
756 class CWsBitmap; |
1691 /** Abstract base class for all graphics contexts. |
757 /** Abstract base class for all graphics contexts. |
1692 |
758 |