1.1 --- a/epoc32/include/fntstore.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/fntstore.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,17 +1,20 @@
1.4 -// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -// All rights reserved.
1.6 -// This component and the accompanying materials are made available
1.7 -// 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.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -//
1.11 -// Initial Contributors:
1.12 -// Nokia Corporation - initial contribution.
1.13 -//
1.14 -// Contributors:
1.15 -//
1.16 -// Description:
1.17 -//
1.18 +/*
1.19 +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.20 +* All rights reserved.
1.21 +* This component and the accompanying materials are made available
1.22 +* under the terms of "Eclipse Public License v1.0"
1.23 +* which accompanies this distribution, and is available
1.24 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.25 +*
1.26 +* Initial Contributors:
1.27 +* Nokia Corporation - initial contribution.
1.28 +*
1.29 +* Contributors:
1.30 +*
1.31 +* Description:
1.32 +*
1.33 +*/
1.34 +
1.35
1.36 #ifndef FNTSTORE_H__
1.37 #define FNTSTORE_H__
1.38 @@ -20,10 +23,37 @@
1.39 #include <f32file.h>
1.40 #include <gdi.h>
1.41 #include <openfont.h>
1.42 +#include <linkedfonts.h>
1.43 +
1.44 +
1.45 +/** Defines the maximum number of linked typefaces that may be placed in a linked typeface specification
1.46 +WARNING: Constant for internal use ONLY. Compatibility is not guaranteed in future releases.
1.47 +@publishedAll
1.48 +@released
1.49 + */
1.50 +const TInt KMaxLinkedTypefaces = 12;
1.51 +/** Defines the maximum number of linked typeface groups that may be placed in a linked typeface specification
1.52 +WARNING: Constant for internal use ONLY. Compatibility is not guaranteed in future releases.
1.53 +@publishedAll
1.54 +@released
1.55 + */
1.56 +const TInt KMaxLinkedTypefaceGroups = 12;
1.57 +
1.58 +/** Defines the maximun number of threads that may tranverse the COpenFontSessionCacheList (read-only)
1.59 + @publishedAll
1.60 + @released
1.61 + */
1.62 +const TInt KSessionCacheSemaphoreCount = 12;
1.63 +
1.64 +/** Defines the name of the semaphore which is used to exclude threads that may tranverse
1.65 + * the COpenFontSessionCacheList (read-only) with FBserv.
1.66 + @publishedAll
1.67 + @released
1.68 + */
1.69 +_LIT(KSessionCacheSemaphoreName,"FBSSessionCacheSemaphore");
1.70
1.71 class CLinkedTypefaceSpecification;
1.72 -class CLinkedFontSpecification;
1.73 -class TLinkedTypefaceSpecArgs;
1.74 +class TLinkedTypefaceSpecificationArgs;
1.75 class CFbClient;
1.76 class CFontStoreFile;
1.77 class CFontBitmap;
1.78 @@ -32,16 +62,22 @@
1.79 class TShapeHeader;
1.80 class TShapeMessageParameters;
1.81 class CTypefaceSupportInfo;
1.82 -
1.83 +class COpenFontRasterizer;
1.84 +class CLinkedTypefaceGroup;
1.85 +IMPORT_C extern const TInt8 KLinkedFontDrive;
1.86 +IMPORT_C extern const TUint32 KFontTable_GlyphOutline_CacheMaxMem;
1.87
1.88 /**
1.89 -@internalTechnology
1.90 -*/
1.91 +WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
1.92 +@publishedAll
1.93 +@released
1.94 + */
1.95 class TCharacterMetrics
1.96 {
1.97 - public:
1.98 +public:
1.99 IMPORT_C TCharacterMetrics();
1.100
1.101 +public:
1.102 TInt16 iAscentInPixels;
1.103 TInt16 iHeightInPixels;
1.104 TInt16 iLeftAdjustInPixels;
1.105 @@ -49,7 +85,6 @@
1.106 TInt16 iRightAdjustInPixels;
1.107 };
1.108
1.109 -class TAlgStyle
1.110 /**
1.111 An algorithmic style for how a font is drawn.
1.112
1.113 @@ -62,6 +97,7 @@
1.114 @see CFbsTypefaceStore::GetFontById()
1.115 @see CFbsDevice::GetFontById()
1.116 */
1.117 +class TAlgStyle
1.118 {
1.119 public:
1.120 IMPORT_C TAlgStyle();
1.121 @@ -95,8 +131,6 @@
1.122 TInt8 iHeightFactor;
1.123 };
1.124
1.125 -class CLinkedFontInformation;
1.126 -
1.127 /**
1.128 Bitmap font class.
1.129 An object of this class may either access and use a bitmap font (a CFontBitmap)
1.130 @@ -107,9 +141,9 @@
1.131 */
1.132 class CBitmapFont : public CFont
1.133 {
1.134 + friend class CFbsFont;
1.135 friend class CFontStore;
1.136 - friend class CLinkedFontSpecification;
1.137 - friend class CLinkedFontInformation;
1.138 + friend class CFbsBitGc;
1.139 public:
1.140 // New functions
1.141 TUid Uid() const;
1.142 @@ -128,11 +162,15 @@
1.143 inline TBool IsOpenFont() const;
1.144 inline COpenFont* OpenFont() const;
1.145 inline TGlyphBitmapType GlyphBitmapType() const;
1.146 - IMPORT_C CLinkedFontInformation* LinkedFontInformation() const;
1.147 - IMPORT_C CBitmapFont* NextFontClientSpace() const;
1.148 - IMPORT_C TBool IsLinkedFont()const;
1.149 - IMPORT_C CBitmapFont* FontWithCharacter(TInt aCode, CLinkedFontInformation *&aInfo, TBool aSearchAllFonts, TBool aGetCanonicalDefault) const;
1.150 -
1.151 + IMPORT_C TUint32 UniqueFontId();
1.152 + IMPORT_C TInt GetFontTable(TUint32 aTag, TAny*& aTableContent,
1.153 + TInt& aLength, TInt aSessionHandle);
1.154 + IMPORT_C TInt GetGlyphOutline(TUint aCode,
1.155 + TBool aHinted, TAny*& aOutline, TInt& aLength, TInt aSessionHandle);
1.156 + IMPORT_C void ReleaseGlyphOutlines(TInt aCount, const TUint* aCodes,
1.157 + TBool aHinted, TInt aSessionHandle);
1.158 + IMPORT_C void ReleaseFontTable(TUint32 aTag, TInt aSessionHandle);
1.159 +
1.160 private:
1.161 // From CFont
1.162 IMPORT_C virtual TUid DoTypeUid() const;
1.163 @@ -160,6 +198,8 @@
1.164 TInt Height(TInt aNum) const;
1.165 CFontBitmap* FontBitmap() const;
1.166 void InstallOpenFontShaper(COpenFont* aOpenFont, CShaper::TInput& aShaperInput);
1.167 + TInt DoTextWidthInPixels(const TDesC &aText, const TMeasureTextInput* aParam) const;
1.168 + void SetUniqueFontId(TUint32 aUniqueFontId);
1.169
1.170 private:
1.171 TFontSpec iFontSpecInTwips;
1.172 @@ -169,16 +209,89 @@
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 + // Binary Compatibility warning - data member iOpenFont is referenced by inline methods
1.181 + RHeap* iHeap;
1.182 + TInt iFontBitmapOffset;
1.183 +
1.184 + // In order to be able to work with the flexible memory model, iOpenFont is
1.185 + // actually an offset from the address of this class.
1.186 + // iOpenFont's type remains unchanged.
1.187 + // As Qt code that uses OpenFont() must be able to run on new and old versions
1.188 + // of Symbian OS, it must be able to determine whether iOpenFont is a pointer or
1.189 + // an offset at run-time. Therefore an offset will have its lowest significant bit set to 1.
1.190 + // If iOpenFont is null, this object is not an open font.
1.191 + // Assumption: a pointer always has least significant bit value of zero.
1.192 + COpenFont* iOpenFont; // if iOpenFont is non-null this is an open font and many functions are forwarded to it
1.193
1.194 -#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.195 - CLinkedFontInformation *iFontLinkage;
1.196 -#endif
1.197 + TUint32 iReserved;
1.198 + TUint32 iUniqueFontId; // unique id for this instance of this font
1.199 + };
1.200 +
1.201 +/**
1.202 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.203 +@publishedAll
1.204 +@released
1.205 + */
1.206 +class TLinkedTypefaceGroupArgs
1.207 + {
1.208 +public:
1.209 + TInt iGroupId;
1.210 + CLinkedTypefaceGroup::TScalingOption iScalingOption;
1.211 + CLinkedTypefaceGroup::TBaselineShift iBaselineShift;
1.212 + TInt iAntialiasingThreshold;
1.213 + TInt iBoldnessPercentage;
1.214 + TInt iItalicAngle;
1.215 +public:
1.216 + void operator =(const CLinkedTypefaceGroup* aRhs);
1.217 + };
1.218 +
1.219 +class COpenFontLinkedTypefaceElementSpec;
1.220 +class COpenFontLinkedTypefaceSpecification;
1.221 +
1.222 +/**
1.223 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.224 +@publishedAll
1.225 +@released
1.226 + */
1.227 +class TLinkedTypefaceElementSpecArgs
1.228 + {
1.229 +public:
1.230 + TBufC<KMaxTypefaceNameLength> iName;
1.231 + TBool iIsCanonical;
1.232 + TInt iGroupId;
1.233 +
1.234 + void operator = (const CLinkedTypefaceElementSpec* aRhs);
1.235 + void operator = (const COpenFontLinkedTypefaceElementSpec* aRhs);
1.236 + };
1.237 +
1.238 +/**
1.239 +WARNING: Class for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.240 +@publishedAll
1.241 +@released
1.242 + */
1.243 +class TLinkedTypefaceSpecificationArgs
1.244 + {
1.245 +public:
1.246 + TBufC<KMaxTypefaceNameLength> iName;
1.247 + TLinkedTypefaceElementSpecArgs iTypefaces[KMaxLinkedTypefaces];
1.248 + TLinkedTypefaceGroupArgs iGroups[KMaxLinkedTypefaceGroups];
1.249 + TInt iSize;
1.250 + TInt iGroupSize;
1.251 + TInt iCanonicalIndex;
1.252 +
1.253 + IMPORT_C void operator = (const CLinkedTypefaceSpecification& aRhs);
1.254 + IMPORT_C void operator = (const COpenFontLinkedTypefaceSpecification& aRhs);
1.255 };
1.256
1.257 +
1.258 +
1.259 +class TUnhintedOutlineId;
1.260 +class THintedOutlineId;
1.261 +class CFontTableCache;
1.262 +class CUnhintedOutlineCache;
1.263 +class CHintedOutlineCache;
1.264 +class TFontTableGlyphOutlineCacheMemMonitor;
1.265 +
1.266 class CFontStore : public CTypefaceStore
1.267 /**
1.268 A store for fonts.
1.269 @@ -193,11 +306,8 @@
1.270 @released
1.271 */
1.272 {
1.273 -#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.274 friend class CLinkedFonts;
1.275 -friend class CLinkedFontSpecification;
1.276 friend class CLinkedTypefaceSpecification;
1.277 -#endif
1.278
1.279 public:
1.280 IMPORT_C static CFontStore* NewL(RHeap* aHeap);
1.281 @@ -234,10 +344,33 @@
1.282 void IncNumShaperCaches();
1.283 void DecNumShaperCaches();
1.284 TInt GetNumShaperCaches();
1.285 - IMPORT_C TInt CreateLinkedTypeface(const TLinkedTypefaceSpecArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.286 - IMPORT_C void RemoveLinkedFont(CBitmapFont *aFont);
1.287 - IMPORT_C TBool IsValidLinkedFontSpecification(TInt aHandle);
1.288 + IMPORT_C TInt CreateLinkedTypeface(const TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.289 + IMPORT_C void GetLinkedTypefaceL(TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec);
1.290 IMPORT_C TBool HaveTypefaceFamilyName(const TDesC& aName);
1.291 + IMPORT_C void UpdateLinkedTypefaceL(const TLinkedTypefaceSpecificationArgs& aLinkedTypefaceSpec);
1.292 + IMPORT_C void LoadFontsAtStartupL();
1.293 + IMPORT_C TBool GetFontFilePath(const TDesC& aFontName, TFileName& aFilePath) const;
1.294 + IMPORT_C void CleanupCacheOnFbsSessionTermination(TInt aSessionHandle);
1.295 +
1.296 + TInt CacheFontTable(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt aLength);
1.297 + TInt ReleaseFontTable(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
1.298 + TInt FindFontTableInCache(TUid aFileUid, TUint32 aTag, TAny*& aContent, TInt& aLength);
1.299 + TInt IncFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
1.300 + TInt DecFontTableRefCount(TUid aFileUid, TUint32 aTag, TInt aSessionHandle);
1.301 + TInt CacheUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TAny* aData,
1.302 + TInt aLength, TAny*& aOutline, TInt& aLen);
1.303 + TInt CacheHintedOutline(const THintedOutlineId& aOutlineId, TAny* aData, TInt aLength,
1.304 + TAny*& aOutline, TInt& aLen);
1.305 + TInt ReleaseUnhintedOutline(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
1.306 + TInt ReleaseHintedOutline(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
1.307 + TInt IncreaseUnhintedOutlineRefCount(const TUnhintedOutlineId& aOutlineId, TInt aSessionHandle);
1.308 + TInt IncreaseHintedOutlineRefCount(const THintedOutlineId& aOutlineId, TInt aSessionHandle);
1.309 + TInt FindUnhintedOutlineInCache(const TUnhintedOutlineId& aOutlineId, TAny*& aData,
1.310 + TInt &aLength);
1.311 + TInt FindHintedOutlineInCache(const THintedOutlineId& aOutlineId, TAny*& aData, TInt& aLength);
1.312 + void CleanupCacheOnOpenFontRemoval(COpenFont* aFont);
1.313 + void CleanupCacheOnOpenFontFileRemoval(COpenFontFile* aFontFile);
1.314 +
1.315 private:
1.316 CFontStore(RHeap* aHeap);
1.317 void ConstructL();
1.318 @@ -254,13 +387,11 @@
1.319 void GetNearestBitmapFontInPixelsL(CFont*& aFont, TFontSpec& aFontSpec, TInt aMaxHeight);
1.320 void GetNearestOpenFontInPixelsL(
1.321 CFont*& aFont, TOpenFontSpec& aActualFontSpec, const TOpenFontSpec& aDesiredFontSpec, TInt aMaxHeight);
1.322 -#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.323 TInt GetNearestRealFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.324 TInt GetNearestFontInPixelsL(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.325 - TInt CreateLinkedTypefaceL(const TLinkedTypefaceSpecArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.326 + TInt CreateLinkedTypefaceL(const TLinkedTypefaceSpecificationArgs &aLinkedTypefaceSpec, TInt aSession, TInt& aId);
1.327 TInt GetCanonicalIndex(TInt aTypefaceIndex) const;
1.328 void TypefaceSupportLinked(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const;
1.329 -#endif
1.330 TInt GetNearestFontInPixels(CFont*& aFont, const TOpenFontSpec& aFontSpec, TInt aMaxHeight);
1.331 void SanityCheckForTtfL(RFile& aFile, TUint aFontFileSize, TBool aStrictChecking);
1.332 void SanityCheckFontFileL(TParse& aParse);
1.333 @@ -269,11 +400,15 @@
1.334 TInt AddTypefacesToSupportList(COpenFontFile* aOpenFontFile);
1.335 void RemoveTypefacesFromSupportList(COpenFontFile* aOpenFontFile);
1.336 TInt FindBitmapFontFileIndexByUid(TUid aUid);
1.337 - TBool IncRefCountOfLoadedFont(const TDesC& aFullName, TUid& aFontUid);
1.338 - TBool LoadFileAsOpenFontL(const TDesC& aFullName, TUid& aFontUid);
1.339 - TUid LoadFileAsBitmapFontL(TParse& aParse);
1.340 + TBool IncRefCountOfLoadedFont(const TParse& aFileName, TUid& aFontUid);
1.341 + TBool LoadFileAsOpenFontL(const TParse& aFileName, TUid& aFontUid);
1.342 + TUid LoadFileAsBitmapFontL(const TParse& aParse);
1.343 static void CleanupRemoveFontFile(TAny* aCleanupInfo);
1.344 -
1.345 + const TAny* FontLinkingInterface() const;
1.346 + TInt ValidateLinkedFontSpecificationL(COpenFontLinkedTypefaceSpecification& aSpec, TBool aOverwrite) const;
1.347 + void GenerateLinkedFontFileL(COpenFontLinkedTypefaceSpecification& aSpec, const TAny* aExtension, TBool aUpdate);
1.348 + void LoadFontsL(const TDesC& aFontsDir);
1.349 + void AddSanityCheckedFontL(const TParse& aFileName, TUid& aUid);
1.350 public:
1.351 /** The width of 1000 pixels in twips.
1.352
1.353 @@ -298,7 +433,11 @@
1.354 CArrayPtrFlat<CFontBitmap> iFontBitmapList;
1.355 CArrayFixFlat<TTypefaceFontBitmap> iTypefaceFontBitmapList;
1.356 CArrayPtrFlat<COpenFontFile> iOpenFontFileList;
1.357 - TInt iReserved[6]; // keep iDefaultBitmapType at the correct offset
1.358 + TInt iReserved[2]; // keep iDefaultBitmapType at the correct offset
1.359 + CFontTableCache *iFontTableCache;
1.360 + CUnhintedOutlineCache *iUnhintedOutlineCache;
1.361 + CHintedOutlineCache *iHintedOutlineCache;
1.362 + TFontTableGlyphOutlineCacheMemMonitor *iCacheMemMon;
1.363 CArrayPtrFlat<COpenFontRasterizer> iOpenFontRasterizerList;
1.364 COpenFontSessionCacheList* iOpenFontSessionCacheList;
1.365 TInt iOpenFontUid;
1.366 @@ -307,10 +446,9 @@
1.367 TInt iOpenFontShaperCacheMemUsage;
1.368 TInt iNumberOfShaperCaches;
1.369 RPointerArray<CTypefaceSupportInfo> iOpenFontTypefaceSupportList;
1.370 -#ifdef SYMBIAN_SUPPORT_LINKED_FONTS
1.371 - RPointerArray<CLinkedTypefaceSpecification> *iLinkedTypefaceSpecificationList;
1.372 - RPointerArray<CLinkedFontSpecification> *iLinkedFontSpecificationList;
1.373 -#endif
1.374 + RArray<RHandleBase> *iHandleArray;
1.375 + TAny* iUnused2;
1.376 + TUint32 iUniqueFontIdCount;
1.377 };
1.378
1.379 // inline functions start here
1.380 @@ -327,6 +465,7 @@
1.381 return iOpenFont != NULL;
1.382 }
1.383
1.384 +
1.385 /** Returns a pointer to the open font being used by the bitmap font object.
1.386
1.387 @return A pointer to an open font.
1.388 @@ -334,7 +473,14 @@
1.389 */
1.390 inline COpenFont* CBitmapFont::OpenFont() const
1.391 {
1.392 - return iOpenFont;
1.393 + if (reinterpret_cast<TInt>(iOpenFont) & 1)
1.394 + {
1.395 + return reinterpret_cast<COpenFont*>(const_cast<CBitmapFont*>(PtrAdd(this, reinterpret_cast<TInt>(iOpenFont) & ~1)));
1.396 + }
1.397 + else
1.398 + {
1.399 + return iOpenFont;
1.400 + }
1.401 }
1.402
1.403 /** Gets the anti-aliasing setting for the font, see TGlyphBitmapType for
1.404 @@ -377,3 +523,4 @@
1.405 }
1.406
1.407 #endif
1.408 +