1.1 --- a/epoc32/include/fntstore.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/fntstore.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,379 @@
1.4 -fntstore.h
1.5 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef FNTSTORE_H__
1.21 +#define FNTSTORE_H__
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <f32file.h>
1.25 +#include <gdi.h>
1.26 +#include <openfont.h>
1.27 +
1.28 +class CLinkedTypefaceSpecification;
1.29 +class CLinkedFontSpecification;
1.30 +class TLinkedTypefaceSpecArgs;
1.31 +class CFbClient;
1.32 +class CFontStoreFile;
1.33 +class CFontBitmap;
1.34 +class RReadStream;
1.35 +class TTypefaceFontBitmap;
1.36 +class TShapeHeader;
1.37 +class TShapeMessageParameters;
1.38 +class CTypefaceSupportInfo;
1.39 +
1.40 +
1.41 +/**
1.42 +@internalTechnology
1.43 +*/
1.44 +class TCharacterMetrics
1.45 + {
1.46 + public:
1.47 + IMPORT_C TCharacterMetrics();
1.48 +
1.49 + TInt16 iAscentInPixels;
1.50 + TInt16 iHeightInPixels;
1.51 + TInt16 iLeftAdjustInPixels;
1.52 + TInt16 iMoveInPixels;
1.53 + TInt16 iRightAdjustInPixels;
1.54 + };
1.55 +
1.56 +class TAlgStyle
1.57 +/**
1.58 +An algorithmic style for how a font is drawn.
1.59 +
1.60 +Holds attributes such as whether the font is bold or italic, and the width
1.61 +and height factors. This is used as an input parameter for the GetFontById() method
1.62 +of some font management classes. See CWsScreenDevice::GetFontById() for more information.
1.63 +@publishedAll
1.64 +@released
1.65 +@see CWsScreenDevice::GetFontById()
1.66 +@see CFbsTypefaceStore::GetFontById()
1.67 +@see CFbsDevice::GetFontById()
1.68 +*/
1.69 + {
1.70 +public:
1.71 + IMPORT_C TAlgStyle();
1.72 + IMPORT_C void SetIsBold(TBool aIsBold);
1.73 + IMPORT_C void SetIsItalic(TBool aIsItalic);
1.74 + IMPORT_C void SetIsMono(TBool aIsMono);
1.75 + IMPORT_C void SetWidthFactor(TInt aWidthFactor);
1.76 + IMPORT_C void SetHeightFactor(TInt aHeightFactor);
1.77 + IMPORT_C TBool IsBold() const;
1.78 + IMPORT_C TBool IsItalic() const;
1.79 + IMPORT_C TBool IsMono() const;
1.80 + IMPORT_C TInt WidthFactor() const;
1.81 + IMPORT_C TInt HeightFactor() const;
1.82 + IMPORT_C TBool operator==(const TAlgStyle& aAlgStyle) const;
1.83 + TBool operator!=(const TAlgStyle& aAlgStyle) const;
1.84 +public:
1.85 + /** Baseline offset in pixels. */
1.86 + TInt iBaselineOffsetInPixels;
1.87 +private:
1.88 + enum
1.89 + {
1.90 + EBold=1,
1.91 + EItalic=2,
1.92 + EMono=4,
1.93 + };
1.94 + /** This member is private and not intended for use. */
1.95 + TInt8 iFlags;
1.96 + /** This member is private and not intended for use. */
1.97 + TInt8 iWidthFactor;
1.98 + /** This member is private and not intended for use. */
1.99 + TInt8 iHeightFactor;
1.100 + };
1.101 +
1.102 +class CLinkedFontInformation;
1.103 +
1.104 +/**
1.105 +Bitmap font class.
1.106 +An object of this class may either access and use a bitmap font (a CFontBitmap)
1.107 +or an open font (a COpenFont).
1.108 +Stored in a CFontStore.
1.109 +@publishedAll
1.110 +@released
1.111 +*/
1.112 +class CBitmapFont : public CFont
1.113 + {
1.114 + friend class CFontStore;
1.115 + friend class CLinkedFontSpecification;
1.116 + friend class CLinkedFontInformation;
1.117 +public:
1.118 + // New functions
1.119 + TUid Uid() const;
1.120 + IMPORT_C TCharacterMetrics CharacterMetrics(TInt aCode,const TUint8*& aBytes) const;
1.121 + IMPORT_C TBool GetCharacterData(TInt aSessionHandle, TInt aCode, TOpenFontCharMetrics& aMetrics, const TUint8*& aBitmap) const;
1.122 + IMPORT_C TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData) const;
1.123 + IMPORT_C void GetFontMetrics(TOpenFontMetrics& aMetrics) const;
1.124 + IMPORT_C TBool GetFaceAttrib(TOpenFontFaceAttrib& aAttrib) const;
1.125 + IMPORT_C TInt BitmapEncoding() const;
1.126 + IMPORT_C TBool HasCharacterL(TInt aCode) const;
1.127 + IMPORT_C TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
1.128 + IMPORT_C TShapeHeader* ShapeTextL(const TDesC16& aText,
1.129 + TInt aSessionHandle, const TShapeMessageParameters& aParams);
1.130 + IMPORT_C void DeleteShape(TInt aSessionHandle,TShapeHeader* aHeader);
1.131 + IMPORT_C void operator delete(TAny*);
1.132 + inline TBool IsOpenFont() const;
1.133 + inline COpenFont* OpenFont() const;
1.134 + inline TGlyphBitmapType GlyphBitmapType() const;
1.135 + IMPORT_C CLinkedFontInformation* LinkedFontInformation() const;
1.136 + IMPORT_C CBitmapFont* NextFontClientSpace() const;
1.137 + IMPORT_C TBool IsLinkedFont()const;
1.138 + IMPORT_C CBitmapFont* FontWithCharacter(TInt aCode, CLinkedFontInformation *&aInfo, TBool aSearchAllFonts, TBool aGetCanonicalDefault) const;
1.139 +
1.140 +private:
1.141 + // From CFont
1.142 + IMPORT_C virtual TUid DoTypeUid() const;
1.143 + IMPORT_C virtual TInt DoHeightInPixels() const;
1.144 + IMPORT_C virtual TInt DoAscentInPixels() const;
1.145 + IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const;
1.146 + IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC &aText) const;
1.147 + IMPORT_C virtual TInt DoBaselineOffsetInPixels() const;
1.148 + IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels) const;
1.149 + IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels, TInt &aExcessWidthInPixels) const;
1.150 + IMPORT_C virtual TInt DoMaxCharWidthInPixels() const;
1.151 + IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const;
1.152 + IMPORT_C virtual TFontSpec DoFontSpecInTwips() const;
1.153 + IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1.154 +
1.155 +private:
1.156 + CBitmapFont(RHeap* aHeap,const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, CFontBitmap* aFontBitmap);
1.157 + CBitmapFont(RHeap* aHeap,const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, COpenFont* aOpenFont);
1.158 + void ConstructL();
1.159 + ~CBitmapFont();
1.160 + static CBitmapFont* NewL(RHeap* aHeap, const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, CFontBitmap* aFontBitmap);
1.161 + static CBitmapFont* NewL(RHeap* aHeap, const TFontSpec& aFontSpecInTwips, const TAlgStyle& aAlgStyle, COpenFont* aOpenFont);
1.162 + inline void operator delete(TAny*, TAny*) {}
1.163 + TInt Width(TInt aNum) const;
1.164 + TInt Height(TInt aNum) const;
1.165 + CFontBitmap* FontBitmap() const;
1.166 + void InstallOpenFontShaper(COpenFont* aOpenFont, CShaper::TInput& aShaperInput);
1.167 +
1.168 +private:
1.169 + TFontSpec iFontSpecInTwips;
1.170 +
1.171 +public:
1.172 + /** The algorithmic font style. */
1.173 + TAlgStyle iAlgStyle; // must not move this member
1.174 +
1.175 +private:
1.176 + // Binary Compatibility warning - data member iOpenFont is referenced by inline methods
1.177 + RHeap* iHeap;
1.178 + TInt iFontBitmapOffset;
1.179 + COpenFont* iOpenFont; // if iOpenFont is non-null this is an open font and many functions are forwarded to it
1.180 +
1.181 +#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.182 + CLinkedFontInformation *iFontLinkage;
1.183 +#endif
1.184 + };
1.185 +
1.186 +class CFontStore : public CTypefaceStore
1.187 +/**
1.188 +A store for fonts.
1.189 +
1.190 +Stores and handles both open and fixed-size fonts. Open fonts are made from
1.191 +open (scalable) typefaces by Open Font plug-in rasterizers. Fonts of other
1.192 +typefaces are stored in a limited number of fixed sizes. However, which is
1.193 +being used is transparent to the user of this class. For example the GetNearestFont...()
1.194 +functions get a bitmap font which may be retrieved from memory or generated
1.195 +via a rasterizer.
1.196 +@publishedAll
1.197 +@released
1.198 +*/
1.199 + {
1.200 +#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.201 +friend class CLinkedFonts;
1.202 +friend class CLinkedFontSpecification;
1.203 +friend class CLinkedTypefaceSpecification;
1.204 +#endif
1.205 +
1.206 +public:
1.207 + IMPORT_C static CFontStore* NewL(RHeap* aHeap);
1.208 + IMPORT_C ~CFontStore();
1.209 + IMPORT_C TUid AddFileL(const TDesC& aName);
1.210 + IMPORT_C void RemoveFile(TUid aFileUid);
1.211 + IMPORT_C TInt GetNearestFontInTwips(CFont *&aFont, const TFontSpec& aFontSpec);
1.212 + IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TFontSpec &aFontSpec);
1.213 + IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec& aFontSpec);
1.214 + IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TFontSpec& aFontSpec);
1.215 + IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.216 + IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.217 + IMPORT_C TInt GetNearestFontInTwips(CFont *&aFont, const TOpenFontSpec& aFontSpec);
1.218 + IMPORT_C TInt GetNearestFontInPixels(CFont *&aFont, const TOpenFontSpec &aFontSpec);
1.219 + IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TOpenFontSpec& aFontSpec);
1.220 + IMPORT_C TInt GetNearestFontToDesignHeightInPixels(CFont *&aFont, const TOpenFontSpec& aFontSpec);
1.221 + IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.222 + IMPORT_C TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.223 + IMPORT_C TInt GetFontById(CFont *&aFont,TUid aUid,const TAlgStyle& aAlgStyle);
1.224 + IMPORT_C TInt NumTypefaces() const;
1.225 + IMPORT_C void TypefaceSupport(TTypefaceSupport &aTypefaceSupport,TInt aTypefaceIndex) const;
1.226 + IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
1.227 + IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
1.228 + IMPORT_C void InstallRasterizerL(COpenFontRasterizer* aRasterizer);
1.229 + IMPORT_C void DeleteSessionCache(TInt aSessionHandle);
1.230 + inline TGlyphBitmapType DefaultBitmapType() const;
1.231 + inline void SetDefaultBitmapType(TGlyphBitmapType aType);
1.232 + IMPORT_C void InstallShaperFactoryL(CShaperFactory* aShaperFactory);
1.233 + const CArrayPtrFlat<CShaperFactory>* ShaperFactoryList() const;
1.234 + COpenFontSessionCacheList* GetSessionCacheList();
1.235 + TInt GetShaperCacheMemUsage();
1.236 + void SetShaperCacheMemUsage(TInt aUsage);
1.237 + CArrayPtrFlat<COpenFontFile>* GetOpenFontFileList();
1.238 + void IncNumShaperCaches();
1.239 + void DecNumShaperCaches();
1.240 + TInt GetNumShaperCaches();
1.241 + IMPORT_C TInt CreateLinkedTypeface(const TLinkedTypefaceSpecArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.242 + IMPORT_C void RemoveLinkedFont(CBitmapFont *aFont);
1.243 + IMPORT_C TBool IsValidLinkedFontSpecification(TInt aHandle);
1.244 + IMPORT_C TBool HaveTypefaceFamilyName(const TDesC& aName);
1.245 +private:
1.246 + CFontStore(RHeap* aHeap);
1.247 + void ConstructL();
1.248 + void InternalizeFontStoreFileL(CFontStoreFile* aFontStoreFile, TInt aFontVersion);
1.249 + TTypeface* GetNearestTypeface(const TTypeface& aTypeface) const;
1.250 + TTypefaceFontBitmap GetNearestTypefaceFontBitmap(const TFontSpec& aFontSpecInPixels, TInt aMaxHeight);
1.251 + CFontBitmap* GetFontBitmapById(TUid aUid);
1.252 + TBool IsFontLoaded(CFont*& aFont, const TAlgStyle& aAlgStyle, const TFontSpec& aFontSpecInPixels, TUid aUid, TInt aMaxHeight = 0) const;
1.253 + TBool IsFontLoaded(CFont*& aFont, const TAlgStyle& aAlgStyle, const TOpenFontSpec& aFontSpecInPixels, TInt aMaxHeight) const;
1.254 + CBitmapFont* NewFontL(const TFontSpec& aFontSpecInTwips,const TAlgStyle& aAlgStyle,CFontBitmap* aFontBitmap);
1.255 + CBitmapFont* NewFontL(const TOpenFontSpec& aFontSpecInTwips,const TAlgStyle& aAlgStyle,COpenFont* aOpenFont);
1.256 + TInt VerticalPixelsToTwips(TInt aPixelHeight) const;
1.257 + TInt VerticalTwipsToPixels(TInt aTwipsHeight) const;
1.258 + void GetNearestBitmapFontInPixelsL(CFont*& aFont, TFontSpec& aFontSpec, TInt aMaxHeight);
1.259 + void GetNearestOpenFontInPixelsL(
1.260 + CFont*& aFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
1.261 +#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.262 + TInt GetNearestRealFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.263 + TInt GetNearestFontInPixelsL(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.264 + TInt CreateLinkedTypefaceL(const TLinkedTypefaceSpecArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.265 + TInt GetCanonicalIndex(TInt aTypefaceIndex) const;
1.266 + void TypefaceSupportLinked(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const;
1.267 +#endif
1.268 + TInt GetNearestFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.269 + void SanityCheckForTtfL(RFile& aFile, TUint aFontFileSize, TBool aStrictChecking);
1.270 + void SanityCheckFontFileL(TParse& aParse);
1.271 + TInt GetNearestOpenFontInPixelsByFontName(COpenFont*& aNearestOpenFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
1.272 + TInt GetNearestOpenFontInPixelsBySimilarity(COpenFont*& aNearestOpenFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
1.273 + TInt AddTypefacesToSupportList(COpenFontFile* aOpenFontFile);
1.274 + void RemoveTypefacesFromSupportList(COpenFontFile* aOpenFontFile);
1.275 + TInt FindBitmapFontFileIndexByUid(TUid aUid);
1.276 + TBool IncRefCountOfLoadedFont(const TDesC& aFullName, TUid& aFontUid);
1.277 + TBool LoadFileAsOpenFontL(const TDesC& aFullName, TUid& aFontUid);
1.278 + TUid LoadFileAsBitmapFontL(TParse& aParse);
1.279 + static void CleanupRemoveFontFile(TAny* aCleanupInfo);
1.280 +
1.281 +public:
1.282 + /** The width of 1000 pixels in twips.
1.283 +
1.284 + This is set in the constructor. If the appropriate HALData attributes are
1.285 + set (EDisplayXPixels and EDisplayXTwips) then the value is calculated using
1.286 + these; otherwise the value is set to 11860. */
1.287 + TInt iKPixelWidthInTwips;
1.288 +
1.289 + /** The height of 1000 pixels in twips.
1.290 +
1.291 + This is set in the constructor. If the appropriate HALData attributes are
1.292 + set (EDisplayYPixels and EDisplayYTwips) then the value is calculated using
1.293 + these; otherwise the value is set to 11860. */
1.294 + TInt iKPixelHeightInTwips;
1.295 +
1.296 +private:
1.297 + // Binary Compatibility warning - data member iDefaultBitmapType is referenced by inline methods
1.298 + RFs iFs;
1.299 + RHeap* iHeap;
1.300 + CArrayPtrFlat<CFontStoreFile> iFontStoreFileList;
1.301 + CArrayPtrFlat<TTypeface> iTypefaceList;
1.302 + CArrayPtrFlat<CFontBitmap> iFontBitmapList;
1.303 + CArrayFixFlat<TTypefaceFontBitmap> iTypefaceFontBitmapList;
1.304 + CArrayPtrFlat<COpenFontFile> iOpenFontFileList;
1.305 + TInt iReserved[6]; // keep iDefaultBitmapType at the correct offset
1.306 + CArrayPtrFlat<COpenFontRasterizer> iOpenFontRasterizerList;
1.307 + COpenFontSessionCacheList* iOpenFontSessionCacheList;
1.308 + TInt iOpenFontUid;
1.309 + TGlyphBitmapType iDefaultBitmapType;
1.310 + CArrayPtrFlat<CShaperFactory> iShaperFactoryList;
1.311 + TInt iOpenFontShaperCacheMemUsage;
1.312 + TInt iNumberOfShaperCaches;
1.313 + RPointerArray<CTypefaceSupportInfo> iOpenFontTypefaceSupportList;
1.314 +#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.315 + RPointerArray<CLinkedTypefaceSpecification> *iLinkedTypefaceSpecificationList;
1.316 + RPointerArray<CLinkedFontSpecification> *iLinkedFontSpecificationList;
1.317 +#endif
1.318 + };
1.319 +
1.320 +// inline functions start here
1.321 +
1.322 +/** Returns whether the bitmap font object is an open font (a COpenFont) rather
1.323 +than a bitmap font (a CFontBitmap).
1.324 +
1.325 +@return ETrue if the bitmap font object is using an open font (a COpenFont);
1.326 +EFalse if it is using a bitmap font (a CFontBitmap).
1.327 +@see OpenFont()
1.328 +*/
1.329 +inline TBool CBitmapFont::IsOpenFont() const
1.330 + {
1.331 + return iOpenFont != NULL;
1.332 + }
1.333 +
1.334 +/** Returns a pointer to the open font being used by the bitmap font object.
1.335 +
1.336 +@return A pointer to an open font.
1.337 +@see IsOpenFont()
1.338 +*/
1.339 +inline COpenFont* CBitmapFont::OpenFont() const
1.340 + {
1.341 + return iOpenFont;
1.342 + }
1.343 +
1.344 +/** Gets the anti-aliasing setting for the font, see TGlyphBitmapType for
1.345 +the range of values.
1.346 +
1.347 +This is only applicable to open fonts (COpenFonts) not bitmap fonts (CBitmapFonts).
1.348 +
1.349 +Note that this setting is stored in the device-independent font specification
1.350 +which is set when the bitmap font object is constructed.
1.351 +
1.352 +@return The anti-aliasing setting for the font.
1.353 +@see IsOpenFont()
1.354 +@see TGlyphBitmapType
1.355 +@see COpenFont
1.356 +@see CBitmapFont
1.357 +*/
1.358 +inline TGlyphBitmapType CBitmapFont::GlyphBitmapType() const
1.359 + {
1.360 + return iFontSpecInTwips.iFontStyle.BitmapType();
1.361 + }
1.362 +
1.363 +/** Returns a default bitmap type.
1.364 +
1.365 +@return A default bitmap type.
1.366 +@see TGlyphBitmapType
1.367 +*/
1.368 +inline TGlyphBitmapType CFontStore::DefaultBitmapType() const
1.369 + {
1.370 + return iDefaultBitmapType;
1.371 + }
1.372 +
1.373 +/** Sets a default bitmap type.
1.374 +
1.375 +@param aType A default bitmap type.
1.376 +@see TGlyphBitmapType
1.377 +*/
1.378 +inline void CFontStore::SetDefaultBitmapType(TGlyphBitmapType aType)
1.379 + {
1.380 + iDefaultBitmapType = aType;
1.381 + }
1.382 +
1.383 +#endif