1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // A header for the open font system, which allows
15 // EPOC32 to use fonts of arbitrary types, including TrueType
16 // and other outline font formats.
25 #include <ecom/ecom.h>
31 class COpenFontGlyphCache;
32 class COpenFontGlyphTreeEntry;
33 class COpenFontPositioner;
34 class COpenFontSessionCache;
35 class COpenFontSessionCacheList;
37 class TCharacterMetrics;
39 class TOpenFontFaceAttrib;
41 class TOpenFontFileData;
47 class TFontShapeFunctionParameters;
48 class TFontShapeDeleteFunctionParameters;
50 class TShapeMessageParameters;
52 The OpenFont ECOM Plug-in Interface Definition UID.
56 const TInt KUidOpenFontRasterizerPlunginInterface = 0x101F7F5D;
60 The Shaper Factory ECOM Plug-in Interface Definition UID.
64 const TInt KUidShaperFactoryPlunginInterface = 0x10279726;
68 Replacement character code.
70 This is a Unicode private use area codepoint, which is reserved in the Symbian
71 OS to represent characters for which a glyph does not exist in a font (either
72 a bitmap or scalable font). If a glyph exists in a font with this character
73 code, it will be used for nonexistent characters, otherwise, the rasterizer's
74 default replacement character glyph will be used. For example, TrueType fonts
75 return glyph index 0 for nonexistent characters, and that is usually mapped
76 to an empty rectangle.
79 const TUint KReplacementCharacter = 0xF6DB;
82 KFillCharacterOffset is a significant offset that is set when a character within a code section is
83 not in the font. This means that for these fill characters nothing is stored within the binary
84 data part of the code section.
87 const TInt KFillCharacterOffset = 0x7FFF;
90 Supplied to COpenFont::ExtendedInterface() to access the extended
91 API interface MOpenFontShapingExtension.
93 @see COpenFont::ExtendedInterface()
94 @see MOpenFontShapingExtension
98 const TUid KUidOpenFontShapingExtension = {0x10274DB9};
101 Supplied to COpenFont::ExtendedInterface() to access the extended
102 API interface MOpenFontTrueTypeExtension.
104 @see COpenFont::ExtendedInterface()
105 @see MOpenFontTrueTypeExtension
109 const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
112 Supplied to CShaper::ExtendedInterface() to get the language and script
113 code with which the current shaper is instatsiated.
114 @see CShaper::ExtendedInterface()
118 const TUid KUidShaperGetScript = {0x20009966};
119 const TUid KUidShaperGetLang = {0x20009967};
124 @see CFbsFont::GetFontMetrics()
128 class TOpenFontMetrics
131 inline TOpenFontMetrics();
132 IMPORT_C TOpenFontMetrics(const CFont* aFont);
133 inline TInt Size() const;
134 inline TInt Ascent() const;
135 inline TInt Descent() const;
136 inline TInt MaxHeight() const;
137 inline TInt MaxDepth() const;
138 inline TInt MaxWidth() const;
139 inline void SetSize(TInt aSize);
140 inline void SetAscent(TInt aAscent);
141 inline void SetDescent(TInt aDescent);
142 inline void SetMaxHeight(TInt aMaxHeight);
143 inline void SetMaxDepth(TInt aMaxDepth);
144 inline void SetMaxWidth(TInt aMaxWidth);
146 TInt16 iDesignHeight; // size of the font ('pointsize' in pixels)
147 TInt16 iAscent; // typographic ascent
148 TInt16 iDescent; // typographic descent
149 TInt16 iMaxHeight; // maximum height of a character; may be greater than iAscent
150 TInt16 iMaxDepth; // maximum depth of a character; may be greater than iDescent
151 TInt16 iMaxWidth; // maximum width of a character
157 Character metrics includes more information than TCharacterMetrics.
159 Character metrics allow characters to be placed horizontally or vertically.
160 The character metrics encapsulated by this class are: Height, Width, Horizontal
161 Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X,
162 Vertical Bearing Y, and Vertical Advance. Their meanings are described in the
163 associated setter and getter functions.
167 Vertical drawing (in the sense of characters drawn with horizontal baselines,
168 but in a vertical line) is not yet supported by Symbian OS.
170 @see CFont::GetCharacterData()
171 @see CFbsFont::GetCharacterData()
175 class TOpenFontCharMetrics
178 enum TUninitialized { EUninitialized };
180 /** Default constructor initializes all members to 0. */
181 inline TOpenFontCharMetrics();
183 /** Constructor that does not initialize any members. */
184 TOpenFontCharMetrics(TUninitialized) {}
185 IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics);
186 IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const;
187 inline TInt Width() const;
188 inline TInt Height() const;
189 inline TInt HorizBearingX() const;
190 inline TInt HorizBearingY() const;
191 inline TInt HorizAdvance() const;
192 inline TInt VertBearingX() const;
193 inline TInt VertBearingY() const;
194 inline TInt VertAdvance() const;
195 inline void GetHorizBounds(TRect& aBounds) const;
196 inline void GetVertBounds(TRect& aBounds) const;
197 inline void SetWidth(TInt aWidth);
198 inline void SetHeight(TInt aHeight);
199 inline void SetHorizBearingX(TInt aHorizBearingX);
200 inline void SetHorizBearingY(TInt aHorizBearingY);
201 inline void SetHorizAdvance(TInt aHorizAdvance);
202 inline void SetVertBearingX(TInt aVertBearingX);
203 inline void SetVertBearingY(TInt aVertBearingY);
204 inline void SetVertAdvance(TInt aVertAdvance);
206 TInt16 iWidth; // width of the glyph
207 TInt16 iHeight; // height of the glyph
208 TInt16 iHorizBearingX; // x component of horizontal bearing
209 TInt16 iHorizBearingY; // y component of horizontal bearing
210 TInt16 iHorizAdvance; // horizontal advance
211 TInt16 iVertBearingX; // x component of vertical bearing
212 TInt16 iVertBearingY; // y component of vertical bearing
213 TInt16 iVertAdvance; // vertical advance
221 Objects of this type are used by rasterizers to supply glyph data to font
222 and bitmap server clients. Unless you are writing a rasterizer you will not
223 need to use an object of this type.
225 The object cannot be constructed and destroyed by normal means. It resides
226 on a specified heap. It is created by New() and deleted by RHeap::Free().
228 @see COpenFont::RasterizeL()
232 class TOpenFontGlyphData
235 IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize);
236 inline TBool Overflow() const;
237 inline TInt BytesNeeded() const;
238 inline TPtrC8 Bitmap() const;
239 inline const TUint8* BitmapPointer() const;
240 inline const TOpenFontCharMetrics* Metrics() const;
241 inline TInt GlyphIndex() const;
242 inline TUint8* BufferStart();
243 inline TUint8* BufferEnd();
244 inline void SetBytesNeeded(TInt aBytes);
245 inline void SetBitmapPointer(const TUint8* aBitmap);
246 inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics);
247 inline void SetPointersToInternalBuffers();
248 inline void SetMetrics(TOpenFontCharMetrics& aMetrics);
249 inline void SetGlyphIndex(TInt aGlyphIndex);
252 Prevent construction and destruction by normal means; the object resides
253 on a specified heap and is created by New and deleted by RHeap::Free.
255 TOpenFontGlyphData();
256 ~TOpenFontGlyphData();
258 TInt iBitmapBufferSize; // size of the buffer in bytes
259 TInt iBytesNeeded; // bytes needed for the bitmap
260 TOpenFontCharMetrics iMetricsBuffer; // the metrics
261 const TUint8* iBitmap; // pointer to the bitmap; points either to iBitmapBuffer or to
262 // the cache if the character was already rasterized
263 const TOpenFontCharMetrics* iMetrics; // pointer to the metrics; points either to iMetricsBuffer or to
264 // the cache if the character was already rasterized
265 TInt iGlyphIndex; // the glyph index
266 TAny* iReserved; // unused; for future expansion
267 TUint8 iBitmapBuffer[1]; // buffer used to write the bitmap when it is first rasterized; this
268 // is actually of size iBitmapBufferSize.
271 class COpenFontGlyph;
272 class CLinkedFontInformation;
274 Open Font System font abstract base class.
276 Derive a class from this class to represent an instance of a typeface at a
277 particular size, provide bitmaps of the glyphs, and determine whether
278 characters exist in the typeface.
280 Writing derived classes construction:
282 You must call the constructor of this class when creating your derived object,
283 passing the arguments aHeap and aSessionCacheList supplied to
284 COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile
285 object that creates the object as aFile.
287 The derived object must be created on the shared heap aHeap because it is
288 shared by several processes: the font and bitmap server and its clients.
289 To do this, use aHeap->AllocL() to obtain memory, then construct in place
290 using a placement argument to new.
292 Derived classes must implement the pure virtual function RasterizeL().
293 Information about this function is provided in the function definition below.
295 Information about deriving from this class is also provided in the API guide.
297 @see COpenFontFile::GetNearestFontInPixelsL()
301 class COpenFont: public CBase
304 /** Creates a bitmap for the specified Unicode character.
306 Implementations of this function should put the bitmap in
307 aGlyphData->iBitmapBuffer, and the character metrics are placed in
308 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
311 There are a number of strategies for achieving this, e.g. pass the
312 rasterization task all the way up to the rasterizer engine. These are
313 discussed in the API guide.
315 At present you must write the bitmap in the Symbian platform's
316 run-length-encoded format. This is a packed binary format starting on a
317 byte boundary and made up of a number of sections. Each section starts
318 with a five-bit header. If the first bit of the header is 0 the next four
319 bits are a repeat count, starting with the least significant bit, and a
320 single row of bits (the number of bits in a row is specified by
321 aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header
322 is 1 the next four bits are a count of non-repeating rows, again starting
323 with the least significant bit, and that many rows of bits follow.
325 @param aCode The character code of the Unicode character for which the
327 @param aGlyphData On return, contains a pointer to a TOpenFontGlyphData
328 containing the character's bitmap and metrics. */
329 virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
330 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
331 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile);
332 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex);
333 IMPORT_C ~COpenFont();
334 IMPORT_C void operator delete(TAny*);
335 inline const TOpenFontMetrics& Metrics() const;
336 inline const TOpenFontFaceAttrib* FaceAttrib() const;
337 inline COpenFontFile* File() const;
338 inline TInt FaceIndex() const;
339 inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
340 void SetShaper(CShaper* aShaper);
341 CShaper* GetShaper();
342 TBool HasShaper() const;
343 TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams);
344 TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader);
345 TInt FreeShaperCacheMemory(TInt aBytesNeeded);
346 TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse);
347 TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData);
348 TBool HasCharacterL(TInt aCode) const;
349 TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
350 void OnFileDeleted();
351 COpenFontGlyphCache* GetGlyphCache();
352 inline TInt FontCapitalAscent() const;
353 inline TInt FontMaxAscent() const;
354 inline TInt FontStandardDescent() const;
355 inline TInt FontMaxDescent() const;
356 inline TInt FontLineGap() const;
357 inline TInt FontMaxHeight() const;
358 void DeleteShaper() const;
361 TOpenFontMetrics iMetrics;
363 /** The shaper for performing complex character positioning and
364 substitution, if available. Null otherwise.
365 @internalComponent */
369 /** The positive distance in pixels from the baseline to
370 the top of an ANSI capital (whether or not there are
371 ANSI capitals in the font) */
372 TInt iFontCapitalAscent;
373 /** The positive distance in pixels from the baseline to
374 the top of the highest pre-composed glyph in the font */
376 /** The positive distance in pixels from the baseline to
377 the bottom of the lowest ANSI descender (whether or
378 not there are ANSI chars in the font)*/
379 TInt iFontStandardDescent;
380 /** The positive distance in pixels from the baseline to
381 the bottom of the lowest pre-composed glyph in the font */
382 TInt iFontMaxDescent;
383 /** The recommended baseline to baseline gap for successive
384 lines of text in the font */
387 const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
392 const COpenFontGlyph* FontCacheGlyph(TInt aCode,COpenFontGlyphTreeEntry**& aNode);
394 const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode,
395 COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const;
396 void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData);
398 COpenFontFile* iFile; // the file used by this font; null if it has been deleted
400 TInt iFaceIndex; // index of the face in the font file
405 COpenFontGlyphCache* iGlyphCache; // the per-font glyph cache; owned by the font
407 COpenFontSessionCacheList* iSessionCacheList; // the list of per-session glyph caches; owned by CFontStore
408 TAny* iReserved; // unused; for future expansion
411 /** Open Font System Extension Interface abstract base class.
413 COpenFont derivers should also derive from this interface to enable complex
416 This interface should be returned by the overridden
417 COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
421 @see KUidOpenFontShapingExtension
425 class MOpenFontShapingExtension
428 /** Various font metrics. */
429 class TExtensionFontMetrics
432 /** The number of font design units per em. */
434 /** The width of the font's em square in pixels. */
436 /** The height of the font's em square in pixels. */
438 /** The horizontal scaling factor from the font's transform;
439 the number of horizontal pixels per font unit. */
441 /** The vertical scaling factor from the font's transform;
442 the number of vertical pixels per font unit. */
445 /** Reserved for future expansion. */
449 /** Creates a bitmap for the specified Glyph code.
451 Implementations of this function should put the bitmap in
452 aGlyphData->iBitmapBuffer, and the character metrics are placed in
453 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
456 This function provides the same functionality as the
457 COpenFont::RasterizeL() except that the glyph code is supplied rather than
460 For more information:
461 @see COpenFont::RasterizeL()
464 The glyph code of the character for which the bitmap is required.
466 The function puts its output here.
468 virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
470 /** Maps a character to a glyph index.
471 @param aUnicodeCharacter Unicode character code to be mapped.
472 @return Glyph code corresponding to aUnicodeCharacter. */
473 virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0;
475 /** Returns the hinted pixel coordinates of a particular point in the
476 outline of the given glyph.
477 @param aGlyphPoint The glyph index.
478 @param aPointNumber The number of the point.
479 @param aX Returns the point's X pixel value.
480 @param aY Returns the point's Y pixel value.
481 @return True on success, false otherwise. */
482 virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber,
483 TReal& aX, TReal& aY) const = 0;
485 /** Returns the coordinates of a particular (unhinted) point in the outline
486 of the given glyph in font units.
487 @param aGlyphPoint The glyph index.
488 @param aPointNumber The number of the point.
489 @param aX Returns the point's X co-ordinate in font units.
490 @param aY Returns the point's Y co-ordinate in font units.
491 @return True on success, false otherwise. */
492 virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber,
493 TInt& aX, TInt& aY) const = 0;
495 /** Returns font metrics.
496 @param aOut Font metrics returned. */
497 virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
500 /** TrueType extension for Open Fonts.
502 If an open font is able to load TrueType or OpenType tables it should derive
505 This class will be used by
507 This interface should be returned by the overridden
508 COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
510 @see KUidOpenFontTrueTypeExtension
514 class MOpenFontTrueTypeExtension
517 /** Returns the specified table. The table need not be released by the
518 caller, so the deriver is responsible for ensuring that any memory
519 allocated is ultimately cleaned up. The caller must not delete or modify
522 Returns KErrNone if successful or one of the system-wide error codes if
523 unsuccessful. Returns KErrNotSupported if the table does not exist in
526 The tag of the table, with the first character in the most significant
527 byte. For example, the "vhea" table is obtained by passing in 'v'<<24 |
528 'h'<<16 | 'e'<<8 | 'a'.
530 The length of the table in bytes that has been returned or 0 if
532 @return The table, if successful.
533 @see ReleaseTrueTypeTable */
534 virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0;
535 /** Releases a table obtained by GetTrueTypeTable. The caller must not
536 use the table after this call.
537 @param aTable The table to be released.
538 @see GetTrueTypeTable */
539 virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0;
540 /** Determines if the font file has a particular table.
541 @param aTag The tag of the table as for GetTrueTypeTable.
542 @return True if the table exists in the font file, false otherwise.
543 @see GetTrueTypeTable */
544 virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
548 Font attribute base class.
550 This class is not intended for user derivation.
552 @see TOpenFontFaceAttrib
557 class TOpenFontFaceAttribBase
560 inline TOpenFontFaceAttribBase();
561 inline TBool HasLatin() const;
562 inline TBool HasGreek() const;
563 inline TBool HasCyrillic() const;
564 inline TBool HasKana() const;
565 inline TBool HasHangul() const;
566 inline TBool HasCJK() const;
567 inline TBool IsSymbol() const;
568 inline TBool IsBold() const;
569 inline TBool IsItalic() const;
570 inline TBool IsSerif() const;
571 inline TBool IsMonoWidth() const;
572 inline TPtrC Name() const;
573 inline const TUint* Coverage() const;
574 inline void SetName(const TDesC& aName);
575 inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0);
576 inline void SetBold(TBool aBold);
577 inline void SetItalic(TBool aItalic);
578 inline void SetSerif(TBool aSerif);
579 inline void SetMonoWidth(TBool aMonoWidth);
580 inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const;
582 // Unicode ranges for iCoverage[0] (incomplete; see the TrueType documentation for other values)
585 ELatinSet = 0x1, // 0000-007F
586 EGreekSet = 0x80, // 0370-03FF
587 ECyrillicSet = 0x200, // 0400-04FF
588 EArmenianSet = 0x400, // 0530-058F
589 EHebrewSet = 0x800, // 0590-05FF
590 EArabicSet = 0x2000, // 0600-06FF
591 EDevanagariSet = 0x8000, // 0900-097F
592 EBengaliSet = 0x10000, // 0980-09FF
593 EGurmukhiSet = 0x20000, // 0A00-0A7F
594 EGujuratiSet = 0x40000, // 0A80-0AFF
595 EOriyaSet = 0x80000, // 0B00-0B7F
596 ETamilSet = 0x100000, // 0B80-0BFF
597 ETeluguSet = 0x200000, // 0C00-0C7F
598 EKannadaSet = 0x400000, // 0C80-0CFF
599 EMalayalamSet = 0x800000, // 0D00-0D7F
600 EThaiSet = 0x1000000, // 0E00-0E7F
601 ELaoSet = 0x2000000, // 0E80-0EFF
602 EGeorgianSet = 0x8000000, // 10A0-10FF
603 EHangulJamoSet = 0x10000000,// 1100-11FF
606 // Unicode ranges for iCoverage[1]
609 ESymbolSets = 0xFFFE,
611 EHangulSet = 0x100000,
618 EBold = 0x1, // weight > 500 in Windows terms
619 EItalic = 0x2, // italic or oblique - any forward slant counts
620 ESerif = 0x4, // characters have serifs
621 EMonoWidth = 0x8 // all characters are the same width
627 ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24
630 TBufC<ENameLength> iName; // the name of the typeface; whether this is the full name or family name
631 // or is in English or another language depends on the context
632 TUint iCoverage[4]; // bitmap of the character sets supported by the typeface;
633 // these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4
634 // in the OS/2 table in TrueType fonts
635 TInt iStyle; // bold, italic serif, and mono-width
643 These attributes include the name, family name, and supported scripts.
645 @see CFbsFont::GetFaceAttrib()
649 class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
652 inline TOpenFontFaceAttrib();
653 inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const;
654 inline TPtrC FullName() const;
655 inline TPtrC FamilyName() const;
656 inline TPtrC LocalFullName() const;
657 inline TPtrC LocalFamilyName() const;
658 inline TPtrC ShortFullName() const;
659 inline TPtrC ShortFamilyName() const;
660 inline TPtrC ShortLocalFullName() const;
661 inline TPtrC ShortLocalFamilyName() const;
662 inline void SetFullName(const TDesC& aName);
663 inline void SetFamilyName(const TDesC& aName);
664 inline void SetLocalFullName(const TDesC& aName);
665 inline void SetLocalFamilyName(const TDesC& aName);
666 inline TInt MinSizeInPixels() const;
667 inline void SetMinSizeInPixels(TInt aSize);
669 TBufC<ENameLength> iFamilyName; // the name without any style suffixes; usually a truncation of iFullName
670 TBufC<ENameLength> iLocalFullName; // the full name in the language of the current locale
671 TBufC<ENameLength> iLocalFamilyName; // the family name in the language of the current locale
672 TInt iMinSizeInPixels; // minimum supported size, (or readable size if scalable) in pixels
678 Font specification allowing more attributes to be specified than TFontSpec.
680 In addition to the attributes specified by TFontSpec, this font specification
681 allows stretching and slanting in the x dimension, and other algorithmic effects.
682 This is used to correct for non-square pixels, and to allow algorithmic slanting
683 and bold. The width factor and slant factor transform any point (x,y) to (x
684 * iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16
687 The font specification also provides access to information about the scripts
688 which are supported by the font. This information is not always reliable,
689 because it may be incorrectly specified, or not specified at all, by some
694 class TOpenFontSpec : public TOpenFontFaceAttribBase
697 IMPORT_C TOpenFontSpec();
698 IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec);
699 IMPORT_C void operator=(const TFontSpec& aFontSpec);
700 inline TBool operator==(const TOpenFontSpec& aFontSpec) const;
701 TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const;
702 IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib);
703 IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const;
704 IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight);
705 IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap);
706 inline TInt Height() const;
707 inline TInt32 WidthFactor() const;
708 inline TInt32 SlantFactor() const;
709 inline TGlyphBitmapType BitmapType() const;
710 inline TUint32 Effects() const;
711 inline TFontPrintPosition PrintPosition() const;
712 inline void SetHeight(TInt aHeight);
713 inline void SetWidthFactor(TInt32 aWidthFactor);
714 inline void SetSlantFactor(TInt32 aSlantFactor);
715 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
716 inline void SetEffects(TUint32 aEffects);
717 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
718 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
719 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
720 IMPORT_C TInt ScriptTypeForMetrics() const;
721 static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight, TReal& aRatio);
723 /** Algorithmic effects flags.
725 These can be combined using an OR operation.
726 @publishedPartner For use by system/UI software.
727 @deprecated Use FontEffect::TEffect instead.
731 /** Font is algorithmic bold. */
732 EAlgorithmicBold = 1,
733 /** Font has a drop shadow. */
735 /** Font is an outline font. */
739 void SetScriptTypeForMetrics(TInt aScript);
740 void SetSymbol(TBool aSymbol);
741 TBool Symbol() const;
742 IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const;
743 IMPORT_C TUint32 DoEffects() const;
744 IMPORT_C void DoSetEffects(TUint32 aEffects);
746 TInt iHeight; // em height
747 TInt32 iWidthFactor; // algorithmic width factor as a 16.16 fixed-point number
748 TInt32 iSlantFactor; // algorithmic slant factor as a 16.16 fixed-point number
749 TInt iBitmapType; // non-anti-aliased, standard anti-aliased, etc.; zero means 'default'
750 TUint32 iEffects; // bit flags for font effects
751 TInt iSymbol; // a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5)
752 // The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec
753 TFontPrintPosition iPrintPosition; // normal, superscript or subscript
759 Constants for attachment points for diacritics.
762 enum TOpenFontAttachment
777 Font file abstract base class.
779 Write a class derived from COpenFontFile to manage a file with the font format
780 supported by your DLL. The derived class must implement the virtual
781 GetNearestFontInPixelsL() function. This function takes a font description
782 and creates a COpenFont derived object if the description matches a typeface
783 contained in the font file.
785 Derived classes must also load typeface attributes from the file into the
786 protected typeface attribute array during construction. This array is what
787 is searched when getting font attribute information see AddFaceL(),
788 GetNearestFontHelper().
790 Writing derived classes construction:
792 Call the COpenFontFile constructor in the constructor for your derived object,
793 passing it aUid and aFileName arguments. These values are the arguments passed
794 when the constructor is called by COpenFontRasterizer::NewFontFileL().
796 A file may contain one or more typefaces. During construction the derived
797 object should extract the information for each typeface and add it to this
798 object's protected typeface attribute array see AddFaceL(). This process
799 will probably leave under some conditions. It should therefore be implemented
800 in a second phase constructor.
802 Writing derived classes implement the pure virtual functions:
804 Derived classes must also implement the two pure virtual functions
805 GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about
806 these functions is provided in the definitions below. Information about
807 deriving from this class is also provided in the API guide.
809 @see COpenFontRasterizer::NewFontFileL()
810 @see CWsScreenDevice::AddFile()
814 class COpenFontFile : public CBase
818 Gets the font which is the nearest to the given font specification.
820 Implementations of this pure virtual function should create the COpenFont
821 derived object that most closely matches aDesiredFontSpec, while fitting within
822 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
823 e.g. if the font name doesn't match, aFont should be set to NULL.
825 The other two arguments, aHeap and aSessionCacheList, should be passed to
826 the COpenFont constructor.
828 Implementations may use the utility function GetNearestFontHelper()
829 to get the attributes of the closest matching font.
831 @param aHeap Shared heap. This value should be passed to the COpenFont derived
832 classes' constructor.
833 @param aSessionCacheList The session cache list. This value should be passed
834 to the COpenFont derived classes' constructor.
835 @param aDesiredFontSpec The desired font specification.
836 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
837 the algorithmic slant of the typeface.
838 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
839 the algorithmic slant of the typeface.
840 @param aFont On return, contains a pointer to the newly created COpenFont
841 derived object, or NULL if no font matching aDesiredFontSpec exists.
842 @param aActualFontSpec The actual font specification of the font retrieved
845 @see GetNearestFontHelper()
847 virtual void GetNearestFontInPixelsL(
848 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
849 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
850 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
853 Gets the font which is the nearest to the given font specification.
855 Implementations of this pure virtual function should create the COpenFont
856 derived object that most closely matches aDesiredFontSpec, while fitting within
857 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
858 e.g. if the font name doesn't match, aFont should be set to NULL.
860 The other two arguments, aHeap and aSessionCacheList, should be passed to
861 the COpenFont constructor.
863 Implementations may use the utility function GetNearestFontHelper()
864 to get the attributes of the closest matching font.
866 @param aHeap Shared heap. This value should be passed to the COpenFont derived
867 classes' constructor.
868 @param aSessionCacheList The session cache list. This value should be passed
869 to the COpenFont derived classes' constructor.
870 @param aDesiredFontSpec The desired font specification.
871 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
872 the algorithmic slant of the typeface.
873 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
874 the algorithmic slant of the typeface.
875 @param aFont On return, contains a pointer to the newly created COpenFont
876 derived object, or NULL if no font matching aDesiredFontSpec exists.
877 @param aActualFontSpec The actual font specification of the font retrieved
880 @see GetNearestFontHelper()
882 virtual void GetNearestFontToDesignHeightInPixelsL(
883 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
884 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
885 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
887 Gets the font which is the nearest to the given font specification.
889 Implementations of this pure virtual function should create the COpenFont
890 derived object that most closely matches aDesiredFontSpec, while fitting within
891 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
892 e.g. if the font name doesn't match, aFont should be set to NULL.
894 The other two arguments, aHeap and aSessionCacheList, should be passed to
895 the COpenFont constructor.
897 Implementations may use the utility function GetNearestFontHelper()
898 to get the attributes of the closest matching font.
900 @param aHeap Shared heap. This value should be passed to the COpenFont derived
901 classes' constructor.
902 @param aSessionCacheList The session cache list. This value should be passed
903 to the COpenFont derived classes' constructor.
904 @param aDesiredFontSpec The desired font specification.
905 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
906 the algorithmic slant of the typeface.
907 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
908 the algorithmic slant of the typeface.
909 @param aFont On return, contains a pointer to the newly created COpenFont
910 derived object, or NULL if no font matching aDesiredFontSpec exists.
911 @param aActualFontSpec The actual font specification of the font retrieved
913 @param aMaxHeight The maximum height within which the font must fit.
915 @see GetNearestFontHelper()
917 virtual void GetNearestFontToMaxHeightInPixelsL(
918 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
919 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
920 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
922 /** Tests whether a specified typeface contains a particular character.
924 @param aFaceIndex The index of the typeface to be tested.
925 @param aCode The Unicode character code for the character to be tested.
926 @return ETrue if the typeface contains aCode, otherwise EFalse. */
927 virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0;
928 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
929 IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName);
930 IMPORT_C ~COpenFontFile();
931 IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
932 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
933 IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
934 inline TUid Uid() const;
935 inline const TDesC& FileName() const;
936 inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
937 inline TInt FaceCount() const;
938 inline void IncRefCount();
939 inline TBool DecRefCount();
940 TInt GetNearestFontInPixels(
941 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
942 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
943 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
944 TInt GetNearestFontToDesignHeightInPixels(
945 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
946 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
947 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
948 TInt GetNearestFontToMaxHeightInPixels(
949 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
950 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
951 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
952 void RemoveFontFromList(const COpenFont* aFont);
953 void SetFontStoreL(CFontStore* aFontStore);
954 CFontStore* GetFontStore();
955 CArrayPtrFlat<COpenFont>* GetOpenFontList();
957 IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
958 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
960 // A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
961 class TAttrib: public TOpenFontFaceAttrib
964 COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface
966 static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
967 static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
968 void GetNearestFontToDesignHeightInPixelsAndAddToListL(
969 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
970 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
971 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
972 void GetNearestFontToMaxHeightInPixelsAndAddToListL(
973 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
974 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
975 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
978 CArrayFixFlat<TAttrib> iFaceAttrib;
980 TBuf<KMaxFileName> iFileName;
982 CArrayPtrFlat<COpenFont> iFontList;
983 TOpenFontFileData* iData;
988 The Open Font rasterizer plug-in Interface Definition class.
990 This interface allows the implementation of an Open Font rasterizer plug-in,
991 which can then be dynamically loaded at run time by the ECOM plug-in framework.
992 The plug-in implementation is instantiated by calling NewL(), passing the implementation
993 UID so that ECOM can instantiate the correct implementation.
995 The rasterizer interface declares a single pure virtual functions, which the
996 plug-in derived from this interface must implement. The function reads font files, and creates
997 a COpenFontFile object if the font file is of the right type.
999 Writing derived classes:
1001 Open font rasterizers should derive from this class and implement the
1002 NewFontFileL() function.
1004 Derived classes should also define the factory function. It is a static function
1005 which takes no arguments. It creates a COpenFontRasterizer derived object on the heap, and returns it
1006 to the caller. This factory function, together with the implementation UID will form
1007 the TImplementationProxy used by the ECOM framework to instatiate the plug-in.
1009 The rasterizer class may also need to store an 'engine context'. This is an
1010 object derived from COpenFontRasterizerContext, which provides functions that
1011 make it easier to write the glyph bitmap during rasterization.
1017 class COpenFontRasterizer: public CBase
1020 /** Creates a COpenFontFile derived object for loading font files in the
1023 This function is called by the framework during font and bitmap server
1024 startup. It creates a font file object for font files in the \\resource\\fonts
1025 directory on all drives, using the default search path. The first font of
1026 a given name overrides subsequent ones. The directory search path is soft
1027 to hard: Y:, X:, W:, ..., C:, B:, A:, Z:. Files may also be added
1028 dynamically after startup using CWsScreenDevice::AddFile(), which
1029 indirectly calls this function.
1031 Implementations of this function should examine the file aFileName, and if
1032 it is of the correct type attempt to create a COpenFontFile derived object
1033 to load it. The caller is responsible for deleting the object. The function
1034 must return NULL if it cannot recognise the file, and it may also leave if
1037 @param aUid An ID to be used for the file. UIDs are required by the font
1038 framework, so the font store allocates them for non Symbian OS-native font
1039 files. This ID persists until the font is unloaded, e.g. if the device is
1041 @param aFileName The full path and filename of the file from which the
1042 COpenFontFile object is created, if the file is the correct type.
1043 @param aFileSession The file session owned by the Font and Bitmap server.
1044 This file session should be used for any file access. If COpenFontFile
1045 objects need to keep files open, aFileSession should be stored in a place
1046 that is accessible to them.
1047 @return A pointer to a new COpenFontFile derived object, or NULL if the
1048 file type is not recognised.
1049 @see CWsScreenDevice::AddFile() */
1050 virtual COpenFontFile* NewFontFileL(TInt aUid,const TDesC& aFileName,RFs& aFileSession) = 0;
1051 inline static COpenFontRasterizer* NewL(TUid aInterfaceImplUid);
1052 inline virtual ~COpenFontRasterizer();
1053 IMPORT_C virtual void Reserved(); // unused; for future expansion
1055 TUid iDtor_ID_Key;//ECOM identifier used during destruction
1060 Convenience class from which rasterizer contexts may be derived.
1062 A rasterizer context object may (optionally) be created to provide the link
1063 between the rasterizer DLL code supported by the Open Font System, and the
1064 rasterizer engine code. A rasterizer context object class should get the
1065 requested bitmap from the associated rasterizer engine. It should then convert
1066 this into Symbian run-length-encoded format. This class contains convenience
1067 functions to make the conversion easier.
1069 Deriving from this class is described in greater detail in the API guide.
1073 class COpenFontRasterizerContext: public CBase
1076 inline COpenFontRasterizerContext();
1077 inline void StartGlyph(TOpenFontGlyphData* aGlyphData);
1078 inline void WriteGlyphBit(TInt aBit);
1079 inline void WriteGlyphByte(TInt aByte);
1080 inline void EndGlyph();
1082 TOpenFontGlyphData* iGlyphData;
1083 TUint8* iGlyphDataStart;
1084 TUint8* iGlyphDataPtr;
1085 TUint8* iGlyphDataEnd;
1089 TAny* iReserved; // unused; for future expansion
1094 Shaper abstract class. All shaper implementations derive from this
1096 class CShaper : public CBase
1102 /** The text to be shaped possibly including context. */
1104 /** The index of the first character in iText to be shaped. */
1106 /** (One past) the end of the text in iText to be shaped. */
1108 /** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
1111 /** Language code. 0 implies "default" */
1113 /** Maximum advance in pixels. Shaping beyond this
1114 advance is not required (but is not harmful). */
1115 TInt iMaximumAdvance;
1116 /** Flags. Currently none is defined. */
1118 /** Session handle. To be used if rasterization is needed. */
1119 TInt iSessionHandle;
1120 /** Reserved for future expansion. Must be set to 0. */
1127 IMPORT_C virtual ~CShaper();
1129 /** construct a shaper object
1130 @param aBitmapFont The font to be shaped.
1131 @param aHeap The heap to be used by the shaper.
1132 @return KErrNone if this font can be shaper or system wide error code*/
1133 virtual TInt ConstructL(CBitmapFont* aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1135 /** If possible, shape the text described by aInput, placing the
1136 output on aHeapForOutput.
1137 @param aOutput The output, as a newly allocate object on
1139 @param aInput The input text and other parameters.
1140 @param aHeapForOutput. On success, aOutput should be allocated from
1141 this and nothing else. On failure, nothing should be allocated from
1143 @return Error value from one of the system-wide error codes on
1144 failure, KErrNone on success.
1145 @see TShapeHeader */
1146 virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0;
1148 /** For future expansion. Any overriders must base-call
1149 if aInterface is unrecognized.
1150 @param aInterfaceId The ID of the interface to return.
1151 @return A pointer to the extension interface.
1155 IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
1158 /** ECOM plug-in base class for shaper factories.
1160 class CShaperFactory : public CBase
1163 /** Create a shaper if possible, for typeface aFaceIndex
1164 within file aFileName.
1165 @param aFont The font to be shaped.
1166 @param iHeap The heap to use for constructing the shaper.
1167 @return 0 If the font is not understood or inappropriate for
1168 any shaper that might be constructed by this class, otherwise
1169 returns the newly-constructed shaper on iHeap. */
1170 virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1172 inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
1173 inline virtual ~CShaperFactory();
1175 /** For future expansion. Any overriders must base-call
1176 if aInterface is unrecognized.
1177 @param aInterfaceId The ID of the interface to return.
1178 @return A pointer to the extension interface.
1181 virtual void* ExtendedInterface(TUid aInterfaceId);
1184 TUid iDtor_ID_Key;//ECOM identifier used during destruction
1188 // Inline functions start here.
1189 /** Default C++ constructor.
1191 This creates then zero fills the object. */
1192 inline TOpenFontMetrics::TOpenFontMetrics()
1194 Mem::FillZ(this,sizeof(*this));
1197 /** Gets the font's size.
1199 @return The font's size.
1201 inline TInt TOpenFontMetrics::Size() const
1203 return iDesignHeight;
1206 /** Gets the font's ascent.
1208 This is the ascent for the Latin character which is highest above the baseline.
1210 @return The font's ascent, in pixels.
1212 inline TInt TOpenFontMetrics::Ascent() const
1217 /** Gets the font's descent.
1219 This is the descent for the Latin character in the font which falls furthest below the baseline.
1221 @return The font's descent, in pixels.
1222 @see SetDescent() */
1223 inline TInt TOpenFontMetrics::Descent() const
1228 /** Sets the font's maximum height.
1230 Note that if this object was initialised from the CFont this will be the same
1233 This is the ascent for the character which is highest above the baseline.
1234 In many fonts this will be the height of an accented character like Â,
1235 including the accent.
1237 @return The maximum height of the font, in pixels.
1238 @see SetMaxDepth() */
1239 inline TInt TOpenFontMetrics::MaxHeight() const
1244 /** Gets the font's maximum depth.
1246 Note: If this object was initialised from the CFont this will be the same as the
1249 This is the descent for the character in the font which falls furthest below
1252 @return The font's maximum depth.
1253 @see SetMaxDepth() */
1254 inline TInt TOpenFontMetrics::MaxDepth() const
1259 /** Gets the maximum character width, in pixels.
1261 @return The maximum character width, in pixels.
1262 @see SetMaxWidth() */
1263 inline TInt TOpenFontMetrics::MaxWidth() const
1268 /** Sets the font's size.
1270 @param aSize The font's size.
1272 inline void TOpenFontMetrics::SetSize(TInt aSize)
1274 iDesignHeight = static_cast<TInt16>(aSize);
1277 /** Sets the ascent.
1279 @param aAscent The ascent, in pixels.
1281 inline void TOpenFontMetrics::SetAscent(TInt aAscent)
1283 iAscent = static_cast<TInt16>(aAscent);
1286 /** Sets the descent.
1288 @param aDescent The descent, in pixels.
1290 inline void TOpenFontMetrics::SetDescent(TInt aDescent)
1292 iDescent = static_cast<TInt16>(aDescent);
1295 /** Sets the font's maximum height.
1297 @param aMaxHeight The font's maximum height, in pixels.
1299 inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
1301 iMaxHeight = static_cast<TInt16>(aMaxHeight);
1304 /** Sets the font's maximum depth.
1306 @param aMaxDepth The font's maximum depth, in pixels.
1308 inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
1310 iMaxDepth = static_cast<TInt16>(aMaxDepth);
1313 /** Sets the maximum character width, in pixels.
1315 @param aMaxWidth The maximum character width, in pixels.
1317 inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
1319 iMaxWidth = static_cast<TInt16>(aMaxWidth);
1322 /** Default C++ constructor.
1324 The constructor initialises all data members to zero. As for other T classes,
1325 there is no need to explicitly cleanup TOpenFontCharMetrics objects. */
1326 inline TOpenFontCharMetrics::TOpenFontCharMetrics()
1328 Mem::FillZ(this,sizeof(*this));
1331 /** Gets the width of the character's bitmap.
1333 @return The width of the bitmap in pixels. */
1334 inline TInt TOpenFontCharMetrics::Width() const
1339 /** Gets the height of the character's bitmap.
1341 @return The character's height in pixels. */
1342 inline TInt TOpenFontCharMetrics::Height() const
1347 /** Gets the horizontal bearing X.
1349 This is the distance in pixels from the pen point before the character is
1350 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1351 A positive value means that the left edge of the bitmap is right of the origin.
1353 @return The horizontal bearing X in pixels */
1354 inline TInt TOpenFontCharMetrics::HorizBearingX() const
1356 return iHorizBearingX;
1359 /** Gets horizontal bearing Y.
1361 This is the vertical distance in pixels from the pen point before the character
1362 is drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1363 A positive value means that the top edge of the bitmap is above the origin
1365 @return The horizontal bearing Y in pixels. */
1366 inline TInt TOpenFontCharMetrics::HorizBearingY() const
1368 return iHorizBearingY;
1371 /** Gets the horizontal advance.
1373 This is the amount added to the x co-ordinate of the origin after the character
1374 is drawn what most people understand by the width or escapement of a character.
1375 The origin here is the pen point before the character is drawn.
1377 @return The horizontal advance in pixels */
1378 inline TInt TOpenFontCharMetrics::HorizAdvance() const
1380 return iHorizAdvance;
1383 /** Gets the vertical bearing X.
1385 This is the distance in pixels from the pen point before the character is
1386 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1387 A positive value means that the left edge of the bitmap is right of the origin.
1389 @return The vertical bearing X in pixels. */
1390 inline TInt TOpenFontCharMetrics::VertBearingX() const
1392 return iVertBearingX;
1395 /** Gets the vertical bearing Y.
1397 This is the distance in pixels from the pen point before the character is
1398 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1399 A positive value means that the top edge of the bitmap is above the origin.
1401 @return The vertical bearing Y in pixels. */
1402 inline TInt TOpenFontCharMetrics::VertBearingY() const
1404 return iVertBearingY;
1407 /** Gets the vertical advance.
1409 When drawing vertically, this is the amount added to the y co-ordinate of
1410 the origin after the character is drawn what most people understand by
1411 the height of a character. The origin here is the pen point before the character
1414 Note: Vertical drawing is not supported in v5.
1416 @return The vertical advance in pixels. */
1417 inline TInt TOpenFontCharMetrics::VertAdvance() const
1419 return iVertAdvance;
1422 /** Gets the bounds of the character relative to its origin when setting text
1425 The origin here is the pen point before the character is drawn.
1427 @param aBounds The character's bounds. */
1428 inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
1430 aBounds.iTl.iX = iHorizBearingX;
1431 aBounds.iTl.iY = -iHorizBearingY;
1432 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1433 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1436 /** Gets the bounds of the character relative to its origin when setting text
1439 The origin here is the pen point before the character is drawn.
1441 @param aBounds The character's bounds. */
1442 inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
1444 aBounds.iTl.iX = -iVertBearingX;
1445 aBounds.iTl.iY = iVertBearingY;
1446 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1447 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1450 /** Sets the width of the character's bitmap.
1452 @param aWidth The width of the bitmap in pixels. */
1453 inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
1455 iWidth = (TInt16)aWidth;
1458 /** Sets the height of the character's bitmap.
1460 @param aHeight The character height (in pixels). */
1461 inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
1463 iHeight = (TInt16)aHeight;
1466 /** Sets the horizontal bearing X.
1468 This is the distance in pixels from the pen point before the character is
1469 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1470 A positive value means that the left edge of the bitmap is right of the origin.
1472 @param aHorizBearingX The horizontal bearing X (in pixels). */
1473 inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
1475 iHorizBearingX = (TInt16)aHorizBearingX;
1478 /** Sets the horizontal bearing Y.
1480 This is the distance in pixels from the pen point before the character is
1481 drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1482 A positive value means that the top edge of the bitmap is above the origin.
1484 @param aHorizBearingY The horizontal bearing Y (in pixels). */
1485 inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
1487 iHorizBearingY = (TInt16)aHorizBearingY;
1490 /** Sets the horizontal advance.
1492 This is the amount added to the x co-ordinate of the origin after the character
1493 is drawn, what most people understand by the width or escapement of a character.
1494 The origin here is the pen point before the character is drawn.
1496 @param aHorizAdvance The horizontal advance (in pixels). */
1497 inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
1499 iHorizAdvance = (TInt16)aHorizAdvance;
1502 /** Set vertical bearing X.
1504 This is the distance in pixels from the pen point before the character is
1505 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1506 A positive value means that the left edge of the bitmap is right of the origin.
1508 @param aVertBearingX The vertical bearing X (in pixels). */
1509 inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
1511 iVertBearingX = (TInt16)aVertBearingX;
1514 /** Sets the vertical bearing Y.
1516 This is the distance in pixels from the pen point before the character is
1517 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1518 A positive value means that the top edge of the bitmap is above the origin.
1520 @param aVertBearingY The vertical bearing Y (in pixels). */
1521 inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
1523 iVertBearingY = (TInt16)aVertBearingY;
1526 /** Sets the vertical advance.
1528 When drawing vertically, this is the amount added to the y co-ordinate of
1529 the origin after the character is drawn what most people understand by
1530 the height of a character. The origin here is the pen point before the character
1533 Note: Vertical drawing is not supported in v5.
1535 @param aVertAdvance The vertical advance (in pixels). */
1536 inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
1538 iVertAdvance = (TInt16)aVertAdvance;
1541 /** Gets the character metrics for this font.
1543 @return The character metrics for this font. */
1544 inline const TOpenFontMetrics& COpenFont::Metrics() const
1549 /** Gets the glyph index.
1551 This is the index of a particular glyph within the font file.
1553 Note: This makes it possible to gain access to glyphs which are not referenced
1554 by the Unicode character set. However, this feature is not yet supported by
1557 @return The glyph index.
1558 @see SetGlyphIndex() */
1559 inline TInt TOpenFontGlyphData::GlyphIndex() const
1564 /** Gets the typeface attributes.
1566 These are the attributes of the font represented by this object.
1568 @return The typeface attributes. */
1569 inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
1571 return iFile ? &iFile->FaceAttrib(iFaceIndex) : NULL;
1574 /** Gets a pointer to the COpenFontFile which created this object.
1576 This is the COpenFontFile which owns the file that contains the definition
1577 of the typeface. It can be used to get information about the typeface, or
1578 to access the rasterizer context (engine).
1580 @return The COpenFontFile which created this object. */
1581 inline COpenFontFile* COpenFont::File() const
1586 /** Gets the index of this typeface within the font file.
1588 @return The index of this typeface within the font file. */
1589 inline TInt COpenFont::FaceIndex() const
1594 /** Tests whether or not a character needs to be rasterized.
1596 Characters that have been rasterized are cached there is no need to regenerate
1597 the character bitmap. This function should only be called by the Font and
1600 @param aSessionHandle A handle to the font and bitmap server session.
1601 @param aCode The code for the Unicode character.
1602 @return ETrue if the character needs to be rasterized, otherwise EFalse. */
1603 inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const
1605 return Glyph(aSessionHandle,aCode) == NULL;
1608 /** Gets the ascent of an ANSI capital letter in the font whether or not
1609 there are any ANSI capitals in the font.
1610 @return The positive distance from the font baseline to the top of a
1611 standard ANSI capital letter
1614 @see AscentInPixels()
1616 inline TInt COpenFont::FontCapitalAscent() const
1618 return iFontCapitalAscent;
1621 /** Gets the max ascent of any pre-composed glyph in the font. This will
1622 include accents or diacritics that form part of pre-composed glyphs. It is
1623 not guaranteed to cover the max ascent of composite glyphs that have to be
1624 created by a layout engine. This is also the recommended distance between
1625 the top of a text box and the baseline of the first line of text.
1627 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1629 @return The positive distance from the font baseline to the top of the
1630 highest pre-composed glyph (including accents) above the baseline.
1633 @see AscentInPixels()
1634 @see SetScriptTypeForMetrics()
1636 inline TInt COpenFont::FontMaxAscent() const
1638 return iFontMaxAscent;
1641 /** Gets the descent of an ANSI descending character in the font.
1642 Whether or not there are any ANSI descenders in the font.
1644 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1646 @return The positive distance from the font baseline to the bottom of the
1647 lowest ANSI descender.
1650 @see DescentInPixels()
1651 @see SetScriptTypeForMetrics()
1653 inline TInt COpenFont::FontStandardDescent() const
1655 return iFontStandardDescent;
1658 /** Gets the max descent of any pre-composed glyph in the font. This will
1659 include accents or diacritics that form part of pre-composed glyphs. It is
1660 not guaranteed to cover the max descent of composite glyphs that have to be
1661 created by a layout engine.
1663 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1665 @return The positive distance from the font baseline to the bottom of the
1666 lowest pre-composed glyph (including accents) below the baseline
1669 @see DescentInPixels()
1670 @see SetScriptTypeForMetrics()
1672 inline TInt COpenFont::FontMaxDescent() const
1674 return iFontMaxDescent;
1677 /** Gets the suggested line gap for the font. This is the recommended
1678 baseline to baseline distance between successive lines of text in the font.
1679 @return The positive recommended gap between successive lines
1683 inline TInt COpenFont::FontLineGap() const
1685 return iFontLineGap;
1688 /** Gets the maximum height for the font. This is the sum of the max ascent
1689 of the font and the max descent of the font.
1691 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1693 @return The positive maximum height of the font
1696 @see HeightInPixels()
1697 @see SetScriptTypeForMetrics()
1699 inline TInt COpenFont::FontMaxHeight() const
1701 return iFontMaxAscent + iFontMaxDescent;
1704 /** Default C++ constructor.
1706 This sets all attribute fields to zero. As for other T classes, there is no
1707 need to explicitly clean-up objects derived from this class. */
1708 inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
1710 Mem::FillZ(this,sizeof(*this));
1713 /** Default C++ constructor.
1715 The function initialises the minimum typeface size to zero, the names to NULL,
1716 and the coverage and style flags to zero. */
1717 inline TOpenFontFaceAttrib::TOpenFontFaceAttrib():
1718 iMinSizeInPixels(0),
1723 /** Tests for support of Latin characters.
1725 Note: A return value of ETrue implies that the font has a usable set of
1726 characters. It does not imply exhaustive coverage.
1728 @return ETrue if Latin characters are supported */
1729 inline TBool TOpenFontFaceAttribBase::HasLatin() const
1731 return iCoverage[0] & ELatinSet;
1734 /** Tests for support of Greek characters.
1736 Note: A return value of ETrue implies that the font has a usable set of
1737 characters. It does not imply exhaustive coverage.
1739 @return ETrue if Greek characters are supported. */
1740 inline TBool TOpenFontFaceAttribBase::HasGreek() const
1742 return iCoverage[0] & EGreekSet;
1745 /** Tests for support of Cyrillic characters.
1747 Note: A return value of ETrue implies that the font has a usable set of
1748 characters. It does not imply exhaustive coverage.
1750 @return ETrue if Cyrillic characters are supported. */
1751 inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
1753 return iCoverage[0] & ECyrillicSet;
1756 /** Tests for support of Japanese syllabic characters.
1758 This function tests for the presence of Hiragana and Katakana syllabic
1759 characters in the font, collectively called kana. These characters are not
1760 sufficient for the Japanese language, which also makes use of Chinese characters.
1762 Note: A return value of ETrue implies that the font has a usable set of
1763 characters. It does not imply exhaustive coverage.
1765 @return ETrue if Japanese characters are supported
1767 inline TBool TOpenFontFaceAttribBase::HasKana() const
1769 return iCoverage[1] & EKanaSets;
1772 /** Tests for support of Korean Hangul characters.
1774 Korean may also make use of Chinese characters.
1776 Note: A return value of ETrue implies that the font has a usable set of
1777 characters. It does not imply exhaustive coverage.
1779 @return ETrue if Korean characters are supported
1781 inline TBool TOpenFontFaceAttribBase::HasHangul() const
1783 return iCoverage[1] & EHangulSet;
1786 /** Tests for support of Chinese ideographic characters.
1788 These are used in Chinese, Japanese and Korean.
1790 Note: A return value of ETrue implies that the font has a usable set of
1791 characters. It does not imply exhaustive coverage.
1793 @return ETrue if Chinese ideographs are supported. */
1794 inline TBool TOpenFontFaceAttribBase::HasCJK() const
1796 return iCoverage[1] & ECJKSet;
1799 /** Tests if the typeface contains symbols only.
1801 @return ETrue if the typeface contains symbols only. */
1802 inline TBool TOpenFontFaceAttribBase::IsSymbol() const
1804 return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
1805 iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
1808 /** Tests if the typeface is inherently bold.
1810 @return ETrue if the typeface is inherently bold. */
1811 inline TBool TOpenFontFaceAttribBase::IsBold() const
1813 return iStyle & EBold;
1816 /** Tests if the typeface is inherently italic.
1818 @return ETrue if the typeface is inherently italic. */
1819 inline TBool TOpenFontFaceAttribBase::IsItalic() const
1821 return iStyle & EItalic;
1824 /** Tests if the typeface has serifs.
1826 @return ETrue if the typeface has serifs. */
1827 inline TBool TOpenFontFaceAttribBase::IsSerif() const
1829 return iStyle & ESerif;
1832 /** Tests if all the characters have the same width.
1834 @return ETrue if all the characters have the same width. */
1835 inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
1837 return iStyle & EMonoWidth;
1840 /** Gets the typeface's name.
1842 @return Descriptor containing typeface name. */
1843 inline TPtrC TOpenFontFaceAttribBase::Name() const
1848 /** Gets the full name.
1850 The full name of the typeface includes style attributes like Italic, Bold,
1853 @return The full name of the typeface.
1854 @see FamilyName() */
1855 inline TPtrC TOpenFontFaceAttrib::FullName() const
1860 /** Gets the family name.
1862 Note: The family name of the typeface does not include style attributes like
1865 @return The family name of the typeface.
1867 inline TPtrC TOpenFontFaceAttrib::FamilyName() const
1872 /** Gets the local full name.
1874 The local full name of the typeface includes style attributes like Italic,
1877 The local name of the typeface is the name in the language of the current
1878 locale, where this is provided by the font file. If the local name is not
1879 available then the local name will be the same as the ordinary name.
1881 @return The local full name of the typeface. */
1882 inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
1884 return iLocalFullName;
1887 /** Gets the local family name.
1889 The local name of the typeface is the name in the language of the current
1890 locale, where this is provided by the font file. If the local name is not
1891 available then the local name will be the same as the ordinary name.
1893 Note: The family name of the typeface does not include style attributes like
1896 @return The local family name of the typeface. */
1897 inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
1899 return iLocalFamilyName;
1902 /** Gets the short full name.
1904 This is the full name of the typeface, truncated to KMaxTypefaceNameLength,
1907 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1908 where necessary so that they can be used in the TTypeFace class. The Open
1909 Font Framework allows 32 characters as a maximum name length.
1911 @return The short full name of the typeface.
1913 inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
1915 // Can't use TDesC::Left for this because it panics if the desired length is > the existing length!
1916 return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength));
1919 /** Gets the short family name.
1921 This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
1923 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1924 where necessary so that they can be used in the TTypeFace class. The Open
1925 Font Framework allows 32 characters as a maximum name length.
1927 @return The short family name of the typeface.
1928 @see FamilyName() */
1929 inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
1931 return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
1934 /** Gets the short local full name.
1936 This is the local full name of the typeface, truncated to KMaxTypefaceNameLength,
1939 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1940 where necessary so that they can be used in the TTypeFace class. The Open
1941 Font Framework allows 32 characters as a maximum name length.
1943 @return The short local full name of the typeface.
1944 @see LocalFullName() */
1945 inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
1947 return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
1950 /** Gets the short local family name.
1952 This is the local family name of the typeface, truncated to KMaxTypefaceNameLength,
1955 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1956 where necessary so that they can be used in the TTypeFace class. The Open
1957 Font Framework allows 32 characters as a maximum name length.
1959 @return The short local family name of the typeface.
1960 @see LocalFamilyName() */
1961 inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
1963 return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
1966 /** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
1968 Each flag that is set represents a supported Unicode range. The mapping is
1969 defined in the TrueType documentation under the OS/2 table.
1971 Note: Some useful subsets are defined as anonymous enumerated constants at the end
1972 of this class, see ELatinSet etc.
1974 @return A pointer to the flags that indicate the font's Unicode coverage.
1975 The flags are stored in an array of four 32-bit integers. When no information
1976 is available, all four integers are zero.
1977 @see SetCoverage() */
1978 inline const TUint* TOpenFontFaceAttribBase::Coverage() const
1983 /** Gets the minimum typeface size.
1985 This is the smallest size that can be drawn legibly.
1987 @return The minimum typeface size (in pixels). */
1988 inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
1990 return iMinSizeInPixels;
1993 /** Sets the name attribute.
1995 @param aName Descriptor containing typeface name. */
1996 inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
1998 iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
2001 /** Sets the full name.
2003 @param aName The full name of the typeface.
2005 inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
2010 /** Sets the family name.
2012 @param aName The family name of the typeface.
2013 @see FamilyName() */
2014 inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
2016 iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
2019 /** Sets the local full name.
2021 @param aName The local full name of the typeface.
2022 @see LocalFullName() */
2023 inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
2025 iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
2028 /** Sets the local family name.
2030 @param aName The local family name of the typeface.
2031 @see LocalFamilyName() */
2032 inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
2034 iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
2037 /** Sets the coverage flags.
2039 The flags are held in four 32 bit integers. Each flag that is set represents
2040 a range of Unicode characters that is supported by the typeface: Latin,
2041 Greek, Cyrillic etc. The mapping is defined in the TrueType documentation
2042 under the OS/2 table.
2044 Note: Some useful subsets are defined as anonymous enumerated constants at
2045 the end of this class, see ELatinSet etc.
2047 @param aCoverage0 The first set of coverage flags (bits 0-31).
2048 @param aCoverage1 The second set of coverage flags (bits 32-63).
2049 @param aCoverage2 The third set of coverage flags (bits 64-95).
2050 @param aCoverage3 The fourth set of coverage flags (bits 96-127). */
2051 inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3)
2053 iCoverage[0] = aCoverage0;
2054 iCoverage[1] = aCoverage1;
2055 iCoverage[2] = aCoverage2;
2056 iCoverage[3] = aCoverage3;
2059 /** Set the minimum typeface size.
2061 This is the smallest size that can be drawn legibly.
2063 @param aSize Sets the minimum typeface size (in pixels).
2064 @see MinSizeInPixels() */
2065 inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
2067 iMinSizeInPixels = aSize;
2070 /** Equality operator.
2072 Compares this and another set of font attributes, including the coverage,
2073 the family name, the local full name, the local family name, and the minimum
2076 @param aAttrib Contains the font attributes and names to compare.
2077 @return ETrue if all values are equal, EFalse if not. */
2078 inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const
2080 return TOpenFontFaceAttribBase::operator==(aAttrib) &&
2081 iFamilyName == aAttrib.iFamilyName &&
2082 iLocalFullName == aAttrib.iLocalFullName &&
2083 iLocalFamilyName == aAttrib.iLocalFamilyName &&
2084 iMinSizeInPixels == aAttrib.iMinSizeInPixels;
2087 /** Sets the bold attribute.
2089 @param aBold The bold attribute takes this value: ETrue or EFalse. */
2090 inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
2098 /** Sets the italic attribute.
2100 @param aItalic The italic attribute takes this value ETrue or EFalse. */
2101 inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
2109 /** Sets the serif attribute.
2111 @param aSerif The serif attribute takes this value ETrue or EFalse. */
2112 inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
2120 /** Sets the mono-width attribute.
2122 @param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
2123 inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
2126 iStyle |= EMonoWidth;
2128 iStyle &= ~EMonoWidth;
2131 /** Equality operator.
2133 Compares this and a specified set of font attributes, including the coverage
2134 and the typeface name.
2136 In version 6.1, and earlier, the return value was TInt.
2138 @param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase
2139 or of a derived class.
2140 @return ETrue if the values are equal. */
2141 inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const
2143 return iStyle == aAttrib.iStyle &&
2144 iCoverage[0] == aAttrib.iCoverage[0] &&
2145 iCoverage[1] == aAttrib.iCoverage[1] &&
2146 iCoverage[2] == aAttrib.iCoverage[2] &&
2147 iCoverage[3] == aAttrib.iCoverage[3] &&
2148 iName.CompareF(aAttrib.iName) == 0;
2151 /** Compares this and another open font specification. Compares all the properties
2155 @param aFontSpec The open font specification to compare with this one.
2156 @return ETrue if all values are equal, EFalse if not.
2158 inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
2161 iHeight == aOpenFontSpec.iHeight &&
2162 iWidthFactor == aOpenFontSpec.iWidthFactor &&
2163 iSlantFactor == aOpenFontSpec.iSlantFactor &&
2164 iBitmapType == aOpenFontSpec.iBitmapType &&
2165 iEffects == aOpenFontSpec.iEffects &&
2166 iSymbol == aOpenFontSpec.iSymbol &&
2167 iPrintPosition == aOpenFontSpec.iPrintPosition &&
2168 TOpenFontFaceAttribBase::operator==(aOpenFontSpec);
2171 /** Gets the height of the font.
2173 @return The height of the font, in pixels or twips.
2175 inline TInt TOpenFontSpec::Height() const
2180 /** Gets the algorithmic width factor.
2182 @return The algorithmic width factor as a 16.16 fixed-point number.
2183 @see SetWidthFactor() */
2184 inline TInt32 TOpenFontSpec::WidthFactor() const
2186 return iWidthFactor;
2189 /** Gets the algorithmic slant factor.
2191 @return The algorithmic slant factor as a 16.16 fixed-point number.
2192 @see SetSlantFactor() */
2193 inline TInt32 TOpenFontSpec::SlantFactor() const
2195 return iSlantFactor;
2198 /** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
2200 @return Indicates whether or not the font should be drawn using anti-aliasing. */
2201 inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
2203 return (TGlyphBitmapType)iBitmapType;
2206 /** Gets the font effects flags.
2207 Because the flags encoded in the Effects are anonymous, the return value should only
2208 be tested for the specific bits that are of interest, and never tested as a whole.
2211 @return The font effects flags.
2212 @see TOpenFontSpec::SetEffects()
2214 inline TUint32 TOpenFontSpec::Effects() const
2219 /** Gets the print position.
2221 @return The print position. */
2222 inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
2224 return iPrintPosition;
2227 /** Sets the font's height.
2229 @param aHeight The font's height, in pixels or twips.
2231 inline void TOpenFontSpec::SetHeight(TInt aHeight)
2236 /** Sets the algorithmic width factor.
2238 The width factor is multiplied by the pixel's x position to get the new position,
2239 causing characters to become wider or narrower. A width factor of 1 (65536
2240 in 16.16 fixed-point number format) should be used if the character width
2241 is not to be changed.
2243 @param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
2244 @see WidthFactor() */
2245 inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
2247 iWidthFactor = aWidthFactor;
2250 /** Sets the algorithmic slant factor.
2252 Note: The slant factor is used to create an italic effect for characters which
2253 do not have an italic glyph in the typeface. When slanting is active, pixel x
2254 co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x
2255 = x + y x slant factor).
2257 The slant factor is a 32 bit, 16.16 fixed-point number. This means that the
2258 first 16 bits are treated as a whole number, and the second 16 as the fractional
2259 part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this
2260 is equivalent to an integer slant value of 1, which causes a 45 degree slant
2263 @param aSlantFactor The slant factor as a 16.16 fixed-point number.
2264 @see SlantFactor() */
2265 inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
2267 iSlantFactor = aSlantFactor;
2270 /** Sets whether the font should be drawn using anti-aliasing. If set, this value
2271 overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
2274 Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
2275 support for bitmapped fonts.
2277 @param aBitmapType Indicates whether or not the font should be drawn using
2279 inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
2281 iBitmapType = aBitmapType;
2284 /** Sets the font effects flags.
2285 Prior to calling this routine, the value from Effects() should be read,
2286 and its flags modified as required, before passing them back in.
2289 @param aEffect The font effects flags to be set.
2290 @see TOpenFontSpec::Effects()
2292 inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
2294 iEffects = aEffects;
2297 /** Gets the font file's UID.
2299 @return The uid of the file. */
2300 inline TUid COpenFontFile::Uid() const
2305 /** Gets the full path and filename of the font file
2307 This is the filename that was passed to the constructor when the object is
2310 @return The filename of the font file. */
2311 inline const TDesC& COpenFontFile::FileName() const
2316 /** Gets the typeface at a specified index in the typeface attribute array.
2318 @param aFaceIndex The index of the typeface for which the attributes are required.
2319 @return The attributes of the typeface with the specified index.
2322 inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
2324 return iFaceAttrib[aFaceIndex];
2327 /** Gets the number of typefaces in the typeface attributes array.
2329 This is the number of typefaces in the font file: the attributes for each
2330 typeface should be loaded into the array when the derived object is constructed.
2332 @return The number of typefaces in the font file.
2334 @see FaceAttrib() */
2335 inline TInt COpenFontFile::FaceCount() const
2337 return iFaceAttrib.Count();
2340 /** Increments a reference count by one.
2342 @see DecRefCount() */
2343 inline void COpenFontFile::IncRefCount()
2348 /** Decrement a reference count by one.
2350 @return ETrue if the reference count has reached zero (i.e. is less than or
2351 equal to zero); EFalse if the reference count has not yet reached zero (i.e.
2353 @see IncRefCount() */
2354 inline TBool COpenFontFile::DecRefCount()
2357 return iRefCount <= 0;
2360 /** Default C++ constructor. */
2361 inline COpenFontRasterizerContext::COpenFontRasterizerContext():
2366 /** Start writing the glyph data.
2368 Use this function to initialise the buffer to which the glyph bitmap is to
2369 be written. Call WriteGlyphBit() to add bits to the buffer.
2371 @param aGlyphData A pointer to the glyph data. */
2372 inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
2374 aGlyphData->SetPointersToInternalBuffers();
2375 iGlyphData = aGlyphData;
2376 iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
2377 // Allow 4 extra bytes; BITGDI requires this.
2378 iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
2385 /** Writes a bit to the glyph buffer.
2387 Before calling this function you should first call StartGlyph().
2389 @param aBit The bit to be added to the buffer. */
2390 inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
2392 if (aBit && !iOverflow)
2393 *iGlyphDataPtr |= iGlyphBit;
2395 if (iGlyphBit == 256)
2399 if (++iGlyphDataPtr < iGlyphDataEnd)
2406 /** Writes a byte to the glyph buffer.
2408 Before calling this function you should first call StartGlyph().
2410 @param aByte The byte to be added to the buffer. */
2411 inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
2413 if (iGlyphDataPtr < iGlyphDataEnd)
2414 *iGlyphDataPtr++ = (TUint8)aByte;
2420 /** Completes writing glyph data.
2422 Use this function to complete writing the glyph bitmap to the buffer. Call
2423 it after adding all necessary bits using WriteGlyphBit(). */
2424 inline void COpenFontRasterizerContext::EndGlyph()
2426 // Add 4 bytes to the data size; some BITGDI functions require this.
2427 iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
2431 /** Tests whether the bitmap buffer is large enough to hold the bitmap.
2433 @return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
2434 inline TBool TOpenFontGlyphData::Overflow() const
2436 return iBytesNeeded > iBitmapBufferSize;
2439 /** Gets the number of bytes needed to store the glyph bitmap.
2441 @return The number of bytes needed to store the glyph bitmap.
2442 @see SetBytesNeeded() */
2443 inline TInt TOpenFontGlyphData::BytesNeeded() const
2445 return iBytesNeeded;
2448 /** Gets a constant pointer descriptor containing the bitmap this object
2451 @return Pointer descriptor for the glyph. */
2452 inline TPtrC8 TOpenFontGlyphData::Bitmap() const
2454 return TPtrC8(iBitmap,iBytesNeeded);
2457 /** Gets a pointer to the bitmap.
2459 This points either to the buffer used to write the bitmap when it is first
2460 rasterized, or to the cache if the character was already rasterized.
2462 @return A pointer to the bitmap. */
2463 inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
2468 /** Gets the character's metrics.
2470 @return The character's open font metrics. */
2471 inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
2476 /** Gets a pointer to the start of the bitmap buffer.
2478 @return A pointer to the start of the bitmap buffer. */
2479 inline TUint8* TOpenFontGlyphData::BufferStart()
2481 return iBitmapBuffer;
2484 /** Gets a pointer to the end of the bitmap buffer.
2486 @return A pointer to the end of the bitmap buffer. */
2487 inline TUint8* TOpenFontGlyphData::BufferEnd()
2489 return iBitmapBuffer + iBitmapBufferSize;
2492 /** Sets the number of bytes needed to store the glyph bitmap.
2494 @param aBytes The number of bytes needed to store the glyph bitmap.
2495 @see BytesNeeded() */
2496 inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
2498 iBytesNeeded = aBytes;
2501 /** Sets the pointer to the bitmap buffer.
2503 @param aBitmap The pointer to the bitmap buffer. */
2504 inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
2509 /** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
2511 @param aMetrics A pointer to the character's open font character metrics. */
2512 inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
2514 iMetrics = aMetrics;
2517 /** Sets the bitmap and metrics pointers to point to the internal buffers.
2519 The alternative is that the pointers point to the cache of metrics and bitmaps
2520 that have already been rasterized. */
2521 inline void TOpenFontGlyphData::SetPointersToInternalBuffers()
2523 iBitmap = iBitmapBuffer;
2524 iMetrics = &iMetricsBuffer;
2527 /** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics
2530 @param aMetrics The character's open font character metrics. */
2531 inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
2533 iMetricsBuffer = aMetrics;
2534 iMetrics = &iMetricsBuffer;
2537 /** Sets the glyph index.
2539 @param aGlyphIndex The glyph index. */
2540 inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
2542 iGlyphIndex = aGlyphIndex;
2545 /** Uses ECOM plug-in framework to instantiate the Open Font rasterizer interface
2546 implementation given its implementation UID.
2548 @param "TUid aInterfaceImplUid"
2549 The UID of the interface implementation required
2551 @return "COpenFontRasterizer*"
2552 A pointer to a COpenFontRasterizer object. */
2553 inline COpenFontRasterizer* COpenFontRasterizer::NewL(TUid aInterfaceImplUid)
2555 return reinterpret_cast <COpenFontRasterizer*> (
2556 REComSession::CreateImplementationL(
2558 _FOFF(COpenFontRasterizer, iDtor_ID_Key)));
2561 /** Default destructor */
2562 inline COpenFontRasterizer::~COpenFontRasterizer()
2564 REComSession::DestroyedImplementation(iDtor_ID_Key);
2567 /** Uses ECOM plug-in framework to instantiate the shaper factory interface
2568 implementation given its implementation UID.
2570 @param "TUid aInterfaceImplUid"
2571 The UID of the interface implementation required
2573 @return "CShaperFactory*"
2574 A pointer to a CShaperFactory object. */
2575 inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
2577 return reinterpret_cast <CShaperFactory*> (
2578 REComSession::CreateImplementationL(
2580 _FOFF(CShaperFactory, iDtor_ID_Key)));
2583 /** Default destructor */
2584 inline CShaperFactory::~CShaperFactory()
2586 REComSession::DestroyedImplementation(iDtor_ID_Key);
2589 #endif // OPENFONT_H__