1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/fontstore/inc/OPENFONT.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2470 @@
1.4 +/*
1.5 +* Copyright (c) 1998-2010 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 "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.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 +* A header for the open font system, which allows SymbianOS
1.19 +* to use fonts of arbitrary types, including TrueType/OpenType
1.20 +* and other outline font formats.
1.21 +*
1.22 +*/
1.23 +
1.24 +
1.25 +#ifndef __OPENFONT_H__
1.26 +#define __OPENFONT_H__
1.27 +
1.28 +#include <e32base.h>
1.29 +#include <gdi.h>
1.30 +#include <ecom/ecom.h>
1.31 +
1.32 +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1.33 +#include <linkedfonts.h>
1.34 +#include <graphics/openfontconstants.h>
1.35 +#include <graphics/openfontrasterizer.h>
1.36 +#include <openfontlinkedtypefaceelementspec.h>
1.37 +#include <graphics/openfontlinkedtypefacespecification.h>
1.38 +#include <graphics/openfontlinkedtypefaceextension.h>
1.39 +#endif
1.40 +
1.41 +class CFont;
1.42 +class COpenFontFile;
1.43 +class COpenFontGlyph;
1.44 +class COpenFontGlyphCache;
1.45 +class COpenFontPositioner;
1.46 +class COpenFontSessionCache;
1.47 +class COpenFontSessionCacheList;
1.48 +class RFs;
1.49 +class TCharacterMetrics;
1.50 +class TFontSpec;
1.51 +class TOpenFontFaceAttrib;
1.52 +class CFontStore;
1.53 +class TOpenFontFileData;
1.54 +class TShapeHeader;
1.55 +class CBitmapFont;
1.56 +class CShaperFactory;
1.57 +class CShaper;
1.58 +class TShapeHeader;
1.59 +class TFontShapeFunctionParameters;
1.60 +class TFontShapeDeleteFunctionParameters;
1.61 +class RShapeInfo;
1.62 +class TShapeMessageParameters;
1.63 +class CRasterizerLinkedTypefaceSpecification;
1.64 +class TLinkedTypefaceSpecificationArgs;
1.65 +
1.66 +/**
1.67 +Supplied to COpenFont::ExtendedInterface() to access the extended
1.68 +API interface MOpenFontShapingExtension.
1.69 +
1.70 +@see COpenFont::ExtendedInterface()
1.71 +@see MOpenFontShapingExtension
1.72 +@publishedAll
1.73 +@released
1.74 +*/
1.75 +const TUid KUidOpenFontShapingExtension = {0x10274DB9};
1.76 +
1.77 +/**
1.78 +Supplied to COpenFont::ExtendedInterface() to access the extended
1.79 +API interface MOpenFontTrueTypeExtension.
1.80 +
1.81 +@see COpenFont::ExtendedInterface()
1.82 +@see MOpenFontTrueTypeExtension
1.83 +@publishedAll
1.84 +@released
1.85 +*/
1.86 +const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
1.87 +const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
1.88 +
1.89 +/**
1.90 +Supplied to CShaper::ExtendedInterface() to get the language and script
1.91 +code with which the current shaper is instatsiated.
1.92 +@see CShaper::ExtendedInterface()
1.93 +@publishedAll
1.94 +@released
1.95 +*/
1.96 +const TUid KUidShaperGetScript = {0x20009966};
1.97 +const TUid KUidShaperGetLang = {0x20009967};
1.98 +
1.99 +/**
1.100 +Font metrics.
1.101 +
1.102 +@see CFbsFont::GetFontMetrics()
1.103 +@publishedAll
1.104 +@released
1.105 +*/
1.106 +class TOpenFontMetrics
1.107 + {
1.108 +public:
1.109 + inline TOpenFontMetrics();
1.110 + IMPORT_C TOpenFontMetrics(const CFont* aFont);
1.111 + inline TInt Size() const;
1.112 + inline TInt Ascent() const;
1.113 + inline TInt Descent() const;
1.114 + inline TInt MaxHeight() const;
1.115 + inline TInt MaxDepth() const;
1.116 + inline TInt MaxWidth() const;
1.117 + inline void SetSize(TInt aSize);
1.118 + inline void SetAscent(TInt aAscent);
1.119 + inline void SetDescent(TInt aDescent);
1.120 + inline void SetMaxHeight(TInt aMaxHeight);
1.121 + inline void SetMaxDepth(TInt aMaxDepth);
1.122 + inline void SetMaxWidth(TInt aMaxWidth);
1.123 + /** WARNING: Function for internal and partner use ONLY. Compatibility is not guaranteed in future releases.*/
1.124 + IMPORT_C void SetBaselineCorrection(TInt aBaselineCorrection);
1.125 + IMPORT_C TInt BaselineCorrection();
1.126 +private:
1.127 + TInt16 iDesignHeight; // size of the font ('pointsize' in pixels)
1.128 + TInt16 iAscent; // typographic ascent
1.129 + TInt16 iDescent; // typographic descent
1.130 + TInt16 iMaxHeight; // maximum height of a character; may be greater than iAscent
1.131 + TInt16 iMaxDepth; // maximum depth of a character; may be greater than iDescent
1.132 + TInt16 iMaxWidth; // maximum width of a character
1.133 + TInt16 iBaselineCorrection;
1.134 + TInt16 iReserved;
1.135 + };
1.136 +
1.137 +
1.138 +/**
1.139 +Character metrics includes more information than TCharacterMetrics.
1.140 +
1.141 +Character metrics allow characters to be placed horizontally or vertically.
1.142 +The character metrics encapsulated by this class are: Height, Width, Horizontal
1.143 +Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X,
1.144 +Vertical Bearing Y, and Vertical Advance. Their meanings are described in the
1.145 +associated setter and getter functions.
1.146 +
1.147 +Note :
1.148 +
1.149 +Vertical drawing (in the sense of characters drawn with horizontal baselines,
1.150 +but in a vertical line) is not yet supported by Symbian OS.
1.151 +
1.152 +@see CFont::GetCharacterData()
1.153 +@see CFbsFont::GetCharacterData()
1.154 +@publishedAll
1.155 +@released
1.156 +*/
1.157 +class TOpenFontCharMetrics
1.158 + {
1.159 +public:
1.160 + enum TUninitialized { EUninitialized };
1.161 +public:
1.162 + /** Default constructor initializes all members to 0. */
1.163 + inline TOpenFontCharMetrics();
1.164 +
1.165 + /** Constructor that does not initialize any members. */
1.166 + TOpenFontCharMetrics(TUninitialized) {}
1.167 + IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics);
1.168 + IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const;
1.169 + inline TInt Width() const;
1.170 + inline TInt Height() const;
1.171 + inline TInt HorizBearingX() const;
1.172 + inline TInt HorizBearingY() const;
1.173 + inline TInt HorizAdvance() const;
1.174 + inline TInt VertBearingX() const;
1.175 + inline TInt VertBearingY() const;
1.176 + inline TInt VertAdvance() const;
1.177 + inline void GetHorizBounds(TRect& aBounds) const;
1.178 + inline void GetVertBounds(TRect& aBounds) const;
1.179 + inline void SetWidth(TInt aWidth);
1.180 + inline void SetHeight(TInt aHeight);
1.181 + inline void SetHorizBearingX(TInt aHorizBearingX);
1.182 + inline void SetHorizBearingY(TInt aHorizBearingY);
1.183 + inline void SetHorizAdvance(TInt aHorizAdvance);
1.184 + inline void SetVertBearingX(TInt aVertBearingX);
1.185 + inline void SetVertBearingY(TInt aVertBearingY);
1.186 + inline void SetVertAdvance(TInt aVertAdvance);
1.187 + IMPORT_C void SetGlyphType(TGlyphBitmapType);
1.188 + IMPORT_C TGlyphBitmapType GlyphType() const;
1.189 +private:
1.190 + TInt16 iWidth; // width of the glyph
1.191 + TInt16 iHeight; // height of the glyph
1.192 + TInt16 iHorizBearingX; // x component of horizontal bearing
1.193 + TInt16 iHorizBearingY; // y component of horizontal bearing
1.194 + TInt16 iHorizAdvance; // horizontal advance
1.195 + TInt16 iVertBearingX; // x component of vertical bearing
1.196 + TInt16 iVertBearingY; // y component of vertical bearing
1.197 + TInt16 iVertAdvance; // vertical advance
1.198 + TUint16 iGlyphBitmapType;// Glyph bitmap type; TGlyphBitmapType
1.199 + TInt16 iReserved;
1.200 + };
1.201 +
1.202 +
1.203 +/**
1.204 +Font glyph data.
1.205 +
1.206 +Objects of this type are used by rasterizers to supply glyph data to font
1.207 +and bitmap server clients. Unless you are writing a rasterizer you will not
1.208 +need to use an object of this type.
1.209 +
1.210 +The object cannot be constructed and destroyed by normal means. It resides
1.211 +on a specified heap. It is created by New() and deleted by RHeap::Free().
1.212 +
1.213 +@see COpenFont::RasterizeL()
1.214 +@publishedAll
1.215 +@released
1.216 +*/
1.217 +class TOpenFontGlyphData
1.218 + {
1.219 +public:
1.220 + IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize);
1.221 + inline TBool Overflow() const;
1.222 + inline TInt BytesNeeded() const;
1.223 + inline TPtrC8 Bitmap() const;
1.224 + inline const TUint8* BitmapPointer() const;
1.225 + inline const TOpenFontCharMetrics* Metrics() const;
1.226 + inline TInt GlyphIndex() const;
1.227 + inline TUint8* BufferStart();
1.228 + inline TUint8* BufferEnd();
1.229 + inline void SetBytesNeeded(TInt aBytes);
1.230 + inline void SetBitmapPointer(const TUint8* aBitmap);
1.231 + inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics);
1.232 + inline void SetPointersToInternalBuffers();
1.233 + inline void SetMetrics(TOpenFontCharMetrics& aMetrics);
1.234 + inline void SetGlyphIndex(TInt aGlyphIndex);
1.235 +private:
1.236 + /*
1.237 + Prevent construction and destruction by normal means; the object resides
1.238 + on a specified heap and is created by New and deleted by RHeap::Free.
1.239 + */
1.240 + TOpenFontGlyphData();
1.241 + ~TOpenFontGlyphData();
1.242 +private:
1.243 + TInt iBitmapBufferSize; // size of the buffer in bytes
1.244 + TInt iBytesNeeded; // bytes needed for the bitmap
1.245 + TOpenFontCharMetrics iMetricsBuffer; // the metrics
1.246 + const TUint8* iBitmap; // pointer to the bitmap; points either to iBitmapBuffer or to
1.247 + // the cache if the character was already rasterized
1.248 + const TOpenFontCharMetrics* iMetrics; // pointer to the metrics; points either to iMetricsBuffer or to
1.249 + // the cache if the character was already rasterized
1.250 + TInt iGlyphIndex; // the glyph index
1.251 + TAny* iReserved; // unused; for future expansion
1.252 + TUint8 iBitmapBuffer[1]; // buffer used to write the bitmap when it is first rasterized; this
1.253 + // is actually of size iBitmapBufferSize.
1.254 + };
1.255 +
1.256 +/**
1.257 +Open Font System font abstract base class.
1.258 +
1.259 +Derive a class from this class to represent an instance of a typeface at a
1.260 +particular size, provide bitmaps of the glyphs, and determine whether
1.261 +characters exist in the typeface.
1.262 +
1.263 +Writing derived classes construction:
1.264 +
1.265 +You must call the constructor of this class when creating your derived object,
1.266 +passing the arguments aHeap and aSessionCacheList supplied to
1.267 +COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile
1.268 +object that creates the object as aFile.
1.269 +
1.270 +The derived object must be created on the shared heap aHeap because it is
1.271 +shared by several processes: the font and bitmap server and its clients.
1.272 +To do this, use aHeap->AllocL() to obtain memory, then construct in place
1.273 +using a placement argument to new.
1.274 +
1.275 +Derived classes must implement the pure virtual function RasterizeL().
1.276 +Information about this function is provided in the function definition below.
1.277 +
1.278 +Information about deriving from this class is also provided in the API guide.
1.279 +
1.280 +@see COpenFontFile::GetNearestFontInPixelsL()
1.281 +@publishedAll
1.282 +@released
1.283 +*/
1.284 +class COpenFont: public CBase
1.285 + {
1.286 +public:
1.287 + /** Creates a bitmap for the specified Unicode character.
1.288 +
1.289 + Implementations of this function should put the bitmap in
1.290 + aGlyphData->iBitmapBuffer, and the character metrics are placed in
1.291 + aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
1.292 + alone.
1.293 +
1.294 + There are a number of strategies for achieving this, e.g. pass the
1.295 + rasterization task all the way up to the rasterizer engine. These are
1.296 + discussed in the API guide.
1.297 +
1.298 + At present you must write the bitmap in the Symbian platform's
1.299 + run-length-encoded format. This is a packed binary format starting on a
1.300 + byte boundary and made up of a number of sections. Each section starts
1.301 + with a five-bit header. If the first bit of the header is 0 the next four
1.302 + bits are a repeat count, starting with the least significant bit, and a
1.303 + single row of bits (the number of bits in a row is specified by
1.304 + aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header
1.305 + is 1 the next four bits are a count of non-repeating rows, again starting
1.306 + with the least significant bit, and that many rows of bits follow.
1.307 +
1.308 + @param aCode The character code of the Unicode character for which the
1.309 + bitmap is required.
1.310 + @param aGlyphData On return, contains a pointer to a TOpenFontGlyphData
1.311 + containing the character's bitmap and metrics. */
1.312 + virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
1.313 + IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
1.314 + IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile);
1.315 + IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex);
1.316 + IMPORT_C ~COpenFont();
1.317 + IMPORT_C void operator delete(TAny*);
1.318 + inline const TOpenFontMetrics& Metrics() const;
1.319 + inline const TOpenFontFaceAttrib* FaceAttrib() const;
1.320 + inline COpenFontFile* File() const;
1.321 + inline TInt FaceIndex() const;
1.322 + inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
1.323 + void SetShaper(CShaper* aShaper);
1.324 + CShaper* GetShaper();
1.325 + TBool HasShaper() const;
1.326 + TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams);
1.327 + TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader);
1.328 + TInt FreeShaperCacheMemory(TInt aBytesNeeded);
1.329 + TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse);
1.330 + TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData);
1.331 + TBool HasCharacterL(TInt aCode) const;
1.332 + TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
1.333 + void OnFileDeleted();
1.334 + COpenFontGlyphCache* GetGlyphCache() const;
1.335 + inline TInt FontCapitalAscent() const;
1.336 + inline TInt FontMaxAscent() const;
1.337 + inline TInt FontStandardDescent() const;
1.338 + inline TInt FontMaxDescent() const;
1.339 + inline TInt FontLineGap() const;
1.340 + inline TInt FontMaxHeight() const;
1.341 + void DeleteShaper() const;
1.342 + TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength);
1.343 + TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength);
1.344 +
1.345 +protected:
1.346 + RHeap* iHeap;
1.347 + TOpenFontMetrics iMetrics;
1.348 +private:
1.349 + /** The shaper for performing complex character positioning and
1.350 + substitution, if available. Null otherwise.
1.351 +
1.352 + WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only.
1.353 + */
1.354 + CShaper* iShaper;
1.355 +
1.356 +protected:
1.357 + /** The positive distance in pixels from the baseline to
1.358 + the top of an ANSI capital (whether or not there are
1.359 + ANSI capitals in the font) */
1.360 + TInt iFontCapitalAscent;
1.361 + /** The positive distance in pixels from the baseline to
1.362 + the top of the highest pre-composed glyph in the font */
1.363 + TInt iFontMaxAscent;
1.364 + /** The positive distance in pixels from the baseline to
1.365 + the bottom of the lowest ANSI descender (whether or
1.366 + not there are ANSI chars in the font)*/
1.367 + TInt iFontStandardDescent;
1.368 + /** The positive distance in pixels from the baseline to
1.369 + the bottom of the lowest pre-composed glyph in the font */
1.370 + TInt iFontMaxDescent;
1.371 + /** The recommended baseline to baseline gap for successive
1.372 + lines of text in the font */
1.373 + TInt iFontLineGap;
1.374 +private:
1.375 + const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
1.376 +
1.377 + const COpenFontGlyph* FontCacheGlyph(TInt aCode) const;
1.378 +
1.379 + void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
1.380 +
1.381 + const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode,
1.382 + COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const;
1.383 + void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData);
1.384 +
1.385 + COpenFontSessionCacheList* SessionCacheList()const;
1.386 +
1.387 + void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList);
1.388 +
1.389 + void SetFile(COpenFontFile* aFile);
1.390 +private:
1.391 +
1.392 + // Offset from the address of the file used by this font.
1.393 + // If the file has been deleted or cannot be used, the offest will be zero.
1.394 + TInt iFileOffset;
1.395 +
1.396 + TInt iFaceIndex; // index of the face in the font file
1.397 +
1.398 + // Offset from the address of this font of the per-font glyph cache which is owned by the font
1.399 + TInt iGlyphCacheOffset;
1.400 +
1.401 + // Offset from the address of this font of the list of per-session glyph
1.402 + // caches which are owned by CFontStore
1.403 + TInt iSessionCacheListOffset;
1.404 +
1.405 + TAny* iReserved; // unused; for future expansion
1.406 + };
1.407 +
1.408 +/** Open Font System Extension Interface abstract base class.
1.409 +
1.410 +COpenFont derivers should also derive from this interface to enable complex
1.411 +font "shaping".
1.412 +
1.413 +This interface should be returned by the overridden
1.414 +COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
1.415 +supplied as the UID.
1.416 +
1.417 +@see COpenFont
1.418 +@see KUidOpenFontShapingExtension
1.419 +@publishedAll
1.420 +@released
1.421 +*/
1.422 +class MOpenFontShapingExtension
1.423 + {
1.424 +public:
1.425 + /** Various font metrics. */
1.426 + class TExtensionFontMetrics
1.427 + {
1.428 + public:
1.429 + /** The number of font design units per em. */
1.430 + TInt iUnitsPerEm;
1.431 + /** The width of the font's em square in pixels. */
1.432 + TReal iXPixelsPerEm;
1.433 + /** The height of the font's em square in pixels. */
1.434 + TReal iYPixelsPerEm;
1.435 + /** The horizontal scaling factor from the font's transform;
1.436 + the number of horizontal pixels per font unit. */
1.437 + TReal iXScaleFactor;
1.438 + /** The vertical scaling factor from the font's transform;
1.439 + the number of vertical pixels per font unit. */
1.440 + TReal iYScaleFactor;
1.441 + private:
1.442 + /** Reserved for future expansion. */
1.443 + TInt iReserved[4];
1.444 + };
1.445 +
1.446 + /** Creates a bitmap for the specified Glyph code.
1.447 +
1.448 + Implementations of this function should put the bitmap in
1.449 + aGlyphData->iBitmapBuffer, and the character metrics are placed in
1.450 + aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
1.451 + alone.
1.452 +
1.453 + This function provides the same functionality as the
1.454 + COpenFont::RasterizeL() except that the glyph code is supplied rather than
1.455 + the unicode.
1.456 +
1.457 + For more information:
1.458 + @see COpenFont::RasterizeL()
1.459 +
1.460 + @param aCode The glyph code of the character for which the bitmap is required.
1.461 + @param aGlyphData The function puts its output here.
1.462 + */
1.463 + virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
1.464 +
1.465 + /** Maps a character to a glyph index.
1.466 + @param aUnicodeCharacter Unicode character code to be mapped.
1.467 + @return Glyph code corresponding to aUnicodeCharacter. */
1.468 + virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0;
1.469 +
1.470 + /** Returns the hinted pixel coordinates of a particular point in the
1.471 + outline of the given glyph.
1.472 + @param aGlyphPoint The glyph index.
1.473 + @param aPointNumber The number of the point.
1.474 + @param aX Returns the point's X pixel value.
1.475 + @param aY Returns the point's Y pixel value.
1.476 + @return True on success, false otherwise. */
1.477 + virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber,
1.478 + TReal& aX, TReal& aY) const = 0;
1.479 +
1.480 + /** Returns the coordinates of a particular (unhinted) point in the outline
1.481 + of the given glyph in font units.
1.482 + @param aGlyphPoint The glyph index.
1.483 + @param aPointNumber The number of the point.
1.484 + @param aX Returns the point's X co-ordinate in font units.
1.485 + @param aY Returns the point's Y co-ordinate in font units.
1.486 + @return True on success, false otherwise. */
1.487 + virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber,
1.488 + TInt& aX, TInt& aY) const = 0;
1.489 +
1.490 + /** Returns font metrics.
1.491 + @param aOut Font metrics returned. */
1.492 + virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
1.493 + };
1.494 +
1.495 +/** TrueType extension for Open Fonts.
1.496 +
1.497 +If an open font is able to load TrueType or OpenType tables it should derive
1.498 +from this class.
1.499 +
1.500 +This class will be used by
1.501 +
1.502 +This interface should be returned by the overridden
1.503 +COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
1.504 +supplied as the UID.
1.505 +@see KUidOpenFontTrueTypeExtension
1.506 +@publishedAll
1.507 +@released
1.508 +*/
1.509 +class MOpenFontTrueTypeExtension
1.510 + {
1.511 +public:
1.512 + /** Returns the specified table. The table need not be released by the
1.513 + caller, so the deriver is responsible for ensuring that any memory
1.514 + allocated is ultimately cleaned up. The caller must not delete or modify
1.515 + the data returned.
1.516 + @param aError
1.517 + Returns KErrNone if successful or one of the system-wide error codes if
1.518 + unsuccessful. Returns KErrNotSupported if the table does not exist in
1.519 + the font file.
1.520 + @param aTag
1.521 + The tag of the table, with the first character in the most significant
1.522 + byte. For example, the "vhea" table is obtained by passing in 'v'<<24 |
1.523 + 'h'<<16 | 'e'<<8 | 'a'.
1.524 + @param aLength
1.525 + The length of the table in bytes that has been returned or 0 if
1.526 + unsuccessful.
1.527 + @return The table, if successful.
1.528 + @see ReleaseTrueTypeTable */
1.529 + virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0;
1.530 + /** Releases a table obtained by GetTrueTypeTable. The caller must not
1.531 + use the table after this call.
1.532 + @param aTable The table to be released.
1.533 + @see GetTrueTypeTable */
1.534 + virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0;
1.535 + /** Determines if the font file has a particular table.
1.536 + @param aTag The tag of the table as for GetTrueTypeTable.
1.537 + @return True if the table exists in the font file, false otherwise.
1.538 + @see GetTrueTypeTable */
1.539 + virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
1.540 + };
1.541 +
1.542 +class MOpenFontGlyphOutlineExtension
1.543 + {
1.544 +public:
1.545 + virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
1.546 + TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
1.547 + };
1.548 +/**
1.549 +Font attribute base class.
1.550 +
1.551 +This class is not intended for user derivation.
1.552 +
1.553 +@see TOpenFontFaceAttrib
1.554 +@see TOpenFontSpec
1.555 +@publishedAll
1.556 +@released
1.557 +*/
1.558 +class TOpenFontFaceAttribBase
1.559 + {
1.560 +public:
1.561 + inline TOpenFontFaceAttribBase();
1.562 + inline TBool HasLatin() const;
1.563 + inline TBool HasGreek() const;
1.564 + inline TBool HasCyrillic() const;
1.565 + inline TBool HasKana() const;
1.566 + inline TBool HasHangul() const;
1.567 + inline TBool HasCJK() const;
1.568 + inline TBool IsSymbol() const;
1.569 + inline TBool IsBold() const;
1.570 + inline TBool IsItalic() const;
1.571 + inline TBool IsSerif() const;
1.572 + inline TBool IsMonoWidth() const;
1.573 + inline TPtrC Name() const;
1.574 + inline const TUint* Coverage() const;
1.575 + inline void SetName(const TDesC& aName);
1.576 + inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0);
1.577 + inline void SetBold(TBool aBold);
1.578 + inline void SetItalic(TBool aItalic);
1.579 + inline void SetSerif(TBool aSerif);
1.580 + inline void SetMonoWidth(TBool aMonoWidth);
1.581 + inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const;
1.582 +
1.583 + // Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included)
1.584 + enum
1.585 + {
1.586 + ELatinSet = 0x1, // 0000-007F
1.587 + EGreekSet = 0x80, // 0370-03FF
1.588 + ECyrillicSet = 0x200, // 0400-04FF
1.589 + EArmenianSet = 0x400, // 0530-058F
1.590 + EHebrewSet = 0x800, // 0590-05FF
1.591 + EArabicSet = 0x2000, // 0600-06FF
1.592 + EDevanagariSet = 0x8000, // 0900-097F
1.593 + EBengaliSet = 0x10000, // 0980-09FF
1.594 + EGurmukhiSet = 0x20000, // 0A00-0A7F
1.595 + EGujuratiSet = 0x40000, // 0A80-0AFF
1.596 + EOriyaSet = 0x80000, // 0B00-0B7F
1.597 + ETamilSet = 0x100000, // 0B80-0BFF
1.598 + ETeluguSet = 0x200000, // 0C00-0C7F
1.599 + EKannadaSet = 0x400000, // 0C80-0CFF
1.600 + EMalayalamSet = 0x800000, // 0D00-0D7F
1.601 + EThaiSet = 0x1000000, // 0E00-0E7F
1.602 + ELaoSet = 0x2000000, // 0E80-0EFF
1.603 + EGeorgianSet = 0x8000000, // 10A0-10FF
1.604 + EHangulJamoSet = 0x10000000,// 1100-11FF
1.605 + };
1.606 +
1.607 + // Unicode ranges for iCoverage[1]
1.608 + enum
1.609 + {
1.610 + ESymbolSets = 0xFFFE,
1.611 + EKanaSets = 0x60000,
1.612 + EHangulSet = 0x100000,
1.613 + ECJKSet = 0x8000000
1.614 + };
1.615 +
1.616 + // Attribute flags
1.617 + enum
1.618 + {
1.619 + EBold = 0x1, // weight > 500 in Windows terms
1.620 + EItalic = 0x2, // italic or oblique - any forward slant counts
1.621 + ESerif = 0x4, // characters have serifs
1.622 + EMonoWidth = 0x8 // all characters are the same width
1.623 + };
1.624 +
1.625 + // Other constants
1.626 + enum
1.627 + {
1.628 + ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24
1.629 + };
1.630 +protected:
1.631 + TBufC<ENameLength> iName; // the name of the typeface; whether this is the full name or family name
1.632 + // or is in English or another language depends on the context
1.633 + TUint iCoverage[4]; // bitmap of the character sets supported by the typeface;
1.634 + // these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4
1.635 + // in the OS/2 table in TrueType fonts
1.636 + TInt iStyle; // bold, italic serif, and mono-width
1.637 + TInt32 iReserved;
1.638 + };
1.639 +
1.640 +
1.641 +/**
1.642 +Typeface attributes.
1.643 +
1.644 +These attributes include the name, family name, and supported scripts.
1.645 +
1.646 +@see CFbsFont::GetFaceAttrib()
1.647 +@publishedAll
1.648 +@released
1.649 +*/
1.650 +class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
1.651 + {
1.652 +public:
1.653 + inline TOpenFontFaceAttrib();
1.654 + inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const;
1.655 + inline TPtrC FullName() const;
1.656 + inline TPtrC FamilyName() const;
1.657 + inline TPtrC LocalFullName() const;
1.658 + inline TPtrC LocalFamilyName() const;
1.659 + inline TPtrC ShortFullName() const;
1.660 + inline TPtrC ShortFamilyName() const;
1.661 + inline TPtrC ShortLocalFullName() const;
1.662 + inline TPtrC ShortLocalFamilyName() const;
1.663 + inline void SetFullName(const TDesC& aName);
1.664 + inline void SetFamilyName(const TDesC& aName);
1.665 + inline void SetLocalFullName(const TDesC& aName);
1.666 + inline void SetLocalFamilyName(const TDesC& aName);
1.667 + inline TInt MinSizeInPixels() const;
1.668 + inline void SetMinSizeInPixels(TInt aSize);
1.669 +private:
1.670 + TBufC<ENameLength> iFamilyName; // the name without any style suffixes; usually a truncation of iFullName
1.671 + TBufC<ENameLength> iLocalFullName; // the full name in the language of the current locale
1.672 + TBufC<ENameLength> iLocalFamilyName; // the family name in the language of the current locale
1.673 + TInt iMinSizeInPixels; // minimum supported size, (or readable size if scalable) in pixels
1.674 + TInt32 iReserved2;
1.675 + };
1.676 +
1.677 +
1.678 +/**
1.679 +Font specification allowing more attributes to be specified than TFontSpec.
1.680 +
1.681 +In addition to the attributes specified by TFontSpec, this font specification
1.682 +allows stretching and slanting in the x dimension, and other algorithmic effects.
1.683 +This is used to correct for non-square pixels, and to allow algorithmic slanting
1.684 +and bold. The width factor and slant factor transform any point (x,y) to (x
1.685 +* iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16
1.686 +fixed-point numbers.
1.687 +
1.688 +The font specification also provides access to information about the scripts
1.689 +which are supported by the font. This information is not always reliable,
1.690 +because it may be incorrectly specified, or not specified at all, by some
1.691 +font manufacturers.
1.692 +@publishedAll
1.693 +@released
1.694 +*/
1.695 +class TOpenFontSpec : public TOpenFontFaceAttribBase
1.696 + {
1.697 +public:
1.698 + IMPORT_C TOpenFontSpec();
1.699 + IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec);
1.700 + IMPORT_C void operator=(const TFontSpec& aFontSpec);
1.701 + inline TBool operator==(const TOpenFontSpec& aFontSpec) const;
1.702 + TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const;
1.703 + IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib);
1.704 + IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const;
1.705 + IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight);
1.706 + IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap);
1.707 + inline TInt Height() const;
1.708 + inline TInt32 WidthFactor() const;
1.709 + inline TInt32 SlantFactor() const;
1.710 + inline TGlyphBitmapType BitmapType() const;
1.711 + inline TUint32 Effects() const;
1.712 + inline TFontPrintPosition PrintPosition() const;
1.713 + inline void SetHeight(TInt aHeight);
1.714 + inline void SetWidthFactor(TInt32 aWidthFactor);
1.715 + inline void SetSlantFactor(TInt32 aSlantFactor);
1.716 + inline void SetBitmapType(TGlyphBitmapType aBitmapType);
1.717 + inline void SetEffects(TUint32 aEffects);
1.718 + IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
1.719 + IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
1.720 + IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
1.721 + IMPORT_C TInt ScriptTypeForMetrics() const;
1.722 + static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight);
1.723 + static TInt ApplyRatio(TInt& aValue,TInt aNumerator,TInt aDenominator);
1.724 + static TInt ApplyRatio(TInt32& aValue,TInt aNumerator,TInt aDenominator);
1.725 +public:
1.726 + /** Algorithmic effects flags.
1.727 +
1.728 + These can be combined using an OR operation.
1.729 +
1.730 + WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
1.731 +
1.732 + @deprecated Use FontEffect::TEffect instead.
1.733 + */
1.734 + enum
1.735 + {
1.736 + /** Font is algorithmic bold. */
1.737 + EAlgorithmicBold = 1,
1.738 + /** Font has a drop shadow. */
1.739 + EDropShadow = 2,
1.740 + /** Font is an outline font. */
1.741 + EOutline = 4
1.742 + };
1.743 +private:
1.744 + void SetScriptTypeForMetrics(TInt aScript);
1.745 + void SetSymbol(TBool aSymbol);
1.746 + TBool Symbol() const;
1.747 + IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const;
1.748 + IMPORT_C TUint32 DoEffects() const;
1.749 + IMPORT_C void DoSetEffects(TUint32 aEffects);
1.750 +private:
1.751 + TInt iHeight; // em height
1.752 + TInt32 iWidthFactor; // algorithmic width factor as a 16.16 fixed-point number
1.753 + TInt32 iSlantFactor; // algorithmic slant factor as a 16.16 fixed-point number
1.754 + TInt iBitmapType; // non-anti-aliased, standard anti-aliased, etc.; zero means 'default'
1.755 + TUint32 iEffects; // bit flags for font effects
1.756 + TInt iSymbol; // a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5)
1.757 + // The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec
1.758 + TFontPrintPosition iPrintPosition; // normal, superscript or subscript
1.759 +
1.760 + TInt iReserved2;
1.761 + };
1.762 +
1.763 +/**
1.764 +Font file abstract base class.
1.765 +
1.766 +Write a class derived from COpenFontFile to manage a file with the font format
1.767 +supported by your DLL. The derived class must implement the virtual
1.768 +GetNearestFontInPixelsL() function. This function takes a font description
1.769 +and creates a COpenFont derived object if the description matches a typeface
1.770 +contained in the font file.
1.771 +
1.772 +Derived classes must also load typeface attributes from the file into the
1.773 +protected typeface attribute array during construction. This array is what
1.774 +is searched when getting font attribute information see AddFaceL(),
1.775 +GetNearestFontHelper().
1.776 +
1.777 +Writing derived classes construction:
1.778 +
1.779 +Call the COpenFontFile constructor in the constructor for your derived object,
1.780 +passing it aUid and aFileName arguments. These values are the arguments passed
1.781 +when the constructor is called by COpenFontRasterizer::NewFontFileL().
1.782 +
1.783 +A file may contain one or more typefaces. During construction the derived
1.784 +object should extract the information for each typeface and add it to this
1.785 +object's protected typeface attribute array see AddFaceL(). This process
1.786 +will probably leave under some conditions. It should therefore be implemented
1.787 +in a second phase constructor.
1.788 +
1.789 +Writing derived classes implement the pure virtual functions:
1.790 +
1.791 +Derived classes must also implement the two pure virtual functions
1.792 +GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about
1.793 +these functions is provided in the definitions below. Information about
1.794 +deriving from this class is also provided in the API guide.
1.795 +
1.796 +@see COpenFontRasterizer::NewFontFileL()
1.797 +@see CWsScreenDevice::AddFile()
1.798 +@publishedAll
1.799 +@released
1.800 +*/
1.801 +class COpenFontFile : public CBase
1.802 + {
1.803 +public:
1.804 + /**
1.805 + Gets the font which is the nearest to the given font specification.
1.806 +
1.807 + Implementations of this pure virtual function should create the COpenFont
1.808 + derived object that most closely matches aDesiredFontSpec, while fitting within
1.809 + aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
1.810 + e.g. if the font name doesn't match, aFont should be set to NULL.
1.811 +
1.812 + The other two arguments, aHeap and aSessionCacheList, should be passed to
1.813 + the COpenFont constructor.
1.814 +
1.815 + Implementations may use the utility function GetNearestFontHelper()
1.816 + to get the attributes of the closest matching font.
1.817 +
1.818 + @param aHeap Shared heap. This value should be passed to the
1.819 + COpenFont derived classes' constructor.
1.820 + @param aSessionCacheList The session cache list. This value should be passed
1.821 + to the COpenFont derived classes' constructor.
1.822 + @param aDesiredFontSpec The desired font specification.
1.823 + @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
1.824 + the algorithmic slant of the typeface.
1.825 + @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
1.826 + the algorithmic slant of the typeface.
1.827 + @param aFont On return, contains a pointer to the newly created COpenFont
1.828 + derived object, or NULL if no font matching aDesiredFontSpec exists.
1.829 + @param aActualFontSpec The actual font specification of the font retrieved into aFont.
1.830 + @see GetNearestFontHelper()
1.831 + */
1.832 + virtual void GetNearestFontInPixelsL(
1.833 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.834 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.835 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
1.836 +
1.837 + /**
1.838 + Gets the font which is the nearest to the given font specification.
1.839 +
1.840 + Implementations of this pure virtual function should create the COpenFont
1.841 + derived object that most closely matches aDesiredFontSpec, while fitting within
1.842 + aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
1.843 + e.g. if the font name doesn't match, aFont should be set to NULL.
1.844 +
1.845 + The other two arguments, aHeap and aSessionCacheList, should be passed to
1.846 + the COpenFont constructor.
1.847 +
1.848 + Implementations may use the utility function GetNearestFontHelper()
1.849 + to get the attributes of the closest matching font.
1.850 +
1.851 + @param aHeap Shared heap. This value should be passed to the COpenFont
1.852 + derived classes' constructor.
1.853 + @param aSessionCacheList The session cache list. This value should be passed
1.854 + to the COpenFont derived classes' constructor.
1.855 + @param aDesiredFontSpec The desired font specification.
1.856 + @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
1.857 + the algorithmic slant of the typeface.
1.858 + @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
1.859 + the algorithmic slant of the typeface.
1.860 + @param aFont On return, contains a pointer to the newly created COpenFont
1.861 + derived object, or NULL if no font matching aDesiredFontSpec exists.
1.862 + @param aActualFontSpec The actual font specification of the font retrieved into aFont.
1.863 + @see GetNearestFontHelper()
1.864 + */
1.865 + virtual void GetNearestFontToDesignHeightInPixelsL(
1.866 + RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
1.867 + const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
1.868 + COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
1.869 + /**
1.870 + Gets the font which is the nearest to the given font specification.
1.871 +
1.872 + Implementations of this pure virtual function should create the COpenFont
1.873 + derived object that most closely matches aDesiredFontSpec, while fitting within
1.874 + aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
1.875 + e.g. if the font name doesn't match, aFont should be set to NULL.
1.876 +
1.877 + The other two arguments, aHeap and aSessionCacheList, should be passed to
1.878 + the COpenFont constructor.
1.879 +
1.880 + Implementations may use the utility function GetNearestFontHelper()
1.881 + to get the attributes of the closest matching font.
1.882 +
1.883 + @param aHeap Shared heap. This value should be passed to the COpenFont
1.884 + derived classes' constructor.
1.885 + @param aSessionCacheList The session cache list. This value should be passed
1.886 + to the COpenFont derived classes' constructor.
1.887 + @param aDesiredFontSpec The desired font specification.
1.888 + @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
1.889 + the algorithmic slant of the typeface.
1.890 + @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
1.891 + the algorithmic slant of the typeface.
1.892 + @param aFont On return, contains a pointer to the newly created COpenFont
1.893 + derived object, or NULL if no font matching aDesiredFontSpec exists.
1.894 + @param aActualFontSpec The actual font specification of the font retrieved into aFont.
1.895 + @param aMaxHeight The maximum height (vertical extent) within which the font must fit.
1.896 + @see GetNearestFontHelper()
1.897 + */
1.898 + virtual void GetNearestFontToMaxHeightInPixelsL(
1.899 + RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
1.900 + const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
1.901 + COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
1.902 +
1.903 + /** Tests whether a specified typeface contains a particular character.
1.904 +
1.905 + @param aFaceIndex The index of the typeface to be tested.
1.906 + @param aCode The Unicode character code for the character to be tested.
1.907 + @return ETrue if the typeface contains aCode, otherwise EFalse. */
1.908 + virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0;
1.909 + IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
1.910 + IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName);
1.911 + IMPORT_C ~COpenFontFile();
1.912 + IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
1.913 + TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
1.914 + IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
1.915 + inline TUid Uid() const;
1.916 + inline const TDesC& FileName() const;
1.917 + inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
1.918 + inline TInt FaceCount() const;
1.919 + inline void IncRefCount();
1.920 + inline TBool DecRefCount();
1.921 + TInt GetNearestFontInPixels(
1.922 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.923 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.924 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
1.925 + TInt GetNearestFontToDesignHeightInPixels(
1.926 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.927 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.928 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
1.929 + TInt GetNearestFontToMaxHeightInPixels(
1.930 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.931 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.932 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
1.933 + void RemoveFontFromList(const COpenFont* aFont);
1.934 + void SetFontStoreL(CFontStore* aFontStore);
1.935 + CFontStore* GetFontStore();
1.936 + CArrayPtrFlat<COpenFont>* GetOpenFontList();
1.937 +protected:
1.938 + IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
1.939 + TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
1.940 +private:
1.941 + // A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
1.942 + class TAttrib: public TOpenFontFaceAttrib
1.943 + {
1.944 + public:
1.945 + COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface
1.946 + };
1.947 + static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
1.948 + static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
1.949 + void GetNearestFontToDesignHeightInPixelsAndAddToListL(
1.950 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.951 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.952 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
1.953 + void GetNearestFontToMaxHeightInPixelsAndAddToListL(
1.954 + RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
1.955 + const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
1.956 + COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
1.957 +
1.958 +private:
1.959 + CArrayFixFlat<TAttrib> iFaceAttrib;
1.960 + TUid iUid;
1.961 + TBuf<KMaxFileName> iFileName;
1.962 + TInt iRefCount;
1.963 + CArrayPtrFlat<COpenFont> iFontList;
1.964 + TOpenFontFileData* iData;
1.965 + };
1.966 +
1.967 +/**
1.968 +Convenience class from which rasterizer contexts may be derived.
1.969 +
1.970 +A rasterizer context object may (optionally) be created to provide the link
1.971 +between the rasterizer DLL code supported by the Open Font System, and the
1.972 +rasterizer engine code. A rasterizer context object class should get the
1.973 +requested bitmap from the associated rasterizer engine. It should then convert
1.974 +this into Symbian run-length-encoded format. This class contains convenience
1.975 +functions to make the conversion easier.
1.976 +
1.977 +Deriving from this class is described in greater detail in the API guide.
1.978 +@publishedAll
1.979 +@released
1.980 +*/
1.981 +class COpenFontRasterizerContext: public CBase
1.982 + {
1.983 +public:
1.984 + inline COpenFontRasterizerContext();
1.985 + inline void StartGlyph(TOpenFontGlyphData* aGlyphData);
1.986 + inline void WriteGlyphBit(TInt aBit);
1.987 + inline void WriteGlyphByte(TInt aByte);
1.988 + inline void EndGlyph();
1.989 +private:
1.990 + TOpenFontGlyphData* iGlyphData;
1.991 + TUint8* iGlyphDataStart;
1.992 + TUint8* iGlyphDataPtr;
1.993 + TUint8* iGlyphDataEnd;
1.994 + TInt iGlyphBit;
1.995 + TInt iBytesNeeded;
1.996 + TBool iOverflow;
1.997 + TAny* iReserved; // unused; for future expansion
1.998 + };
1.999 +
1.1000 +
1.1001 +/**
1.1002 +Shaper abstract class. All shaper implementations derive from this
1.1003 +@publishedAll
1.1004 +@released
1.1005 +*/
1.1006 +class CShaper : public CBase
1.1007 + {
1.1008 +public:
1.1009 + class TInput
1.1010 + {
1.1011 + public:
1.1012 + /** The text to be shaped possibly including context. */
1.1013 + const TDesC* iText;
1.1014 + /** The index of the first character in iText to be shaped. */
1.1015 + TInt iStart;
1.1016 + /** (One past) the end of the text in iText to be shaped. */
1.1017 + TInt iEnd;
1.1018 + /** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
1.1019 + for Devanagari. */
1.1020 + TInt iScript;
1.1021 + /** Language code. 0 implies "default" */
1.1022 + TUint32 iLanguage;
1.1023 + /** Maximum advance in pixels. Shaping beyond this
1.1024 + advance is not required (but is not harmful). */
1.1025 + TInt iMaximumAdvance;
1.1026 + /** Flags. Currently none is defined. */
1.1027 + TInt iFlags;
1.1028 + /** Session handle. To be used if rasterization is needed. */
1.1029 + TInt iSessionHandle;
1.1030 + /** Reserved for future expansion. Must be set to 0. */
1.1031 + TInt iReserved1;
1.1032 + };
1.1033 + /** Constructor */
1.1034 + IMPORT_C CShaper();
1.1035 +
1.1036 + /** Destructor */
1.1037 + IMPORT_C virtual ~CShaper();
1.1038 +
1.1039 + /** construct a shaper object
1.1040 + @param aBitmapFont The font to be shaped.
1.1041 + @param aHeap The heap to be used by the shaper.
1.1042 + @return KErrNone if this font can be shaper or system wide error code*/
1.1043 + virtual TInt ConstructL(CBitmapFont* aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1.1044 +
1.1045 + /** If possible, shape the text described by aInput, placing the output on aHeapForOutput.
1.1046 + @param aOutput The output, as a newly allocate object on aHeapForOutput.
1.1047 + @param aInput The input text and other parameters.
1.1048 + @param aHeapForOutput On success, aOutput should be allocated from this and nothing else.
1.1049 + On failure, nothing should be allocated from it.
1.1050 + @return Error value from one of the system-wide error codes on failure, KErrNone on success.
1.1051 + @see TShapeHeader */
1.1052 + virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0;
1.1053 +
1.1054 + /** For future expansion. Any overriders must base-call
1.1055 + if aInterface is unrecognized.
1.1056 +
1.1057 + WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1.1058 +
1.1059 + @param aInterfaceId The ID of the interface to return.
1.1060 + @return A pointer to the extension interface.
1.1061 + */
1.1062 + IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
1.1063 + };
1.1064 +
1.1065 +/** ECOM plug-in base class for shaper factories.
1.1066 +@publishedAll
1.1067 +@released
1.1068 +*/
1.1069 +class CShaperFactory : public CBase
1.1070 + {
1.1071 +public:
1.1072 + /** Create a shaper if possible, for typeface aFaceIndex
1.1073 + within file aFileName.
1.1074 + @param aFont The font to be shaped.
1.1075 + @param iHeap The heap to use for constructing the shaper.
1.1076 + @return 0 If the font is not understood or inappropriate for any shaper that might be constructed
1.1077 + by this class, otherwise returns the newly-constructed shaper on iHeap. */
1.1078 + virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1.1079 +
1.1080 + inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
1.1081 + inline virtual ~CShaperFactory();
1.1082 +
1.1083 + /** For future expansion. Any overriders must base-call if aInterface is unrecognized.
1.1084 +
1.1085 + WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1.1086 +
1.1087 + @param aInterfaceId The ID of the interface to return.
1.1088 + @return A pointer to the extension interface.
1.1089 + */
1.1090 + virtual void* ExtendedInterface(TUid aInterfaceId);
1.1091 +
1.1092 +private:
1.1093 + TUid iDtor_ID_Key;//ECOM identifier used during destruction
1.1094 + };
1.1095 +
1.1096 +// Inline functions start here.
1.1097 +/** Default C++ constructor.
1.1098 +
1.1099 +This creates then zero fills the object. */
1.1100 +inline TOpenFontMetrics::TOpenFontMetrics()
1.1101 + {
1.1102 + Mem::FillZ(this,sizeof(*this));
1.1103 + }
1.1104 +
1.1105 +/** Gets the font's size.
1.1106 +
1.1107 +@return The font's size.
1.1108 +@see SetSize() */
1.1109 +inline TInt TOpenFontMetrics::Size() const
1.1110 + {
1.1111 + return iDesignHeight;
1.1112 + }
1.1113 +
1.1114 +/** Gets the font's ascent.
1.1115 +
1.1116 +This is the ascent for the Latin character which is highest above the baseline.
1.1117 +
1.1118 +@return The font's ascent, in pixels.
1.1119 +@see SetAscent() */
1.1120 +inline TInt TOpenFontMetrics::Ascent() const
1.1121 + {
1.1122 + return iAscent;
1.1123 + }
1.1124 +
1.1125 +/** Gets the font's descent.
1.1126 +
1.1127 +This is the descent for the Latin character in the font which falls furthest below the baseline.
1.1128 +
1.1129 +@return The font's descent, in pixels.
1.1130 +@see SetDescent() */
1.1131 +inline TInt TOpenFontMetrics::Descent() const
1.1132 + {
1.1133 + return iDescent;
1.1134 + }
1.1135 +
1.1136 +/** Sets the font's maximum height.
1.1137 +
1.1138 +Note that if this object was initialised from the CFont this will be the same
1.1139 +as the ascent.
1.1140 +
1.1141 +This is the ascent for the character which is highest above the baseline.
1.1142 +In many fonts this will be the height of an accented character like Â,
1.1143 +including the accent.
1.1144 +
1.1145 +@return The maximum height of the font, in pixels.
1.1146 +@see SetMaxDepth() */
1.1147 +inline TInt TOpenFontMetrics::MaxHeight() const
1.1148 + {
1.1149 + return iMaxHeight;
1.1150 + }
1.1151 +
1.1152 +/** Gets the font's maximum depth.
1.1153 +
1.1154 +Note: If this object was initialised from the CFont this will be the same as the
1.1155 +descent.
1.1156 +
1.1157 +This is the descent for the character in the font which falls furthest below
1.1158 +the baseline.
1.1159 +
1.1160 +@return The font's maximum depth.
1.1161 +@see SetMaxDepth() */
1.1162 +inline TInt TOpenFontMetrics::MaxDepth() const
1.1163 + {
1.1164 + return iMaxDepth;
1.1165 + }
1.1166 +
1.1167 +/** Gets the maximum character width, in pixels.
1.1168 +
1.1169 +@return The maximum character width, in pixels.
1.1170 +@see SetMaxWidth() */
1.1171 +inline TInt TOpenFontMetrics::MaxWidth() const
1.1172 + {
1.1173 + return iMaxWidth;
1.1174 + }
1.1175 +
1.1176 +/** Sets the font's size.
1.1177 +
1.1178 +@param aSize The font's size.
1.1179 +@see Size() */
1.1180 +inline void TOpenFontMetrics::SetSize(TInt aSize)
1.1181 + {
1.1182 + iDesignHeight = static_cast<TInt16>(aSize);
1.1183 + }
1.1184 +
1.1185 +/** Sets the ascent.
1.1186 +
1.1187 +@param aAscent The ascent, in pixels.
1.1188 +@see Ascent() */
1.1189 +inline void TOpenFontMetrics::SetAscent(TInt aAscent)
1.1190 + {
1.1191 + iAscent = static_cast<TInt16>(aAscent);
1.1192 + }
1.1193 +
1.1194 +/** Sets the descent.
1.1195 +
1.1196 +@param aDescent The descent, in pixels.
1.1197 +@see Descent() */
1.1198 +inline void TOpenFontMetrics::SetDescent(TInt aDescent)
1.1199 + {
1.1200 + iDescent = static_cast<TInt16>(aDescent);
1.1201 + }
1.1202 +
1.1203 +/** Sets the font's maximum height.
1.1204 +
1.1205 +@param aMaxHeight The font's maximum height, in pixels.
1.1206 +@see MaxHeight() */
1.1207 +inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
1.1208 + {
1.1209 + iMaxHeight = static_cast<TInt16>(aMaxHeight);
1.1210 + }
1.1211 +
1.1212 +/** Sets the font's maximum depth.
1.1213 +
1.1214 +@param aMaxDepth The font's maximum depth, in pixels.
1.1215 +@see MaxDepth() */
1.1216 +inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
1.1217 + {
1.1218 + iMaxDepth = static_cast<TInt16>(aMaxDepth);
1.1219 + }
1.1220 +
1.1221 +/** Sets the maximum character width, in pixels.
1.1222 +
1.1223 +@param aMaxWidth The maximum character width, in pixels.
1.1224 +@see MaxWidth() */
1.1225 +inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
1.1226 + {
1.1227 + iMaxWidth = static_cast<TInt16>(aMaxWidth);
1.1228 + }
1.1229 +
1.1230 +/** Default C++ constructor.
1.1231 +
1.1232 +The constructor initialises all data members to zero. As for other T classes,
1.1233 +there is no need to explicitly cleanup TOpenFontCharMetrics objects. */
1.1234 +inline TOpenFontCharMetrics::TOpenFontCharMetrics()
1.1235 + {
1.1236 + Mem::FillZ(this,sizeof(*this));
1.1237 + }
1.1238 +
1.1239 +/** Gets the width of the character's bitmap.
1.1240 +
1.1241 +@return The width of the bitmap in pixels. */
1.1242 +inline TInt TOpenFontCharMetrics::Width() const
1.1243 + {
1.1244 + return iWidth;
1.1245 + }
1.1246 +
1.1247 +/** Gets the height of the character's bitmap.
1.1248 +
1.1249 +@return The character's height in pixels. */
1.1250 +inline TInt TOpenFontCharMetrics::Height() const
1.1251 + {
1.1252 + return iHeight;
1.1253 + }
1.1254 +
1.1255 +/** Gets the horizontal bearing X.
1.1256 +
1.1257 +This is the distance in pixels from the pen point before the character is
1.1258 +drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1.1259 +A positive value means that the left edge of the bitmap is right of the origin.
1.1260 +
1.1261 +@return The horizontal bearing X in pixels */
1.1262 +inline TInt TOpenFontCharMetrics::HorizBearingX() const
1.1263 + {
1.1264 + return iHorizBearingX;
1.1265 + }
1.1266 +
1.1267 +/** Gets horizontal bearing Y.
1.1268 +
1.1269 +This is the vertical distance in pixels from the pen point before the character
1.1270 +is drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1.1271 +A positive value means that the top edge of the bitmap is above the origin
1.1272 +
1.1273 +@return The horizontal bearing Y in pixels. */
1.1274 +inline TInt TOpenFontCharMetrics::HorizBearingY() const
1.1275 + {
1.1276 + return iHorizBearingY;
1.1277 + }
1.1278 +
1.1279 +/** Gets the horizontal advance.
1.1280 +
1.1281 +This is the amount added to the x co-ordinate of the origin after the character
1.1282 +is drawn what most people understand by the width or escapement of a character.
1.1283 +The origin here is the pen point before the character is drawn.
1.1284 +
1.1285 +@return The horizontal advance in pixels */
1.1286 +inline TInt TOpenFontCharMetrics::HorizAdvance() const
1.1287 + {
1.1288 + return iHorizAdvance;
1.1289 + }
1.1290 +
1.1291 +/** Gets the vertical bearing X.
1.1292 +
1.1293 +This is the distance in pixels from the pen point before the character is
1.1294 +drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1.1295 +A positive value means that the left edge of the bitmap is right of the origin.
1.1296 +
1.1297 +@return The vertical bearing X in pixels. */
1.1298 +inline TInt TOpenFontCharMetrics::VertBearingX() const
1.1299 + {
1.1300 + return iVertBearingX;
1.1301 + }
1.1302 +
1.1303 +/** Gets the vertical bearing Y.
1.1304 +
1.1305 +This is the distance in pixels from the pen point before the character is
1.1306 +drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1.1307 +A positive value means that the top edge of the bitmap is above the origin.
1.1308 +
1.1309 +@return The vertical bearing Y in pixels. */
1.1310 +inline TInt TOpenFontCharMetrics::VertBearingY() const
1.1311 + {
1.1312 + return iVertBearingY;
1.1313 + }
1.1314 +
1.1315 +/** Gets the vertical advance.
1.1316 +
1.1317 +When drawing vertically, this is the amount added to the y co-ordinate of
1.1318 +the origin after the character is drawn what most people understand by
1.1319 +the height of a character. The origin here is the pen point before the character
1.1320 +is drawn.
1.1321 +
1.1322 +Note: Vertical drawing is not supported in v5.
1.1323 +
1.1324 +@return The vertical advance in pixels. */
1.1325 +inline TInt TOpenFontCharMetrics::VertAdvance() const
1.1326 + {
1.1327 + return iVertAdvance;
1.1328 + }
1.1329 +
1.1330 +/** Gets the bounds of the character relative to its origin when setting text
1.1331 +horizontally.
1.1332 +
1.1333 +The origin here is the pen point before the character is drawn.
1.1334 +
1.1335 +@param aBounds The character's bounds. */
1.1336 +inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
1.1337 + {
1.1338 + aBounds.iTl.iX = iHorizBearingX;
1.1339 + aBounds.iTl.iY = -iHorizBearingY;
1.1340 + aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1.1341 + aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1.1342 + }
1.1343 +
1.1344 +/** Gets the bounds of the character relative to its origin when setting text
1.1345 +vertically.
1.1346 +
1.1347 +The origin here is the pen point before the character is drawn.
1.1348 +
1.1349 +@param aBounds The character's bounds. */
1.1350 +inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
1.1351 + {
1.1352 + aBounds.iTl.iX = -iVertBearingX;
1.1353 + aBounds.iTl.iY = iVertBearingY;
1.1354 + aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1.1355 + aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1.1356 + }
1.1357 +
1.1358 +/** Sets the width of the character's bitmap.
1.1359 +
1.1360 +@param aWidth The width of the bitmap in pixels. */
1.1361 +inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
1.1362 + {
1.1363 + iWidth = (TInt16)aWidth;
1.1364 + }
1.1365 +
1.1366 +/** Sets the height of the character's bitmap.
1.1367 +
1.1368 +@param aHeight The character height (in pixels). */
1.1369 +inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
1.1370 + {
1.1371 + iHeight = (TInt16)aHeight;
1.1372 + }
1.1373 +
1.1374 +/** Sets the horizontal bearing X.
1.1375 +
1.1376 +This is the distance in pixels from the pen point before the character is
1.1377 +drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1.1378 +A positive value means that the left edge of the bitmap is right of the origin.
1.1379 +
1.1380 +@param aHorizBearingX The horizontal bearing X (in pixels). */
1.1381 +inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
1.1382 + {
1.1383 + iHorizBearingX = (TInt16)aHorizBearingX;
1.1384 + }
1.1385 +
1.1386 +/** Sets the horizontal bearing Y.
1.1387 +
1.1388 +This is the distance in pixels from the pen point before the character is
1.1389 +drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1.1390 +A positive value means that the top edge of the bitmap is above the origin.
1.1391 +
1.1392 +@param aHorizBearingY The horizontal bearing Y (in pixels). */
1.1393 +inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
1.1394 + {
1.1395 + iHorizBearingY = (TInt16)aHorizBearingY;
1.1396 + }
1.1397 +
1.1398 +/** Sets the horizontal advance.
1.1399 +
1.1400 +This is the amount added to the x co-ordinate of the origin after the character
1.1401 +is drawn, what most people understand by the width or escapement of a character.
1.1402 +The origin here is the pen point before the character is drawn.
1.1403 +
1.1404 +@param aHorizAdvance The horizontal advance (in pixels). */
1.1405 +inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
1.1406 + {
1.1407 + iHorizAdvance = (TInt16)aHorizAdvance;
1.1408 + }
1.1409 +
1.1410 +/** Set vertical bearing X.
1.1411 +
1.1412 +This is the distance in pixels from the pen point before the character is
1.1413 +drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1.1414 +A positive value means that the left edge of the bitmap is right of the origin.
1.1415 +
1.1416 +@param aVertBearingX The vertical bearing X (in pixels). */
1.1417 +inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
1.1418 + {
1.1419 + iVertBearingX = (TInt16)aVertBearingX;
1.1420 + }
1.1421 +
1.1422 +/** Sets the vertical bearing Y.
1.1423 +
1.1424 +This is the distance in pixels from the pen point before the character is
1.1425 +drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1.1426 +A positive value means that the top edge of the bitmap is above the origin.
1.1427 +
1.1428 +@param aVertBearingY The vertical bearing Y (in pixels). */
1.1429 +inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
1.1430 + {
1.1431 + iVertBearingY = (TInt16)aVertBearingY;
1.1432 + }
1.1433 +
1.1434 +/** Sets the vertical advance.
1.1435 +
1.1436 +When drawing vertically, this is the amount added to the y co-ordinate of
1.1437 +the origin after the character is drawn what most people understand by
1.1438 +the height of a character. The origin here is the pen point before the character
1.1439 +is drawn.
1.1440 +
1.1441 +Note: Vertical drawing is not supported in v5.
1.1442 +
1.1443 +@param aVertAdvance The vertical advance (in pixels). */
1.1444 +inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
1.1445 + {
1.1446 + iVertAdvance = (TInt16)aVertAdvance;
1.1447 + }
1.1448 +
1.1449 +/** Gets the character metrics for this font.
1.1450 +
1.1451 +@return The character metrics for this font. */
1.1452 +inline const TOpenFontMetrics& COpenFont::Metrics() const
1.1453 + {
1.1454 + return iMetrics;
1.1455 + }
1.1456 +
1.1457 +/** Gets the glyph index.
1.1458 +
1.1459 +This is the index of a particular glyph within the font file.
1.1460 +
1.1461 +Note: This makes it possible to gain access to glyphs which are not referenced
1.1462 +by the Unicode character set. However, this feature is not yet supported by
1.1463 +Symbian OS.
1.1464 +
1.1465 +@return The glyph index.
1.1466 +@see SetGlyphIndex() */
1.1467 +inline TInt TOpenFontGlyphData::GlyphIndex() const
1.1468 + {
1.1469 + return iGlyphIndex;
1.1470 + }
1.1471 +
1.1472 +/** Gets the typeface attributes.
1.1473 +
1.1474 +These are the attributes of the font represented by this object.
1.1475 +
1.1476 +@return The typeface attributes. */
1.1477 +inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
1.1478 + {
1.1479 + return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex);
1.1480 + }
1.1481 +
1.1482 +/** Gets a pointer to the COpenFontFile which created this object.
1.1483 +
1.1484 +This is the COpenFontFile which owns the file that contains the definition
1.1485 +of the typeface. It can be used to get information about the typeface, or
1.1486 +to access the rasterizer context (engine).
1.1487 +
1.1488 +@return The COpenFontFile which created this object. */
1.1489 +inline COpenFontFile* COpenFont::File() const
1.1490 + {
1.1491 + return iFileOffset == 0 ? NULL : reinterpret_cast<COpenFontFile*>(const_cast<COpenFont*>(PtrAdd(this, iFileOffset)));
1.1492 + }
1.1493 +
1.1494 +/** Gets the index of this typeface within the font file.
1.1495 +
1.1496 +@return The index of this typeface within the font file. */
1.1497 +inline TInt COpenFont::FaceIndex() const
1.1498 + {
1.1499 + return iFaceIndex;
1.1500 + }
1.1501 +
1.1502 +/** Tests whether or not a character needs to be rasterized.
1.1503 +
1.1504 +Characters that have been rasterized are cached there is no need to regenerate
1.1505 +the character bitmap. This function should only be called by the Font and
1.1506 +Bitmap server.
1.1507 +
1.1508 +@param aSessionHandle A handle to the font and bitmap server session.
1.1509 +@param aCode The code for the Unicode character.
1.1510 +@return ETrue if the character needs to be rasterized, otherwise EFalse. */
1.1511 +inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const
1.1512 + {
1.1513 + return Glyph(aSessionHandle,aCode) == NULL;
1.1514 + }
1.1515 +
1.1516 +/** Gets the ascent of an ANSI capital letter in the font whether or not
1.1517 +there are any ANSI capitals in the font.
1.1518 +@return The positive distance from the font baseline to the top of a
1.1519 +standard ANSI capital letter
1.1520 +@publishedAll
1.1521 +@released
1.1522 +@see AscentInPixels()
1.1523 +*/
1.1524 +inline TInt COpenFont::FontCapitalAscent() const
1.1525 + {
1.1526 + return iFontCapitalAscent;
1.1527 + }
1.1528 +
1.1529 +/** Gets the max ascent of any pre-composed glyph in the font. This will
1.1530 +include accents or diacritics that form part of pre-composed glyphs. It is
1.1531 +not guaranteed to cover the max ascent of composite glyphs that have to be
1.1532 +created by a layout engine. This is also the recommended distance between
1.1533 +the top of a text box and the baseline of the first line of text.
1.1534 +
1.1535 +The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1.1536 +
1.1537 +@return The positive distance from the font baseline to the top of the
1.1538 +highest pre-composed glyph (including accents) above the baseline.
1.1539 +@publishedAll
1.1540 +@released
1.1541 +@see AscentInPixels()
1.1542 +@see SetScriptTypeForMetrics()
1.1543 +*/
1.1544 +inline TInt COpenFont::FontMaxAscent() const
1.1545 + {
1.1546 + return iFontMaxAscent;
1.1547 + }
1.1548 +
1.1549 +/** Gets the descent of an ANSI descending character in the font.
1.1550 +Whether or not there are any ANSI descenders in the font.
1.1551 +
1.1552 +The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1.1553 +
1.1554 +@return The positive distance from the font baseline to the bottom of the
1.1555 +lowest ANSI descender.
1.1556 +@publishedAll
1.1557 +@released
1.1558 +@see DescentInPixels()
1.1559 +@see SetScriptTypeForMetrics()
1.1560 +*/
1.1561 +inline TInt COpenFont::FontStandardDescent() const
1.1562 + {
1.1563 + return iFontStandardDescent;
1.1564 + }
1.1565 +
1.1566 +/** Gets the max descent of any pre-composed glyph in the font. This will
1.1567 +include accents or diacritics that form part of pre-composed glyphs. It is
1.1568 +not guaranteed to cover the max descent of composite glyphs that have to be
1.1569 +created by a layout engine.
1.1570 +
1.1571 +The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1.1572 +
1.1573 +@return The positive distance from the font baseline to the bottom of the
1.1574 +lowest pre-composed glyph (including accents) below the baseline
1.1575 +@publishedAll
1.1576 +@released
1.1577 +@see DescentInPixels()
1.1578 +@see SetScriptTypeForMetrics()
1.1579 +*/
1.1580 +inline TInt COpenFont::FontMaxDescent() const
1.1581 + {
1.1582 + return iFontMaxDescent;
1.1583 + }
1.1584 +
1.1585 +/** Gets the suggested line gap for the font. This is the recommended
1.1586 +baseline to baseline distance between successive lines of text in the font.
1.1587 +@return The positive recommended gap between successive lines
1.1588 +@publishedAll
1.1589 +@released
1.1590 +*/
1.1591 +inline TInt COpenFont::FontLineGap() const
1.1592 + {
1.1593 + return iFontLineGap;
1.1594 + }
1.1595 +
1.1596 +/** Gets the maximum height for the font. This is the sum of the max ascent
1.1597 +of the font and the max descent of the font.
1.1598 +
1.1599 +The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1.1600 +
1.1601 +@return The positive maximum height of the font
1.1602 +@publishedAll
1.1603 +@released
1.1604 +@see HeightInPixels()
1.1605 +@see SetScriptTypeForMetrics()
1.1606 +*/
1.1607 +inline TInt COpenFont::FontMaxHeight() const
1.1608 + {
1.1609 + return iFontMaxAscent + iFontMaxDescent;
1.1610 + }
1.1611 +
1.1612 +/** Default C++ constructor.
1.1613 +
1.1614 +This sets all attribute fields to zero. As for other T classes, there is no
1.1615 +need to explicitly clean-up objects derived from this class. */
1.1616 +inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
1.1617 + {
1.1618 + Mem::FillZ(this,sizeof(*this));
1.1619 + }
1.1620 +
1.1621 +/** Default C++ constructor.
1.1622 +
1.1623 +The function initialises the minimum typeface size to zero, the names to NULL,
1.1624 +and the coverage and style flags to zero. */
1.1625 +inline TOpenFontFaceAttrib::TOpenFontFaceAttrib():
1.1626 + iMinSizeInPixels(0),
1.1627 + iReserved2(0)
1.1628 + {
1.1629 + }
1.1630 +
1.1631 +/** Tests for support of Latin characters.
1.1632 +
1.1633 +Note: A return value of ETrue implies that the font has a usable set of
1.1634 +characters. It does not imply exhaustive coverage.
1.1635 +
1.1636 +@return ETrue if Latin characters are supported */
1.1637 +inline TBool TOpenFontFaceAttribBase::HasLatin() const
1.1638 + {
1.1639 + return iCoverage[0] & ELatinSet;
1.1640 + }
1.1641 +
1.1642 +/** Tests for support of Greek characters.
1.1643 +
1.1644 +Note: A return value of ETrue implies that the font has a usable set of
1.1645 +characters. It does not imply exhaustive coverage.
1.1646 +
1.1647 +@return ETrue if Greek characters are supported. */
1.1648 +inline TBool TOpenFontFaceAttribBase::HasGreek() const
1.1649 + {
1.1650 + return iCoverage[0] & EGreekSet;
1.1651 + }
1.1652 +
1.1653 +/** Tests for support of Cyrillic characters.
1.1654 +
1.1655 +Note: A return value of ETrue implies that the font has a usable set of
1.1656 +characters. It does not imply exhaustive coverage.
1.1657 +
1.1658 +@return ETrue if Cyrillic characters are supported. */
1.1659 +inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
1.1660 + {
1.1661 + return iCoverage[0] & ECyrillicSet;
1.1662 + }
1.1663 +
1.1664 +/** Tests for support of Japanese syllabic characters.
1.1665 +
1.1666 +This function tests for the presence of Hiragana and Katakana syllabic
1.1667 +characters in the font, collectively called kana. These characters are not
1.1668 +sufficient for the Japanese language, which also makes use of Chinese characters.
1.1669 +
1.1670 +Note: A return value of ETrue implies that the font has a usable set of
1.1671 +characters. It does not imply exhaustive coverage.
1.1672 +
1.1673 +@return ETrue if Japanese characters are supported
1.1674 +@see HasCJK() */
1.1675 +inline TBool TOpenFontFaceAttribBase::HasKana() const
1.1676 + {
1.1677 + return iCoverage[1] & EKanaSets;
1.1678 + }
1.1679 +
1.1680 +/** Tests for support of Korean Hangul characters.
1.1681 +
1.1682 +Korean may also make use of Chinese characters.
1.1683 +
1.1684 +Note: A return value of ETrue implies that the font has a usable set of
1.1685 +characters. It does not imply exhaustive coverage.
1.1686 +
1.1687 +@return ETrue if Korean characters are supported
1.1688 +@see HasCJK() */
1.1689 +inline TBool TOpenFontFaceAttribBase::HasHangul() const
1.1690 + {
1.1691 + return iCoverage[1] & EHangulSet;
1.1692 + }
1.1693 +
1.1694 +/** Tests for support of Chinese ideographic characters.
1.1695 +
1.1696 +These are used in Chinese, Japanese and Korean.
1.1697 +
1.1698 +Note: A return value of ETrue implies that the font has a usable set of
1.1699 +characters. It does not imply exhaustive coverage.
1.1700 +
1.1701 +@return ETrue if Chinese ideographs are supported. */
1.1702 +inline TBool TOpenFontFaceAttribBase::HasCJK() const
1.1703 + {
1.1704 + return iCoverage[1] & ECJKSet;
1.1705 + }
1.1706 +
1.1707 +/** Tests if the typeface contains symbols only.
1.1708 +
1.1709 +@return ETrue if the typeface contains symbols only. */
1.1710 +inline TBool TOpenFontFaceAttribBase::IsSymbol() const
1.1711 + {
1.1712 + return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
1.1713 + iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
1.1714 + }
1.1715 +
1.1716 +/** Tests if the typeface is inherently bold.
1.1717 +
1.1718 +@return ETrue if the typeface is inherently bold. */
1.1719 +inline TBool TOpenFontFaceAttribBase::IsBold() const
1.1720 + {
1.1721 + return iStyle & EBold;
1.1722 + }
1.1723 +
1.1724 +/** Tests if the typeface is inherently italic.
1.1725 +
1.1726 +@return ETrue if the typeface is inherently italic. */
1.1727 +inline TBool TOpenFontFaceAttribBase::IsItalic() const
1.1728 + {
1.1729 + return iStyle & EItalic;
1.1730 + }
1.1731 +
1.1732 +/** Tests if the typeface has serifs.
1.1733 +
1.1734 +@return ETrue if the typeface has serifs. */
1.1735 +inline TBool TOpenFontFaceAttribBase::IsSerif() const
1.1736 + {
1.1737 + return iStyle & ESerif;
1.1738 + }
1.1739 +
1.1740 +/** Tests if all the characters have the same width.
1.1741 +
1.1742 +@return ETrue if all the characters have the same width. */
1.1743 +inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
1.1744 + {
1.1745 + return iStyle & EMonoWidth;
1.1746 + }
1.1747 +
1.1748 +/** Gets the typeface's name.
1.1749 +
1.1750 +@return Descriptor containing typeface name. */
1.1751 +inline TPtrC TOpenFontFaceAttribBase::Name() const
1.1752 + {
1.1753 + return iName;
1.1754 + }
1.1755 +
1.1756 +/** Gets the full name.
1.1757 +
1.1758 +The full name of the typeface includes style attributes like Italic, Bold,
1.1759 +and Cursive.
1.1760 +
1.1761 +@return The full name of the typeface.
1.1762 +@see FamilyName() */
1.1763 +inline TPtrC TOpenFontFaceAttrib::FullName() const
1.1764 + {
1.1765 + return Name();
1.1766 + }
1.1767 +
1.1768 +/** Gets the family name.
1.1769 +
1.1770 +Note: The family name of the typeface does not include style attributes like
1.1771 +"Italic".
1.1772 +
1.1773 +@return The family name of the typeface.
1.1774 +@see FullName() */
1.1775 +inline TPtrC TOpenFontFaceAttrib::FamilyName() const
1.1776 + {
1.1777 + return iFamilyName;
1.1778 + }
1.1779 +
1.1780 +/** Gets the local full name.
1.1781 +
1.1782 +The local full name of the typeface includes style attributes like Italic,
1.1783 +Bold, and Cursive.
1.1784 +
1.1785 +The local name of the typeface is the name in the language of the current
1.1786 +locale, where this is provided by the font file. If the local name is not
1.1787 +available then the local name will be the same as the ordinary name.
1.1788 +
1.1789 +@return The local full name of the typeface. */
1.1790 +inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
1.1791 + {
1.1792 + return iLocalFullName;
1.1793 + }
1.1794 +
1.1795 +/** Gets the local family name.
1.1796 +
1.1797 +The local name of the typeface is the name in the language of the current
1.1798 +locale, where this is provided by the font file. If the local name is not
1.1799 +available then the local name will be the same as the ordinary name.
1.1800 +
1.1801 +Note: The family name of the typeface does not include style attributes like
1.1802 +'Italic'.
1.1803 +
1.1804 +@return The local family name of the typeface. */
1.1805 +inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
1.1806 + {
1.1807 + return iLocalFamilyName;
1.1808 + }
1.1809 +
1.1810 +/** Gets the short full name.
1.1811 +
1.1812 +This is the full name of the typeface, truncated to KMaxTypefaceNameLength,
1.1813 +if necessary.
1.1814 +
1.1815 +Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1.1816 +where necessary so that they can be used in the TTypeFace class. The Open
1.1817 +Font Framework allows 32 characters as a maximum name length.
1.1818 +
1.1819 +@return The short full name of the typeface.
1.1820 +@see FullName() */
1.1821 +inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
1.1822 + {
1.1823 + // Can't use TDesC::Left for this because it panics if the desired length is > the existing length!
1.1824 + return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength));
1.1825 + }
1.1826 +
1.1827 +/** Gets the short family name.
1.1828 +
1.1829 +This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
1.1830 +
1.1831 +Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1.1832 +where necessary so that they can be used in the TTypeFace class. The Open
1.1833 +Font Framework allows 32 characters as a maximum name length.
1.1834 +
1.1835 +@return The short family name of the typeface.
1.1836 +@see FamilyName() */
1.1837 +inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
1.1838 + {
1.1839 + return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
1.1840 + }
1.1841 +
1.1842 +/** Gets the short local full name.
1.1843 +
1.1844 +This is the local full name of the typeface, truncated to KMaxTypefaceNameLength,
1.1845 +if necessary.
1.1846 +
1.1847 +Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1.1848 +where necessary so that they can be used in the TTypeFace class. The Open
1.1849 +Font Framework allows 32 characters as a maximum name length.
1.1850 +
1.1851 +@return The short local full name of the typeface.
1.1852 +@see LocalFullName() */
1.1853 +inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
1.1854 + {
1.1855 + return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
1.1856 + }
1.1857 +
1.1858 +/** Gets the short local family name.
1.1859 +
1.1860 +This is the local family name of the typeface, truncated to KMaxTypefaceNameLength,
1.1861 +if necessary.
1.1862 +
1.1863 +Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1.1864 +where necessary so that they can be used in the TTypeFace class. The Open
1.1865 +Font Framework allows 32 characters as a maximum name length.
1.1866 +
1.1867 +@return The short local family name of the typeface.
1.1868 +@see LocalFamilyName() */
1.1869 +inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
1.1870 + {
1.1871 + return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
1.1872 + }
1.1873 +
1.1874 +/** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
1.1875 +
1.1876 +Each flag that is set represents a supported Unicode range. The mapping is
1.1877 +defined in the TrueType documentation under the OS/2 table.
1.1878 +
1.1879 +Note: Some useful subsets are defined as anonymous enumerated constants at the end
1.1880 +of this class, see ELatinSet etc.
1.1881 +
1.1882 +@return A pointer to the flags that indicate the font's Unicode coverage.
1.1883 +The flags are stored in an array of four 32-bit integers. When no information
1.1884 +is available, all four integers are zero.
1.1885 +@see SetCoverage() */
1.1886 +inline const TUint* TOpenFontFaceAttribBase::Coverage() const
1.1887 + {
1.1888 + return iCoverage;
1.1889 + }
1.1890 +
1.1891 +/** Gets the minimum typeface size.
1.1892 +
1.1893 +This is the smallest size that can be drawn legibly.
1.1894 +
1.1895 +@return The minimum typeface size (in pixels). */
1.1896 +inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
1.1897 + {
1.1898 + return iMinSizeInPixels;
1.1899 + }
1.1900 +
1.1901 +/** Sets the name attribute.
1.1902 +
1.1903 +@param aName Descriptor containing typeface name. */
1.1904 +inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
1.1905 + {
1.1906 + iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1.1907 + }
1.1908 +
1.1909 +/** Sets the full name.
1.1910 +
1.1911 +@param aName The full name of the typeface.
1.1912 +@see FullName() */
1.1913 +inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
1.1914 + {
1.1915 + SetName(aName);
1.1916 + }
1.1917 +
1.1918 +/** Sets the family name.
1.1919 +
1.1920 +@param aName The family name of the typeface.
1.1921 +@see FamilyName() */
1.1922 +inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
1.1923 + {
1.1924 + iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1.1925 + }
1.1926 +
1.1927 +/** Sets the local full name.
1.1928 +
1.1929 +@param aName The local full name of the typeface.
1.1930 +@see LocalFullName() */
1.1931 +inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
1.1932 + {
1.1933 + iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1.1934 + }
1.1935 +
1.1936 +/** Sets the local family name.
1.1937 +
1.1938 +@param aName The local family name of the typeface.
1.1939 +@see LocalFamilyName() */
1.1940 +inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
1.1941 + {
1.1942 + iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1.1943 + }
1.1944 +
1.1945 +/** Sets the coverage flags.
1.1946 +
1.1947 +The flags are held in four 32 bit integers. Each flag that is set represents
1.1948 +a range of Unicode characters that is supported by the typeface: Latin,
1.1949 +Greek, Cyrillic etc. The mapping is defined in the TrueType documentation
1.1950 +under the OS/2 table.
1.1951 +
1.1952 +Note: Some useful subsets are defined as anonymous enumerated constants at
1.1953 +the end of this class, see ELatinSet etc.
1.1954 +
1.1955 +@param aCoverage0 The first set of coverage flags (bits 0-31).
1.1956 +@param aCoverage1 The second set of coverage flags (bits 32-63).
1.1957 +@param aCoverage2 The third set of coverage flags (bits 64-95).
1.1958 +@param aCoverage3 The fourth set of coverage flags (bits 96-127). */
1.1959 +inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3)
1.1960 + {
1.1961 + iCoverage[0] = aCoverage0;
1.1962 + iCoverage[1] = aCoverage1;
1.1963 + iCoverage[2] = aCoverage2;
1.1964 + iCoverage[3] = aCoverage3;
1.1965 + }
1.1966 +
1.1967 +/** Set the minimum typeface size.
1.1968 +
1.1969 +This is the smallest size that can be drawn legibly.
1.1970 +
1.1971 +@param aSize Sets the minimum typeface size (in pixels).
1.1972 +@see MinSizeInPixels() */
1.1973 +inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
1.1974 + {
1.1975 + iMinSizeInPixels = aSize;
1.1976 + }
1.1977 +
1.1978 +/** Equality operator.
1.1979 +
1.1980 +Compares this and another set of font attributes, including the coverage,
1.1981 +the family name, the local full name, the local family name, and the minimum
1.1982 +size in pixels.
1.1983 +
1.1984 +@param aAttrib Contains the font attributes and names to compare.
1.1985 +@return ETrue if all values are equal, EFalse if not. */
1.1986 +inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const
1.1987 + {
1.1988 + return TOpenFontFaceAttribBase::operator==(aAttrib) &&
1.1989 + iFamilyName == aAttrib.iFamilyName &&
1.1990 + iLocalFullName == aAttrib.iLocalFullName &&
1.1991 + iLocalFamilyName == aAttrib.iLocalFamilyName &&
1.1992 + iMinSizeInPixels == aAttrib.iMinSizeInPixels;
1.1993 + }
1.1994 +
1.1995 +/** Sets the bold attribute.
1.1996 +
1.1997 +@param aBold The bold attribute takes this value: ETrue or EFalse. */
1.1998 +inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
1.1999 + {
1.2000 + if (aBold)
1.2001 + iStyle |= EBold;
1.2002 + else
1.2003 + iStyle &= ~EBold;
1.2004 + }
1.2005 +
1.2006 +/** Sets the italic attribute.
1.2007 +
1.2008 +@param aItalic The italic attribute takes this value ETrue or EFalse. */
1.2009 +inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
1.2010 + {
1.2011 + if (aItalic)
1.2012 + iStyle |= EItalic;
1.2013 + else
1.2014 + iStyle &= ~EItalic;
1.2015 + }
1.2016 +
1.2017 +/** Sets the serif attribute.
1.2018 +
1.2019 +@param aSerif The serif attribute takes this value ETrue or EFalse. */
1.2020 +inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
1.2021 + {
1.2022 + if (aSerif)
1.2023 + iStyle |= ESerif;
1.2024 + else
1.2025 + iStyle &= ~ESerif;
1.2026 + }
1.2027 +
1.2028 +/** Sets the mono-width attribute.
1.2029 +
1.2030 +@param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
1.2031 +inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
1.2032 + {
1.2033 + if (aMonoWidth)
1.2034 + iStyle |= EMonoWidth;
1.2035 + else
1.2036 + iStyle &= ~EMonoWidth;
1.2037 + }
1.2038 +
1.2039 +/** Equality operator.
1.2040 +
1.2041 +Compares this and a specified set of font attributes, including the coverage
1.2042 +and the typeface name.
1.2043 +
1.2044 +In version 6.1, and earlier, the return value was TInt.
1.2045 +
1.2046 +@param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase
1.2047 +or of a derived class.
1.2048 +@return ETrue if the values are equal. */
1.2049 +inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const
1.2050 + {
1.2051 + return iStyle == aAttrib.iStyle &&
1.2052 + iCoverage[0] == aAttrib.iCoverage[0] &&
1.2053 + iCoverage[1] == aAttrib.iCoverage[1] &&
1.2054 + iCoverage[2] == aAttrib.iCoverage[2] &&
1.2055 + iCoverage[3] == aAttrib.iCoverage[3] &&
1.2056 + iName.CompareF(aAttrib.iName) == 0;
1.2057 + }
1.2058 +
1.2059 +/** Compares this and another open font specification. Compares all the properties
1.2060 +of the two fonts.
1.2061 +@publishedAll
1.2062 +@released
1.2063 +@param aFontSpec The open font specification to compare with this one.
1.2064 +@return ETrue if all values are equal, EFalse if not.
1.2065 +*/
1.2066 +inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
1.2067 + {
1.2068 + return
1.2069 + iHeight == aOpenFontSpec.iHeight &&
1.2070 + iWidthFactor == aOpenFontSpec.iWidthFactor &&
1.2071 + iSlantFactor == aOpenFontSpec.iSlantFactor &&
1.2072 + iBitmapType == aOpenFontSpec.iBitmapType &&
1.2073 + iEffects == aOpenFontSpec.iEffects &&
1.2074 + iSymbol == aOpenFontSpec.iSymbol &&
1.2075 + iPrintPosition == aOpenFontSpec.iPrintPosition &&
1.2076 + TOpenFontFaceAttribBase::operator==(aOpenFontSpec);
1.2077 + }
1.2078 +
1.2079 +/** Gets the height of the font.
1.2080 +
1.2081 +@return The height of the font, in pixels or twips.
1.2082 +@see SetHeight() */
1.2083 +inline TInt TOpenFontSpec::Height() const
1.2084 + {
1.2085 + return iHeight;
1.2086 + }
1.2087 +
1.2088 +/** Gets the algorithmic width factor.
1.2089 +
1.2090 +@return The algorithmic width factor as a 16.16 fixed-point number.
1.2091 +@see SetWidthFactor() */
1.2092 +inline TInt32 TOpenFontSpec::WidthFactor() const
1.2093 + {
1.2094 + return iWidthFactor;
1.2095 + }
1.2096 +
1.2097 +/** Gets the algorithmic slant factor.
1.2098 +
1.2099 +@return The algorithmic slant factor as a 16.16 fixed-point number.
1.2100 +@see SetSlantFactor() */
1.2101 +inline TInt32 TOpenFontSpec::SlantFactor() const
1.2102 + {
1.2103 + return iSlantFactor;
1.2104 + }
1.2105 +
1.2106 +/** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
1.2107 +
1.2108 +@return Indicates whether or not the font should be drawn using anti-aliasing. */
1.2109 +inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
1.2110 + {
1.2111 + return (TGlyphBitmapType)iBitmapType;
1.2112 + }
1.2113 +
1.2114 +/** Gets the font effects flags.
1.2115 +Because the flags encoded in the Effects are anonymous, the return value should only
1.2116 + be tested for the specific bits that are of interest, and never tested as a whole.
1.2117 +@publishedAll
1.2118 +@released
1.2119 +@return The font effects flags.
1.2120 +@see TOpenFontSpec::SetEffects()
1.2121 +*/
1.2122 +inline TUint32 TOpenFontSpec::Effects() const
1.2123 + {
1.2124 + return iEffects;
1.2125 + }
1.2126 +
1.2127 +/** Gets the print position.
1.2128 +
1.2129 +@return The print position. */
1.2130 +inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
1.2131 + {
1.2132 + return iPrintPosition;
1.2133 + }
1.2134 +
1.2135 +/** Sets the font's height.
1.2136 +
1.2137 +@param aHeight The font's height, in pixels or twips.
1.2138 +@see Height() */
1.2139 +inline void TOpenFontSpec::SetHeight(TInt aHeight)
1.2140 + {
1.2141 + iHeight = aHeight;
1.2142 + }
1.2143 +
1.2144 +/** Sets the algorithmic width factor.
1.2145 +
1.2146 +The width factor is multiplied by the pixel's x position to get the new position,
1.2147 +causing characters to become wider or narrower. A width factor of 1 (65536
1.2148 +in 16.16 fixed-point number format) should be used if the character width
1.2149 +is not to be changed.
1.2150 +
1.2151 +@param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
1.2152 +@see WidthFactor() */
1.2153 +inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
1.2154 + {
1.2155 + iWidthFactor = aWidthFactor;
1.2156 + }
1.2157 +
1.2158 +/** Sets the algorithmic slant factor.
1.2159 +
1.2160 +Note: The slant factor is used to create an italic effect for characters which
1.2161 +do not have an italic glyph in the typeface. When slanting is active, pixel x
1.2162 +co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x
1.2163 += x + y x slant factor).
1.2164 +
1.2165 +The slant factor is a 32 bit, 16.16 fixed-point number. This means that the
1.2166 +first 16 bits are treated as a whole number, and the second 16 as the fractional
1.2167 +part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this
1.2168 +is equivalent to an integer slant value of 1, which causes a 45 degree slant
1.2169 +on the character.
1.2170 +
1.2171 +@param aSlantFactor The slant factor as a 16.16 fixed-point number.
1.2172 +@see SlantFactor() */
1.2173 +inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
1.2174 + {
1.2175 + iSlantFactor = aSlantFactor;
1.2176 + }
1.2177 +
1.2178 +/** Sets whether the font should be drawn using anti-aliasing. If set, this value
1.2179 +overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
1.2180 +for this font.
1.2181 +
1.2182 +Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
1.2183 +support for bitmapped fonts.
1.2184 +
1.2185 +@param aBitmapType Indicates whether or not the font should be drawn using
1.2186 +anti-aliasing. */
1.2187 +inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
1.2188 + {
1.2189 + iBitmapType = aBitmapType;
1.2190 + }
1.2191 +
1.2192 +/** Sets the font effects flags.
1.2193 +Prior to calling this routine, the value from Effects() should be read,
1.2194 + and its flags modified as required, before passing them back in.
1.2195 +@publishedAll
1.2196 +@released
1.2197 +@param aEffect The font effects flags to be set.
1.2198 +@see TOpenFontSpec::Effects()
1.2199 +*/
1.2200 +inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
1.2201 + {
1.2202 + iEffects = aEffects;
1.2203 + }
1.2204 +
1.2205 +/** Gets the font file's UID.
1.2206 +
1.2207 +@return The uid of the file. */
1.2208 +inline TUid COpenFontFile::Uid() const
1.2209 + {
1.2210 + return iUid;
1.2211 + }
1.2212 +
1.2213 +/** Gets the full path and filename of the font file
1.2214 +
1.2215 +This is the filename that was passed to the constructor when the object is
1.2216 +created.
1.2217 +
1.2218 +@return The filename of the font file. */
1.2219 +inline const TDesC& COpenFontFile::FileName() const
1.2220 + {
1.2221 + return iFileName;
1.2222 + }
1.2223 +
1.2224 +/** Gets the typeface at a specified index in the typeface attribute array.
1.2225 +
1.2226 +@param aFaceIndex The index of the typeface for which the attributes are required.
1.2227 +@return The attributes of the typeface with the specified index.
1.2228 +@see AddFaceL()
1.2229 +@see FaceCount() */
1.2230 +inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
1.2231 + {
1.2232 + return iFaceAttrib[aFaceIndex];
1.2233 + }
1.2234 +
1.2235 +/** Gets the number of typefaces in the typeface attributes array.
1.2236 +
1.2237 +This is the number of typefaces in the font file: the attributes for each
1.2238 +typeface should be loaded into the array when the derived object is constructed.
1.2239 +
1.2240 +@return The number of typefaces in the font file.
1.2241 +@see AddFaceL()
1.2242 +@see FaceAttrib() */
1.2243 +inline TInt COpenFontFile::FaceCount() const
1.2244 + {
1.2245 + return iFaceAttrib.Count();
1.2246 + }
1.2247 +
1.2248 +/** Increments a reference count by one.
1.2249 +
1.2250 +@see DecRefCount() */
1.2251 +inline void COpenFontFile::IncRefCount()
1.2252 + {
1.2253 + iRefCount++;
1.2254 + }
1.2255 +
1.2256 +/** Decrement a reference count by one.
1.2257 +
1.2258 +@return ETrue if the reference count has reached zero (i.e. is less than or
1.2259 +equal to zero); EFalse if the reference count has not yet reached zero (i.e.
1.2260 +is positive).
1.2261 +@see IncRefCount() */
1.2262 +inline TBool COpenFontFile::DecRefCount()
1.2263 + {
1.2264 + iRefCount--;
1.2265 + return iRefCount <= 0;
1.2266 + }
1.2267 +
1.2268 +/** Default C++ constructor. */
1.2269 +inline COpenFontRasterizerContext::COpenFontRasterizerContext():
1.2270 + iGlyphData(NULL)
1.2271 + {
1.2272 + }
1.2273 +
1.2274 +/** Start writing the glyph data.
1.2275 +
1.2276 +Use this function to initialise the buffer to which the glyph bitmap is to
1.2277 +be written. Call WriteGlyphBit() to add bits to the buffer.
1.2278 +
1.2279 +@param aGlyphData A pointer to the glyph data. */
1.2280 +inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
1.2281 + {
1.2282 + aGlyphData->SetPointersToInternalBuffers();
1.2283 + iGlyphData = aGlyphData;
1.2284 + iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
1.2285 + // Allow 4 extra bytes; BITGDI requires this.
1.2286 + iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
1.2287 + iGlyphBit = 1;
1.2288 + *iGlyphDataPtr = 0;
1.2289 + iBytesNeeded = 1;
1.2290 + iOverflow = FALSE;
1.2291 + }
1.2292 +
1.2293 +/** Writes a bit to the glyph buffer.
1.2294 +
1.2295 +Before calling this function you should first call StartGlyph().
1.2296 +
1.2297 +@param aBit The bit to be added to the buffer. */
1.2298 +inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
1.2299 + {
1.2300 + if (aBit && !iOverflow)
1.2301 + *iGlyphDataPtr |= iGlyphBit;
1.2302 + iGlyphBit <<= 1;
1.2303 + if (iGlyphBit == 256)
1.2304 + {
1.2305 + iGlyphBit = 1;
1.2306 + iBytesNeeded++;
1.2307 + if (++iGlyphDataPtr < iGlyphDataEnd)
1.2308 + *iGlyphDataPtr = 0;
1.2309 + else
1.2310 + iOverflow = TRUE;
1.2311 + }
1.2312 + }
1.2313 +
1.2314 +/** Writes a byte to the glyph buffer.
1.2315 +
1.2316 +Before calling this function you should first call StartGlyph().
1.2317 +
1.2318 +@param aByte The byte to be added to the buffer. */
1.2319 +inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
1.2320 + {
1.2321 + if (iGlyphDataPtr < iGlyphDataEnd)
1.2322 + *iGlyphDataPtr++ = (TUint8)aByte;
1.2323 + else
1.2324 + iOverflow = TRUE;
1.2325 + iBytesNeeded++;
1.2326 + }
1.2327 +
1.2328 +/** Completes writing glyph data.
1.2329 +
1.2330 +Use this function to complete writing the glyph bitmap to the buffer. Call
1.2331 +it after adding all necessary bits using WriteGlyphBit(). */
1.2332 +inline void COpenFontRasterizerContext::EndGlyph()
1.2333 + {
1.2334 + // Add 4 bytes to the data size; some BITGDI functions require this.
1.2335 + iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
1.2336 + iGlyphData = NULL;
1.2337 + }
1.2338 +
1.2339 +/** Tests whether the bitmap buffer is large enough to hold the bitmap.
1.2340 +
1.2341 +@return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
1.2342 +inline TBool TOpenFontGlyphData::Overflow() const
1.2343 + {
1.2344 + return iBytesNeeded > iBitmapBufferSize;
1.2345 + }
1.2346 +
1.2347 +/** Gets the number of bytes needed to store the glyph bitmap.
1.2348 +
1.2349 +@return The number of bytes needed to store the glyph bitmap.
1.2350 +@see SetBytesNeeded() */
1.2351 +inline TInt TOpenFontGlyphData::BytesNeeded() const
1.2352 + {
1.2353 + return iBytesNeeded;
1.2354 + }
1.2355 +
1.2356 +/** Gets a constant pointer descriptor containing the bitmap this object
1.2357 +represents.
1.2358 +
1.2359 +@return Pointer descriptor for the glyph. */
1.2360 +inline TPtrC8 TOpenFontGlyphData::Bitmap() const
1.2361 + {
1.2362 + return TPtrC8(iBitmap,iBytesNeeded);
1.2363 + }
1.2364 +
1.2365 +/** Gets a pointer to the bitmap.
1.2366 +
1.2367 +This points either to the buffer used to write the bitmap when it is first
1.2368 +rasterized, or to the cache if the character was already rasterized.
1.2369 +
1.2370 +@return A pointer to the bitmap. */
1.2371 +inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
1.2372 + {
1.2373 + return iBitmap;
1.2374 + }
1.2375 +
1.2376 +/** Gets the character's metrics.
1.2377 +
1.2378 +@return The character's open font metrics. */
1.2379 +inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
1.2380 + {
1.2381 + return iMetrics;
1.2382 + }
1.2383 +
1.2384 +/** Gets a pointer to the start of the bitmap buffer.
1.2385 +
1.2386 +@return A pointer to the start of the bitmap buffer. */
1.2387 +inline TUint8* TOpenFontGlyphData::BufferStart()
1.2388 + {
1.2389 + return iBitmapBuffer;
1.2390 + }
1.2391 +
1.2392 +/** Gets a pointer to the end of the bitmap buffer.
1.2393 +
1.2394 +@return A pointer to the end of the bitmap buffer. */
1.2395 +inline TUint8* TOpenFontGlyphData::BufferEnd()
1.2396 + {
1.2397 + return iBitmapBuffer + iBitmapBufferSize;
1.2398 + }
1.2399 +
1.2400 +/** Sets the number of bytes needed to store the glyph bitmap.
1.2401 +
1.2402 +@param aBytes The number of bytes needed to store the glyph bitmap.
1.2403 +@see BytesNeeded() */
1.2404 +inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
1.2405 + {
1.2406 + iBytesNeeded = aBytes;
1.2407 + }
1.2408 +
1.2409 +/** Sets the pointer to the bitmap buffer.
1.2410 +
1.2411 +@param aBitmap The pointer to the bitmap buffer. */
1.2412 +inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
1.2413 + {
1.2414 + iBitmap = aBitmap;
1.2415 + }
1.2416 +
1.2417 +/** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
1.2418 +
1.2419 +@param aMetrics A pointer to the character's open font character metrics. */
1.2420 +inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
1.2421 + {
1.2422 + iMetrics = aMetrics;
1.2423 + }
1.2424 +
1.2425 +/** Sets the bitmap and metrics pointers to point to the internal buffers.
1.2426 +
1.2427 +The alternative is that the pointers point to the cache of metrics and bitmaps
1.2428 +that have already been rasterized. */
1.2429 +inline void TOpenFontGlyphData::SetPointersToInternalBuffers()
1.2430 + {
1.2431 + iBitmap = iBitmapBuffer;
1.2432 + iMetrics = &iMetricsBuffer;
1.2433 + }
1.2434 +
1.2435 +/** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics
1.2436 +object.
1.2437 +
1.2438 +@param aMetrics The character's open font character metrics. */
1.2439 +inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
1.2440 + {
1.2441 + iMetricsBuffer = aMetrics;
1.2442 + iMetrics = &iMetricsBuffer;
1.2443 + }
1.2444 +
1.2445 +/** Sets the glyph index.
1.2446 +
1.2447 +@param aGlyphIndex The glyph index. */
1.2448 +inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
1.2449 + {
1.2450 + iGlyphIndex = aGlyphIndex;
1.2451 + }
1.2452 +
1.2453 +/** Uses ECOM plug-in framework to instantiate the shaper factory interface
1.2454 +implementation given its implementation UID.
1.2455 +
1.2456 +@param aInterfaceImplUid The UID of the interface implementation required
1.2457 +
1.2458 +@return CShaperFactory* A pointer to a CShaperFactory object. */
1.2459 +inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
1.2460 + {
1.2461 + return reinterpret_cast <CShaperFactory*> (
1.2462 + REComSession::CreateImplementationL(
1.2463 + aInterfaceImplUid,
1.2464 + _FOFF(CShaperFactory, iDtor_ID_Key)));
1.2465 + }
1.2466 +
1.2467 +/** Default destructor */
1.2468 +inline CShaperFactory::~CShaperFactory()
1.2469 +{
1.2470 + REComSession::DestroyedImplementation(iDtor_ID_Key);
1.2471 +}
1.2472 +
1.2473 +#endif // __OPENFONT_H__