2 * Copyright (c) 1998-2009 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 COpenFontGlyphTreeEntry;
43 class COpenFontPositioner;
44 class COpenFontSessionCache;
45 class COpenFontSessionCacheList;
47 class TCharacterMetrics;
49 class TOpenFontFaceAttrib;
51 class TOpenFontFileData;
57 class TFontShapeFunctionParameters;
58 class TFontShapeDeleteFunctionParameters;
60 class TShapeMessageParameters;
61 class CRasterizerLinkedTypefaceSpecification;
62 class TLinkedTypefaceSpecificationArgs;
65 Supplied to COpenFont::ExtendedInterface() to access the extended
66 API interface MOpenFontShapingExtension.
68 @see COpenFont::ExtendedInterface()
69 @see MOpenFontShapingExtension
73 const TUid KUidOpenFontShapingExtension = {0x10274DB9};
76 Supplied to COpenFont::ExtendedInterface() to access the extended
77 API interface MOpenFontTrueTypeExtension.
79 @see COpenFont::ExtendedInterface()
80 @see MOpenFontTrueTypeExtension
84 const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
85 const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
88 Supplied to CShaper::ExtendedInterface() to get the language and script
89 code with which the current shaper is instatsiated.
90 @see CShaper::ExtendedInterface()
94 const TUid KUidShaperGetScript = {0x20009966};
95 const TUid KUidShaperGetLang = {0x20009967};
100 @see CFbsFont::GetFontMetrics()
104 class TOpenFontMetrics
107 inline TOpenFontMetrics();
108 IMPORT_C TOpenFontMetrics(const CFont* aFont);
109 inline TInt Size() const;
110 inline TInt Ascent() const;
111 inline TInt Descent() const;
112 inline TInt MaxHeight() const;
113 inline TInt MaxDepth() const;
114 inline TInt MaxWidth() const;
115 inline void SetSize(TInt aSize);
116 inline void SetAscent(TInt aAscent);
117 inline void SetDescent(TInt aDescent);
118 inline void SetMaxHeight(TInt aMaxHeight);
119 inline void SetMaxDepth(TInt aMaxDepth);
120 inline void SetMaxWidth(TInt aMaxWidth);
121 /** WARNING: Function for internal and partner use ONLY. Compatibility is not guaranteed in future releases.*/
122 IMPORT_C void SetBaselineCorrection(TInt aBaselineCorrection);
123 IMPORT_C TInt BaselineCorrection();
125 TInt16 iDesignHeight; // size of the font ('pointsize' in pixels)
126 TInt16 iAscent; // typographic ascent
127 TInt16 iDescent; // typographic descent
128 TInt16 iMaxHeight; // maximum height of a character; may be greater than iAscent
129 TInt16 iMaxDepth; // maximum depth of a character; may be greater than iDescent
130 TInt16 iMaxWidth; // maximum width of a character
131 TInt16 iBaselineCorrection;
137 Character metrics includes more information than TCharacterMetrics.
139 Character metrics allow characters to be placed horizontally or vertically.
140 The character metrics encapsulated by this class are: Height, Width, Horizontal
141 Bearing X, Horizontal Bearing Y, Horizontal Advance, Vertical Bearing X,
142 Vertical Bearing Y, and Vertical Advance. Their meanings are described in the
143 associated setter and getter functions.
147 Vertical drawing (in the sense of characters drawn with horizontal baselines,
148 but in a vertical line) is not yet supported by Symbian OS.
150 @see CFont::GetCharacterData()
151 @see CFbsFont::GetCharacterData()
155 class TOpenFontCharMetrics
158 enum TUninitialized { EUninitialized };
160 /** Default constructor initializes all members to 0. */
161 inline TOpenFontCharMetrics();
163 /** Constructor that does not initialize any members. */
164 TOpenFontCharMetrics(TUninitialized) {}
165 IMPORT_C TOpenFontCharMetrics(const TCharacterMetrics& aMetrics);
166 IMPORT_C TBool GetTCharacterMetrics(TCharacterMetrics& aMetrics) const;
167 inline TInt Width() const;
168 inline TInt Height() const;
169 inline TInt HorizBearingX() const;
170 inline TInt HorizBearingY() const;
171 inline TInt HorizAdvance() const;
172 inline TInt VertBearingX() const;
173 inline TInt VertBearingY() const;
174 inline TInt VertAdvance() const;
175 inline void GetHorizBounds(TRect& aBounds) const;
176 inline void GetVertBounds(TRect& aBounds) const;
177 inline void SetWidth(TInt aWidth);
178 inline void SetHeight(TInt aHeight);
179 inline void SetHorizBearingX(TInt aHorizBearingX);
180 inline void SetHorizBearingY(TInt aHorizBearingY);
181 inline void SetHorizAdvance(TInt aHorizAdvance);
182 inline void SetVertBearingX(TInt aVertBearingX);
183 inline void SetVertBearingY(TInt aVertBearingY);
184 inline void SetVertAdvance(TInt aVertAdvance);
185 IMPORT_C void SetGlyphType(TGlyphBitmapType);
186 IMPORT_C TGlyphBitmapType GlyphType() const;
188 TInt16 iWidth; // width of the glyph
189 TInt16 iHeight; // height of the glyph
190 TInt16 iHorizBearingX; // x component of horizontal bearing
191 TInt16 iHorizBearingY; // y component of horizontal bearing
192 TInt16 iHorizAdvance; // horizontal advance
193 TInt16 iVertBearingX; // x component of vertical bearing
194 TInt16 iVertBearingY; // y component of vertical bearing
195 TInt16 iVertAdvance; // vertical advance
196 TUint16 iGlyphBitmapType;// Glyph bitmap type; TGlyphBitmapType
204 Objects of this type are used by rasterizers to supply glyph data to font
205 and bitmap server clients. Unless you are writing a rasterizer you will not
206 need to use an object of this type.
208 The object cannot be constructed and destroyed by normal means. It resides
209 on a specified heap. It is created by New() and deleted by RHeap::Free().
211 @see COpenFont::RasterizeL()
215 class TOpenFontGlyphData
218 IMPORT_C static TOpenFontGlyphData* New(RHeap* aHeap,TInt aBufferSize);
219 inline TBool Overflow() const;
220 inline TInt BytesNeeded() const;
221 inline TPtrC8 Bitmap() const;
222 inline const TUint8* BitmapPointer() const;
223 inline const TOpenFontCharMetrics* Metrics() const;
224 inline TInt GlyphIndex() const;
225 inline TUint8* BufferStart();
226 inline TUint8* BufferEnd();
227 inline void SetBytesNeeded(TInt aBytes);
228 inline void SetBitmapPointer(const TUint8* aBitmap);
229 inline void SetMetricsPointer(const TOpenFontCharMetrics* aMetrics);
230 inline void SetPointersToInternalBuffers();
231 inline void SetMetrics(TOpenFontCharMetrics& aMetrics);
232 inline void SetGlyphIndex(TInt aGlyphIndex);
235 Prevent construction and destruction by normal means; the object resides
236 on a specified heap and is created by New and deleted by RHeap::Free.
238 TOpenFontGlyphData();
239 ~TOpenFontGlyphData();
241 TInt iBitmapBufferSize; // size of the buffer in bytes
242 TInt iBytesNeeded; // bytes needed for the bitmap
243 TOpenFontCharMetrics iMetricsBuffer; // the metrics
244 const TUint8* iBitmap; // pointer to the bitmap; points either to iBitmapBuffer or to
245 // the cache if the character was already rasterized
246 const TOpenFontCharMetrics* iMetrics; // pointer to the metrics; points either to iMetricsBuffer or to
247 // the cache if the character was already rasterized
248 TInt iGlyphIndex; // the glyph index
249 TAny* iReserved; // unused; for future expansion
250 TUint8 iBitmapBuffer[1]; // buffer used to write the bitmap when it is first rasterized; this
251 // is actually of size iBitmapBufferSize.
254 class COpenFontGlyph;
256 Open Font System font abstract base class.
258 Derive a class from this class to represent an instance of a typeface at a
259 particular size, provide bitmaps of the glyphs, and determine whether
260 characters exist in the typeface.
262 Writing derived classes construction:
264 You must call the constructor of this class when creating your derived object,
265 passing the arguments aHeap and aSessionCacheList supplied to
266 COpenFontFile::GetNearestFontInPixelsL(), and the address of the COpenFontFile
267 object that creates the object as aFile.
269 The derived object must be created on the shared heap aHeap because it is
270 shared by several processes: the font and bitmap server and its clients.
271 To do this, use aHeap->AllocL() to obtain memory, then construct in place
272 using a placement argument to new.
274 Derived classes must implement the pure virtual function RasterizeL().
275 Information about this function is provided in the function definition below.
277 Information about deriving from this class is also provided in the API guide.
279 @see COpenFontFile::GetNearestFontInPixelsL()
283 class COpenFont: public CBase
286 /** Creates a bitmap for the specified Unicode character.
288 Implementations of this function should put the bitmap in
289 aGlyphData->iBitmapBuffer, and the character metrics are placed in
290 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
293 There are a number of strategies for achieving this, e.g. pass the
294 rasterization task all the way up to the rasterizer engine. These are
295 discussed in the API guide.
297 At present you must write the bitmap in the Symbian platform's
298 run-length-encoded format. This is a packed binary format starting on a
299 byte boundary and made up of a number of sections. Each section starts
300 with a five-bit header. If the first bit of the header is 0 the next four
301 bits are a repeat count, starting with the least significant bit, and a
302 single row of bits (the number of bits in a row is specified by
303 aGlyphData->iMetricsBuffer.Width()) follows. If the first bit of the header
304 is 1 the next four bits are a count of non-repeating rows, again starting
305 with the least significant bit, and that many rows of bits follow.
307 @param aCode The character code of the Unicode character for which the
309 @param aGlyphData On return, contains a pointer to a TOpenFontGlyphData
310 containing the character's bitmap and metrics. */
311 virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
312 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
313 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile);
314 IMPORT_C COpenFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,COpenFontFile* aFile,TInt aFaceIndex);
315 IMPORT_C ~COpenFont();
316 IMPORT_C void operator delete(TAny*);
317 inline const TOpenFontMetrics& Metrics() const;
318 inline const TOpenFontFaceAttrib* FaceAttrib() const;
319 inline COpenFontFile* File() const;
320 inline TInt FaceIndex() const;
321 inline TBool CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const;
322 void SetShaper(CShaper* aShaper);
323 CShaper* GetShaper();
324 TBool HasShaper() const;
325 TShapeHeader* GetShapedData(TInt aSessionHandle,TFontShapeFunctionParameters* aParams);
326 TShapeHeader* InsertShapedDataIntoCache(TInt aSessionHandle,TFontShapeFunctionParameters* aParams, TShapeHeader* aShapeHeader);
327 TInt FreeShaperCacheMemory(TInt aBytesNeeded);
328 TInt DecrementCachedRefCount(TInt aSessionHandle,TShapeHeader* aShapeHeader,TBool aResetAll=EFalse);
329 TBool Rasterize(TInt aSessionHandle,TInt aCode,TOpenFontGlyphData* aGlyphData);
330 TBool HasCharacterL(TInt aCode) const;
331 TBool GetCharacterData(TInt aSessionHandle,TInt aCode,const TOpenFontCharMetrics*& aMetrics,const TUint8*& aBitmap) const;
332 void OnFileDeleted();
333 COpenFontGlyphCache* GetGlyphCache();
334 inline TInt FontCapitalAscent() const;
335 inline TInt FontMaxAscent() const;
336 inline TInt FontStandardDescent() const;
337 inline TInt FontMaxDescent() const;
338 inline TInt FontLineGap() const;
339 inline TInt FontMaxHeight() const;
340 void DeleteShaper() const;
341 TInt GetFontTable(TUint32 aTag, TAny*& aTableContent, TInt& aLength);
342 TInt GetGlyphOutline(TUint aCode, TBool aHinted, TAny*& aOutline, TInt& aLength);
345 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
347 TInt PointerToThisOffset(const TAny* aAny);
348 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
350 TAny* ThisOffsetToPointer(const TInt aOffset);
354 TOpenFontMetrics iMetrics;
356 /** The shaper for performing complex character positioning and
357 substitution, if available. Null otherwise.
359 WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only.
364 /** The positive distance in pixels from the baseline to
365 the top of an ANSI capital (whether or not there are
366 ANSI capitals in the font) */
367 TInt iFontCapitalAscent;
368 /** The positive distance in pixels from the baseline to
369 the top of the highest pre-composed glyph in the font */
371 /** The positive distance in pixels from the baseline to
372 the bottom of the lowest ANSI descender (whether or
373 not there are ANSI chars in the font)*/
374 TInt iFontStandardDescent;
375 /** The positive distance in pixels from the baseline to
376 the bottom of the lowest pre-composed glyph in the font */
377 TInt iFontMaxDescent;
378 /** The recommended baseline to baseline gap for successive
379 lines of text in the font */
382 const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
385 /** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
387 const COpenFontGlyph* FontCacheGlyph(TInt aCode,TInt*& aNode);
388 const COpenFontGlyph* FontCacheGlyph(TInt aCode);
390 void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
393 const COpenFontGlyph* SessionCacheGlyph(RHeap* aHeap,TInt aSessionHandle,TInt aCode,
394 COpenFontSessionCache*& aCache,TInt& aIndex,TBool aCreate) const;
395 void RasterizeHelperL(TInt aCode,TOpenFontGlyphData* aGlyphData,TOpenFontGlyphData*& aTempGlyphData);
397 COpenFontSessionCacheList* SessionCacheList()const;
399 void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList);
401 void SetFile(COpenFontFile* aFile);
404 // Offset from the address of the file used by this font.
405 // If the file has been deleted or cannot be used, the offest will be zero.
408 TInt iFaceIndex; // index of the face in the font file
411 WARNING: Compatibility is not guaranteed in future releases. Please use the provided APIs only.
412 Offset from the address of this font of the per-font glyph cache which is owned by the font
415 TInt iGlyphCacheOffset;
417 // Offset from the address of this font of the list of per-session glyph
418 // caches which are owned by CFontStore
419 TInt iSessionCacheListOffset;
421 TAny* iReserved; // unused; for future expansion
424 /** Open Font System Extension Interface abstract base class.
426 COpenFont derivers should also derive from this interface to enable complex
429 This interface should be returned by the overridden
430 COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
434 @see KUidOpenFontShapingExtension
438 class MOpenFontShapingExtension
441 /** Various font metrics. */
442 class TExtensionFontMetrics
445 /** The number of font design units per em. */
447 /** The width of the font's em square in pixels. */
449 /** The height of the font's em square in pixels. */
451 /** The horizontal scaling factor from the font's transform;
452 the number of horizontal pixels per font unit. */
454 /** The vertical scaling factor from the font's transform;
455 the number of vertical pixels per font unit. */
458 /** Reserved for future expansion. */
462 /** Creates a bitmap for the specified Glyph code.
464 Implementations of this function should put the bitmap in
465 aGlyphData->iBitmapBuffer, and the character metrics are placed in
466 aGlyphData->iMetricsBuffer. The other parts of aGlyphData should be left
469 This function provides the same functionality as the
470 COpenFont::RasterizeL() except that the glyph code is supplied rather than
473 For more information:
474 @see COpenFont::RasterizeL()
476 @param aCode The glyph code of the character for which the bitmap is required.
477 @param aGlyphData The function puts its output here.
479 virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
481 /** Maps a character to a glyph index.
482 @param aUnicodeCharacter Unicode character code to be mapped.
483 @return Glyph code corresponding to aUnicodeCharacter. */
484 virtual TInt GlyphIndex(TInt aUnicodeCharacter) const = 0;
486 /** Returns the hinted pixel coordinates of a particular point in the
487 outline of the given glyph.
488 @param aGlyphPoint The glyph index.
489 @param aPointNumber The number of the point.
490 @param aX Returns the point's X pixel value.
491 @param aY Returns the point's Y pixel value.
492 @return True on success, false otherwise. */
493 virtual TBool GlyphPointInHintedPixels(TInt aGlyphIndex, TInt aPointNumber,
494 TReal& aX, TReal& aY) const = 0;
496 /** Returns the coordinates of a particular (unhinted) point in the outline
497 of the given glyph in font units.
498 @param aGlyphPoint The glyph index.
499 @param aPointNumber The number of the point.
500 @param aX Returns the point's X co-ordinate in font units.
501 @param aY Returns the point's Y co-ordinate in font units.
502 @return True on success, false otherwise. */
503 virtual TBool GlyphPointInFontUnits(TInt aGlyphIndex, TInt aPointNumber,
504 TInt& aX, TInt& aY) const = 0;
506 /** Returns font metrics.
507 @param aOut Font metrics returned. */
508 virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
511 /** TrueType extension for Open Fonts.
513 If an open font is able to load TrueType or OpenType tables it should derive
516 This class will be used by
518 This interface should be returned by the overridden
519 COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
521 @see KUidOpenFontTrueTypeExtension
525 class MOpenFontTrueTypeExtension
528 /** Returns the specified table. The table need not be released by the
529 caller, so the deriver is responsible for ensuring that any memory
530 allocated is ultimately cleaned up. The caller must not delete or modify
533 Returns KErrNone if successful or one of the system-wide error codes if
534 unsuccessful. Returns KErrNotSupported if the table does not exist in
537 The tag of the table, with the first character in the most significant
538 byte. For example, the "vhea" table is obtained by passing in 'v'<<24 |
539 'h'<<16 | 'e'<<8 | 'a'.
541 The length of the table in bytes that has been returned or 0 if
543 @return The table, if successful.
544 @see ReleaseTrueTypeTable */
545 virtual TAny* GetTrueTypeTable(TInt& aError, TUint32 aTag, TInt* aLength) = 0;
546 /** Releases a table obtained by GetTrueTypeTable. The caller must not
547 use the table after this call.
548 @param aTable The table to be released.
549 @see GetTrueTypeTable */
550 virtual TInt ReleaseTrueTypeTable(TAny* aTable) = 0;
551 /** Determines if the font file has a particular table.
552 @param aTag The tag of the table as for GetTrueTypeTable.
553 @return True if the table exists in the font file, false otherwise.
554 @see GetTrueTypeTable */
555 virtual TBool HasTrueTypeTable(TUint32 aTag) = 0;
558 class MOpenFontGlyphOutlineExtension
561 virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
562 TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
565 Font attribute base class.
567 This class is not intended for user derivation.
569 @see TOpenFontFaceAttrib
574 class TOpenFontFaceAttribBase
577 inline TOpenFontFaceAttribBase();
578 inline TBool HasLatin() const;
579 inline TBool HasGreek() const;
580 inline TBool HasCyrillic() const;
581 inline TBool HasKana() const;
582 inline TBool HasHangul() const;
583 inline TBool HasCJK() const;
584 inline TBool IsSymbol() const;
585 inline TBool IsBold() const;
586 inline TBool IsItalic() const;
587 inline TBool IsSerif() const;
588 inline TBool IsMonoWidth() const;
589 inline TPtrC Name() const;
590 inline const TUint* Coverage() const;
591 inline void SetName(const TDesC& aName);
592 inline void SetCoverage(TUint aCoverage0,TUint aCoverage1 = 0,TUint aCoverage2 = 0,TUint aCoverage3 = 0);
593 inline void SetBold(TBool aBold);
594 inline void SetItalic(TBool aItalic);
595 inline void SetSerif(TBool aSerif);
596 inline void SetMonoWidth(TBool aMonoWidth);
597 inline TBool operator==(const TOpenFontFaceAttribBase& aAttrib) const;
599 // Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included)
602 ELatinSet = 0x1, // 0000-007F
603 EGreekSet = 0x80, // 0370-03FF
604 ECyrillicSet = 0x200, // 0400-04FF
605 EArmenianSet = 0x400, // 0530-058F
606 EHebrewSet = 0x800, // 0590-05FF
607 EArabicSet = 0x2000, // 0600-06FF
608 EDevanagariSet = 0x8000, // 0900-097F
609 EBengaliSet = 0x10000, // 0980-09FF
610 EGurmukhiSet = 0x20000, // 0A00-0A7F
611 EGujuratiSet = 0x40000, // 0A80-0AFF
612 EOriyaSet = 0x80000, // 0B00-0B7F
613 ETamilSet = 0x100000, // 0B80-0BFF
614 ETeluguSet = 0x200000, // 0C00-0C7F
615 EKannadaSet = 0x400000, // 0C80-0CFF
616 EMalayalamSet = 0x800000, // 0D00-0D7F
617 EThaiSet = 0x1000000, // 0E00-0E7F
618 ELaoSet = 0x2000000, // 0E80-0EFF
619 EGeorgianSet = 0x8000000, // 10A0-10FF
620 EHangulJamoSet = 0x10000000,// 1100-11FF
623 // Unicode ranges for iCoverage[1]
626 ESymbolSets = 0xFFFE,
628 EHangulSet = 0x100000,
635 EBold = 0x1, // weight > 500 in Windows terms
636 EItalic = 0x2, // italic or oblique - any forward slant counts
637 ESerif = 0x4, // characters have serifs
638 EMonoWidth = 0x8 // all characters are the same width
644 ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24
647 TBufC<ENameLength> iName; // the name of the typeface; whether this is the full name or family name
648 // or is in English or another language depends on the context
649 TUint iCoverage[4]; // bitmap of the character sets supported by the typeface;
650 // these are the same as the fields ulUnicodeRange1 .. ulUnicodeRange4
651 // in the OS/2 table in TrueType fonts
652 TInt iStyle; // bold, italic serif, and mono-width
660 These attributes include the name, family name, and supported scripts.
662 @see CFbsFont::GetFaceAttrib()
666 class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
669 inline TOpenFontFaceAttrib();
670 inline TBool operator==(const TOpenFontFaceAttrib& aAttrib) const;
671 inline TPtrC FullName() const;
672 inline TPtrC FamilyName() const;
673 inline TPtrC LocalFullName() const;
674 inline TPtrC LocalFamilyName() const;
675 inline TPtrC ShortFullName() const;
676 inline TPtrC ShortFamilyName() const;
677 inline TPtrC ShortLocalFullName() const;
678 inline TPtrC ShortLocalFamilyName() const;
679 inline void SetFullName(const TDesC& aName);
680 inline void SetFamilyName(const TDesC& aName);
681 inline void SetLocalFullName(const TDesC& aName);
682 inline void SetLocalFamilyName(const TDesC& aName);
683 inline TInt MinSizeInPixels() const;
684 inline void SetMinSizeInPixels(TInt aSize);
686 TBufC<ENameLength> iFamilyName; // the name without any style suffixes; usually a truncation of iFullName
687 TBufC<ENameLength> iLocalFullName; // the full name in the language of the current locale
688 TBufC<ENameLength> iLocalFamilyName; // the family name in the language of the current locale
689 TInt iMinSizeInPixels; // minimum supported size, (or readable size if scalable) in pixels
695 Font specification allowing more attributes to be specified than TFontSpec.
697 In addition to the attributes specified by TFontSpec, this font specification
698 allows stretching and slanting in the x dimension, and other algorithmic effects.
699 This is used to correct for non-square pixels, and to allow algorithmic slanting
700 and bold. The width factor and slant factor transform any point (x,y) to (x
701 * iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16
704 The font specification also provides access to information about the scripts
705 which are supported by the font. This information is not always reliable,
706 because it may be incorrectly specified, or not specified at all, by some
711 class TOpenFontSpec : public TOpenFontFaceAttribBase
714 IMPORT_C TOpenFontSpec();
715 IMPORT_C TOpenFontSpec(const TFontSpec& aFontSpec);
716 IMPORT_C void operator=(const TFontSpec& aFontSpec);
717 inline TBool operator==(const TOpenFontSpec& aFontSpec) const;
718 TBool operator!=(const TOpenFontSpec& aOpenFontSpec) const;
719 IMPORT_C void SetAttrib(const TOpenFontFaceAttribBase& aAttrib);
720 IMPORT_C void GetTFontSpec(TFontSpec& aFontSpec) const;
721 IMPORT_C void CompensateForAspectRatio(TInt aPixelWidth,TInt aPixelHeight);
722 IMPORT_C void CompensateForAspectRatio(const MGraphicsDeviceMap& aMap);
723 inline TInt Height() const;
724 inline TInt32 WidthFactor() const;
725 inline TInt32 SlantFactor() const;
726 inline TGlyphBitmapType BitmapType() const;
727 inline TUint32 Effects() const;
728 inline TFontPrintPosition PrintPosition() const;
729 inline void SetHeight(TInt aHeight);
730 inline void SetWidthFactor(TInt32 aWidthFactor);
731 inline void SetSlantFactor(TInt32 aSlantFactor);
732 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
733 inline void SetEffects(TUint32 aEffects);
734 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
735 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
736 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
737 IMPORT_C TInt ScriptTypeForMetrics() const;
738 static TBool IsCompensationForAspectRatioNeeded(TInt aPixelWidth, TInt aPixelHeight);
739 static TInt ApplyRatio(TInt& aValue,TInt aNumerator,TInt aDenominator);
740 static TInt ApplyRatio(TInt32& aValue,TInt aNumerator,TInt aDenominator);
742 /** Algorithmic effects flags.
744 These can be combined using an OR operation.
746 WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
748 @deprecated Use FontEffect::TEffect instead.
752 /** Font is algorithmic bold. */
753 EAlgorithmicBold = 1,
754 /** Font has a drop shadow. */
756 /** Font is an outline font. */
760 void SetScriptTypeForMetrics(TInt aScript);
761 void SetSymbol(TBool aSymbol);
762 TBool Symbol() const;
763 IMPORT_C TBool OperatorEquality(const TOpenFontSpec& aOpenFontSpec) const;
764 IMPORT_C TUint32 DoEffects() const;
765 IMPORT_C void DoSetEffects(TUint32 aEffects);
767 TInt iHeight; // em height
768 TInt32 iWidthFactor; // algorithmic width factor as a 16.16 fixed-point number
769 TInt32 iSlantFactor; // algorithmic slant factor as a 16.16 fixed-point number
770 TInt iBitmapType; // non-anti-aliased, standard anti-aliased, etc.; zero means 'default'
771 TUint32 iEffects; // bit flags for font effects
772 TInt iSymbol; // a symbol font as understood by TFontSpec (bit 1), script type (bits 2-5)
773 // The following data member exists only to allow round-trip conversion between TFontSpec and TOpenFontSpec
774 TFontPrintPosition iPrintPosition; // normal, superscript or subscript
780 Font file abstract base class.
782 Write a class derived from COpenFontFile to manage a file with the font format
783 supported by your DLL. The derived class must implement the virtual
784 GetNearestFontInPixelsL() function. This function takes a font description
785 and creates a COpenFont derived object if the description matches a typeface
786 contained in the font file.
788 Derived classes must also load typeface attributes from the file into the
789 protected typeface attribute array during construction. This array is what
790 is searched when getting font attribute information see AddFaceL(),
791 GetNearestFontHelper().
793 Writing derived classes construction:
795 Call the COpenFontFile constructor in the constructor for your derived object,
796 passing it aUid and aFileName arguments. These values are the arguments passed
797 when the constructor is called by COpenFontRasterizer::NewFontFileL().
799 A file may contain one or more typefaces. During construction the derived
800 object should extract the information for each typeface and add it to this
801 object's protected typeface attribute array see AddFaceL(). This process
802 will probably leave under some conditions. It should therefore be implemented
803 in a second phase constructor.
805 Writing derived classes implement the pure virtual functions:
807 Derived classes must also implement the two pure virtual functions
808 GetNearestFontInPixelsL() and HasUnicodeCharacterL(). Information about
809 these functions is provided in the definitions below. Information about
810 deriving from this class is also provided in the API guide.
812 @see COpenFontRasterizer::NewFontFileL()
813 @see CWsScreenDevice::AddFile()
817 class COpenFontFile : public CBase
821 Gets the font which is the nearest to the given font specification.
823 Implementations of this pure virtual function should create the COpenFont
824 derived object that most closely matches aDesiredFontSpec, while fitting within
825 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
826 e.g. if the font name doesn't match, aFont should be set to NULL.
828 The other two arguments, aHeap and aSessionCacheList, should be passed to
829 the COpenFont constructor.
831 Implementations may use the utility function GetNearestFontHelper()
832 to get the attributes of the closest matching font.
834 @param aHeap Shared heap. This value should be passed to the
835 COpenFont derived classes' constructor.
836 @param aSessionCacheList The session cache list. This value should be passed
837 to the COpenFont derived classes' constructor.
838 @param aDesiredFontSpec The desired font specification.
839 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
840 the algorithmic slant of the typeface.
841 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
842 the algorithmic slant of the typeface.
843 @param aFont On return, contains a pointer to the newly created COpenFont
844 derived object, or NULL if no font matching aDesiredFontSpec exists.
845 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
846 @see GetNearestFontHelper()
848 virtual void GetNearestFontInPixelsL(
849 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
850 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
851 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
854 Gets the font which is the nearest to the given font specification.
856 Implementations of this pure virtual function should create the COpenFont
857 derived object that most closely matches aDesiredFontSpec, while fitting within
858 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
859 e.g. if the font name doesn't match, aFont should be set to NULL.
861 The other two arguments, aHeap and aSessionCacheList, should be passed to
862 the COpenFont constructor.
864 Implementations may use the utility function GetNearestFontHelper()
865 to get the attributes of the closest matching font.
867 @param aHeap Shared heap. This value should be passed to the COpenFont
868 derived classes' constructor.
869 @param aSessionCacheList The session cache list. This value should be passed
870 to the COpenFont derived classes' constructor.
871 @param aDesiredFontSpec The desired font specification.
872 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
873 the algorithmic slant of the typeface.
874 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
875 the algorithmic slant of the typeface.
876 @param aFont On return, contains a pointer to the newly created COpenFont
877 derived object, or NULL if no font matching aDesiredFontSpec exists.
878 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
879 @see GetNearestFontHelper()
881 virtual void GetNearestFontToDesignHeightInPixelsL(
882 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
883 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
884 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
886 Gets the font which is the nearest to the given font specification.
888 Implementations of this pure virtual function should create the COpenFont
889 derived object that most closely matches aDesiredFontSpec, while fitting within
890 aMaxHeight, and place a pointer to it in aFont. If this cannot be done,
891 e.g. if the font name doesn't match, aFont should be set to NULL.
893 The other two arguments, aHeap and aSessionCacheList, should be passed to
894 the COpenFont constructor.
896 Implementations may use the utility function GetNearestFontHelper()
897 to get the attributes of the closest matching font.
899 @param aHeap Shared heap. This value should be passed to the COpenFont
900 derived classes' constructor.
901 @param aSessionCacheList The session cache list. This value should be passed
902 to the COpenFont derived classes' constructor.
903 @param aDesiredFontSpec The desired font specification.
904 @param aPixelWidth The width of a pixel. Used with aPixelHeight for calculating
905 the algorithmic slant of the typeface.
906 @param aPixelHeight The height of a pixel. Used with aPixelWidth for calculating
907 the algorithmic slant of the typeface.
908 @param aFont On return, contains a pointer to the newly created COpenFont
909 derived object, or NULL if no font matching aDesiredFontSpec exists.
910 @param aActualFontSpec The actual font specification of the font retrieved into aFont.
911 @param aMaxHeight The maximum height (vertical extent) within which the font must fit.
912 @see GetNearestFontHelper()
914 virtual void GetNearestFontToMaxHeightInPixelsL(
915 RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
916 const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
917 COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
919 /** Tests whether a specified typeface contains a particular character.
921 @param aFaceIndex The index of the typeface to be tested.
922 @param aCode The Unicode character code for the character to be tested.
923 @return ETrue if the typeface contains aCode, otherwise EFalse. */
924 virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const = 0;
925 IMPORT_C virtual void ExtendedInterface(TUid aUid, TAny*& aParam);
926 IMPORT_C COpenFontFile(TInt aUid,const TDesC& aFileName);
927 IMPORT_C ~COpenFontFile();
928 IMPORT_C TBool GetNearestFontHelper(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
929 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
930 IMPORT_C void AddFaceL(const TOpenFontFaceAttrib& aAttrib);
931 inline TUid Uid() const;
932 inline const TDesC& FileName() const;
933 inline const TOpenFontFaceAttrib& FaceAttrib(TInt aFaceIndex) const;
934 inline TInt FaceCount() const;
935 inline void IncRefCount();
936 inline TBool DecRefCount();
937 TInt GetNearestFontInPixels(
938 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
939 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
940 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
941 TInt GetNearestFontToDesignHeightInPixels(
942 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
943 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
944 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
945 TInt GetNearestFontToMaxHeightInPixels(
946 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
947 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
948 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
949 void RemoveFontFromList(const COpenFont* aFont);
950 void SetFontStoreL(CFontStore* aFontStore);
951 CFontStore* GetFontStore();
952 CArrayPtrFlat<COpenFont>* GetOpenFontList();
954 IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
955 TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
957 // A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
958 class TAttrib: public TOpenFontFaceAttrib
961 COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface
963 static TInt ScoreByName(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
964 static TInt ScoreByStyle(const TOpenFontSpec& aDesiredFontSpec, const TAttrib& aAttrib);
965 void GetNearestFontToDesignHeightInPixelsAndAddToListL(
966 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
967 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
968 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec);
969 void GetNearestFontToMaxHeightInPixelsAndAddToListL(
970 RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
971 const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
972 COpenFont*& aFont, TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
975 CArrayFixFlat<TAttrib> iFaceAttrib;
977 TBuf<KMaxFileName> iFileName;
979 CArrayPtrFlat<COpenFont> iFontList;
980 TOpenFontFileData* iData;
984 Convenience class from which rasterizer contexts may be derived.
986 A rasterizer context object may (optionally) be created to provide the link
987 between the rasterizer DLL code supported by the Open Font System, and the
988 rasterizer engine code. A rasterizer context object class should get the
989 requested bitmap from the associated rasterizer engine. It should then convert
990 this into Symbian run-length-encoded format. This class contains convenience
991 functions to make the conversion easier.
993 Deriving from this class is described in greater detail in the API guide.
997 class COpenFontRasterizerContext: public CBase
1000 inline COpenFontRasterizerContext();
1001 inline void StartGlyph(TOpenFontGlyphData* aGlyphData);
1002 inline void WriteGlyphBit(TInt aBit);
1003 inline void WriteGlyphByte(TInt aByte);
1004 inline void EndGlyph();
1006 TOpenFontGlyphData* iGlyphData;
1007 TUint8* iGlyphDataStart;
1008 TUint8* iGlyphDataPtr;
1009 TUint8* iGlyphDataEnd;
1013 TAny* iReserved; // unused; for future expansion
1018 Shaper abstract class. All shaper implementations derive from this
1022 class CShaper : public CBase
1028 /** The text to be shaped possibly including context. */
1030 /** The index of the first character in iText to be shaped. */
1032 /** (One past) the end of the text in iText to be shaped. */
1034 /** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
1037 /** Language code. 0 implies "default" */
1039 /** Maximum advance in pixels. Shaping beyond this
1040 advance is not required (but is not harmful). */
1041 TInt iMaximumAdvance;
1042 /** Flags. Currently none is defined. */
1044 /** Session handle. To be used if rasterization is needed. */
1045 TInt iSessionHandle;
1046 /** Reserved for future expansion. Must be set to 0. */
1053 IMPORT_C virtual ~CShaper();
1055 /** construct a shaper object
1056 @param aBitmapFont The font to be shaped.
1057 @param aHeap The heap to be used by the shaper.
1058 @return KErrNone if this font can be shaper or system wide error code*/
1059 virtual TInt ConstructL(CBitmapFont* aBitmapFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1061 /** If possible, shape the text described by aInput, placing the output on aHeapForOutput.
1062 @param aOutput The output, as a newly allocate object on aHeapForOutput.
1063 @param aInput The input text and other parameters.
1064 @param aHeapForOutput On success, aOutput should be allocated from this and nothing else.
1065 On failure, nothing should be allocated from it.
1066 @return Error value from one of the system-wide error codes on failure, KErrNone on success.
1067 @see TShapeHeader */
1068 virtual TInt ShapeText(TShapeHeader*& aOutput, const TInput& aInput, RHeap* aHeapForOutput) = 0;
1070 /** For future expansion. Any overriders must base-call
1071 if aInterface is unrecognized.
1073 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1075 @param aInterfaceId The ID of the interface to return.
1076 @return A pointer to the extension interface.
1078 IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
1081 /** ECOM plug-in base class for shaper factories.
1085 class CShaperFactory : public CBase
1088 /** Create a shaper if possible, for typeface aFaceIndex
1089 within file aFileName.
1090 @param aFont The font to be shaped.
1091 @param iHeap The heap to use for constructing the shaper.
1092 @return 0 If the font is not understood or inappropriate for any shaper that might be constructed
1093 by this class, otherwise returns the newly-constructed shaper on iHeap. */
1094 virtual CShaper* NewShaperL(CBitmapFont* aFont, TInt aScript, TInt aLanguage, RHeap* iHeap) = 0;
1096 inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
1097 inline virtual ~CShaperFactory();
1099 /** For future expansion. Any overriders must base-call if aInterface is unrecognized.
1101 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
1103 @param aInterfaceId The ID of the interface to return.
1104 @return A pointer to the extension interface.
1106 virtual void* ExtendedInterface(TUid aInterfaceId);
1109 TUid iDtor_ID_Key;//ECOM identifier used during destruction
1112 // Inline functions start here.
1113 /** Default C++ constructor.
1115 This creates then zero fills the object. */
1116 inline TOpenFontMetrics::TOpenFontMetrics()
1118 Mem::FillZ(this,sizeof(*this));
1121 /** Gets the font's size.
1123 @return The font's size.
1125 inline TInt TOpenFontMetrics::Size() const
1127 return iDesignHeight;
1130 /** Gets the font's ascent.
1132 This is the ascent for the Latin character which is highest above the baseline.
1134 @return The font's ascent, in pixels.
1136 inline TInt TOpenFontMetrics::Ascent() const
1141 /** Gets the font's descent.
1143 This is the descent for the Latin character in the font which falls furthest below the baseline.
1145 @return The font's descent, in pixels.
1146 @see SetDescent() */
1147 inline TInt TOpenFontMetrics::Descent() const
1152 /** Sets the font's maximum height.
1154 Note that if this object was initialised from the CFont this will be the same
1157 This is the ascent for the character which is highest above the baseline.
1158 In many fonts this will be the height of an accented character like Â,
1159 including the accent.
1161 @return The maximum height of the font, in pixels.
1162 @see SetMaxDepth() */
1163 inline TInt TOpenFontMetrics::MaxHeight() const
1168 /** Gets the font's maximum depth.
1170 Note: If this object was initialised from the CFont this will be the same as the
1173 This is the descent for the character in the font which falls furthest below
1176 @return The font's maximum depth.
1177 @see SetMaxDepth() */
1178 inline TInt TOpenFontMetrics::MaxDepth() const
1183 /** Gets the maximum character width, in pixels.
1185 @return The maximum character width, in pixels.
1186 @see SetMaxWidth() */
1187 inline TInt TOpenFontMetrics::MaxWidth() const
1192 /** Sets the font's size.
1194 @param aSize The font's size.
1196 inline void TOpenFontMetrics::SetSize(TInt aSize)
1198 iDesignHeight = static_cast<TInt16>(aSize);
1201 /** Sets the ascent.
1203 @param aAscent The ascent, in pixels.
1205 inline void TOpenFontMetrics::SetAscent(TInt aAscent)
1207 iAscent = static_cast<TInt16>(aAscent);
1210 /** Sets the descent.
1212 @param aDescent The descent, in pixels.
1214 inline void TOpenFontMetrics::SetDescent(TInt aDescent)
1216 iDescent = static_cast<TInt16>(aDescent);
1219 /** Sets the font's maximum height.
1221 @param aMaxHeight The font's maximum height, in pixels.
1223 inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
1225 iMaxHeight = static_cast<TInt16>(aMaxHeight);
1228 /** Sets the font's maximum depth.
1230 @param aMaxDepth The font's maximum depth, in pixels.
1232 inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
1234 iMaxDepth = static_cast<TInt16>(aMaxDepth);
1237 /** Sets the maximum character width, in pixels.
1239 @param aMaxWidth The maximum character width, in pixels.
1241 inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
1243 iMaxWidth = static_cast<TInt16>(aMaxWidth);
1246 /** Default C++ constructor.
1248 The constructor initialises all data members to zero. As for other T classes,
1249 there is no need to explicitly cleanup TOpenFontCharMetrics objects. */
1250 inline TOpenFontCharMetrics::TOpenFontCharMetrics()
1252 Mem::FillZ(this,sizeof(*this));
1255 /** Gets the width of the character's bitmap.
1257 @return The width of the bitmap in pixels. */
1258 inline TInt TOpenFontCharMetrics::Width() const
1263 /** Gets the height of the character's bitmap.
1265 @return The character's height in pixels. */
1266 inline TInt TOpenFontCharMetrics::Height() const
1271 /** Gets the horizontal bearing X.
1273 This is the distance in pixels from the pen point before the character is
1274 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1275 A positive value means that the left edge of the bitmap is right of the origin.
1277 @return The horizontal bearing X in pixels */
1278 inline TInt TOpenFontCharMetrics::HorizBearingX() const
1280 return iHorizBearingX;
1283 /** Gets horizontal bearing Y.
1285 This is the vertical distance in pixels from the pen point before the character
1286 is drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1287 A positive value means that the top edge of the bitmap is above the origin
1289 @return The horizontal bearing Y in pixels. */
1290 inline TInt TOpenFontCharMetrics::HorizBearingY() const
1292 return iHorizBearingY;
1295 /** Gets the horizontal advance.
1297 This is the amount added to the x co-ordinate of the origin after the character
1298 is drawn what most people understand by the width or escapement of a character.
1299 The origin here is the pen point before the character is drawn.
1301 @return The horizontal advance in pixels */
1302 inline TInt TOpenFontCharMetrics::HorizAdvance() const
1304 return iHorizAdvance;
1307 /** Gets the vertical bearing X.
1309 This is the distance in pixels from the pen point before the character is
1310 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1311 A positive value means that the left edge of the bitmap is right of the origin.
1313 @return The vertical bearing X in pixels. */
1314 inline TInt TOpenFontCharMetrics::VertBearingX() const
1316 return iVertBearingX;
1319 /** Gets the vertical bearing Y.
1321 This is the distance in pixels from the pen point before the character is
1322 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1323 A positive value means that the top edge of the bitmap is above the origin.
1325 @return The vertical bearing Y in pixels. */
1326 inline TInt TOpenFontCharMetrics::VertBearingY() const
1328 return iVertBearingY;
1331 /** Gets the vertical advance.
1333 When drawing vertically, this is the amount added to the y co-ordinate of
1334 the origin after the character is drawn what most people understand by
1335 the height of a character. The origin here is the pen point before the character
1338 Note: Vertical drawing is not supported in v5.
1340 @return The vertical advance in pixels. */
1341 inline TInt TOpenFontCharMetrics::VertAdvance() const
1343 return iVertAdvance;
1346 /** Gets the bounds of the character relative to its origin when setting text
1349 The origin here is the pen point before the character is drawn.
1351 @param aBounds The character's bounds. */
1352 inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
1354 aBounds.iTl.iX = iHorizBearingX;
1355 aBounds.iTl.iY = -iHorizBearingY;
1356 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1357 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1360 /** Gets the bounds of the character relative to its origin when setting text
1363 The origin here is the pen point before the character is drawn.
1365 @param aBounds The character's bounds. */
1366 inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
1368 aBounds.iTl.iX = -iVertBearingX;
1369 aBounds.iTl.iY = iVertBearingY;
1370 aBounds.iBr.iX = aBounds.iTl.iX + iWidth;
1371 aBounds.iBr.iY = aBounds.iTl.iY + iHeight;
1374 /** Sets the width of the character's bitmap.
1376 @param aWidth The width of the bitmap in pixels. */
1377 inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
1379 iWidth = (TInt16)aWidth;
1382 /** Sets the height of the character's bitmap.
1384 @param aHeight The character height (in pixels). */
1385 inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
1387 iHeight = (TInt16)aHeight;
1390 /** Sets the horizontal bearing X.
1392 This is the distance in pixels from the pen point before the character is
1393 drawn (the origin) to the left edge of the bitmap, when drawing horizontally.
1394 A positive value means that the left edge of the bitmap is right of the origin.
1396 @param aHorizBearingX The horizontal bearing X (in pixels). */
1397 inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
1399 iHorizBearingX = (TInt16)aHorizBearingX;
1402 /** Sets the horizontal bearing Y.
1404 This is the distance in pixels from the pen point before the character is
1405 drawn (the origin) to the top edge of the bitmap, when drawing horizontally.
1406 A positive value means that the top edge of the bitmap is above the origin.
1408 @param aHorizBearingY The horizontal bearing Y (in pixels). */
1409 inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
1411 iHorizBearingY = (TInt16)aHorizBearingY;
1414 /** Sets the horizontal advance.
1416 This is the amount added to the x co-ordinate of the origin after the character
1417 is drawn, what most people understand by the width or escapement of a character.
1418 The origin here is the pen point before the character is drawn.
1420 @param aHorizAdvance The horizontal advance (in pixels). */
1421 inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
1423 iHorizAdvance = (TInt16)aHorizAdvance;
1426 /** Set vertical bearing X.
1428 This is the distance in pixels from the pen point before the character is
1429 drawn (the origin) to the left edge of the bitmap, when drawing vertically.
1430 A positive value means that the left edge of the bitmap is right of the origin.
1432 @param aVertBearingX The vertical bearing X (in pixels). */
1433 inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
1435 iVertBearingX = (TInt16)aVertBearingX;
1438 /** Sets the vertical bearing Y.
1440 This is the distance in pixels from the pen point before the character is
1441 drawn (the origin) to the top edge of the bitmap, when drawing vertically.
1442 A positive value means that the top edge of the bitmap is above the origin.
1444 @param aVertBearingY The vertical bearing Y (in pixels). */
1445 inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
1447 iVertBearingY = (TInt16)aVertBearingY;
1450 /** Sets the vertical advance.
1452 When drawing vertically, this is the amount added to the y co-ordinate of
1453 the origin after the character is drawn what most people understand by
1454 the height of a character. The origin here is the pen point before the character
1457 Note: Vertical drawing is not supported in v5.
1459 @param aVertAdvance The vertical advance (in pixels). */
1460 inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
1462 iVertAdvance = (TInt16)aVertAdvance;
1465 /** Gets the character metrics for this font.
1467 @return The character metrics for this font. */
1468 inline const TOpenFontMetrics& COpenFont::Metrics() const
1473 /** Gets the glyph index.
1475 This is the index of a particular glyph within the font file.
1477 Note: This makes it possible to gain access to glyphs which are not referenced
1478 by the Unicode character set. However, this feature is not yet supported by
1481 @return The glyph index.
1482 @see SetGlyphIndex() */
1483 inline TInt TOpenFontGlyphData::GlyphIndex() const
1488 /** Gets the typeface attributes.
1490 These are the attributes of the font represented by this object.
1492 @return The typeface attributes. */
1493 inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
1495 return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex);
1498 /** Gets a pointer to the COpenFontFile which created this object.
1500 This is the COpenFontFile which owns the file that contains the definition
1501 of the typeface. It can be used to get information about the typeface, or
1502 to access the rasterizer context (engine).
1504 @return The COpenFontFile which created this object. */
1505 inline COpenFontFile* COpenFont::File() const
1507 return iFileOffset == 0 ? NULL : reinterpret_cast<COpenFontFile*>(const_cast<COpenFont*>(PtrAdd(this, iFileOffset)));
1510 /** Gets the index of this typeface within the font file.
1512 @return The index of this typeface within the font file. */
1513 inline TInt COpenFont::FaceIndex() const
1518 /** Tests whether or not a character needs to be rasterized.
1520 Characters that have been rasterized are cached there is no need to regenerate
1521 the character bitmap. This function should only be called by the Font and
1524 @param aSessionHandle A handle to the font and bitmap server session.
1525 @param aCode The code for the Unicode character.
1526 @return ETrue if the character needs to be rasterized, otherwise EFalse. */
1527 inline TBool COpenFont::CharacterNeedsToBeRasterized(TInt aSessionHandle,TInt aCode) const
1529 return Glyph(aSessionHandle,aCode) == NULL;
1532 /** Gets the ascent of an ANSI capital letter in the font whether or not
1533 there are any ANSI capitals in the font.
1534 @return The positive distance from the font baseline to the top of a
1535 standard ANSI capital letter
1538 @see AscentInPixels()
1540 inline TInt COpenFont::FontCapitalAscent() const
1542 return iFontCapitalAscent;
1545 /** Gets the max ascent of any pre-composed glyph in the font. This will
1546 include accents or diacritics that form part of pre-composed glyphs. It is
1547 not guaranteed to cover the max ascent of composite glyphs that have to be
1548 created by a layout engine. This is also the recommended distance between
1549 the top of a text box and the baseline of the first line of text.
1551 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1553 @return The positive distance from the font baseline to the top of the
1554 highest pre-composed glyph (including accents) above the baseline.
1557 @see AscentInPixels()
1558 @see SetScriptTypeForMetrics()
1560 inline TInt COpenFont::FontMaxAscent() const
1562 return iFontMaxAscent;
1565 /** Gets the descent of an ANSI descending character in the font.
1566 Whether or not there are any ANSI descenders in the font.
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 ANSI descender.
1574 @see DescentInPixels()
1575 @see SetScriptTypeForMetrics()
1577 inline TInt COpenFont::FontStandardDescent() const
1579 return iFontStandardDescent;
1582 /** Gets the max descent of any pre-composed glyph in the font. This will
1583 include accents or diacritics that form part of pre-composed glyphs. It is
1584 not guaranteed to cover the max descent of composite glyphs that have to be
1585 created by a layout engine.
1587 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1589 @return The positive distance from the font baseline to the bottom of the
1590 lowest pre-composed glyph (including accents) below the baseline
1593 @see DescentInPixels()
1594 @see SetScriptTypeForMetrics()
1596 inline TInt COpenFont::FontMaxDescent() const
1598 return iFontMaxDescent;
1601 /** Gets the suggested line gap for the font. This is the recommended
1602 baseline to baseline distance between successive lines of text in the font.
1603 @return The positive recommended gap between successive lines
1607 inline TInt COpenFont::FontLineGap() const
1609 return iFontLineGap;
1612 /** Gets the maximum height for the font. This is the sum of the max ascent
1613 of the font and the max descent of the font.
1615 The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
1617 @return The positive maximum height of the font
1620 @see HeightInPixels()
1621 @see SetScriptTypeForMetrics()
1623 inline TInt COpenFont::FontMaxHeight() const
1625 return iFontMaxAscent + iFontMaxDescent;
1628 /** Default C++ constructor.
1630 This sets all attribute fields to zero. As for other T classes, there is no
1631 need to explicitly clean-up objects derived from this class. */
1632 inline TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
1634 Mem::FillZ(this,sizeof(*this));
1637 /** Default C++ constructor.
1639 The function initialises the minimum typeface size to zero, the names to NULL,
1640 and the coverage and style flags to zero. */
1641 inline TOpenFontFaceAttrib::TOpenFontFaceAttrib():
1642 iMinSizeInPixels(0),
1647 /** Tests for support of Latin characters.
1649 Note: A return value of ETrue implies that the font has a usable set of
1650 characters. It does not imply exhaustive coverage.
1652 @return ETrue if Latin characters are supported */
1653 inline TBool TOpenFontFaceAttribBase::HasLatin() const
1655 return iCoverage[0] & ELatinSet;
1658 /** Tests for support of Greek characters.
1660 Note: A return value of ETrue implies that the font has a usable set of
1661 characters. It does not imply exhaustive coverage.
1663 @return ETrue if Greek characters are supported. */
1664 inline TBool TOpenFontFaceAttribBase::HasGreek() const
1666 return iCoverage[0] & EGreekSet;
1669 /** Tests for support of Cyrillic characters.
1671 Note: A return value of ETrue implies that the font has a usable set of
1672 characters. It does not imply exhaustive coverage.
1674 @return ETrue if Cyrillic characters are supported. */
1675 inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
1677 return iCoverage[0] & ECyrillicSet;
1680 /** Tests for support of Japanese syllabic characters.
1682 This function tests for the presence of Hiragana and Katakana syllabic
1683 characters in the font, collectively called kana. These characters are not
1684 sufficient for the Japanese language, which also makes use of Chinese characters.
1686 Note: A return value of ETrue implies that the font has a usable set of
1687 characters. It does not imply exhaustive coverage.
1689 @return ETrue if Japanese characters are supported
1691 inline TBool TOpenFontFaceAttribBase::HasKana() const
1693 return iCoverage[1] & EKanaSets;
1696 /** Tests for support of Korean Hangul characters.
1698 Korean may also make use of Chinese characters.
1700 Note: A return value of ETrue implies that the font has a usable set of
1701 characters. It does not imply exhaustive coverage.
1703 @return ETrue if Korean characters are supported
1705 inline TBool TOpenFontFaceAttribBase::HasHangul() const
1707 return iCoverage[1] & EHangulSet;
1710 /** Tests for support of Chinese ideographic characters.
1712 These are used in Chinese, Japanese and Korean.
1714 Note: A return value of ETrue implies that the font has a usable set of
1715 characters. It does not imply exhaustive coverage.
1717 @return ETrue if Chinese ideographs are supported. */
1718 inline TBool TOpenFontFaceAttribBase::HasCJK() const
1720 return iCoverage[1] & ECJKSet;
1723 /** Tests if the typeface contains symbols only.
1725 @return ETrue if the typeface contains symbols only. */
1726 inline TBool TOpenFontFaceAttribBase::IsSymbol() const
1728 return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
1729 iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
1732 /** Tests if the typeface is inherently bold.
1734 @return ETrue if the typeface is inherently bold. */
1735 inline TBool TOpenFontFaceAttribBase::IsBold() const
1737 return iStyle & EBold;
1740 /** Tests if the typeface is inherently italic.
1742 @return ETrue if the typeface is inherently italic. */
1743 inline TBool TOpenFontFaceAttribBase::IsItalic() const
1745 return iStyle & EItalic;
1748 /** Tests if the typeface has serifs.
1750 @return ETrue if the typeface has serifs. */
1751 inline TBool TOpenFontFaceAttribBase::IsSerif() const
1753 return iStyle & ESerif;
1756 /** Tests if all the characters have the same width.
1758 @return ETrue if all the characters have the same width. */
1759 inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
1761 return iStyle & EMonoWidth;
1764 /** Gets the typeface's name.
1766 @return Descriptor containing typeface name. */
1767 inline TPtrC TOpenFontFaceAttribBase::Name() const
1772 /** Gets the full name.
1774 The full name of the typeface includes style attributes like Italic, Bold,
1777 @return The full name of the typeface.
1778 @see FamilyName() */
1779 inline TPtrC TOpenFontFaceAttrib::FullName() const
1784 /** Gets the family name.
1786 Note: The family name of the typeface does not include style attributes like
1789 @return The family name of the typeface.
1791 inline TPtrC TOpenFontFaceAttrib::FamilyName() const
1796 /** Gets the local full name.
1798 The local full name of the typeface includes style attributes like Italic,
1801 The local name of the typeface is the name in the language of the current
1802 locale, where this is provided by the font file. If the local name is not
1803 available then the local name will be the same as the ordinary name.
1805 @return The local full name of the typeface. */
1806 inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
1808 return iLocalFullName;
1811 /** Gets the local family name.
1813 The local name of the typeface is the name in the language of the current
1814 locale, where this is provided by the font file. If the local name is not
1815 available then the local name will be the same as the ordinary name.
1817 Note: The family name of the typeface does not include style attributes like
1820 @return The local family name of the typeface. */
1821 inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
1823 return iLocalFamilyName;
1826 /** Gets the short full name.
1828 This is the full name of the typeface, truncated to KMaxTypefaceNameLength,
1831 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1832 where necessary so that they can be used in the TTypeFace class. The Open
1833 Font Framework allows 32 characters as a maximum name length.
1835 @return The short full name of the typeface.
1837 inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
1839 // Can't use TDesC::Left for this because it panics if the desired length is > the existing length!
1840 return TPtrC(iName.Ptr(),Min(iName.Length(),KMaxTypefaceNameLength));
1843 /** Gets the short family name.
1845 This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
1847 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1848 where necessary so that they can be used in the TTypeFace class. The Open
1849 Font Framework allows 32 characters as a maximum name length.
1851 @return The short family name of the typeface.
1852 @see FamilyName() */
1853 inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
1855 return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
1858 /** Gets the short local full name.
1860 This is the local full name of the typeface, truncated to KMaxTypefaceNameLength,
1863 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1864 where necessary so that they can be used in the TTypeFace class. The Open
1865 Font Framework allows 32 characters as a maximum name length.
1867 @return The short local full name of the typeface.
1868 @see LocalFullName() */
1869 inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
1871 return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
1874 /** Gets the short local family name.
1876 This is the local family name of the typeface, truncated to KMaxTypefaceNameLength,
1879 Note: Short names are names truncated to KMaxTypefaceNameLength (24) characters
1880 where necessary so that they can be used in the TTypeFace class. The Open
1881 Font Framework allows 32 characters as a maximum name length.
1883 @return The short local family name of the typeface.
1884 @see LocalFamilyName() */
1885 inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
1887 return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
1890 /** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
1892 Each flag that is set represents a supported Unicode range. The mapping is
1893 defined in the TrueType documentation under the OS/2 table.
1895 Note: Some useful subsets are defined as anonymous enumerated constants at the end
1896 of this class, see ELatinSet etc.
1898 @return A pointer to the flags that indicate the font's Unicode coverage.
1899 The flags are stored in an array of four 32-bit integers. When no information
1900 is available, all four integers are zero.
1901 @see SetCoverage() */
1902 inline const TUint* TOpenFontFaceAttribBase::Coverage() const
1907 /** Gets the minimum typeface size.
1909 This is the smallest size that can be drawn legibly.
1911 @return The minimum typeface size (in pixels). */
1912 inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
1914 return iMinSizeInPixels;
1917 /** Sets the name attribute.
1919 @param aName Descriptor containing typeface name. */
1920 inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
1922 iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1925 /** Sets the full name.
1927 @param aName The full name of the typeface.
1929 inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
1934 /** Sets the family name.
1936 @param aName The family name of the typeface.
1937 @see FamilyName() */
1938 inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
1940 iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1943 /** Sets the local full name.
1945 @param aName The local full name of the typeface.
1946 @see LocalFullName() */
1947 inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
1949 iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1952 /** Sets the local family name.
1954 @param aName The local family name of the typeface.
1955 @see LocalFamilyName() */
1956 inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
1958 iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
1961 /** Sets the coverage flags.
1963 The flags are held in four 32 bit integers. Each flag that is set represents
1964 a range of Unicode characters that is supported by the typeface: Latin,
1965 Greek, Cyrillic etc. The mapping is defined in the TrueType documentation
1966 under the OS/2 table.
1968 Note: Some useful subsets are defined as anonymous enumerated constants at
1969 the end of this class, see ELatinSet etc.
1971 @param aCoverage0 The first set of coverage flags (bits 0-31).
1972 @param aCoverage1 The second set of coverage flags (bits 32-63).
1973 @param aCoverage2 The third set of coverage flags (bits 64-95).
1974 @param aCoverage3 The fourth set of coverage flags (bits 96-127). */
1975 inline void TOpenFontFaceAttribBase::SetCoverage(TUint aCoverage0,TUint aCoverage1,TUint aCoverage2,TUint aCoverage3)
1977 iCoverage[0] = aCoverage0;
1978 iCoverage[1] = aCoverage1;
1979 iCoverage[2] = aCoverage2;
1980 iCoverage[3] = aCoverage3;
1983 /** Set the minimum typeface size.
1985 This is the smallest size that can be drawn legibly.
1987 @param aSize Sets the minimum typeface size (in pixels).
1988 @see MinSizeInPixels() */
1989 inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
1991 iMinSizeInPixels = aSize;
1994 /** Equality operator.
1996 Compares this and another set of font attributes, including the coverage,
1997 the family name, the local full name, the local family name, and the minimum
2000 @param aAttrib Contains the font attributes and names to compare.
2001 @return ETrue if all values are equal, EFalse if not. */
2002 inline TBool TOpenFontFaceAttrib::operator==(const TOpenFontFaceAttrib& aAttrib) const
2004 return TOpenFontFaceAttribBase::operator==(aAttrib) &&
2005 iFamilyName == aAttrib.iFamilyName &&
2006 iLocalFullName == aAttrib.iLocalFullName &&
2007 iLocalFamilyName == aAttrib.iLocalFamilyName &&
2008 iMinSizeInPixels == aAttrib.iMinSizeInPixels;
2011 /** Sets the bold attribute.
2013 @param aBold The bold attribute takes this value: ETrue or EFalse. */
2014 inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
2022 /** Sets the italic attribute.
2024 @param aItalic The italic attribute takes this value ETrue or EFalse. */
2025 inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
2033 /** Sets the serif attribute.
2035 @param aSerif The serif attribute takes this value ETrue or EFalse. */
2036 inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
2044 /** Sets the mono-width attribute.
2046 @param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
2047 inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
2050 iStyle |= EMonoWidth;
2052 iStyle &= ~EMonoWidth;
2055 /** Equality operator.
2057 Compares this and a specified set of font attributes, including the coverage
2058 and the typeface name.
2060 In version 6.1, and earlier, the return value was TInt.
2062 @param aAttrib The font attributes to compare. This is an object of TOpenFontFaceAttribBase
2063 or of a derived class.
2064 @return ETrue if the values are equal. */
2065 inline TBool TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase& aAttrib) const
2067 return iStyle == aAttrib.iStyle &&
2068 iCoverage[0] == aAttrib.iCoverage[0] &&
2069 iCoverage[1] == aAttrib.iCoverage[1] &&
2070 iCoverage[2] == aAttrib.iCoverage[2] &&
2071 iCoverage[3] == aAttrib.iCoverage[3] &&
2072 iName.CompareF(aAttrib.iName) == 0;
2075 /** Compares this and another open font specification. Compares all the properties
2079 @param aFontSpec The open font specification to compare with this one.
2080 @return ETrue if all values are equal, EFalse if not.
2082 inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
2085 iHeight == aOpenFontSpec.iHeight &&
2086 iWidthFactor == aOpenFontSpec.iWidthFactor &&
2087 iSlantFactor == aOpenFontSpec.iSlantFactor &&
2088 iBitmapType == aOpenFontSpec.iBitmapType &&
2089 iEffects == aOpenFontSpec.iEffects &&
2090 iSymbol == aOpenFontSpec.iSymbol &&
2091 iPrintPosition == aOpenFontSpec.iPrintPosition &&
2092 TOpenFontFaceAttribBase::operator==(aOpenFontSpec);
2095 /** Gets the height of the font.
2097 @return The height of the font, in pixels or twips.
2099 inline TInt TOpenFontSpec::Height() const
2104 /** Gets the algorithmic width factor.
2106 @return The algorithmic width factor as a 16.16 fixed-point number.
2107 @see SetWidthFactor() */
2108 inline TInt32 TOpenFontSpec::WidthFactor() const
2110 return iWidthFactor;
2113 /** Gets the algorithmic slant factor.
2115 @return The algorithmic slant factor as a 16.16 fixed-point number.
2116 @see SetSlantFactor() */
2117 inline TInt32 TOpenFontSpec::SlantFactor() const
2119 return iSlantFactor;
2122 /** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
2124 @return Indicates whether or not the font should be drawn using anti-aliasing. */
2125 inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
2127 return (TGlyphBitmapType)iBitmapType;
2130 /** Gets the font effects flags.
2131 Because the flags encoded in the Effects are anonymous, the return value should only
2132 be tested for the specific bits that are of interest, and never tested as a whole.
2135 @return The font effects flags.
2136 @see TOpenFontSpec::SetEffects()
2138 inline TUint32 TOpenFontSpec::Effects() const
2143 /** Gets the print position.
2145 @return The print position. */
2146 inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
2148 return iPrintPosition;
2151 /** Sets the font's height.
2153 @param aHeight The font's height, in pixels or twips.
2155 inline void TOpenFontSpec::SetHeight(TInt aHeight)
2160 /** Sets the algorithmic width factor.
2162 The width factor is multiplied by the pixel's x position to get the new position,
2163 causing characters to become wider or narrower. A width factor of 1 (65536
2164 in 16.16 fixed-point number format) should be used if the character width
2165 is not to be changed.
2167 @param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
2168 @see WidthFactor() */
2169 inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
2171 iWidthFactor = aWidthFactor;
2174 /** Sets the algorithmic slant factor.
2176 Note: The slant factor is used to create an italic effect for characters which
2177 do not have an italic glyph in the typeface. When slanting is active, pixel x
2178 co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x
2179 = x + y x slant factor).
2181 The slant factor is a 32 bit, 16.16 fixed-point number. This means that the
2182 first 16 bits are treated as a whole number, and the second 16 as the fractional
2183 part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this
2184 is equivalent to an integer slant value of 1, which causes a 45 degree slant
2187 @param aSlantFactor The slant factor as a 16.16 fixed-point number.
2188 @see SlantFactor() */
2189 inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
2191 iSlantFactor = aSlantFactor;
2194 /** Sets whether the font should be drawn using anti-aliasing. If set, this value
2195 overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
2198 Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
2199 support for bitmapped fonts.
2201 @param aBitmapType Indicates whether or not the font should be drawn using
2203 inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
2205 iBitmapType = aBitmapType;
2208 /** Sets the font effects flags.
2209 Prior to calling this routine, the value from Effects() should be read,
2210 and its flags modified as required, before passing them back in.
2213 @param aEffect The font effects flags to be set.
2214 @see TOpenFontSpec::Effects()
2216 inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
2218 iEffects = aEffects;
2221 /** Gets the font file's UID.
2223 @return The uid of the file. */
2224 inline TUid COpenFontFile::Uid() const
2229 /** Gets the full path and filename of the font file
2231 This is the filename that was passed to the constructor when the object is
2234 @return The filename of the font file. */
2235 inline const TDesC& COpenFontFile::FileName() const
2240 /** Gets the typeface at a specified index in the typeface attribute array.
2242 @param aFaceIndex The index of the typeface for which the attributes are required.
2243 @return The attributes of the typeface with the specified index.
2246 inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
2248 return iFaceAttrib[aFaceIndex];
2251 /** Gets the number of typefaces in the typeface attributes array.
2253 This is the number of typefaces in the font file: the attributes for each
2254 typeface should be loaded into the array when the derived object is constructed.
2256 @return The number of typefaces in the font file.
2258 @see FaceAttrib() */
2259 inline TInt COpenFontFile::FaceCount() const
2261 return iFaceAttrib.Count();
2264 /** Increments a reference count by one.
2266 @see DecRefCount() */
2267 inline void COpenFontFile::IncRefCount()
2272 /** Decrement a reference count by one.
2274 @return ETrue if the reference count has reached zero (i.e. is less than or
2275 equal to zero); EFalse if the reference count has not yet reached zero (i.e.
2277 @see IncRefCount() */
2278 inline TBool COpenFontFile::DecRefCount()
2281 return iRefCount <= 0;
2284 /** Default C++ constructor. */
2285 inline COpenFontRasterizerContext::COpenFontRasterizerContext():
2290 /** Start writing the glyph data.
2292 Use this function to initialise the buffer to which the glyph bitmap is to
2293 be written. Call WriteGlyphBit() to add bits to the buffer.
2295 @param aGlyphData A pointer to the glyph data. */
2296 inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
2298 aGlyphData->SetPointersToInternalBuffers();
2299 iGlyphData = aGlyphData;
2300 iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
2301 // Allow 4 extra bytes; BITGDI requires this.
2302 iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
2309 /** Writes a bit to the glyph buffer.
2311 Before calling this function you should first call StartGlyph().
2313 @param aBit The bit to be added to the buffer. */
2314 inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
2316 if (aBit && !iOverflow)
2317 *iGlyphDataPtr |= iGlyphBit;
2319 if (iGlyphBit == 256)
2323 if (++iGlyphDataPtr < iGlyphDataEnd)
2330 /** Writes a byte to the glyph buffer.
2332 Before calling this function you should first call StartGlyph().
2334 @param aByte The byte to be added to the buffer. */
2335 inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
2337 if (iGlyphDataPtr < iGlyphDataEnd)
2338 *iGlyphDataPtr++ = (TUint8)aByte;
2344 /** Completes writing glyph data.
2346 Use this function to complete writing the glyph bitmap to the buffer. Call
2347 it after adding all necessary bits using WriteGlyphBit(). */
2348 inline void COpenFontRasterizerContext::EndGlyph()
2350 // Add 4 bytes to the data size; some BITGDI functions require this.
2351 iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
2355 /** Tests whether the bitmap buffer is large enough to hold the bitmap.
2357 @return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
2358 inline TBool TOpenFontGlyphData::Overflow() const
2360 return iBytesNeeded > iBitmapBufferSize;
2363 /** Gets the number of bytes needed to store the glyph bitmap.
2365 @return The number of bytes needed to store the glyph bitmap.
2366 @see SetBytesNeeded() */
2367 inline TInt TOpenFontGlyphData::BytesNeeded() const
2369 return iBytesNeeded;
2372 /** Gets a constant pointer descriptor containing the bitmap this object
2375 @return Pointer descriptor for the glyph. */
2376 inline TPtrC8 TOpenFontGlyphData::Bitmap() const
2378 return TPtrC8(iBitmap,iBytesNeeded);
2381 /** Gets a pointer to the bitmap.
2383 This points either to the buffer used to write the bitmap when it is first
2384 rasterized, or to the cache if the character was already rasterized.
2386 @return A pointer to the bitmap. */
2387 inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
2392 /** Gets the character's metrics.
2394 @return The character's open font metrics. */
2395 inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
2400 /** Gets a pointer to the start of the bitmap buffer.
2402 @return A pointer to the start of the bitmap buffer. */
2403 inline TUint8* TOpenFontGlyphData::BufferStart()
2405 return iBitmapBuffer;
2408 /** Gets a pointer to the end of the bitmap buffer.
2410 @return A pointer to the end of the bitmap buffer. */
2411 inline TUint8* TOpenFontGlyphData::BufferEnd()
2413 return iBitmapBuffer + iBitmapBufferSize;
2416 /** Sets the number of bytes needed to store the glyph bitmap.
2418 @param aBytes The number of bytes needed to store the glyph bitmap.
2419 @see BytesNeeded() */
2420 inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
2422 iBytesNeeded = aBytes;
2425 /** Sets the pointer to the bitmap buffer.
2427 @param aBitmap The pointer to the bitmap buffer. */
2428 inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
2433 /** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
2435 @param aMetrics A pointer to the character's open font character metrics. */
2436 inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
2438 iMetrics = aMetrics;
2441 /** Sets the bitmap and metrics pointers to point to the internal buffers.
2443 The alternative is that the pointers point to the cache of metrics and bitmaps
2444 that have already been rasterized. */
2445 inline void TOpenFontGlyphData::SetPointersToInternalBuffers()
2447 iBitmap = iBitmapBuffer;
2448 iMetrics = &iMetricsBuffer;
2451 /** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics
2454 @param aMetrics The character's open font character metrics. */
2455 inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
2457 iMetricsBuffer = aMetrics;
2458 iMetrics = &iMetricsBuffer;
2461 /** Sets the glyph index.
2463 @param aGlyphIndex The glyph index. */
2464 inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
2466 iGlyphIndex = aGlyphIndex;
2469 /** Uses ECOM plug-in framework to instantiate the shaper factory interface
2470 implementation given its implementation UID.
2472 @param aInterfaceImplUid The UID of the interface implementation required
2474 @return CShaperFactory* A pointer to a CShaperFactory object. */
2475 inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
2477 return reinterpret_cast <CShaperFactory*> (
2478 REComSession::CreateImplementationL(
2480 _FOFF(CShaperFactory, iDtor_ID_Key)));
2483 /** Default destructor */
2484 inline CShaperFactory::~CShaperFactory()
2486 REComSession::DestroyedImplementation(iDtor_ID_Key);
2489 #endif // __OPENFONT_H__