Update contrib.
2 * Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * A header for the open font system, which allows SymbianOS
16 * to use fonts of arbitrary types, including TrueType/OpenType
17 * and other outline font formats.
22 #ifndef __OPENFONT_H__
23 #define __OPENFONT_H__
27 #include <ecom/ecom.h>
29 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
30 #include <linkedfonts.h>
31 #include <graphics/openfontconstants.h>
32 #include <graphics/openfontrasterizer.h>
33 #include <openfontlinkedtypefaceelementspec.h>
34 #include <graphics/openfontlinkedtypefacespecification.h>
35 #include <graphics/openfontlinkedtypefaceextension.h>
41 class COpenFontGlyphCache;
42 class COpenFontPositioner;
43 class COpenFontSessionCache;
44 class COpenFontSessionCacheList;
46 class TCharacterMetrics;
48 class TOpenFontFaceAttrib;
50 class TOpenFontFileData;
56 class TFontShapeFunctionParameters;
57 class TFontShapeDeleteFunctionParameters;
59 class TShapeMessageParameters;
60 class CRasterizerLinkedTypefaceSpecification;
61 class TLinkedTypefaceSpecificationArgs;
64 Supplied to COpenFont::ExtendedInterface() to access the extended
65 API interface MOpenFontShapingExtension.
67 @see COpenFont::ExtendedInterface()
68 @see MOpenFontShapingExtension
72 const TUid KUidOpenFontShapingExtension = {0x10274DB9};
75 Supplied to COpenFont::ExtendedInterface() to access the extended
76 API interface MOpenFontTrueTypeExtension.
78 @see COpenFont::ExtendedInterface()
79 @see MOpenFontTrueTypeExtension
83 const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
84 const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
87 Supplied to CShaper::ExtendedInterface() to get the language and script
88 code with which the current shaper is instatsiated.
89 @see CShaper::ExtendedInterface()
93 const TUid KUidShaperGetScript = {0x20009966};
94 const TUid KUidShaperGetLang = {0x20009967};
99 @see CFbsFont::GetFontMetrics()
103 class TOpenFontMetrics
106 inline TOpenFontMetrics();
107 IMPORT_C TOpenFontMetrics(const CFont* aFont);
108 inline TInt Size() const;
109 inline TInt Ascent() const;
110 inline TInt Descent() const;
111 inline TInt MaxHeight() const;
112 inline TInt MaxDepth() const;
113 inline TInt MaxWidth() const;
114 inline void SetSize(TInt aSize);
115 inline void SetAscent(TInt aAscent);
116 inline void SetDescent(TInt aDescent);
117 inline void SetMaxHeight(TInt aMaxHeight);
118 inline void SetMaxDepth(TInt aMaxDepth);
119 inline void SetMaxWidth(TInt aMaxWidth);
120 /** WARNING: Function for internal and partner use ONLY. Compatibility is not guaranteed in future releases.*/
121 IMPORT_C void SetBaselineCorrection(TInt aBaselineCorrection);
122 IMPORT_C TInt BaselineCorrection();
124 TInt16 iDesignHeight; // size of the font ('pointsize' in pixels)
125 TInt16 iAscent; // typographic ascent
126 TInt16 iDescent; // typographic descent
127 TInt16 iMaxHeight; // maximum height of a character; may be greater than iAscent
128 TInt16 iMaxDepth; // maximum depth of a character; may be greater than iDescent
129 TInt16 iMaxWidth; // maximum width of a character
130 TInt16 iBaselineCorrection;
136 Character metrics includes more information than TCharacterMetrics.
138 Character metrics allow characters to be placed horizontally or vertically.
139 The character metrics encapsulated by this class are: Height, Width, Horizontal
140 Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X,
141 Vertical Bearing Y, and Vertical Advance. Their meanings are described in the
142 associated setter and getter functions.
146 Vertical drawing (in the sense of characters drawn with horizontal baselines,
147 but in a vertical line) is not yet supported by Symbian OS.
149 @see CFont::GetCharacterData()
150 @see CFbsFont::GetCharacterData()
154 class TOpenFontCharMetrics
157 enum TUninitialized { EUninitialized };
159 /** Default constructor initializes all members to 0. */
160 inline TOpenFontCharMetrics();
162 /** Constructor that does not initialize any members. */
163 TOpenFontCharMetrics(TUninitialized) {}
164 IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics);
165 IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const;
166 inline TInt Width() const;
167 inline TInt Height() const;
168 inline TInt HorizBearingX() const;
169 inline TInt HorizBearingY() const;
170 inline TInt HorizAdvance() const;
171 inline TInt VertBearingX() const;
172 inline TInt VertBearingY() const;
173 inline TInt VertAdvance() const;
174 inline void GetHorizBounds(TRect& aBounds) const;
175 inline void GetVertBounds(TRect& aBounds) const;
176 inline void SetWidth(TInt aWidth);
177 inline void SetHeight(TInt aHeight);
178 inline void SetHorizBearingX(TInt aHorizBearingX);
179 inline void SetHorizBearingY(TInt aHorizBearingY);
180 inline void SetHorizAdvance(TInt aHorizAdvance);
181 inline void SetVertBearingX(TInt aVertBearingX);
182 inline void SetVertBearingY(TInt aVertBearingY);
183 inline void SetVertAdvance(TInt aVertAdvance);
184 IMPORT_C void SetGlyphType(TGlyphBitmapType);
185 IMPORT_C TGlyphBitmapType GlyphType() const;
187 TInt16 iWidth; // width of the glyph
188 TInt16 iHeight; // height of the glyph
189 TInt16 iHorizBearingX; // x component of horizontal bearing
190 TInt16 iHorizBearingY; // y component of horizontal bearing
191 TInt16 iHorizAdvance; // horizontal advance
192 TInt16 iVertBearingX; // x component of vertical bearing
193 TInt16 iVertBearingY; // y component of vertical bearing
194 TInt16 iVertAdvance; // vertical advance
195 TUint16 iGlyphBitmapType;// Glyph bitmap type; TGlyphBitmapType
203 Objects of this type are used by rasterizers to supply glyph data to font
204 and bitmap server clients. Unless you are writing a rasterizer you will not
205 need to use an object of this type.
207 The object cannot be constructed and destroyed by normal means. It resides
208 on a specified heap. It is created by New() and deleted by RHeap::Free().
210 @see COpenFont::RasterizeL()
214 class TOpenFontGlyphData
217 IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize);
218 inline TBool Overflow() const;
219 inline TInt BytesNeeded() const;
220 inline TPtrC8 Bitmap() const;
221 inline const TUint8* BitmapPointer() const;
222 inline const TOpenFontCharMetrics* Metrics() const;
223 inline TInt GlyphIndex() const;
224 inline TUint8* BufferStart();
225 inline TUint8* BufferEnd();
226 inline void SetBytesNeeded(TInt aBytes);
227 inline void SetBitmapPointer(const TUint8* aBitmap);
228 inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics);
229 inline void SetPointersToInternalBuffers();
230 inline void SetMetrics(TOpenFontCharMetrics& aMetrics);
231 inline void SetGlyphIndex(TInt aGlyphIndex);
234 Prevent construction and destruction by normal means; the object resides
235 on a specified heap and is created by New and deleted by RHeap::Free.
237 TOpenFontGlyphData();
238 ~TOpenFontGlyphData();
240 TInt iBitmapBufferSize; // size of the buffer in bytes
241 TInt iBytesNeeded; // bytes needed for the bitmap
242 TOpenFontCharMetrics iMetricsBuffer; // the metrics
243 const TUint8* iBitmap; // pointer to the bitmap; points either to iBitmapBuffer or to
244 // the cache if the character was already rasterized
245 const TOpenFontCharMetrics* iMetrics; // pointer to the metrics; points either to iMetricsBuffer or to
246 // the cache if the character was already rasterized
247 TInt iGlyphIndex; // the glyph index
248 TAny* iReserved; // unused; for future expansion
249 TUint8 iBitmapBuffer[1]; // buffer used to write the bitmap when it is first rasterized; this
250 // is actually of size iBitmapBufferSize.
254 Open Font System font abstract base class.
256 Derive a class from this class to represent an instance of a typeface at a
257 particular size, provide bitmaps of the glyphs, and determine whether
258 characters exist in the typeface.
260 Writing derived classes construction:
262 You must call the constructor of this class when creating your derived object,
263 passing the arguments aHeap and aSessionCacheList supplied to
264 COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile
265 object that creates the object as aFile.
267 The derived object must be created on the shared heap aHeap because it is
268 shared by several processes: the font and bitmap server and its clients.
269 To do this, use aHeap->AllocL() to obtain memory, then construct in place
270 using a placement argument to new.
272 Derived classes must implement the pure virtual function RasterizeL().
273 Information about this function is provided in the function definition below.
275 Information about deriving from this class is also provided in the API guide.
277 @see COpenFontFile::GetNearestFontInPixelsL()
281 class COpenFont: public CBase
284 /** Creates a bitmap for the specified Unicode character.
286 Implementations of this function should put the bitmap in
287 aGlyphData->iBitmapBuffer, and the character metrics are placed in
288 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
291 There are a number of strategies for achieving this, e.g. pass the
292 rasterization task all the way up to the rasterizer engine. These are
293 discussed in the API guide.
295 At present you must write the bitmap in the Symbian platform's
296 run-length-encoded format. This is a packed binary format starting on a
297 byte boundary and made up of a number of sections. Each section starts
298 with a five-bit header. If the first bit of the header is 0 the next four
299 bits are a repeat count, starting with the least significant bit, and a
300 single row of bits (the number of bits in a row is specified by
301 aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header
302 is 1 the next four bits are a count of non-repeating rows, again starting
303 with the least significant bit, and that many rows of bits follow.
305 @param aCode The character code of the Unicode character for which the
307 @param aGlyphData On return, contains a pointer to a TOpenFontGlyphData
308 containing the character's bitmap and metrics. */
309 virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
310 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
311 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile);
312 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex);
313 IMPORT_C ~COpenFont();
314 IMPORT_C void operator delete(TAny*);
315 inline const TOpenFontMetrics& Metrics() const;
316 inline const TOpenFontFaceAttrib* FaceAttrib() const;
317 inline COpenFontFile* File() const;
318 inline TInt FaceIndex() const;
319 inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
320 void SetShaper(CShaper* aShaper);
321 CShaper* GetShaper();
322 TBool HasShaper() const;
323 TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams);
324 TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader);
325 TInt FreeShaperCacheMemory(TInt aBytesNeeded);
326 TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse);
327 TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData);
328 TBool HasCharacterL(TInt aCode) const;
329 TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
330 void OnFileDeleted();
331 COpenFontGlyphCache* GetGlyphCache() const;
332 inline TInt FontCapitalAscent() const;
333 inline TInt FontMaxAscent() const;
334 inline TInt FontStandardDescent() const;
335 inline TInt FontMaxDescent() const;
336 inline TInt FontLineGap() const;
337 inline TInt FontMaxHeight() const;
338 void DeleteShaper() const;
339 TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength);
340 TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength);
344 TOpenFontMetrics iMetrics;
346 /** The shaper for performing complex character positioning and
347 substitution, if available. Null otherwise.
349 WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only.
354 /** The positive distance in pixels from the baseline to
355 the top of an ANSI capital (whether or not there are
356 ANSI capitals in the font) */
357 TInt iFontCapitalAscent;
358 /** The positive distance in pixels from the baseline to
359 the top of the highest pre-composed glyph in the font */
361 /** The positive distance in pixels from the baseline to
362 the bottom of the lowest ANSI descender (whether or
363 not there are ANSI chars in the font)*/
364 TInt iFontStandardDescent;
365 /** The positive distance in pixels from the baseline to
366 the bottom of the lowest pre-composed glyph in the font */
367 TInt iFontMaxDescent;
368 /** The recommended baseline to baseline gap for successive
369 lines of text in the font */
372 const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
374 const COpenFontGlyph* FontCacheGlyph(TInt aCode) const;
376 void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
378 const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode,
379 COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const;
380 void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData);
382 COpenFontSessionCacheList* SessionCacheList()const;
384 void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList);
386 void SetFile(COpenFontFile* aFile);
389 // Offset from the address of the file used by this font.
390 // If the file has been deleted or cannot be used, the offest will be zero.
393 TInt iFaceIndex; // index of the face in the font file
395 // Offset from the address of this font of the per-font glyph cache which is owned by the font
396 TInt iGlyphCacheOffset;
398 // Offset from the address of this font of the list of per-session glyph
399 // caches which are owned by CFontStore
400 TInt iSessionCacheListOffset;
402 TAny* iReserved; // unused; for future expansion
405 /** Open Font System Extension Interface abstract base class.
407 COpenFont derivers should also derive from this interface to enable complex
410 This interface should be returned by the overridden
411 COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
415 @see KUidOpenFontShapingExtension
419 class MOpenFontShapingExtension
422 /** Various font metrics. */
423 class TExtensionFontMetrics
426 /** The number of font design units per em. */
428 /** The width of the font's em square in pixels. */
430 /** The height of the font's em square in pixels. */
432 /** The horizontal scaling factor from the font's transform;
433 the number of horizontal pixels per font unit. */
435 /** The vertical scaling factor from the font's transform;
436 the number of vertical pixels per font unit. */
439 /** Reserved for future expansion. */
443 /** Creates a bitmap for the specified Glyph code.
445 Implementations of this function should put the bitmap in
446 aGlyphData->iBitmapBuffer, and the character metrics are placed in
447 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
450 This function provides the same functionality as the
451 COpenFont::RasterizeL() except that the glyph code is supplied rather than
454 For more information:
455 @see COpenFont::RasterizeL()
457 @param aCode The glyph code of the character for which the bitmap is required.
458 @param aGlyphData The function puts its output here.
460 virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
462 /** Maps a character to a glyph index.
463 @param aUnicodeCharacter Unicode character code to be mapped.
464 @return Glyph code corresponding to aUnicodeCharacter. */
465 virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0;
467 /** Returns the hinted pixel coordinates of a particular point in the
468 outline of the given glyph.
469 @param aGlyphPoint The glyph index.
470 @param aPointNumber The number of the point.
471 @param aX Returns the point's X pixel value.
472 @param aY Returns the point's Y pixel value.
473 @return True on success, false otherwise. */
474 virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber,
475 TReal& aX, TReal& aY) const = 0;
477 /** Returns the coordinates of a particular (unhinted) point in the outline
478 of the given glyph in font units.
479 @param aGlyphPoint The glyph index.
480 @param aPointNumber The number of the point.
481 @param aX Returns the point's X co-ordinate in font units.
482 @param aY Returns the point's Y co-ordinate in font units.
483 @return True on success, false otherwise. */
484 virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber,
485 TInt& aX, TInt& aY) const = 0;
487 /** Returns font metrics.
488 @param aOut Font metrics returned. */
489 virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
492 /** TrueType extension for Open Fonts.
494 If an open font is able to load TrueType or OpenType tables it should derive
497 This class will be used by
499 This interface should be returned by the overridden
500 COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
502 @see KUidOpenFontTrueTypeExtension
506 class MOpenFontTrueTypeExtension
509 /** Returns the specified table. The table need not be released by the
510 caller, so the deriver is responsible for ensuring that any memory
511 allocated is ultimately cleaned up. The caller must not delete or modify
514 Returns KErrNone if successful or one of the system-wide error codes if
515 unsuccessful. Returns KErrNotSupported if the table does not exist in
518 The tag of the table, with the first character in the most significant
519 byte. For example, the "vhea" table is obtained by passing in 'v'<<24 |
520 'h'<<16 | 'e'<<8 | 'a'.
522 The length of the table in bytes that has been returned or 0 if
524 @return The table, if successful.
525 @see ReleaseTrueTypeTable */
526 virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0;
527 /** Releases a table obtained by GetTrueTypeTable. The caller must not
528 use the table after this call.
529 @param aTable The table to be released.
530 @see GetTrueTypeTable */
531 virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0;
532 /** Determines if the font file has a particular table.
533 @param aTag The tag of the table as for GetTrueTypeTable.
534 @return True if the table exists in the font file, false otherwise.
535 @see GetTrueTypeTable */
536 virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
539 class MOpenFontGlyphOutlineExtension
542 virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
543 TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
546 Font attribute base class.
548 This class is not intended for user derivation.
550 @see TOpenFontFaceAttrib
555 class TOpenFontFaceAttribBase
558 inline TOpenFontFaceAttribBase();
559 inline TBool HasLatin() const;
560 inline TBool HasGreek() const;
561 inline TBool HasCyrillic() const;
562 inline TBool HasKana() const;
563 inline TBool HasHangul() const;
564 inline TBool HasCJK() const;
565 inline TBool IsSymbol() const;
566 inline TBool IsBold() const;
567 inline TBool IsItalic() const;
568 inline TBool IsSerif() const;
569 inline TBool IsMonoWidth() const;
570 inline TPtrC Name() const;
571 inline const TUint* Coverage() const;
572 inline void SetName(const TDesC& aName);
573 inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0);
574 inline void SetBold(TBool aBold);
575 inline void SetItalic(TBool aItalic);
576 inline void SetSerif(TBool aSerif);
577 inline void SetMonoWidth(TBool aMonoWidth);
578 inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const;
580 // Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included)
583 ELatinSet = 0x1, // 0000-007F
584 EGreekSet = 0x80, // 0370-03FF
585 ECyrillicSet = 0x200, // 0400-04FF
586 EArmenianSet = 0x400, // 0530-058F
587 EHebrewSet = 0x800, // 0590-05FF
588 EArabicSet = 0x2000, // 0600-06FF
589 EDevanagariSet = 0x8000, // 0900-097F
590 EBengaliSet = 0x10000, // 0980-09FF
591 EGurmukhiSet = 0x20000, // 0A00-0A7F
592 EGujuratiSet = 0x40000, // 0A80-0AFF
593 EOriyaSet = 0x80000, // 0B00-0B7F
594 ETamilSet = 0x100000, // 0B80-0BFF
595 ETeluguSet = 0x200000, // 0C00-0C7F
596 EKannadaSet = 0x400000, // 0C80-0CFF
597 EMalayalamSet = 0x800000, // 0D00-0D7F
598 EThaiSet = 0x1000000, // 0E00-0E7F
599 ELaoSet = 0x2000000, // 0E80-0EFF
600 EGeorgianSet = 0x8000000, // 10A0-10FF
601 EHangulJamoSet = 0x10000000,// 1100-11FF
604 // Unicode ranges for iCoverage[1]
607 ESymbolSets = 0xFFFE,
609 EHangulSet = 0x100000,
616 EBold = 0x1, // weight > 500 in Windows terms
617 EItalic = 0x2, // italic or oblique - any forward slant counts
618 ESerif = 0x4, // characters have serifs
619 EMonoWidth = 0x8 // all characters are the same width
625 ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24
628 TBufC<ENameLength> iName; // the name of the typeface; whether this is the full name or family name
629 // or is in English or another language depends on the context
630 TUint iCoverage[4]; // bitmap of the character sets supported by the typeface;
631 // these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4
632 // in the OS/2 table in TrueType fonts
633 TInt iStyle; // bold, italic serif, and mono-width
641 These attributes include the name, family name, and supported scripts.
643 @see CFbsFont::GetFaceAttrib()
647 class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
650 inline TOpenFontFaceAttrib();
651 inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const;
652 inline TPtrC FullName() const;
653 inline TPtrC FamilyName() const;
654 inline TPtrC LocalFullName() const;
655 inline TPtrC LocalFamilyName() const;
656 inline TPtrC ShortFullName() const;
657 inline TPtrC ShortFamilyName() const;
658 inline TPtrC ShortLocalFullName() const;
659 inline TPtrC ShortLocalFamilyName() const;
660 inline void SetFullName(const TDesC& aName);
661 inline void SetFamilyName(const TDesC& aName);
662 inline void SetLocalFullName(const TDesC& aName);
663 inline void SetLocalFamilyName(const TDesC& aName);
664 inline TInt MinSizeInPixels() const;
665 inline void SetMinSizeInPixels(TInt aSize);
667 TBufC<ENameLength> iFamilyName; // the name without any style suffixes; usually a truncation of iFullName
668 TBufC<ENameLength> iLocalFullName; // the full name in the language of the current locale
669 TBufC<ENameLength> iLocalFamilyName; // the family name in the language of the current locale
670 TInt iMinSizeInPixels; // minimum supported size, (or readable size if scalable) in pixels
676 Font specification allowing more attributes to be specified than TFontSpec.
678 In addition to the attributes specified by TFontSpec, this font specification
679 allows stretching and slanting in the x dimension, and other algorithmic effects.
680 This is used to correct for non-square pixels, and to allow algorithmic slanting
681 and bold. The width factor and slant factor transform any point (x,y) to (x
682 * iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16
685 The font specification also provides access to information about the scripts
686 which are supported by the font. This information is not always reliable,
687 because it may be incorrectly specified, or not specified at all, by some
692 class TOpenFontSpec : public TOpenFontFaceAttribBase
695 IMPORT_C TOpenFontSpec();
696 IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec);
697 IMPORT_C void operator=(const TFontSpec& aFontSpec);
698 inline TBool operator==(const TOpenFontSpec& aFontSpec) const;
699 TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const;
700 IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib);
701 IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const;
702 IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight);
703 IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap);
704 inline TInt Height() const;
705 inline TInt32 WidthFactor() const;
706 inline TInt32 SlantFactor() const;
707 inline TGlyphBitmapType BitmapType() const;
708 inline TUint32 Effects() const;
709 inline TFontPrintPosition PrintPosition() const;
710 inline void SetHeight(TInt aHeight);
711 inline void SetWidthFactor(TInt32 aWidthFactor);
712 inline void SetSlantFactor(TInt32 aSlantFactor);
713 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
714 inline void SetEffects(TUint32 aEffects);
715 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
716 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
717 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
718 IMPORT_C TInt ScriptTypeForMetrics() const;
719 static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight);
720 static TInt ApplyRatio(TInt& aValue,TInt aNumerator,TInt aDenominator);
721 static TInt ApplyRatio(TInt32& aValue,TInt aNumerator,TInt aDenominator);
723 /** Algorithmic effects flags.
725 These can be combined using an OR operation.
727 WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
729 @deprecated Use FontEffect::TEffect instead.
733 /** Font is algorithmic bold. */
734 EAlgorithmicBold = 1,
735 /** Font has a drop shadow. */
737 /** Font is an outline font. */
741 void SetScriptTypeForMetrics(TInt aScript);
742 void SetSymbol(TBool aSymbol);
743 TBool Symbol() const;
744 IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const;
745 IMPORT_C TUint32 DoEffects() const;
746 IMPORT_C void DoSetEffects(TUint32 aEffects);
748 TInt iHeight; // em height
749 TInt32 iWidthFactor; // algorithmic width factor as a 16.16 fixed-point number
750 TInt32 iSlantFactor; // algorithmic slant factor as a 16.16 fixed-point number
751 TInt iBitmapType; // non-anti-aliased, standard anti-aliased, etc.; zero means 'default'
752 TUint32 iEffects; // bit flags for font effects
753 TInt iSymbol; // a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5)
754 // The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec
755 TFontPrintPosition iPrintPosition; // normal, superscript or subscript
761 Font file abstract base class.
763 Write a class derived from COpenFontFile to manage a file with the font format
764 supported by your DLL. The derived class must implement the virtual
765 GetNearestFontInPixelsL() function. This function takes a font description
766 and creates a COpenFont derived object if the description matches a typeface
767 contained in the font file.
769 Derived classes must also load typeface attributes from the file into the
770 protected typeface attribute array during construction. This array is what
771 is searched when getting font attribute information see AddFaceL(),
772 GetNearestFontHelper().
774 Writing derived classes construction:
776 Call the COpenFontFile constructor in the constructor for your derived object,
777 passing it aUid and aFileName arguments. These values are the arguments passed
778 when the constructor is called by COpenFontRasterizer::NewFontFileL().
780 A file may contain one or more typefaces. During construction the derived
781 object should extract the information for each typeface and add it to this
782 object's protected typeface attribute array see AddFaceL(). This process
783 will probably leave under some conditions. It should therefore be implemented
784 in a second phase constructor.
786 Writing derived classes implement the pure virtual functions:
788 Derived classes must also implement the two pure virtual functions
789 GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about
790 these functions is provided in the definitions below. Information about
791 deriving from this class is also provided in the API guide.
793 @see COpenFontRasterizer::NewFontFileL()
794 @see CWsScreenDevice::AddFile()
798 class COpenFontFile : public CBase
802 Gets the font which is the nearest to the given font specification.
804 Implementations of this pure virtual function should create the COpenFont
805 derived object that most closely matches aDesiredFontSpec, while fitting within
806 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
807 e.g. if the font name doesn't match, aFont should be set to NULL.
809 The other two arguments, aHeap and aSessionCacheList, should be passed to
810 the COpenFont constructor.
812 Implementations may use the utility function GetNearestFontHelper()
813 to get the attributes of the closest matching font.
815 @param aHeap Shared heap. This value should be passed to the
816 COpenFont derived classes' constructor.
817 @param aSessionCacheList The session cache list. This value should be passed
818 to the COpenFont derived classes' constructor.
819 @param aDesiredFontSpec The desired font specification.
820 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
821 the algorithmic slant of the typeface.
822 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
823 the algorithmic slant of the typeface.
824 @param aFont On return, contains a pointer to the newly created COpenFont
825 derived object, or NULL if no font matching aDesiredFontSpec exists.
826 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
827 @see GetNearestFontHelper()
829 virtual void GetNearestFontInPixelsL(
830 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
831 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
832 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
835 Gets the font which is the nearest to the given font specification.
837 Implementations of this pure virtual function should create the COpenFont
838 derived object that most closely matches aDesiredFontSpec, while fitting within
839 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
840 e.g. if the font name doesn't match, aFont should be set to NULL.
842 The other two arguments, aHeap and aSessionCacheList, should be passed to
843 the COpenFont constructor.
845 Implementations may use the utility function GetNearestFontHelper()
846 to get the attributes of the closest matching font.
848 @param aHeap Shared heap. This value should be passed to the COpenFont
849 derived classes' constructor.
850 @param aSessionCacheList The session cache list. This value should be passed
851 to the COpenFont derived classes' constructor.
852 @param aDesiredFontSpec The desired font specification.
853 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
854 the algorithmic slant of the typeface.
855 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
856 the algorithmic slant of the typeface.
857 @param aFont On return, contains a pointer to the newly created COpenFont
858 derived object, or NULL if no font matching aDesiredFontSpec exists.
859 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
860 @see GetNearestFontHelper()
862 virtual void GetNearestFontToDesignHeightInPixelsL(
863 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
864 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
865 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
867 Gets the font which is the nearest to the given font specification.
869 Implementations of this pure virtual function should create the COpenFont
870 derived object that most closely matches aDesiredFontSpec, while fitting within
871 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
872 e.g. if the font name doesn't match, aFont should be set to NULL.
874 The other two arguments, aHeap and aSessionCacheList, should be passed to
875 the COpenFont constructor.
877 Implementations may use the utility function GetNearestFontHelper()
878 to get the attributes of the closest matching font.
880 @param aHeap Shared heap. This value should be passed to the COpenFont
881 derived classes' constructor.
882 @param aSessionCacheList The session cache list. This value should be passed
883 to the COpenFont derived classes' constructor.
884 @param aDesiredFontSpec The desired font specification.
885 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
886 the algorithmic slant of the typeface.
887 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
888 the algorithmic slant of the typeface.
889 @param aFont On return, contains a pointer to the newly created COpenFont
890 derived object, or NULL if no font matching aDesiredFontSpec exists.
891 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
892 @param aMaxHeight The maximum height (vertical extent) within which the font must fit.
893 @see GetNearestFontHelper()
895 virtual void GetNearestFontToMaxHeightInPixelsL(
896 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
897 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
898 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
900 /** Tests whether a specified typeface contains a particular character.
902 @param aFaceIndex The index of the typeface to be tested.
903 @param aCode The Unicode character code for the character to be tested.
904 @return ETrue if the typeface contains aCode, otherwise EFalse. */
905 virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0;
906 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
907 IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName);
908 IMPORT_C ~COpenFontFile();
909 IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
910 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
911 IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
912 inline TUid Uid() const;
913 inline const TDesC& FileName() const;
914 inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
915 inline TInt FaceCount() const;
916 inline void IncRefCount();
917 inline TBool DecRefCount();
918 TInt GetNearestFontInPixels(
919 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
920 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
921 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
922 TInt GetNearestFontToDesignHeightInPixels(
923 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
924 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
925 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
926 TInt GetNearestFontToMaxHeightInPixels(
927 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
928 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
929 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
930 void RemoveFontFromList(const COpenFont* aFont);
931 void SetFontStoreL(CFontStore* aFontStore);
932 CFontStore* GetFontStore();
933 CArrayPtrFlat<COpenFont>* GetOpenFontList();
935 IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
936 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
938 // A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
939 class TAttrib: public TOpenFontFaceAttrib
942 COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface
944 static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
945 static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
946 void GetNearestFontToDesignHeightInPixelsAndAddToListL(
947 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
948 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
949 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
950 void GetNearestFontToMaxHeightInPixelsAndAddToListL(
951 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
952 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
953 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
956 CArrayFixFlat<TAttrib> iFaceAttrib;
958 TBuf<KMaxFileName> iFileName;
960 CArrayPtrFlat<COpenFont> iFontList;
961 TOpenFontFileData* iData;
965 Convenience class from which rasterizer contexts may be derived.
967 A rasterizer context object may (optionally) be created to provide the link
968 between the rasterizer DLL code supported by the Open Font System, and the
969 rasterizer engine code. A rasterizer context object class should get the
970 requested bitmap from the associated rasterizer engine. It should then convert
971 this into Symbian run-length-encoded format. This class contains convenience
972 functions to make the conversion easier.
974 Deriving from this class is described in greater detail in the API guide.
978 class COpenFontRasterizerContext: public CBase
981 inline COpenFontRasterizerContext();
982 inline void StartGlyph(TOpenFontGlyphData* aGlyphData);
983 inline void WriteGlyphBit(TInt aBit);
984 inline void WriteGlyphByte(TInt aByte);
985 inline void EndGlyph();
987 TOpenFontGlyphData* iGlyphData;
988 TUint8* iGlyphDataStart;
989 TUint8* iGlyphDataPtr;
990 TUint8* iGlyphDataEnd;
994 TAny* iReserved; // unused; for future expansion
999 Shaper abstract class. All shaper implementations derive from this
1003 class CShaper : public CBase
1009 /** The text to be shaped possibly including context. */
1011 /** The index of the first character in iText to be shaped. */
1013 /** (One past) the end of the text in iText to be shaped. */
1015 /** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
1018 /** Language code. 0 implies "default" */
1020 /** Maximum advance in pixels. Shaping beyond this
1021 advance is not required (but is not harmful). */
1022 TInt iMaximumAdvance;
1023 /** Flags. Currently none is defined. */
1025 /** Session handle. To be used if rasterization is needed. */
1026 TInt iSessionHandle;
1027 /** Reserved for future expansion. Must be set to 0. */
1034 IMPORT_C virtual ~CShaper();
1036 /** construct a shaper object
1037 @param aBitmapFont The font to be shaped.
1038 @param aHeap The heap to be used by the shaper.
1039 @return KErrNone if this font can be shaper or system wide error code*/
1040 virtual TInt ConstructL(CBitmapFont* aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1042 /** If possible, shape the text described by aInput, placing the output on aHeapForOutput.
1043 @param aOutput The output, as a newly allocate object on aHeapForOutput.
1044 @param aInput The input text and other parameters.
1045 @param aHeapForOutput On success, aOutput should be allocated from this and nothing else.
1046 On failure, nothing should be allocated from it.
1047 @return Error value from one of the system-wide error codes on failure, KErrNone on success.
1048 @see TShapeHeader */
1049 virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0;
1051 /** For future expansion. Any overriders must base-call
1052 if aInterface is unrecognized.
1054 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1056 @param aInterfaceId The ID of the interface to return.
1057 @return A pointer to the extension interface.
1059 IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
1062 /** ECOM plug-in base class for shaper factories.
1066 class CShaperFactory : public CBase
1069 /** Create a shaper if possible, for typeface aFaceIndex
1070 within file aFileName.
1071 @param aFont The font to be shaped.
1072 @param iHeap The heap to use for constructing the shaper.
1073 @return 0 If the font is not understood or inappropriate for any shaper that might be constructed
1074 by this class, otherwise returns the newly-constructed shaper on iHeap. */
1075 virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1077 inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
1078 inline virtual ~CShaperFactory();
1080 /** For future expansion. Any overriders must base-call if aInterface is unrecognized.
1082 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1084 @param aInterfaceId The ID of the interface to return.
1085 @return A pointer to the extension interface.
1087 virtual void* ExtendedInterface(TUid aInterfaceId);
1090 TUid iDtor_ID_Key;//ECOM identifier used during destruction
1093 // Inline functions start here.
1094 /** Default C++ constructor.
1096 This creates then zero fills the object. */
1097 inline TOpenFontMetrics::TOpenFontMetrics()
1099 Mem::FillZ(this,sizeof(*this));
1102 /** Gets the font's size.
1104 @return The font's size.
1106 inline TInt TOpenFontMetrics::Size() const
1108 return iDesignHeight;
1111 /** Gets the font's ascent.
1113 This is the ascent for the Latin character which is highest above the baseline.
1115 @return The font's ascent, in pixels.
1117 inline TInt TOpenFontMetrics::Ascent() const
1122 /** Gets the font's descent.
1124 This is the descent for the Latin character in the font which falls furthest below the baseline.
1126 @return The font's descent, in pixels.
1127 @see SetDescent() */
1128 inline TInt TOpenFontMetrics::Descent() const
1133 /** Sets the font's maximum height.
1135 Note that if this object was initialised from the CFont this will be the same
1138 This is the ascent for the character which is highest above the baseline.
1139 In many fonts this will be the height of an accented character like Â,
1140 including the accent.
1142 @return The maximum height of the font, in pixels.
1143 @see SetMaxDepth() */
1144 inline TInt TOpenFontMetrics::MaxHeight() const
1149 /** Gets the font's maximum depth.
1151 Note: If this object was initialised from the CFont this will be the same as the
1154 This is the descent for the character in the font which falls furthest below
1157 @return The font's maximum depth.
1158 @see SetMaxDepth() */
1159 inline TInt TOpenFontMetrics::MaxDepth() const
1164 /** Gets the maximum character width, in pixels.
1166 @return The maximum character width, in pixels.
1167 @see SetMaxWidth() */
1168 inline TInt TOpenFontMetrics::MaxWidth() const
1173 /** Sets the font's size.
1175 @param aSize The font's size.
1177 inline void TOpenFontMetrics::SetSize(TInt aSize)
1179 iDesignHeight = static_cast<TInt16>(aSize);
1182 /** Sets the ascent.
1184 @param aAscent The ascent, in pixels.
1186 inline void TOpenFontMetrics::SetAscent(TInt aAscent)
1188 iAscent = static_cast<TInt16>(aAscent);
1191 /** Sets the descent.
1193 @param aDescent The descent, in pixels.
1195 inline void TOpenFontMetrics::SetDescent(TInt aDescent)
1197 iDescent = static_cast<TInt16>(aDescent);
1200 /** Sets the font's maximum height.
1202 @param aMaxHeight The font's maximum height, in pixels.
1204 inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
1206 iMaxHeight = static_cast<TInt16>(aMaxHeight);
1209 /** Sets the font's maximum depth.
1211 @param aMaxDepth The font's maximum depth, in pixels.
1213 inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
1215 iMaxDepth = static_cast<TInt16>(aMaxDepth);
1218 /** Sets the maximum character width, in pixels.
1220 @param aMaxWidth The maximum character width, in pixels.
1222 inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
1224 iMaxWidth = static_cast<TInt16>(aMaxWidth);
1227 /** Default C++ constructor.
1229 The constructor initialises all data members to zero. As for other T classes,
1230 there is no need to explicitly cleanup TOpenFontCharMetrics objects. */
1231 inline TOpenFontCharMetrics::TOpenFontCharMetrics()
1233 Mem::FillZ(this,sizeof(*this));
1236 /** Gets the width of the character's bitmap.
1238 @return The width of the bitmap in pixels. */
1239 inline TInt TOpenFontCharMetrics::Width() const
1244 /** Gets the height of the character's bitmap.
1246 @return The character's height in pixels. */
1247 inline TInt TOpenFontCharMetrics::Height() const
1252 /** Gets the horizontal bearing X.
1254 This is the distance in pixels from the pen point before the character is
1255 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1256 A positive value means that the left edge of the bitmap is right of the origin.
1258 @return The horizontal bearing X in pixels */
1259 inline TInt TOpenFontCharMetrics::HorizBearingX() const
1261 return iHorizBearingX;
1264 /** Gets horizontal bearing Y.
1266 This is the vertical distance in pixels from the pen point before the character
1267 is drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1268 A positive value means that the top edge of the bitmap is above the origin
1270 @return The horizontal bearing Y in pixels. */
1271 inline TInt TOpenFontCharMetrics::HorizBearingY() const
1273 return iHorizBearingY;
1276 /** Gets the horizontal advance.
1278 This is the amount added to the x co-ordinate of the origin after the character
1279 is drawn what most people understand by the width or escapement of a character.
1280 The origin here is the pen point before the character is drawn.
1282 @return The horizontal advance in pixels */
1283 inline TInt TOpenFontCharMetrics::HorizAdvance() const
1285 return iHorizAdvance;
1288 /** Gets the vertical bearing X.
1290 This is the distance in pixels from the pen point before the character is
1291 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1292 A positive value means that the left edge of the bitmap is right of the origin.
1294 @return The vertical bearing X in pixels. */
1295 inline TInt TOpenFontCharMetrics::VertBearingX() const
1297 return iVertBearingX;
1300 /** Gets the vertical bearing Y.
1302 This is the distance in pixels from the pen point before the character is
1303 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1304 A positive value means that the top edge of the bitmap is above the origin.
1306 @return The vertical bearing Y in pixels. */
1307 inline TInt TOpenFontCharMetrics::VertBearingY() const
1309 return iVertBearingY;
1312 /** Gets the vertical advance.
1314 When drawing vertically, this is the amount added to the y co-ordinate of
1315 the origin after the character is drawn what most people understand by
1316 the height of a character. The origin here is the pen point before the character
1319 Note: Vertical drawing is not supported in v5.
1321 @return The vertical advance in pixels. */
1322 inline TInt TOpenFontCharMetrics::VertAdvance() const
1324 return iVertAdvance;
1327 /** Gets the bounds of the character relative to its origin when setting text
1330 The origin here is the pen point before the character is drawn.
1332 @param aBounds The character's bounds. */
1333 inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
1335 aBounds.iTl.iX = iHorizBearingX;
1336 aBounds.iTl.iY = -iHorizBearingY;
1337 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1338 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1341 /** Gets the bounds of the character relative to its origin when setting text
1344 The origin here is the pen point before the character is drawn.
1346 @param aBounds The character's bounds. */
1347 inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
1349 aBounds.iTl.iX = -iVertBearingX;
1350 aBounds.iTl.iY = iVertBearingY;
1351 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1352 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1355 /** Sets the width of the character's bitmap.
1357 @param aWidth The width of the bitmap in pixels. */
1358 inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
1360 iWidth = (TInt16)aWidth;
1363 /** Sets the height of the character's bitmap.
1365 @param aHeight The character height (in pixels). */
1366 inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
1368 iHeight = (TInt16)aHeight;
1371 /** Sets the horizontal bearing X.
1373 This is the distance in pixels from the pen point before the character is
1374 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1375 A positive value means that the left edge of the bitmap is right of the origin.
1377 @param aHorizBearingX The horizontal bearing X (in pixels). */
1378 inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
1380 iHorizBearingX = (TInt16)aHorizBearingX;
1383 /** Sets the horizontal bearing Y.
1385 This is the distance in pixels from the pen point before the character is
1386 drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1387 A positive value means that the top edge of the bitmap is above the origin.
1389 @param aHorizBearingY The horizontal bearing Y (in pixels). */
1390 inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
1392 iHorizBearingY = (TInt16)aHorizBearingY;
1395 /** Sets the horizontal advance.
1397 This is the amount added to the x co-ordinate of the origin after the character
1398 is drawn, what most people understand by the width or escapement of a character.
1399 The origin here is the pen point before the character is drawn.
1401 @param aHorizAdvance The horizontal advance (in pixels). */
1402 inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
1404 iHorizAdvance = (TInt16)aHorizAdvance;
1407 /** Set vertical bearing X.
1409 This is the distance in pixels from the pen point before the character is
1410 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1411 A positive value means that the left edge of the bitmap is right of the origin.
1413 @param aVertBearingX The vertical bearing X (in pixels). */
1414 inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
1416 iVertBearingX = (TInt16)aVertBearingX;
1419 /** Sets the vertical bearing Y.
1421 This is the distance in pixels from the pen point before the character is
1422 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1423 A positive value means that the top edge of the bitmap is above the origin.
1425 @param aVertBearingY The vertical bearing Y (in pixels). */
1426 inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
1428 iVertBearingY = (TInt16)aVertBearingY;
1431 /** Sets the vertical advance.
1433 When drawing vertically, this is the amount added to the y co-ordinate of
1434 the origin after the character is drawn what most people understand by
1435 the height of a character. The origin here is the pen point before the character
1438 Note: Vertical drawing is not supported in v5.
1440 @param aVertAdvance The vertical advance (in pixels). */
1441 inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
1443 iVertAdvance = (TInt16)aVertAdvance;
1446 /** Gets the character metrics for this font.
1448 @return The character metrics for this font. */
1449 inline const TOpenFontMetrics& COpenFont::Metrics() const
1454 /** Gets the glyph index.
1456 This is the index of a particular glyph within the font file.
1458 Note: This makes it possible to gain access to glyphs which are not referenced
1459 by the Unicode character set. However, this feature is not yet supported by
1462 @return The glyph index.
1463 @see SetGlyphIndex() */
1464 inline TInt TOpenFontGlyphData::GlyphIndex() const
1469 /** Gets the typeface attributes.
1471 These are the attributes of the font represented by this object.
1473 @return The typeface attributes. */
1474 inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
1476 return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex);
1479 /** Gets a pointer to the COpenFontFile which created this object.
1481 This is the COpenFontFile which owns the file that contains the definition
1482 of the typeface. It can be used to get information about the typeface, or
1483 to access the rasterizer context (engine).
1485 @return The COpenFontFile which created this object. */
1486 inline COpenFontFile* COpenFont::File() const
1488 return iFileOffset == 0 ? NULL : reinterpret_cast<COpenFontFile*>(const_cast<COpenFont*>(PtrAdd(this, iFileOffset)));
1491 /** Gets the index of this typeface within the font file.
1493 @return The index of this typeface within the font file. */
1494 inline TInt COpenFont::FaceIndex() const
1499 /** Tests whether or not a character needs to be rasterized.
1501 Characters that have been rasterized are cached there is no need to regenerate
1502 the character bitmap. This function should only be called by the Font and
1505 @param aSessionHandle A handle to the font and bitmap server session.
1506 @param aCode The code for the Unicode character.
1507 @return ETrue if the character needs to be rasterized, otherwise EFalse. */
1508 inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const
1510 return Glyph(aSessionHandle,aCode) == NULL;
1513 /** Gets the ascent of an ANSI capital letter in the font whether or not
1514 there are any ANSI capitals in the font.
1515 @return The positive distance from the font baseline to the top of a
1516 standard ANSI capital letter
1519 @see AscentInPixels()
1521 inline TInt COpenFont::FontCapitalAscent() const
1523 return iFontCapitalAscent;
1526 /** Gets the max ascent of any pre-composed glyph in the font. This will
1527 include accents or diacritics that form part of pre-composed glyphs. It is
1528 not guaranteed to cover the max ascent of composite glyphs that have to be
1529 created by a layout engine. This is also the recommended distance between
1530 the top of a text box and the baseline of the first line of text.
1532 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1534 @return The positive distance from the font baseline to the top of the
1535 highest pre-composed glyph (including accents) above the baseline.
1538 @see AscentInPixels()
1539 @see SetScriptTypeForMetrics()
1541 inline TInt COpenFont::FontMaxAscent() const
1543 return iFontMaxAscent;
1546 /** Gets the descent of an ANSI descending character in the font.
1547 Whether or not there are any ANSI descenders in the font.
1549 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1551 @return The positive distance from the font baseline to the bottom of the
1552 lowest ANSI descender.
1555 @see DescentInPixels()
1556 @see SetScriptTypeForMetrics()
1558 inline TInt COpenFont::FontStandardDescent() const
1560 return iFontStandardDescent;
1563 /** Gets the max descent of any pre-composed glyph in the font. This will
1564 include accents or diacritics that form part of pre-composed glyphs. It is
1565 not guaranteed to cover the max descent of composite glyphs that have to be
1566 created by a layout engine.
1568 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1570 @return The positive distance from the font baseline to the bottom of the
1571 lowest pre-composed glyph (including accents) below the baseline
1574 @see DescentInPixels()
1575 @see SetScriptTypeForMetrics()
1577 inline TInt COpenFont::FontMaxDescent() const
1579 return iFontMaxDescent;
1582 /** Gets the suggested line gap for the font. This is the recommended
1583 baseline to baseline distance between successive lines of text in the font.
1584 @return The positive recommended gap between successive lines
1588 inline TInt COpenFont::FontLineGap() const
1590 return iFontLineGap;
1593 /** Gets the maximum height for the font. This is the sum of the max ascent
1594 of the font and the max descent of the font.
1596 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1598 @return The positive maximum height of the font
1601 @see HeightInPixels()
1602 @see SetScriptTypeForMetrics()
1604 inline TInt COpenFont::FontMaxHeight() const
1606 return iFontMaxAscent + iFontMaxDescent;
1609 /** Default C++ constructor.
1611 This sets all attribute fields to zero. As for other T classes, there is no
1612 need to explicitly clean-up objects derived from this class. */
1613 inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
1615 Mem::FillZ(this,sizeof(*this));
1618 /** Default C++ constructor.
1620 The function initialises the minimum typeface size to zero, the names to NULL,
1621 and the coverage and style flags to zero. */
1622 inline TOpenFontFaceAttrib::TOpenFontFaceAttrib():
1623 iMinSizeInPixels(0),
1628 /** Tests for support of Latin characters.
1630 Note: A return value of ETrue implies that the font has a usable set of
1631 characters. It does not imply exhaustive coverage.
1633 @return ETrue if Latin characters are supported */
1634 inline TBool TOpenFontFaceAttribBase::HasLatin() const
1636 return iCoverage[0] & ELatinSet;
1639 /** Tests for support of Greek characters.
1641 Note: A return value of ETrue implies that the font has a usable set of
1642 characters. It does not imply exhaustive coverage.
1644 @return ETrue if Greek characters are supported. */
1645 inline TBool TOpenFontFaceAttribBase::HasGreek() const
1647 return iCoverage[0] & EGreekSet;
1650 /** Tests for support of Cyrillic characters.
1652 Note: A return value of ETrue implies that the font has a usable set of
1653 characters. It does not imply exhaustive coverage.
1655 @return ETrue if Cyrillic characters are supported. */
1656 inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
1658 return iCoverage[0] & ECyrillicSet;
1661 /** Tests for support of Japanese syllabic characters.
1663 This function tests for the presence of Hiragana and Katakana syllabic
1664 characters in the font, collectively called kana. These characters are not
1665 sufficient for the Japanese language, which also makes use of Chinese characters.
1667 Note: A return value of ETrue implies that the font has a usable set of
1668 characters. It does not imply exhaustive coverage.
1670 @return ETrue if Japanese characters are supported
1672 inline TBool TOpenFontFaceAttribBase::HasKana() const
1674 return iCoverage[1] & EKanaSets;
1677 /** Tests for support of Korean Hangul characters.
1679 Korean may also make use of Chinese characters.
1681 Note: A return value of ETrue implies that the font has a usable set of
1682 characters. It does not imply exhaustive coverage.
1684 @return ETrue if Korean characters are supported
1686 inline TBool TOpenFontFaceAttribBase::HasHangul() const
1688 return iCoverage[1] & EHangulSet;
1691 /** Tests for support of Chinese ideographic characters.
1693 These are used in Chinese, Japanese and Korean.
1695 Note: A return value of ETrue implies that the font has a usable set of
1696 characters. It does not imply exhaustive coverage.
1698 @return ETrue if Chinese ideographs are supported. */
1699 inline TBool TOpenFontFaceAttribBase::HasCJK() const
1701 return iCoverage[1] & ECJKSet;
1704 /** Tests if the typeface contains symbols only.
1706 @return ETrue if the typeface contains symbols only. */
1707 inline TBool TOpenFontFaceAttribBase::IsSymbol() const
1709 return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
1710 iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
1713 /** Tests if the typeface is inherently bold.
1715 @return ETrue if the typeface is inherently bold. */
1716 inline TBool TOpenFontFaceAttribBase::IsBold() const
1718 return iStyle & EBold;
1721 /** Tests if the typeface is inherently italic.
1723 @return ETrue if the typeface is inherently italic. */
1724 inline TBool TOpenFontFaceAttribBase::IsItalic() const
1726 return iStyle & EItalic;
1729 /** Tests if the typeface has serifs.
1731 @return ETrue if the typeface has serifs. */
1732 inline TBool TOpenFontFaceAttribBase::IsSerif() const
1734 return iStyle & ESerif;
1737 /** Tests if all the characters have the same width.
1739 @return ETrue if all the characters have the same width. */
1740 inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
1742 return iStyle & EMonoWidth;
1745 /** Gets the typeface's name.
1747 @return Descriptor containing typeface name. */
1748 inline TPtrC TOpenFontFaceAttribBase::Name() const
1753 /** Gets the full name.
1755 The full name of the typeface includes style attributes like Italic, Bold,
1758 @return The full name of the typeface.
1759 @see FamilyName() */
1760 inline TPtrC TOpenFontFaceAttrib::FullName() const
1765 /** Gets the family name.
1767 Note: The family name of the typeface does not include style attributes like
1770 @return The family name of the typeface.
1772 inline TPtrC TOpenFontFaceAttrib::FamilyName() const
1777 /** Gets the local full name.
1779 The local full name of the typeface includes style attributes like Italic,
1782 The local name of the typeface is the name in the language of the current
1783 locale, where this is provided by the font file. If the local name is not
1784 available then the local name will be the same as the ordinary name.
1786 @return The local full name of the typeface. */
1787 inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
1789 return iLocalFullName;
1792 /** Gets the local family name.
1794 The local name of the typeface is the name in the language of the current
1795 locale, where this is provided by the font file. If the local name is not
1796 available then the local name will be the same as the ordinary name.
1798 Note: The family name of the typeface does not include style attributes like
1801 @return The local family name of the typeface. */
1802 inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
1804 return iLocalFamilyName;
1807 /** Gets the short full name.
1809 This is the full name of the typeface, truncated to KMaxTypefaceNameLength,
1812 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1813 where necessary so that they can be used in the TTypeFace class. The Open
1814 Font Framework allows 32 characters as a maximum name length.
1816 @return The short full name of the typeface.
1818 inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
1820 // Can't use TDesC::Left for this because it panics if the desired length is > the existing length!
1821 return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength));
1824 /** Gets the short family name.
1826 This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
1828 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1829 where necessary so that they can be used in the TTypeFace class. The Open
1830 Font Framework allows 32 characters as a maximum name length.
1832 @return The short family name of the typeface.
1833 @see FamilyName() */
1834 inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
1836 return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
1839 /** Gets the short local full name.
1841 This is the local full name of the typeface, truncated to KMaxTypefaceNameLength,
1844 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1845 where necessary so that they can be used in the TTypeFace class. The Open
1846 Font Framework allows 32 characters as a maximum name length.
1848 @return The short local full name of the typeface.
1849 @see LocalFullName() */
1850 inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
1852 return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
1855 /** Gets the short local family name.
1857 This is the local family name of the typeface, truncated to KMaxTypefaceNameLength,
1860 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1861 where necessary so that they can be used in the TTypeFace class. The Open
1862 Font Framework allows 32 characters as a maximum name length.
1864 @return The short local family name of the typeface.
1865 @see LocalFamilyName() */
1866 inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
1868 return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
1871 /** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
1873 Each flag that is set represents a supported Unicode range. The mapping is
1874 defined in the TrueType documentation under the OS/2 table.
1876 Note: Some useful subsets are defined as anonymous enumerated constants at the end
1877 of this class, see ELatinSet etc.
1879 @return A pointer to the flags that indicate the font's Unicode coverage.
1880 The flags are stored in an array of four 32-bit integers. When no information
1881 is available, all four integers are zero.
1882 @see SetCoverage() */
1883 inline const TUint* TOpenFontFaceAttribBase::Coverage() const
1888 /** Gets the minimum typeface size.
1890 This is the smallest size that can be drawn legibly.
1892 @return The minimum typeface size (in pixels). */
1893 inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
1895 return iMinSizeInPixels;
1898 /** Sets the name attribute.
1900 @param aName Descriptor containing typeface name. */
1901 inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
1903 iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1906 /** Sets the full name.
1908 @param aName The full name of the typeface.
1910 inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
1915 /** Sets the family name.
1917 @param aName The family name of the typeface.
1918 @see FamilyName() */
1919 inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
1921 iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1924 /** Sets the local full name.
1926 @param aName The local full name of the typeface.
1927 @see LocalFullName() */
1928 inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
1930 iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1933 /** Sets the local family name.
1935 @param aName The local family name of the typeface.
1936 @see LocalFamilyName() */
1937 inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
1939 iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1942 /** Sets the coverage flags.
1944 The flags are held in four 32 bit integers. Each flag that is set represents
1945 a range of Unicode characters that is supported by the typeface: Latin,
1946 Greek, Cyrillic etc. The mapping is defined in the TrueType documentation
1947 under the OS/2 table.
1949 Note: Some useful subsets are defined as anonymous enumerated constants at
1950 the end of this class, see ELatinSet etc.
1952 @param aCoverage0 The first set of coverage flags (bits 0-31).
1953 @param aCoverage1 The second set of coverage flags (bits 32-63).
1954 @param aCoverage2 The third set of coverage flags (bits 64-95).
1955 @param aCoverage3 The fourth set of coverage flags (bits 96-127). */
1956 inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3)
1958 iCoverage[0] = aCoverage0;
1959 iCoverage[1] = aCoverage1;
1960 iCoverage[2] = aCoverage2;
1961 iCoverage[3] = aCoverage3;
1964 /** Set the minimum typeface size.
1966 This is the smallest size that can be drawn legibly.
1968 @param aSize Sets the minimum typeface size (in pixels).
1969 @see MinSizeInPixels() */
1970 inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
1972 iMinSizeInPixels = aSize;
1975 /** Equality operator.
1977 Compares this and another set of font attributes, including the coverage,
1978 the family name, the local full name, the local family name, and the minimum
1981 @param aAttrib Contains the font attributes and names to compare.
1982 @return ETrue if all values are equal, EFalse if not. */
1983 inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const
1985 return TOpenFontFaceAttribBase::operator==(aAttrib) &&
1986 iFamilyName == aAttrib.iFamilyName &&
1987 iLocalFullName == aAttrib.iLocalFullName &&
1988 iLocalFamilyName == aAttrib.iLocalFamilyName &&
1989 iMinSizeInPixels == aAttrib.iMinSizeInPixels;
1992 /** Sets the bold attribute.
1994 @param aBold The bold attribute takes this value: ETrue or EFalse. */
1995 inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
2003 /** Sets the italic attribute.
2005 @param aItalic The italic attribute takes this value ETrue or EFalse. */
2006 inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
2014 /** Sets the serif attribute.
2016 @param aSerif The serif attribute takes this value ETrue or EFalse. */
2017 inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
2025 /** Sets the mono-width attribute.
2027 @param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
2028 inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
2031 iStyle |= EMonoWidth;
2033 iStyle &= ~EMonoWidth;
2036 /** Equality operator.
2038 Compares this and a specified set of font attributes, including the coverage
2039 and the typeface name.
2041 In version 6.1, and earlier, the return value was TInt.
2043 @param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase
2044 or of a derived class.
2045 @return ETrue if the values are equal. */
2046 inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const
2048 return iStyle == aAttrib.iStyle &&
2049 iCoverage[0] == aAttrib.iCoverage[0] &&
2050 iCoverage[1] == aAttrib.iCoverage[1] &&
2051 iCoverage[2] == aAttrib.iCoverage[2] &&
2052 iCoverage[3] == aAttrib.iCoverage[3] &&
2053 iName.CompareF(aAttrib.iName) == 0;
2056 /** Compares this and another open font specification. Compares all the properties
2060 @param aFontSpec The open font specification to compare with this one.
2061 @return ETrue if all values are equal, EFalse if not.
2063 inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
2066 iHeight == aOpenFontSpec.iHeight &&
2067 iWidthFactor == aOpenFontSpec.iWidthFactor &&
2068 iSlantFactor == aOpenFontSpec.iSlantFactor &&
2069 iBitmapType == aOpenFontSpec.iBitmapType &&
2070 iEffects == aOpenFontSpec.iEffects &&
2071 iSymbol == aOpenFontSpec.iSymbol &&
2072 iPrintPosition == aOpenFontSpec.iPrintPosition &&
2073 TOpenFontFaceAttribBase::operator==(aOpenFontSpec);
2076 /** Gets the height of the font.
2078 @return The height of the font, in pixels or twips.
2080 inline TInt TOpenFontSpec::Height() const
2085 /** Gets the algorithmic width factor.
2087 @return The algorithmic width factor as a 16.16 fixed-point number.
2088 @see SetWidthFactor() */
2089 inline TInt32 TOpenFontSpec::WidthFactor() const
2091 return iWidthFactor;
2094 /** Gets the algorithmic slant factor.
2096 @return The algorithmic slant factor as a 16.16 fixed-point number.
2097 @see SetSlantFactor() */
2098 inline TInt32 TOpenFontSpec::SlantFactor() const
2100 return iSlantFactor;
2103 /** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
2105 @return Indicates whether or not the font should be drawn using anti-aliasing. */
2106 inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
2108 return (TGlyphBitmapType)iBitmapType;
2111 /** Gets the font effects flags.
2112 Because the flags encoded in the Effects are anonymous, the return value should only
2113 be tested for the specific bits that are of interest, and never tested as a whole.
2116 @return The font effects flags.
2117 @see TOpenFontSpec::SetEffects()
2119 inline TUint32 TOpenFontSpec::Effects() const
2124 /** Gets the print position.
2126 @return The print position. */
2127 inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
2129 return iPrintPosition;
2132 /** Sets the font's height.
2134 @param aHeight The font's height, in pixels or twips.
2136 inline void TOpenFontSpec::SetHeight(TInt aHeight)
2141 /** Sets the algorithmic width factor.
2143 The width factor is multiplied by the pixel's x position to get the new position,
2144 causing characters to become wider or narrower. A width factor of 1 (65536
2145 in 16.16 fixed-point number format) should be used if the character width
2146 is not to be changed.
2148 @param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
2149 @see WidthFactor() */
2150 inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
2152 iWidthFactor = aWidthFactor;
2155 /** Sets the algorithmic slant factor.
2157 Note: The slant factor is used to create an italic effect for characters which
2158 do not have an italic glyph in the typeface. When slanting is active, pixel x
2159 co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x
2160 = x + y x slant factor).
2162 The slant factor is a 32 bit, 16.16 fixed-point number. This means that the
2163 first 16 bits are treated as a whole number, and the second 16 as the fractional
2164 part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this
2165 is equivalent to an integer slant value of 1, which causes a 45 degree slant
2168 @param aSlantFactor The slant factor as a 16.16 fixed-point number.
2169 @see SlantFactor() */
2170 inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
2172 iSlantFactor = aSlantFactor;
2175 /** Sets whether the font should be drawn using anti-aliasing. If set, this value
2176 overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
2179 Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
2180 support for bitmapped fonts.
2182 @param aBitmapType Indicates whether or not the font should be drawn using
2184 inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
2186 iBitmapType = aBitmapType;
2189 /** Sets the font effects flags.
2190 Prior to calling this routine, the value from Effects() should be read,
2191 and its flags modified as required, before passing them back in.
2194 @param aEffect The font effects flags to be set.
2195 @see TOpenFontSpec::Effects()
2197 inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
2199 iEffects = aEffects;
2202 /** Gets the font file's UID.
2204 @return The uid of the file. */
2205 inline TUid COpenFontFile::Uid() const
2210 /** Gets the full path and filename of the font file
2212 This is the filename that was passed to the constructor when the object is
2215 @return The filename of the font file. */
2216 inline const TDesC& COpenFontFile::FileName() const
2221 /** Gets the typeface at a specified index in the typeface attribute array.
2223 @param aFaceIndex The index of the typeface for which the attributes are required.
2224 @return The attributes of the typeface with the specified index.
2227 inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
2229 return iFaceAttrib[aFaceIndex];
2232 /** Gets the number of typefaces in the typeface attributes array.
2234 This is the number of typefaces in the font file: the attributes for each
2235 typeface should be loaded into the array when the derived object is constructed.
2237 @return The number of typefaces in the font file.
2239 @see FaceAttrib() */
2240 inline TInt COpenFontFile::FaceCount() const
2242 return iFaceAttrib.Count();
2245 /** Increments a reference count by one.
2247 @see DecRefCount() */
2248 inline void COpenFontFile::IncRefCount()
2253 /** Decrement a reference count by one.
2255 @return ETrue if the reference count has reached zero (i.e. is less than or
2256 equal to zero); EFalse if the reference count has not yet reached zero (i.e.
2258 @see IncRefCount() */
2259 inline TBool COpenFontFile::DecRefCount()
2262 return iRefCount <= 0;
2265 /** Default C++ constructor. */
2266 inline COpenFontRasterizerContext::COpenFontRasterizerContext():
2271 /** Start writing the glyph data.
2273 Use this function to initialise the buffer to which the glyph bitmap is to
2274 be written. Call WriteGlyphBit() to add bits to the buffer.
2276 @param aGlyphData A pointer to the glyph data. */
2277 inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
2279 aGlyphData->SetPointersToInternalBuffers();
2280 iGlyphData = aGlyphData;
2281 iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
2282 // Allow 4 extra bytes; BITGDI requires this.
2283 iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
2290 /** Writes a bit to the glyph buffer.
2292 Before calling this function you should first call StartGlyph().
2294 @param aBit The bit to be added to the buffer. */
2295 inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
2297 if (aBit && !iOverflow)
2298 *iGlyphDataPtr |= iGlyphBit;
2300 if (iGlyphBit == 256)
2304 if (++iGlyphDataPtr < iGlyphDataEnd)
2311 /** Writes a byte to the glyph buffer.
2313 Before calling this function you should first call StartGlyph().
2315 @param aByte The byte to be added to the buffer. */
2316 inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
2318 if (iGlyphDataPtr < iGlyphDataEnd)
2319 *iGlyphDataPtr++ = (TUint8)aByte;
2325 /** Completes writing glyph data.
2327 Use this function to complete writing the glyph bitmap to the buffer. Call
2328 it after adding all necessary bits using WriteGlyphBit(). */
2329 inline void COpenFontRasterizerContext::EndGlyph()
2331 // Add 4 bytes to the data size; some BITGDI functions require this.
2332 iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
2336 /** Tests whether the bitmap buffer is large enough to hold the bitmap.
2338 @return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
2339 inline TBool TOpenFontGlyphData::Overflow() const
2341 return iBytesNeeded > iBitmapBufferSize;
2344 /** Gets the number of bytes needed to store the glyph bitmap.
2346 @return The number of bytes needed to store the glyph bitmap.
2347 @see SetBytesNeeded() */
2348 inline TInt TOpenFontGlyphData::BytesNeeded() const
2350 return iBytesNeeded;
2353 /** Gets a constant pointer descriptor containing the bitmap this object
2356 @return Pointer descriptor for the glyph. */
2357 inline TPtrC8 TOpenFontGlyphData::Bitmap() const
2359 return TPtrC8(iBitmap,iBytesNeeded);
2362 /** Gets a pointer to the bitmap.
2364 This points either to the buffer used to write the bitmap when it is first
2365 rasterized, or to the cache if the character was already rasterized.
2367 @return A pointer to the bitmap. */
2368 inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
2373 /** Gets the character's metrics.
2375 @return The character's open font metrics. */
2376 inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
2381 /** Gets a pointer to the start of the bitmap buffer.
2383 @return A pointer to the start of the bitmap buffer. */
2384 inline TUint8* TOpenFontGlyphData::BufferStart()
2386 return iBitmapBuffer;
2389 /** Gets a pointer to the end of the bitmap buffer.
2391 @return A pointer to the end of the bitmap buffer. */
2392 inline TUint8* TOpenFontGlyphData::BufferEnd()
2394 return iBitmapBuffer + iBitmapBufferSize;
2397 /** Sets the number of bytes needed to store the glyph bitmap.
2399 @param aBytes The number of bytes needed to store the glyph bitmap.
2400 @see BytesNeeded() */
2401 inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
2403 iBytesNeeded = aBytes;
2406 /** Sets the pointer to the bitmap buffer.
2408 @param aBitmap The pointer to the bitmap buffer. */
2409 inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
2414 /** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
2416 @param aMetrics A pointer to the character's open font character metrics. */
2417 inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
2419 iMetrics = aMetrics;
2422 /** Sets the bitmap and metrics pointers to point to the internal buffers.
2424 The alternative is that the pointers point to the cache of metrics and bitmaps
2425 that have already been rasterized. */
2426 inline void TOpenFontGlyphData::SetPointersToInternalBuffers()
2428 iBitmap = iBitmapBuffer;
2429 iMetrics = &iMetricsBuffer;
2432 /** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics
2435 @param aMetrics The character's open font character metrics. */
2436 inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
2438 iMetricsBuffer = aMetrics;
2439 iMetrics = &iMetricsBuffer;
2442 /** Sets the glyph index.
2444 @param aGlyphIndex The glyph index. */
2445 inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
2447 iGlyphIndex = aGlyphIndex;
2450 /** Uses ECOM plug-in framework to instantiate the shaper factory interface
2451 implementation given its implementation UID.
2453 @param aInterfaceImplUid The UID of the interface implementation required
2455 @return CShaperFactory* A pointer to a CShaperFactory object. */
2456 inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
2458 return reinterpret_cast <CShaperFactory*> (
2459 REComSession::CreateImplementationL(
2461 _FOFF(CShaperFactory, iDtor_ID_Key)));
2464 /** Default destructor */
2465 inline CShaperFactory::~CShaperFactory()
2467 REComSession::DestroyedImplementation(iDtor_ID_Key);
2470 #endif // __OPENFONT_H__