32
|
1 |
/*
|
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
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".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
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.
|
|
18 |
*
|
|
19 |
*/
|
|
20 |
|
|
21 |
|
|
22 |
#ifndef __OPENFONT_H__
|
|
23 |
#define __OPENFONT_H__
|
|
24 |
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <gdi.h>
|
|
27 |
#include <ecom/ecom.h>
|
|
28 |
|
|
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>
|
|
36 |
#endif
|
|
37 |
|
|
38 |
class CFont;
|
|
39 |
class COpenFontFile;
|
|
40 |
class COpenFontGlyph;
|
|
41 |
class COpenFontGlyphCache;
|
|
42 |
class COpenFontGlyphTreeEntry;
|
|
43 |
class COpenFontPositioner;
|
|
44 |
class COpenFontSessionCache;
|
|
45 |
class COpenFontSessionCacheList;
|
|
46 |
class RFs;
|
|
47 |
class TCharacterMetrics;
|
|
48 |
class TFontSpec;
|
|
49 |
class TOpenFontFaceAttrib;
|
|
50 |
class CFontStore;
|
|
51 |
class TOpenFontFileData;
|
|
52 |
class TShapeHeader;
|
|
53 |
class CBitmapFont;
|
|
54 |
class CShaperFactory;
|
|
55 |
class CShaper;
|
|
56 |
class TShapeHeader;
|
|
57 |
class TFontShapeFunctionParameters;
|
|
58 |
class TFontShapeDeleteFunctionParameters;
|
|
59 |
class RShapeInfo;
|
|
60 |
class TShapeMessageParameters;
|
|
61 |
class CRasterizerLinkedTypefaceSpecification;
|
|
62 |
class TLinkedTypefaceSpecificationArgs;
|
|
63 |
|
|
64 |
/**
|
|
65 |
Supplied to COpenFont::ExtendedInterface() to access the extended
|
|
66 |
API interface MOpenFontShapingExtension.
|
|
67 |
|
|
68 |
@see COpenFont::ExtendedInterface()
|
|
69 |
@see MOpenFontShapingExtension
|
|
70 |
@publishedAll
|
|
71 |
@released
|
|
72 |
*/
|
|
73 |
const TUid KUidOpenFontShapingExtension = {0x10274DB9};
|
|
74 |
|
|
75 |
/**
|
|
76 |
Supplied to COpenFont::ExtendedInterface() to access the extended
|
|
77 |
API interface MOpenFontTrueTypeExtension.
|
|
78 |
|
|
79 |
@see COpenFont::ExtendedInterface()
|
|
80 |
@see MOpenFontTrueTypeExtension
|
|
81 |
@publishedAll
|
|
82 |
@released
|
|
83 |
*/
|
|
84 |
const TUid KUidOpenFontTrueTypeExtension = {0x1027553E};
|
|
85 |
const TUid KUidOpenFontGlyphOutlineExtension = {0x102872CE};
|
|
86 |
|
|
87 |
/**
|
|
88 |
Supplied to CShaper::ExtendedInterface() to get the language and script
|
|
89 |
code with which the current shaper is instatsiated.
|
|
90 |
@see CShaper::ExtendedInterface()
|
|
91 |
@publishedAll
|
|
92 |
@released
|
|
93 |
*/
|
|
94 |
const TUid KUidShaperGetScript = {0x20009966};
|
|
95 |
const TUid KUidShaperGetLang = {0x20009967};
|
|
96 |
|
|
97 |
/**
|
|
98 |
Font metrics.
|
|
99 |
|
|
100 |
@see CFbsFont::GetFontMetrics()
|
|
101 |
@publishedAll
|
|
102 |
@released
|
|
103 |
*/
|
|
104 |
class TOpenFontMetrics
|
|
105 |
{
|
|
106 |
public:
|
|
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();
|
|
124 |
private:
|
|
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;
|
|
132 |
TInt16 iReserved;
|
|
133 |
};
|
|
134 |
|
|
135 |
|
|
136 |
/**
|
|
137 |
Character metrics includes more information than TCharacterMetrics.
|
|
138 |
|
|
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.
|
|
144 |
|
|
145 |
Note :
|
|
146 |
|
|
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.
|
|
149 |
|
|
150 |
@see CFont::GetCharacterData()
|
|
151 |
@see CFbsFont::GetCharacterData()
|
|
152 |
@publishedAll
|
|
153 |
@released
|
|
154 |
*/
|
|
155 |
class TOpenFontCharMetrics
|
|
156 |
{
|
|
157 |
public:
|
|
158 |
enum TUninitialized { EUninitialized };
|
|
159 |
public:
|
|
160 |
/** Default constructor initializes all members to 0. */
|
|
161 |
inline TOpenFontCharMetrics();
|
|
162 |
|
|
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;
|
|
187 |
private:
|
|
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
|
|
197 |
TInt16 iReserved;
|
|
198 |
};
|
|
199 |
|
|
200 |
|
|
201 |
/**
|
|
202 |
Font glyph data.
|
|
203 |
|
|
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.
|
|
207 |
|
|
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().
|
|
210 |
|
|
211 |
@see COpenFont::RasterizeL()
|
|
212 |
@publishedAll
|
|
213 |
@released
|
|
214 |
*/
|
|
215 |
class TOpenFontGlyphData
|
|
216 |
{
|
|
217 |
public:
|
|
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);
|
|
233 |
private:
|
|
234 |
/*
|
|
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.
|
|
237 |
*/
|
|
238 |
TOpenFontGlyphData();
|
|
239 |
~TOpenFontGlyphData();
|
|
240 |
private:
|
|
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.
|
|
252 |
};
|
|
253 |
|
|
254 |
class COpenFontGlyph;
|
|
255 |
/**
|
|
256 |
Open Font System font abstract base class.
|
|
257 |
|
|
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.
|
|
261 |
|
|
262 |
Writing derived classes construction:
|
|
263 |
|
|
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.
|
|
268 |
|
|
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.
|
|
273 |
|
|
274 |
Derived classes must implement the pure virtual function RasterizeL().
|
|
275 |
Information about this function is provided in the function definition below.
|
|
276 |
|
|
277 |
Information about deriving from this class is also provided in the API guide.
|
|
278 |
|
|
279 |
@see COpenFontFile::GetNearestFontInPixelsL()
|
|
280 |
@publishedAll
|
|
281 |
@released
|
|
282 |
*/
|
|
283 |
class COpenFont: public CBase
|
|
284 |
{
|
|
285 |
public:
|
|
286 |
/** Creates a bitmap for the specified Unicode character.
|
|
287 |
|
|
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
|
|
291 |
alone.
|
|
292 |
|
|
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.
|
|
296 |
|
|
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.
|
|
306 |
|
|
307 |
@param aCode The character code of the Unicode character for which the
|
|
308 |
bitmap is required.
|
|
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);
|
|
343 |
|
|
344 |
protected:
|
|
345 |
/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
|
|
346 |
*/
|
|
347 |
TInt PointerToThisOffset(const TAny* aAny);
|
|
348 |
/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
|
|
349 |
*/
|
|
350 |
TAny* ThisOffsetToPointer(const TInt aOffset);
|
|
351 |
|
|
352 |
protected:
|
|
353 |
RHeap* iHeap;
|
|
354 |
TOpenFontMetrics iMetrics;
|
|
355 |
private:
|
|
356 |
/** The shaper for performing complex character positioning and
|
|
357 |
substitution, if available. Null otherwise.
|
|
358 |
|
|
359 |
WARNING: Member variable for internal use ONLY. Compatibility is not guaranteed in future releases. Please access using the provided get/set APIs only.
|
|
360 |
*/
|
|
361 |
CShaper* iShaper;
|
|
362 |
|
|
363 |
protected:
|
|
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 */
|
|
370 |
TInt iFontMaxAscent;
|
|
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 */
|
|
380 |
TInt iFontLineGap;
|
|
381 |
private:
|
|
382 |
const COpenFontGlyph* Glyph(TInt aSessionHandle,TInt aCode) const;
|
|
383 |
protected:
|
|
384 |
|
|
385 |
/** WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
|
|
386 |
*/
|
|
387 |
const COpenFontGlyph* FontCacheGlyph(TInt aCode,TInt*& aNode);
|
|
388 |
const COpenFontGlyph* FontCacheGlyph(TInt aCode);
|
|
389 |
|
|
390 |
void SetGlyphCache(COpenFontGlyphCache* aGlyphCache);
|
|
391 |
|
|
392 |
private:
|
|
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);
|
|
396 |
|
|
397 |
COpenFontSessionCacheList* SessionCacheList()const;
|
|
398 |
|
|
399 |
void SetSessionCacheList(COpenFontSessionCacheList* aSessionCacheList);
|
|
400 |
|
|
401 |
void SetFile(COpenFontFile* aFile);
|
|
402 |
private:
|
|
403 |
|
|
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.
|
|
406 |
TInt iFileOffset;
|
|
407 |
|
|
408 |
TInt iFaceIndex; // index of the face in the font file
|
|
409 |
protected:
|
|
410 |
/**
|
|
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
|
|
413 |
@internalTechnology
|
|
414 |
*/
|
|
415 |
TInt iGlyphCacheOffset;
|
|
416 |
private:
|
|
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;
|
|
420 |
|
|
421 |
TAny* iReserved; // unused; for future expansion
|
|
422 |
};
|
|
423 |
|
|
424 |
/** Open Font System Extension Interface abstract base class.
|
|
425 |
|
|
426 |
COpenFont derivers should also derive from this interface to enable complex
|
|
427 |
font "shaping".
|
|
428 |
|
|
429 |
This interface should be returned by the overridden
|
|
430 |
COpenFont::ExtendedInterface function when KUidOpenFontShapingExtension is
|
|
431 |
supplied as the UID.
|
|
432 |
|
|
433 |
@see COpenFont
|
|
434 |
@see KUidOpenFontShapingExtension
|
|
435 |
@publishedAll
|
|
436 |
@released
|
|
437 |
*/
|
|
438 |
class MOpenFontShapingExtension
|
|
439 |
{
|
|
440 |
public:
|
|
441 |
/** Various font metrics. */
|
|
442 |
class TExtensionFontMetrics
|
|
443 |
{
|
|
444 |
public:
|
|
445 |
/** The number of font design units per em. */
|
|
446 |
TInt iUnitsPerEm;
|
|
447 |
/** The width of the font's em square in pixels. */
|
|
448 |
TReal iXPixelsPerEm;
|
|
449 |
/** The height of the font's em square in pixels. */
|
|
450 |
TReal iYPixelsPerEm;
|
|
451 |
/** The horizontal scaling factor from the font's transform;
|
|
452 |
the number of horizontal pixels per font unit. */
|
|
453 |
TReal iXScaleFactor;
|
|
454 |
/** The vertical scaling factor from the font's transform;
|
|
455 |
the number of vertical pixels per font unit. */
|
|
456 |
TReal iYScaleFactor;
|
|
457 |
private:
|
|
458 |
/** Reserved for future expansion. */
|
|
459 |
TInt iReserved[4];
|
|
460 |
};
|
|
461 |
|
|
462 |
/** Creates a bitmap for the specified Glyph code.
|
|
463 |
|
|
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
|
|
467 |
alone.
|
|
468 |
|
|
469 |
This function provides the same functionality as the
|
|
470 |
COpenFont::RasterizeL() except that the glyph code is supplied rather than
|
|
471 |
the unicode.
|
|
472 |
|
|
473 |
For more information:
|
|
474 |
@see COpenFont::RasterizeL()
|
|
475 |
|
|
476 |
@param aCode The glyph code of the character for which the bitmap is required.
|
|
477 |
@param aGlyphData The function puts its output here.
|
|
478 |
*/
|
|
479 |
virtual void RasterizeGlyphL(TInt aCode,TOpenFontGlyphData* aGlyphData) = 0;
|
|
480 |
|
|
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;
|
|
485 |
|
|
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;
|
|
495 |
|
|
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;
|
|
505 |
|
|
506 |
/** Returns font metrics.
|
|
507 |
@param aOut Font metrics returned. */
|
|
508 |
virtual void GetExtensionFontMetrics(TExtensionFontMetrics& aOut) = 0;
|
|
509 |
};
|
|
510 |
|
|
511 |
/** TrueType extension for Open Fonts.
|
|
512 |
|
|
513 |
If an open font is able to load TrueType or OpenType tables it should derive
|
|
514 |
from this class.
|
|
515 |
|
|
516 |
This class will be used by
|
|
517 |
|
|
518 |
This interface should be returned by the overridden
|
|
519 |
COpenFont::ExtendedInterface function when KUidOpenFontTrueTypeExtension is
|
|
520 |
supplied as the UID.
|
|
521 |
@see KUidOpenFontTrueTypeExtension
|
|
522 |
@publishedAll
|
|
523 |
@released
|
|
524 |
*/
|
|
525 |
class MOpenFontTrueTypeExtension
|
|
526 |
{
|
|
527 |
public:
|
|
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
|
|
531 |
the data returned.
|
|
532 |
@param aError
|
|
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
|
|
535 |
the font file.
|
|
536 |
@param aTag
|
|
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'.
|
|
540 |
@param aLength
|
|
541 |
The length of the table in bytes that has been returned or 0 if
|
|
542 |
unsuccessful.
|
|
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;
|
|
556 |
};
|
|
557 |
|
|
558 |
class MOpenFontGlyphOutlineExtension
|
|
559 |
{
|
|
560 |
public:
|
|
561 |
virtual TInt GetGlyphOutline(TUint aCode, TBool aIsGlyphId,
|
|
562 |
TBool aHinted, TAny*& aOutline, TInt& aLength) = 0;
|
|
563 |
};
|
|
564 |
/**
|
|
565 |
Font attribute base class.
|
|
566 |
|
|
567 |
This class is not intended for user derivation.
|
|
568 |
|
|
569 |
@see TOpenFontFaceAttrib
|
|
570 |
@see TOpenFontSpec
|
|
571 |
@publishedAll
|
|
572 |
@released
|
|
573 |
*/
|
|
574 |
class TOpenFontFaceAttribBase
|
|
575 |
{
|
|
576 |
public:
|
|
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;
|
|
598 |
|
|
599 |
// Unicode ranges for iCoverage[0] (see the TrueType documentation for other values which are not included)
|
|
600 |
enum
|
|
601 |
{
|
|
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
|
|
621 |
};
|
|
622 |
|
|
623 |
// Unicode ranges for iCoverage[1]
|
|
624 |
enum
|
|
625 |
{
|
|
626 |
ESymbolSets = 0xFFFE,
|
|
627 |
EKanaSets = 0x60000,
|
|
628 |
EHangulSet = 0x100000,
|
|
629 |
ECJKSet = 0x8000000
|
|
630 |
};
|
|
631 |
|
|
632 |
// Attribute flags
|
|
633 |
enum
|
|
634 |
{
|
|
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
|
|
639 |
};
|
|
640 |
|
|
641 |
// Other constants
|
|
642 |
enum
|
|
643 |
{
|
|
644 |
ENameLength = 32 // we allow 32 but names that are compatible with old-style fonts are limited to 24
|
|
645 |
};
|
|
646 |
protected:
|
|
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
|
|
653 |
TInt32 iReserved;
|
|
654 |
};
|
|
655 |
|
|
656 |
|
|
657 |
/**
|
|
658 |
Typeface attributes.
|
|
659 |
|
|
660 |
These attributes include the name, family name, and supported scripts.
|
|
661 |
|
|
662 |
@see CFbsFont::GetFaceAttrib()
|
|
663 |
@publishedAll
|
|
664 |
@released
|
|
665 |
*/
|
|
666 |
class TOpenFontFaceAttrib: public TOpenFontFaceAttribBase
|
|
667 |
{
|
|
668 |
public:
|
|
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);
|
|
685 |
private:
|
|
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
|
|
690 |
TInt32 iReserved2;
|
|
691 |
};
|
|
692 |
|
|
693 |
|
|
694 |
/**
|
|
695 |
Font specification allowing more attributes to be specified than TFontSpec.
|
|
696 |
|
|
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
|
|
702 |
fixed-point numbers.
|
|
703 |
|
|
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
|
|
707 |
font manufacturers.
|
|
708 |
@publishedAll
|
|
709 |
@released
|
|
710 |
*/
|
|
711 |
class TOpenFontSpec : public TOpenFontFaceAttribBase
|
|
712 |
{
|
|
713 |
public:
|
|
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);
|
|
741 |
public:
|
|
742 |
/** Algorithmic effects flags.
|
|
743 |
|
|
744 |
These can be combined using an OR operation.
|
|
745 |
|
|
746 |
WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases.
|
|
747 |
|
|
748 |
@deprecated Use FontEffect::TEffect instead.
|
|
749 |
*/
|
|
750 |
enum
|
|
751 |
{
|
|
752 |
/** Font is algorithmic bold. */
|
|
753 |
EAlgorithmicBold = 1,
|
|
754 |
/** Font has a drop shadow. */
|
|
755 |
EDropShadow = 2,
|
|
756 |
/** Font is an outline font. */
|
|
757 |
EOutline = 4
|
|
758 |
};
|
|
759 |
private:
|
|
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);
|
|
766 |
private:
|
|
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
|
|
775 |
|
|
776 |
TInt iReserved2;
|
|
777 |
};
|
|
778 |
|
|
779 |
/**
|
|
780 |
Font file abstract base class.
|
|
781 |
|
|
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.
|
|
787 |
|
|
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().
|
|
792 |
|
|
793 |
Writing derived classes construction:
|
|
794 |
|
|
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().
|
|
798 |
|
|
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.
|
|
804 |
|
|
805 |
Writing derived classes implement the pure virtual functions:
|
|
806 |
|
|
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.
|
|
811 |
|
|
812 |
@see COpenFontRasterizer::NewFontFileL()
|
|
813 |
@see CWsScreenDevice::AddFile()
|
|
814 |
@publishedAll
|
|
815 |
@released
|
|
816 |
*/
|
|
817 |
class COpenFontFile : public CBase
|
|
818 |
{
|
|
819 |
public:
|
|
820 |
/**
|
|
821 |
Gets the font which is the nearest to the given font specification.
|
|
822 |
|
|
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.
|
|
827 |
|
|
828 |
The other two arguments, aHeap and aSessionCacheList, should be passed to
|
|
829 |
the COpenFont constructor.
|
|
830 |
|
|
831 |
Implementations may use the utility function GetNearestFontHelper()
|
|
832 |
to get the attributes of the closest matching font.
|
|
833 |
|
|
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()
|
|
847 |
*/
|
|
848 |
virtual void GetNearestFontInPixelsL(
|
|
849 |
RHeap* aHeap, COpenFontSessionCacheList* aSessionCacheList,
|
|
850 |
const TOpenFontSpec& aDesiredFontSpec, TInt aPixelWidth, TInt aPixelHeight,
|
|
851 |
COpenFont*& aFont, TOpenFontSpec& aActualFontSpec) = 0;
|
|
852 |
|
|
853 |
/**
|
|
854 |
Gets the font which is the nearest to the given font specification.
|
|
855 |
|
|
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.
|
|
860 |
|
|
861 |
The other two arguments, aHeap and aSessionCacheList, should be passed to
|
|
862 |
the COpenFont constructor.
|
|
863 |
|
|
864 |
Implementations may use the utility function GetNearestFontHelper()
|
|
865 |
to get the attributes of the closest matching font.
|
|
866 |
|
|
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()
|
|
880 |
*/
|
|
881 |
virtual void GetNearestFontToDesignHeightInPixelsL(
|
|
882 |
RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
|
|
883 |
const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
|
|
884 |
COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/) {}
|
|
885 |
/**
|
|
886 |
Gets the font which is the nearest to the given font specification.
|
|
887 |
|
|
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.
|
|
892 |
|
|
893 |
The other two arguments, aHeap and aSessionCacheList, should be passed to
|
|
894 |
the COpenFont constructor.
|
|
895 |
|
|
896 |
Implementations may use the utility function GetNearestFontHelper()
|
|
897 |
to get the attributes of the closest matching font.
|
|
898 |
|
|
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()
|
|
913 |
*/
|
|
914 |
virtual void GetNearestFontToMaxHeightInPixelsL(
|
|
915 |
RHeap* /*aHeap*/, COpenFontSessionCacheList* /*aSessionCacheList*/,
|
|
916 |
const TOpenFontSpec& /*aDesiredFontSpec*/, TInt /*aPixelWidth*/, TInt /*aPixelHeight*/,
|
|
917 |
COpenFont*& /*aFont*/, TOpenFontSpec& /*aActualFontSpec*/, TInt /*aMaxHeight*/) {}
|
|
918 |
|
|
919 |
/** Tests whether a specified typeface contains a particular character.
|
|
920 |
|
|
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();
|
|
953 |
protected:
|
|
954 |
IMPORT_C TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
|
|
955 |
TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
|
|
956 |
private:
|
|
957 |
// A class to contain the public font attributes and private positioning information (for kerning, ligatures, etc.)
|
|
958 |
class TAttrib: public TOpenFontFaceAttrib
|
|
959 |
{
|
|
960 |
public:
|
|
961 |
COpenFontPositioner* iPositioner; // if non-null, positioning information for the typeface
|
|
962 |
};
|
|
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);
|
|
973 |
|
|
974 |
private:
|
|
975 |
CArrayFixFlat<TAttrib> iFaceAttrib;
|
|
976 |
TUid iUid;
|
|
977 |
TBuf<KMaxFileName> iFileName;
|
|
978 |
TInt iRefCount;
|
|
979 |
CArrayPtrFlat<COpenFont> iFontList;
|
|
980 |
TOpenFontFileData* iData;
|
|
981 |
};
|
|
982 |
|
|
983 |
/**
|
|
984 |
Convenience class from which rasterizer contexts may be derived.
|
|
985 |
|
|
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.
|
|
992 |
|
|
993 |
Deriving from this class is described in greater detail in the API guide.
|
|
994 |
@publishedAll
|
|
995 |
@released
|
|
996 |
*/
|
|
997 |
class COpenFontRasterizerContext: public CBase
|
|
998 |
{
|
|
999 |
public:
|
|
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();
|
|
1005 |
private:
|
|
1006 |
TOpenFontGlyphData* iGlyphData;
|
|
1007 |
TUint8* iGlyphDataStart;
|
|
1008 |
TUint8* iGlyphDataPtr;
|
|
1009 |
TUint8* iGlyphDataEnd;
|
|
1010 |
TInt iGlyphBit;
|
|
1011 |
TInt iBytesNeeded;
|
|
1012 |
TBool iOverflow;
|
|
1013 |
TAny* iReserved; // unused; for future expansion
|
|
1014 |
};
|
|
1015 |
|
|
1016 |
|
|
1017 |
/**
|
|
1018 |
Shaper abstract class. All shaper implementations derive from this
|
|
1019 |
@publishedAll
|
|
1020 |
@released
|
|
1021 |
*/
|
|
1022 |
class CShaper : public CBase
|
|
1023 |
{
|
|
1024 |
public:
|
|
1025 |
class TInput
|
|
1026 |
{
|
|
1027 |
public:
|
|
1028 |
/** The text to be shaped possibly including context. */
|
|
1029 |
const TDesC* iText;
|
|
1030 |
/** The index of the first character in iText to be shaped. */
|
|
1031 |
TInt iStart;
|
|
1032 |
/** (One past) the end of the text in iText to be shaped. */
|
|
1033 |
TInt iEnd;
|
|
1034 |
/** Script code, for example 'd'<<24 | 'e'<<16 | 'v'<<8 | 'a'
|
|
1035 |
for Devanagari. */
|
|
1036 |
TInt iScript;
|
|
1037 |
/** Language code. 0 implies "default" */
|
|
1038 |
TUint32 iLanguage;
|
|
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. */
|
|
1043 |
TInt iFlags;
|
|
1044 |
/** Session handle. To be used if rasterization is needed. */
|
|
1045 |
TInt iSessionHandle;
|
|
1046 |
/** Reserved for future expansion. Must be set to 0. */
|
|
1047 |
TInt iReserved1;
|
|
1048 |
};
|
|
1049 |
/** Constructor */
|
|
1050 |
IMPORT_C CShaper();
|
|
1051 |
|
|
1052 |
/** Destructor */
|
|
1053 |
IMPORT_C virtual ~CShaper();
|
|
1054 |
|
|
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;
|
|
1060 |
|
|
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;
|
|
1069 |
|
|
1070 |
/** For future expansion. Any overriders must base-call
|
|
1071 |
if aInterface is unrecognized.
|
|
1072 |
|
|
1073 |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
|
|
1074 |
|
|
1075 |
@param aInterfaceId The ID of the interface to return.
|
|
1076 |
@return A pointer to the extension interface.
|
|
1077 |
*/
|
|
1078 |
IMPORT_C virtual void* ExtendedInterface(TUid aInterfaceId);
|
|
1079 |
};
|
|
1080 |
|
|
1081 |
/** ECOM plug-in base class for shaper factories.
|
|
1082 |
@publishedAll
|
|
1083 |
@released
|
|
1084 |
*/
|
|
1085 |
class CShaperFactory : public CBase
|
|
1086 |
{
|
|
1087 |
public:
|
|
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;
|
|
1095 |
|
|
1096 |
inline static CShaperFactory* NewL(TUid aInterfaceImplUid);
|
|
1097 |
inline virtual ~CShaperFactory();
|
|
1098 |
|
|
1099 |
/** For future expansion. Any overriders must base-call if aInterface is unrecognized.
|
|
1100 |
|
|
1101 |
WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
|
|
1102 |
|
|
1103 |
@param aInterfaceId The ID of the interface to return.
|
|
1104 |
@return A pointer to the extension interface.
|
|
1105 |
*/
|
|
1106 |
virtual void* ExtendedInterface(TUid aInterfaceId);
|
|
1107 |
|
|
1108 |
private:
|
|
1109 |
TUid iDtor_ID_Key;//ECOM identifier used during destruction
|
|
1110 |
};
|
|
1111 |
|
|
1112 |
// Inline functions start here.
|
|
1113 |
/** Default C++ constructor.
|
|
1114 |
|
|
1115 |
This creates then zero fills the object. */
|
|
1116 |
inline TOpenFontMetrics::TOpenFontMetrics()
|
|
1117 |
{
|
|
1118 |
Mem::FillZ(this,sizeof(*this));
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
/** Gets the font's size.
|
|
1122 |
|
|
1123 |
@return The font's size.
|
|
1124 |
@see SetSize() */
|
|
1125 |
inline TInt TOpenFontMetrics::Size() const
|
|
1126 |
{
|
|
1127 |
return iDesignHeight;
|
|
1128 |
}
|
|
1129 |
|
|
1130 |
/** Gets the font's ascent.
|
|
1131 |
|
|
1132 |
This is the ascent for the Latin character which is highest above the baseline.
|
|
1133 |
|
|
1134 |
@return The font's ascent, in pixels.
|
|
1135 |
@see SetAscent() */
|
|
1136 |
inline TInt TOpenFontMetrics::Ascent() const
|
|
1137 |
{
|
|
1138 |
return iAscent;
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
/** Gets the font's descent.
|
|
1142 |
|
|
1143 |
This is the descent for the Latin character in the font which falls furthest below the baseline.
|
|
1144 |
|
|
1145 |
@return The font's descent, in pixels.
|
|
1146 |
@see SetDescent() */
|
|
1147 |
inline TInt TOpenFontMetrics::Descent() const
|
|
1148 |
{
|
|
1149 |
return iDescent;
|
|
1150 |
}
|
|
1151 |
|
|
1152 |
/** Sets the font's maximum height.
|
|
1153 |
|
|
1154 |
Note that if this object was initialised from the CFont this will be the same
|
|
1155 |
as the ascent.
|
|
1156 |
|
|
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.
|
|
1160 |
|
|
1161 |
@return The maximum height of the font, in pixels.
|
|
1162 |
@see SetMaxDepth() */
|
|
1163 |
inline TInt TOpenFontMetrics::MaxHeight() const
|
|
1164 |
{
|
|
1165 |
return iMaxHeight;
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
/** Gets the font's maximum depth.
|
|
1169 |
|
|
1170 |
Note: If this object was initialised from the CFont this will be the same as the
|
|
1171 |
descent.
|
|
1172 |
|
|
1173 |
This is the descent for the character in the font which falls furthest below
|
|
1174 |
the baseline.
|
|
1175 |
|
|
1176 |
@return The font's maximum depth.
|
|
1177 |
@see SetMaxDepth() */
|
|
1178 |
inline TInt TOpenFontMetrics::MaxDepth() const
|
|
1179 |
{
|
|
1180 |
return iMaxDepth;
|
|
1181 |
}
|
|
1182 |
|
|
1183 |
/** Gets the maximum character width, in pixels.
|
|
1184 |
|
|
1185 |
@return The maximum character width, in pixels.
|
|
1186 |
@see SetMaxWidth() */
|
|
1187 |
inline TInt TOpenFontMetrics::MaxWidth() const
|
|
1188 |
{
|
|
1189 |
return iMaxWidth;
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
/** Sets the font's size.
|
|
1193 |
|
|
1194 |
@param aSize The font's size.
|
|
1195 |
@see Size() */
|
|
1196 |
inline void TOpenFontMetrics::SetSize(TInt aSize)
|
|
1197 |
{
|
|
1198 |
iDesignHeight = static_cast<TInt16>(aSize);
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
/** Sets the ascent.
|
|
1202 |
|
|
1203 |
@param aAscent The ascent, in pixels.
|
|
1204 |
@see Ascent() */
|
|
1205 |
inline void TOpenFontMetrics::SetAscent(TInt aAscent)
|
|
1206 |
{
|
|
1207 |
iAscent = static_cast<TInt16>(aAscent);
|
|
1208 |
}
|
|
1209 |
|
|
1210 |
/** Sets the descent.
|
|
1211 |
|
|
1212 |
@param aDescent The descent, in pixels.
|
|
1213 |
@see Descent() */
|
|
1214 |
inline void TOpenFontMetrics::SetDescent(TInt aDescent)
|
|
1215 |
{
|
|
1216 |
iDescent = static_cast<TInt16>(aDescent);
|
|
1217 |
}
|
|
1218 |
|
|
1219 |
/** Sets the font's maximum height.
|
|
1220 |
|
|
1221 |
@param aMaxHeight The font's maximum height, in pixels.
|
|
1222 |
@see MaxHeight() */
|
|
1223 |
inline void TOpenFontMetrics::SetMaxHeight(TInt aMaxHeight)
|
|
1224 |
{
|
|
1225 |
iMaxHeight = static_cast<TInt16>(aMaxHeight);
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
/** Sets the font's maximum depth.
|
|
1229 |
|
|
1230 |
@param aMaxDepth The font's maximum depth, in pixels.
|
|
1231 |
@see MaxDepth() */
|
|
1232 |
inline void TOpenFontMetrics::SetMaxDepth(TInt aMaxDepth)
|
|
1233 |
{
|
|
1234 |
iMaxDepth = static_cast<TInt16>(aMaxDepth);
|
|
1235 |
}
|
|
1236 |
|
|
1237 |
/** Sets the maximum character width, in pixels.
|
|
1238 |
|
|
1239 |
@param aMaxWidth The maximum character width, in pixels.
|
|
1240 |
@see MaxWidth() */
|
|
1241 |
inline void TOpenFontMetrics::SetMaxWidth(TInt aMaxWidth)
|
|
1242 |
{
|
|
1243 |
iMaxWidth = static_cast<TInt16>(aMaxWidth);
|
|
1244 |
}
|
|
1245 |
|
|
1246 |
/** Default C++ constructor.
|
|
1247 |
|
|
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()
|
|
1251 |
{
|
|
1252 |
Mem::FillZ(this,sizeof(*this));
|
|
1253 |
}
|
|
1254 |
|
|
1255 |
/** Gets the width of the character's bitmap.
|
|
1256 |
|
|
1257 |
@return The width of the bitmap in pixels. */
|
|
1258 |
inline TInt TOpenFontCharMetrics::Width() const
|
|
1259 |
{
|
|
1260 |
return iWidth;
|
|
1261 |
}
|
|
1262 |
|
|
1263 |
/** Gets the height of the character's bitmap.
|
|
1264 |
|
|
1265 |
@return The character's height in pixels. */
|
|
1266 |
inline TInt TOpenFontCharMetrics::Height() const
|
|
1267 |
{
|
|
1268 |
return iHeight;
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
/** Gets the horizontal bearing X.
|
|
1272 |
|
|
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.
|
|
1276 |
|
|
1277 |
@return The horizontal bearing X in pixels */
|
|
1278 |
inline TInt TOpenFontCharMetrics::HorizBearingX() const
|
|
1279 |
{
|
|
1280 |
return iHorizBearingX;
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
/** Gets horizontal bearing Y.
|
|
1284 |
|
|
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
|
|
1288 |
|
|
1289 |
@return The horizontal bearing Y in pixels. */
|
|
1290 |
inline TInt TOpenFontCharMetrics::HorizBearingY() const
|
|
1291 |
{
|
|
1292 |
return iHorizBearingY;
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
/** Gets the horizontal advance.
|
|
1296 |
|
|
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.
|
|
1300 |
|
|
1301 |
@return The horizontal advance in pixels */
|
|
1302 |
inline TInt TOpenFontCharMetrics::HorizAdvance() const
|
|
1303 |
{
|
|
1304 |
return iHorizAdvance;
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
/** Gets the vertical bearing X.
|
|
1308 |
|
|
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.
|
|
1312 |
|
|
1313 |
@return The vertical bearing X in pixels. */
|
|
1314 |
inline TInt TOpenFontCharMetrics::VertBearingX() const
|
|
1315 |
{
|
|
1316 |
return iVertBearingX;
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
/** Gets the vertical bearing Y.
|
|
1320 |
|
|
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.
|
|
1324 |
|
|
1325 |
@return The vertical bearing Y in pixels. */
|
|
1326 |
inline TInt TOpenFontCharMetrics::VertBearingY() const
|
|
1327 |
{
|
|
1328 |
return iVertBearingY;
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
/** Gets the vertical advance.
|
|
1332 |
|
|
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
|
|
1336 |
is drawn.
|
|
1337 |
|
|
1338 |
Note: Vertical drawing is not supported in v5.
|
|
1339 |
|
|
1340 |
@return The vertical advance in pixels. */
|
|
1341 |
inline TInt TOpenFontCharMetrics::VertAdvance() const
|
|
1342 |
{
|
|
1343 |
return iVertAdvance;
|
|
1344 |
}
|
|
1345 |
|
|
1346 |
/** Gets the bounds of the character relative to its origin when setting text
|
|
1347 |
horizontally.
|
|
1348 |
|
|
1349 |
The origin here is the pen point before the character is drawn.
|
|
1350 |
|
|
1351 |
@param aBounds The character's bounds. */
|
|
1352 |
inline void TOpenFontCharMetrics::GetHorizBounds(TRect& aBounds) const
|
|
1353 |
{
|
|
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;
|
|
1358 |
}
|
|
1359 |
|
|
1360 |
/** Gets the bounds of the character relative to its origin when setting text
|
|
1361 |
vertically.
|
|
1362 |
|
|
1363 |
The origin here is the pen point before the character is drawn.
|
|
1364 |
|
|
1365 |
@param aBounds The character's bounds. */
|
|
1366 |
inline void TOpenFontCharMetrics::GetVertBounds(TRect& aBounds) const
|
|
1367 |
{
|
|
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;
|
|
1372 |
}
|
|
1373 |
|
|
1374 |
/** Sets the width of the character's bitmap.
|
|
1375 |
|
|
1376 |
@param aWidth The width of the bitmap in pixels. */
|
|
1377 |
inline void TOpenFontCharMetrics::SetWidth(TInt aWidth)
|
|
1378 |
{
|
|
1379 |
iWidth = (TInt16)aWidth;
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
/** Sets the height of the character's bitmap.
|
|
1383 |
|
|
1384 |
@param aHeight The character height (in pixels). */
|
|
1385 |
inline void TOpenFontCharMetrics::SetHeight(TInt aHeight)
|
|
1386 |
{
|
|
1387 |
iHeight = (TInt16)aHeight;
|
|
1388 |
}
|
|
1389 |
|
|
1390 |
/** Sets the horizontal bearing X.
|
|
1391 |
|
|
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.
|
|
1395 |
|
|
1396 |
@param aHorizBearingX The horizontal bearing X (in pixels). */
|
|
1397 |
inline void TOpenFontCharMetrics::SetHorizBearingX(TInt aHorizBearingX)
|
|
1398 |
{
|
|
1399 |
iHorizBearingX = (TInt16)aHorizBearingX;
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
/** Sets the horizontal bearing Y.
|
|
1403 |
|
|
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.
|
|
1407 |
|
|
1408 |
@param aHorizBearingY The horizontal bearing Y (in pixels). */
|
|
1409 |
inline void TOpenFontCharMetrics::SetHorizBearingY(TInt aHorizBearingY)
|
|
1410 |
{
|
|
1411 |
iHorizBearingY = (TInt16)aHorizBearingY;
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
/** Sets the horizontal advance.
|
|
1415 |
|
|
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.
|
|
1419 |
|
|
1420 |
@param aHorizAdvance The horizontal advance (in pixels). */
|
|
1421 |
inline void TOpenFontCharMetrics::SetHorizAdvance(TInt aHorizAdvance)
|
|
1422 |
{
|
|
1423 |
iHorizAdvance = (TInt16)aHorizAdvance;
|
|
1424 |
}
|
|
1425 |
|
|
1426 |
/** Set vertical bearing X.
|
|
1427 |
|
|
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.
|
|
1431 |
|
|
1432 |
@param aVertBearingX The vertical bearing X (in pixels). */
|
|
1433 |
inline void TOpenFontCharMetrics::SetVertBearingX(TInt aVertBearingX)
|
|
1434 |
{
|
|
1435 |
iVertBearingX = (TInt16)aVertBearingX;
|
|
1436 |
}
|
|
1437 |
|
|
1438 |
/** Sets the vertical bearing Y.
|
|
1439 |
|
|
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.
|
|
1443 |
|
|
1444 |
@param aVertBearingY The vertical bearing Y (in pixels). */
|
|
1445 |
inline void TOpenFontCharMetrics::SetVertBearingY(TInt aVertBearingY)
|
|
1446 |
{
|
|
1447 |
iVertBearingY = (TInt16)aVertBearingY;
|
|
1448 |
}
|
|
1449 |
|
|
1450 |
/** Sets the vertical advance.
|
|
1451 |
|
|
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
|
|
1455 |
is drawn.
|
|
1456 |
|
|
1457 |
Note: Vertical drawing is not supported in v5.
|
|
1458 |
|
|
1459 |
@param aVertAdvance The vertical advance (in pixels). */
|
|
1460 |
inline void TOpenFontCharMetrics::SetVertAdvance(TInt aVertAdvance)
|
|
1461 |
{
|
|
1462 |
iVertAdvance = (TInt16)aVertAdvance;
|
|
1463 |
}
|
|
1464 |
|
|
1465 |
/** Gets the character metrics for this font.
|
|
1466 |
|
|
1467 |
@return The character metrics for this font. */
|
|
1468 |
inline const TOpenFontMetrics& COpenFont::Metrics() const
|
|
1469 |
{
|
|
1470 |
return iMetrics;
|
|
1471 |
}
|
|
1472 |
|
|
1473 |
/** Gets the glyph index.
|
|
1474 |
|
|
1475 |
This is the index of a particular glyph within the font file.
|
|
1476 |
|
|
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
|
|
1479 |
Symbian OS.
|
|
1480 |
|
|
1481 |
@return The glyph index.
|
|
1482 |
@see SetGlyphIndex() */
|
|
1483 |
inline TInt TOpenFontGlyphData::GlyphIndex() const
|
|
1484 |
{
|
|
1485 |
return iGlyphIndex;
|
|
1486 |
}
|
|
1487 |
|
|
1488 |
/** Gets the typeface attributes.
|
|
1489 |
|
|
1490 |
These are the attributes of the font represented by this object.
|
|
1491 |
|
|
1492 |
@return The typeface attributes. */
|
|
1493 |
inline const TOpenFontFaceAttrib* COpenFont::FaceAttrib() const
|
|
1494 |
{
|
|
1495 |
return iFileOffset == 0 ? NULL : &File()->FaceAttrib(iFaceIndex);
|
|
1496 |
}
|
|
1497 |
|
|
1498 |
/** Gets a pointer to the COpenFontFile which created this object.
|
|
1499 |
|
|
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).
|
|
1503 |
|
|
1504 |
@return The COpenFontFile which created this object. */
|
|
1505 |
inline COpenFontFile* COpenFont::File() const
|
|
1506 |
{
|
|
1507 |
return iFileOffset == 0 ? NULL : reinterpret_cast<COpenFontFile*>(const_cast<COpenFont*>(PtrAdd(this, iFileOffset)));
|
|
1508 |
}
|
|
1509 |
|
|
1510 |
/** Gets the index of this typeface within the font file.
|
|
1511 |
|
|
1512 |
@return The index of this typeface within the font file. */
|
|
1513 |
inline TInt COpenFont::FaceIndex() const
|
|
1514 |
{
|
|
1515 |
return iFaceIndex;
|
|
1516 |
}
|
|
1517 |
|
|
1518 |
/** Tests whether or not a character needs to be rasterized.
|
|
1519 |
|
|
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
|
|
1522 |
Bitmap server.
|
|
1523 |
|
|
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
|
|
1528 |
{
|
|
1529 |
return Glyph(aSessionHandle,aCode) == NULL;
|
|
1530 |
}
|
|
1531 |
|
|
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
|
|
1536 |
@publishedAll
|
|
1537 |
@released
|
|
1538 |
@see AscentInPixels()
|
|
1539 |
*/
|
|
1540 |
inline TInt COpenFont::FontCapitalAscent() const
|
|
1541 |
{
|
|
1542 |
return iFontCapitalAscent;
|
|
1543 |
}
|
|
1544 |
|
|
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.
|
|
1550 |
|
|
1551 |
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
|
|
1552 |
|
|
1553 |
@return The positive distance from the font baseline to the top of the
|
|
1554 |
highest pre-composed glyph (including accents) above the baseline.
|
|
1555 |
@publishedAll
|
|
1556 |
@released
|
|
1557 |
@see AscentInPixels()
|
|
1558 |
@see SetScriptTypeForMetrics()
|
|
1559 |
*/
|
|
1560 |
inline TInt COpenFont::FontMaxAscent() const
|
|
1561 |
{
|
|
1562 |
return iFontMaxAscent;
|
|
1563 |
}
|
|
1564 |
|
|
1565 |
/** Gets the descent of an ANSI descending character in the font.
|
|
1566 |
Whether or not there are any ANSI descenders in the font.
|
|
1567 |
|
|
1568 |
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
|
|
1569 |
|
|
1570 |
@return The positive distance from the font baseline to the bottom of the
|
|
1571 |
lowest ANSI descender.
|
|
1572 |
@publishedAll
|
|
1573 |
@released
|
|
1574 |
@see DescentInPixels()
|
|
1575 |
@see SetScriptTypeForMetrics()
|
|
1576 |
*/
|
|
1577 |
inline TInt COpenFont::FontStandardDescent() const
|
|
1578 |
{
|
|
1579 |
return iFontStandardDescent;
|
|
1580 |
}
|
|
1581 |
|
|
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.
|
|
1586 |
|
|
1587 |
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
|
|
1588 |
|
|
1589 |
@return The positive distance from the font baseline to the bottom of the
|
|
1590 |
lowest pre-composed glyph (including accents) below the baseline
|
|
1591 |
@publishedAll
|
|
1592 |
@released
|
|
1593 |
@see DescentInPixels()
|
|
1594 |
@see SetScriptTypeForMetrics()
|
|
1595 |
*/
|
|
1596 |
inline TInt COpenFont::FontMaxDescent() const
|
|
1597 |
{
|
|
1598 |
return iFontMaxDescent;
|
|
1599 |
}
|
|
1600 |
|
|
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
|
|
1604 |
@publishedAll
|
|
1605 |
@released
|
|
1606 |
*/
|
|
1607 |
inline TInt COpenFont::FontLineGap() const
|
|
1608 |
{
|
|
1609 |
return iFontLineGap;
|
|
1610 |
}
|
|
1611 |
|
|
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.
|
|
1614 |
|
|
1615 |
The value may be affected by the TLanguage value set by SetScriptTypeForMetrics().
|
|
1616 |
|
|
1617 |
@return The positive maximum height of the font
|
|
1618 |
@publishedAll
|
|
1619 |
@released
|
|
1620 |
@see HeightInPixels()
|
|
1621 |
@see SetScriptTypeForMetrics()
|
|
1622 |
*/
|
|
1623 |
inline TInt COpenFont::FontMaxHeight() const
|
|
1624 |
{
|
|
1625 |
return iFontMaxAscent + iFontMaxDescent;
|
|
1626 |
}
|
|
1627 |
|
|
1628 |
/** Default C++ constructor.
|
|
1629 |
|
|
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()
|
|
1633 |
{
|
|
1634 |
Mem::FillZ(this,sizeof(*this));
|
|
1635 |
}
|
|
1636 |
|
|
1637 |
/** Default C++ constructor.
|
|
1638 |
|
|
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),
|
|
1643 |
iReserved2(0)
|
|
1644 |
{
|
|
1645 |
}
|
|
1646 |
|
|
1647 |
/** Tests for support of Latin characters.
|
|
1648 |
|
|
1649 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1650 |
characters. It does not imply exhaustive coverage.
|
|
1651 |
|
|
1652 |
@return ETrue if Latin characters are supported */
|
|
1653 |
inline TBool TOpenFontFaceAttribBase::HasLatin() const
|
|
1654 |
{
|
|
1655 |
return iCoverage[0] & ELatinSet;
|
|
1656 |
}
|
|
1657 |
|
|
1658 |
/** Tests for support of Greek characters.
|
|
1659 |
|
|
1660 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1661 |
characters. It does not imply exhaustive coverage.
|
|
1662 |
|
|
1663 |
@return ETrue if Greek characters are supported. */
|
|
1664 |
inline TBool TOpenFontFaceAttribBase::HasGreek() const
|
|
1665 |
{
|
|
1666 |
return iCoverage[0] & EGreekSet;
|
|
1667 |
}
|
|
1668 |
|
|
1669 |
/** Tests for support of Cyrillic characters.
|
|
1670 |
|
|
1671 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1672 |
characters. It does not imply exhaustive coverage.
|
|
1673 |
|
|
1674 |
@return ETrue if Cyrillic characters are supported. */
|
|
1675 |
inline TBool TOpenFontFaceAttribBase::HasCyrillic() const
|
|
1676 |
{
|
|
1677 |
return iCoverage[0] & ECyrillicSet;
|
|
1678 |
}
|
|
1679 |
|
|
1680 |
/** Tests for support of Japanese syllabic characters.
|
|
1681 |
|
|
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.
|
|
1685 |
|
|
1686 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1687 |
characters. It does not imply exhaustive coverage.
|
|
1688 |
|
|
1689 |
@return ETrue if Japanese characters are supported
|
|
1690 |
@see HasCJK() */
|
|
1691 |
inline TBool TOpenFontFaceAttribBase::HasKana() const
|
|
1692 |
{
|
|
1693 |
return iCoverage[1] & EKanaSets;
|
|
1694 |
}
|
|
1695 |
|
|
1696 |
/** Tests for support of Korean Hangul characters.
|
|
1697 |
|
|
1698 |
Korean may also make use of Chinese characters.
|
|
1699 |
|
|
1700 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1701 |
characters. It does not imply exhaustive coverage.
|
|
1702 |
|
|
1703 |
@return ETrue if Korean characters are supported
|
|
1704 |
@see HasCJK() */
|
|
1705 |
inline TBool TOpenFontFaceAttribBase::HasHangul() const
|
|
1706 |
{
|
|
1707 |
return iCoverage[1] & EHangulSet;
|
|
1708 |
}
|
|
1709 |
|
|
1710 |
/** Tests for support of Chinese ideographic characters.
|
|
1711 |
|
|
1712 |
These are used in Chinese, Japanese and Korean.
|
|
1713 |
|
|
1714 |
Note: A return value of ETrue implies that the font has a usable set of
|
|
1715 |
characters. It does not imply exhaustive coverage.
|
|
1716 |
|
|
1717 |
@return ETrue if Chinese ideographs are supported. */
|
|
1718 |
inline TBool TOpenFontFaceAttribBase::HasCJK() const
|
|
1719 |
{
|
|
1720 |
return iCoverage[1] & ECJKSet;
|
|
1721 |
}
|
|
1722 |
|
|
1723 |
/** Tests if the typeface contains symbols only.
|
|
1724 |
|
|
1725 |
@return ETrue if the typeface contains symbols only. */
|
|
1726 |
inline TBool TOpenFontFaceAttribBase::IsSymbol() const
|
|
1727 |
{
|
|
1728 |
return iCoverage[0] == 0 && iCoverage[2] == 0 && iCoverage[3] == 0 &&
|
|
1729 |
iCoverage[1] & ESymbolSets && !(iCoverage[1] & ~ESymbolSets);
|
|
1730 |
}
|
|
1731 |
|
|
1732 |
/** Tests if the typeface is inherently bold.
|
|
1733 |
|
|
1734 |
@return ETrue if the typeface is inherently bold. */
|
|
1735 |
inline TBool TOpenFontFaceAttribBase::IsBold() const
|
|
1736 |
{
|
|
1737 |
return iStyle & EBold;
|
|
1738 |
}
|
|
1739 |
|
|
1740 |
/** Tests if the typeface is inherently italic.
|
|
1741 |
|
|
1742 |
@return ETrue if the typeface is inherently italic. */
|
|
1743 |
inline TBool TOpenFontFaceAttribBase::IsItalic() const
|
|
1744 |
{
|
|
1745 |
return iStyle & EItalic;
|
|
1746 |
}
|
|
1747 |
|
|
1748 |
/** Tests if the typeface has serifs.
|
|
1749 |
|
|
1750 |
@return ETrue if the typeface has serifs. */
|
|
1751 |
inline TBool TOpenFontFaceAttribBase::IsSerif() const
|
|
1752 |
{
|
|
1753 |
return iStyle & ESerif;
|
|
1754 |
}
|
|
1755 |
|
|
1756 |
/** Tests if all the characters have the same width.
|
|
1757 |
|
|
1758 |
@return ETrue if all the characters have the same width. */
|
|
1759 |
inline TBool TOpenFontFaceAttribBase::IsMonoWidth() const
|
|
1760 |
{
|
|
1761 |
return iStyle & EMonoWidth;
|
|
1762 |
}
|
|
1763 |
|
|
1764 |
/** Gets the typeface's name.
|
|
1765 |
|
|
1766 |
@return Descriptor containing typeface name. */
|
|
1767 |
inline TPtrC TOpenFontFaceAttribBase::Name() const
|
|
1768 |
{
|
|
1769 |
return iName;
|
|
1770 |
}
|
|
1771 |
|
|
1772 |
/** Gets the full name.
|
|
1773 |
|
|
1774 |
The full name of the typeface includes style attributes like Italic, Bold,
|
|
1775 |
and Cursive.
|
|
1776 |
|
|
1777 |
@return The full name of the typeface.
|
|
1778 |
@see FamilyName() */
|
|
1779 |
inline TPtrC TOpenFontFaceAttrib::FullName() const
|
|
1780 |
{
|
|
1781 |
return Name();
|
|
1782 |
}
|
|
1783 |
|
|
1784 |
/** Gets the family name.
|
|
1785 |
|
|
1786 |
Note: The family name of the typeface does not include style attributes like
|
|
1787 |
"Italic".
|
|
1788 |
|
|
1789 |
@return The family name of the typeface.
|
|
1790 |
@see FullName() */
|
|
1791 |
inline TPtrC TOpenFontFaceAttrib::FamilyName() const
|
|
1792 |
{
|
|
1793 |
return iFamilyName;
|
|
1794 |
}
|
|
1795 |
|
|
1796 |
/** Gets the local full name.
|
|
1797 |
|
|
1798 |
The local full name of the typeface includes style attributes like Italic,
|
|
1799 |
Bold, and Cursive.
|
|
1800 |
|
|
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.
|
|
1804 |
|
|
1805 |
@return The local full name of the typeface. */
|
|
1806 |
inline TPtrC TOpenFontFaceAttrib::LocalFullName() const
|
|
1807 |
{
|
|
1808 |
return iLocalFullName;
|
|
1809 |
}
|
|
1810 |
|
|
1811 |
/** Gets the local family name.
|
|
1812 |
|
|
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.
|
|
1816 |
|
|
1817 |
Note: The family name of the typeface does not include style attributes like
|
|
1818 |
'Italic'.
|
|
1819 |
|
|
1820 |
@return The local family name of the typeface. */
|
|
1821 |
inline TPtrC TOpenFontFaceAttrib::LocalFamilyName() const
|
|
1822 |
{
|
|
1823 |
return iLocalFamilyName;
|
|
1824 |
}
|
|
1825 |
|
|
1826 |
/** Gets the short full name.
|
|
1827 |
|
|
1828 |
This is the full name of the typeface, truncated to KMaxTypefaceNameLength,
|
|
1829 |
if necessary.
|
|
1830 |
|
|
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.
|
|
1834 |
|
|
1835 |
@return The short full name of the typeface.
|
|
1836 |
@see FullName() */
|
|
1837 |
inline TPtrC TOpenFontFaceAttrib::ShortFullName() const
|
|
1838 |
{
|
|
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));
|
|
1841 |
}
|
|
1842 |
|
|
1843 |
/** Gets the short family name.
|
|
1844 |
|
|
1845 |
This is the family name, truncated to KMaxTypefaceNameLength, if necessary.
|
|
1846 |
|
|
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.
|
|
1850 |
|
|
1851 |
@return The short family name of the typeface.
|
|
1852 |
@see FamilyName() */
|
|
1853 |
inline TPtrC TOpenFontFaceAttrib::ShortFamilyName() const
|
|
1854 |
{
|
|
1855 |
return TPtrC(iFamilyName.Ptr(),Min(iFamilyName.Length(),KMaxTypefaceNameLength));
|
|
1856 |
}
|
|
1857 |
|
|
1858 |
/** Gets the short local full name.
|
|
1859 |
|
|
1860 |
This is the local full name of the typeface, truncated to KMaxTypefaceNameLength,
|
|
1861 |
if necessary.
|
|
1862 |
|
|
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.
|
|
1866 |
|
|
1867 |
@return The short local full name of the typeface.
|
|
1868 |
@see LocalFullName() */
|
|
1869 |
inline TPtrC TOpenFontFaceAttrib::ShortLocalFullName() const
|
|
1870 |
{
|
|
1871 |
return TPtrC(iLocalFullName.Ptr(),Min(iLocalFullName.Length(),KMaxTypefaceNameLength));
|
|
1872 |
}
|
|
1873 |
|
|
1874 |
/** Gets the short local family name.
|
|
1875 |
|
|
1876 |
This is the local family name of the typeface, truncated to KMaxTypefaceNameLength,
|
|
1877 |
if necessary.
|
|
1878 |
|
|
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.
|
|
1882 |
|
|
1883 |
@return The short local family name of the typeface.
|
|
1884 |
@see LocalFamilyName() */
|
|
1885 |
inline TPtrC TOpenFontFaceAttrib::ShortLocalFamilyName() const
|
|
1886 |
{
|
|
1887 |
return TPtrC(iLocalFamilyName.Ptr(),Min(iLocalFamilyName.Length(),KMaxTypefaceNameLength));
|
|
1888 |
}
|
|
1889 |
|
|
1890 |
/** Gets a pointer to the sets of flags that indicate the font's Unicode coverage.
|
|
1891 |
|
|
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.
|
|
1894 |
|
|
1895 |
Note: Some useful subsets are defined as anonymous enumerated constants at the end
|
|
1896 |
of this class, see ELatinSet etc.
|
|
1897 |
|
|
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
|
|
1903 |
{
|
|
1904 |
return iCoverage;
|
|
1905 |
}
|
|
1906 |
|
|
1907 |
/** Gets the minimum typeface size.
|
|
1908 |
|
|
1909 |
This is the smallest size that can be drawn legibly.
|
|
1910 |
|
|
1911 |
@return The minimum typeface size (in pixels). */
|
|
1912 |
inline TInt TOpenFontFaceAttrib::MinSizeInPixels() const
|
|
1913 |
{
|
|
1914 |
return iMinSizeInPixels;
|
|
1915 |
}
|
|
1916 |
|
|
1917 |
/** Sets the name attribute.
|
|
1918 |
|
|
1919 |
@param aName Descriptor containing typeface name. */
|
|
1920 |
inline void TOpenFontFaceAttribBase::SetName(const TDesC& aName)
|
|
1921 |
{
|
|
1922 |
iName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
/** Sets the full name.
|
|
1926 |
|
|
1927 |
@param aName The full name of the typeface.
|
|
1928 |
@see FullName() */
|
|
1929 |
inline void TOpenFontFaceAttrib::SetFullName(const TDesC& aName)
|
|
1930 |
{
|
|
1931 |
SetName(aName);
|
|
1932 |
}
|
|
1933 |
|
|
1934 |
/** Sets the family name.
|
|
1935 |
|
|
1936 |
@param aName The family name of the typeface.
|
|
1937 |
@see FamilyName() */
|
|
1938 |
inline void TOpenFontFaceAttrib::SetFamilyName(const TDesC& aName)
|
|
1939 |
{
|
|
1940 |
iFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
|
|
1941 |
}
|
|
1942 |
|
|
1943 |
/** Sets the local full name.
|
|
1944 |
|
|
1945 |
@param aName The local full name of the typeface.
|
|
1946 |
@see LocalFullName() */
|
|
1947 |
inline void TOpenFontFaceAttrib::SetLocalFullName(const TDesC& aName)
|
|
1948 |
{
|
|
1949 |
iLocalFullName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
|
|
1950 |
}
|
|
1951 |
|
|
1952 |
/** Sets the local family name.
|
|
1953 |
|
|
1954 |
@param aName The local family name of the typeface.
|
|
1955 |
@see LocalFamilyName() */
|
|
1956 |
inline void TOpenFontFaceAttrib::SetLocalFamilyName(const TDesC& aName)
|
|
1957 |
{
|
|
1958 |
iLocalFamilyName = TPtrC(aName.Ptr(),Min(aName.Length(),(TInt)ENameLength));
|
|
1959 |
}
|
|
1960 |
|
|
1961 |
/** Sets the coverage flags.
|
|
1962 |
|
|
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.
|
|
1967 |
|
|
1968 |
Note: Some useful subsets are defined as anonymous enumerated constants at
|
|
1969 |
the end of this class, see ELatinSet etc.
|
|
1970 |
|
|
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)
|
|
1976 |
{
|
|
1977 |
iCoverage[0] = aCoverage0;
|
|
1978 |
iCoverage[1] = aCoverage1;
|
|
1979 |
iCoverage[2] = aCoverage2;
|
|
1980 |
iCoverage[3] = aCoverage3;
|
|
1981 |
}
|
|
1982 |
|
|
1983 |
/** Set the minimum typeface size.
|
|
1984 |
|
|
1985 |
This is the smallest size that can be drawn legibly.
|
|
1986 |
|
|
1987 |
@param aSize Sets the minimum typeface size (in pixels).
|
|
1988 |
@see MinSizeInPixels() */
|
|
1989 |
inline void TOpenFontFaceAttrib::SetMinSizeInPixels(TInt aSize)
|
|
1990 |
{
|
|
1991 |
iMinSizeInPixels = aSize;
|
|
1992 |
}
|
|
1993 |
|
|
1994 |
/** Equality operator.
|
|
1995 |
|
|
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
|
|
1998 |
size in pixels.
|
|
1999 |
|
|
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
|
|
2003 |
{
|
|
2004 |
return TOpenFontFaceAttribBase::operator==(aAttrib) &&
|
|
2005 |
iFamilyName == aAttrib.iFamilyName &&
|
|
2006 |
iLocalFullName == aAttrib.iLocalFullName &&
|
|
2007 |
iLocalFamilyName == aAttrib.iLocalFamilyName &&
|
|
2008 |
iMinSizeInPixels == aAttrib.iMinSizeInPixels;
|
|
2009 |
}
|
|
2010 |
|
|
2011 |
/** Sets the bold attribute.
|
|
2012 |
|
|
2013 |
@param aBold The bold attribute takes this value: ETrue or EFalse. */
|
|
2014 |
inline void TOpenFontFaceAttribBase::SetBold(TBool aBold)
|
|
2015 |
{
|
|
2016 |
if (aBold)
|
|
2017 |
iStyle |= EBold;
|
|
2018 |
else
|
|
2019 |
iStyle &= ~EBold;
|
|
2020 |
}
|
|
2021 |
|
|
2022 |
/** Sets the italic attribute.
|
|
2023 |
|
|
2024 |
@param aItalic The italic attribute takes this value ETrue or EFalse. */
|
|
2025 |
inline void TOpenFontFaceAttribBase::SetItalic(TBool aItalic)
|
|
2026 |
{
|
|
2027 |
if (aItalic)
|
|
2028 |
iStyle |= EItalic;
|
|
2029 |
else
|
|
2030 |
iStyle &= ~EItalic;
|
|
2031 |
}
|
|
2032 |
|
|
2033 |
/** Sets the serif attribute.
|
|
2034 |
|
|
2035 |
@param aSerif The serif attribute takes this value ETrue or EFalse. */
|
|
2036 |
inline void TOpenFontFaceAttribBase::SetSerif(TBool aSerif)
|
|
2037 |
{
|
|
2038 |
if (aSerif)
|
|
2039 |
iStyle |= ESerif;
|
|
2040 |
else
|
|
2041 |
iStyle &= ~ESerif;
|
|
2042 |
}
|
|
2043 |
|
|
2044 |
/** Sets the mono-width attribute.
|
|
2045 |
|
|
2046 |
@param aMonoWidth The mono-width attribute takes this value: ETrue or EFalse. */
|
|
2047 |
inline void TOpenFontFaceAttribBase::SetMonoWidth(TBool aMonoWidth)
|
|
2048 |
{
|
|
2049 |
if (aMonoWidth)
|
|
2050 |
iStyle |= EMonoWidth;
|
|
2051 |
else
|
|
2052 |
iStyle &= ~EMonoWidth;
|
|
2053 |
}
|
|
2054 |
|
|
2055 |
/** Equality operator.
|
|
2056 |
|
|
2057 |
Compares this and a specified set of font attributes, including the coverage
|
|
2058 |
and the typeface name.
|
|
2059 |
|
|
2060 |
In version 6.1, and earlier, the return value was TInt.
|
|
2061 |
|
|
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
|
|
2066 |
{
|
|
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;
|
|
2073 |
}
|
|
2074 |
|
|
2075 |
/** Compares this and another open font specification. Compares all the properties
|
|
2076 |
of the two fonts.
|
|
2077 |
@publishedAll
|
|
2078 |
@released
|
|
2079 |
@param aFontSpec The open font specification to compare with this one.
|
|
2080 |
@return ETrue if all values are equal, EFalse if not.
|
|
2081 |
*/
|
|
2082 |
inline TBool TOpenFontSpec::operator==(const TOpenFontSpec& aOpenFontSpec) const
|
|
2083 |
{
|
|
2084 |
return
|
|
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);
|
|
2093 |
}
|
|
2094 |
|
|
2095 |
/** Gets the height of the font.
|
|
2096 |
|
|
2097 |
@return The height of the font, in pixels or twips.
|
|
2098 |
@see SetHeight() */
|
|
2099 |
inline TInt TOpenFontSpec::Height() const
|
|
2100 |
{
|
|
2101 |
return iHeight;
|
|
2102 |
}
|
|
2103 |
|
|
2104 |
/** Gets the algorithmic width factor.
|
|
2105 |
|
|
2106 |
@return The algorithmic width factor as a 16.16 fixed-point number.
|
|
2107 |
@see SetWidthFactor() */
|
|
2108 |
inline TInt32 TOpenFontSpec::WidthFactor() const
|
|
2109 |
{
|
|
2110 |
return iWidthFactor;
|
|
2111 |
}
|
|
2112 |
|
|
2113 |
/** Gets the algorithmic slant factor.
|
|
2114 |
|
|
2115 |
@return The algorithmic slant factor as a 16.16 fixed-point number.
|
|
2116 |
@see SetSlantFactor() */
|
|
2117 |
inline TInt32 TOpenFontSpec::SlantFactor() const
|
|
2118 |
{
|
|
2119 |
return iSlantFactor;
|
|
2120 |
}
|
|
2121 |
|
|
2122 |
/** Gets the anti-aliasing setting for the font, as set by SetBitmapType().
|
|
2123 |
|
|
2124 |
@return Indicates whether or not the font should be drawn using anti-aliasing. */
|
|
2125 |
inline TGlyphBitmapType TOpenFontSpec::BitmapType() const
|
|
2126 |
{
|
|
2127 |
return (TGlyphBitmapType)iBitmapType;
|
|
2128 |
}
|
|
2129 |
|
|
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.
|
|
2133 |
@publishedAll
|
|
2134 |
@released
|
|
2135 |
@return The font effects flags.
|
|
2136 |
@see TOpenFontSpec::SetEffects()
|
|
2137 |
*/
|
|
2138 |
inline TUint32 TOpenFontSpec::Effects() const
|
|
2139 |
{
|
|
2140 |
return iEffects;
|
|
2141 |
}
|
|
2142 |
|
|
2143 |
/** Gets the print position.
|
|
2144 |
|
|
2145 |
@return The print position. */
|
|
2146 |
inline TFontPrintPosition TOpenFontSpec::PrintPosition() const
|
|
2147 |
{
|
|
2148 |
return iPrintPosition;
|
|
2149 |
}
|
|
2150 |
|
|
2151 |
/** Sets the font's height.
|
|
2152 |
|
|
2153 |
@param aHeight The font's height, in pixels or twips.
|
|
2154 |
@see Height() */
|
|
2155 |
inline void TOpenFontSpec::SetHeight(TInt aHeight)
|
|
2156 |
{
|
|
2157 |
iHeight = aHeight;
|
|
2158 |
}
|
|
2159 |
|
|
2160 |
/** Sets the algorithmic width factor.
|
|
2161 |
|
|
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.
|
|
2166 |
|
|
2167 |
@param aWidthFactor The algorithmic width factor as a 16.16 fixed-point number.
|
|
2168 |
@see WidthFactor() */
|
|
2169 |
inline void TOpenFontSpec::SetWidthFactor(TInt32 aWidthFactor)
|
|
2170 |
{
|
|
2171 |
iWidthFactor = aWidthFactor;
|
|
2172 |
}
|
|
2173 |
|
|
2174 |
/** Sets the algorithmic slant factor.
|
|
2175 |
|
|
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).
|
|
2180 |
|
|
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
|
|
2185 |
on the character.
|
|
2186 |
|
|
2187 |
@param aSlantFactor The slant factor as a 16.16 fixed-point number.
|
|
2188 |
@see SlantFactor() */
|
|
2189 |
inline void TOpenFontSpec::SetSlantFactor(TInt32 aSlantFactor)
|
|
2190 |
{
|
|
2191 |
iSlantFactor = aSlantFactor;
|
|
2192 |
}
|
|
2193 |
|
|
2194 |
/** Sets whether the font should be drawn using anti-aliasing. If set, this value
|
|
2195 |
overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType())
|
|
2196 |
for this font.
|
|
2197 |
|
|
2198 |
Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing
|
|
2199 |
support for bitmapped fonts.
|
|
2200 |
|
|
2201 |
@param aBitmapType Indicates whether or not the font should be drawn using
|
|
2202 |
anti-aliasing. */
|
|
2203 |
inline void TOpenFontSpec::SetBitmapType(TGlyphBitmapType aBitmapType)
|
|
2204 |
{
|
|
2205 |
iBitmapType = aBitmapType;
|
|
2206 |
}
|
|
2207 |
|
|
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.
|
|
2211 |
@publishedAll
|
|
2212 |
@released
|
|
2213 |
@param aEffect The font effects flags to be set.
|
|
2214 |
@see TOpenFontSpec::Effects()
|
|
2215 |
*/
|
|
2216 |
inline void TOpenFontSpec::SetEffects(TUint32 aEffects)
|
|
2217 |
{
|
|
2218 |
iEffects = aEffects;
|
|
2219 |
}
|
|
2220 |
|
|
2221 |
/** Gets the font file's UID.
|
|
2222 |
|
|
2223 |
@return The uid of the file. */
|
|
2224 |
inline TUid COpenFontFile::Uid() const
|
|
2225 |
{
|
|
2226 |
return iUid;
|
|
2227 |
}
|
|
2228 |
|
|
2229 |
/** Gets the full path and filename of the font file
|
|
2230 |
|
|
2231 |
This is the filename that was passed to the constructor when the object is
|
|
2232 |
created.
|
|
2233 |
|
|
2234 |
@return The filename of the font file. */
|
|
2235 |
inline const TDesC& COpenFontFile::FileName() const
|
|
2236 |
{
|
|
2237 |
return iFileName;
|
|
2238 |
}
|
|
2239 |
|
|
2240 |
/** Gets the typeface at a specified index in the typeface attribute array.
|
|
2241 |
|
|
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.
|
|
2244 |
@see AddFaceL()
|
|
2245 |
@see FaceCount() */
|
|
2246 |
inline const TOpenFontFaceAttrib& COpenFontFile::FaceAttrib(TInt aFaceIndex) const
|
|
2247 |
{
|
|
2248 |
return iFaceAttrib[aFaceIndex];
|
|
2249 |
}
|
|
2250 |
|
|
2251 |
/** Gets the number of typefaces in the typeface attributes array.
|
|
2252 |
|
|
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.
|
|
2255 |
|
|
2256 |
@return The number of typefaces in the font file.
|
|
2257 |
@see AddFaceL()
|
|
2258 |
@see FaceAttrib() */
|
|
2259 |
inline TInt COpenFontFile::FaceCount() const
|
|
2260 |
{
|
|
2261 |
return iFaceAttrib.Count();
|
|
2262 |
}
|
|
2263 |
|
|
2264 |
/** Increments a reference count by one.
|
|
2265 |
|
|
2266 |
@see DecRefCount() */
|
|
2267 |
inline void COpenFontFile::IncRefCount()
|
|
2268 |
{
|
|
2269 |
iRefCount++;
|
|
2270 |
}
|
|
2271 |
|
|
2272 |
/** Decrement a reference count by one.
|
|
2273 |
|
|
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.
|
|
2276 |
is positive).
|
|
2277 |
@see IncRefCount() */
|
|
2278 |
inline TBool COpenFontFile::DecRefCount()
|
|
2279 |
{
|
|
2280 |
iRefCount--;
|
|
2281 |
return iRefCount <= 0;
|
|
2282 |
}
|
|
2283 |
|
|
2284 |
/** Default C++ constructor. */
|
|
2285 |
inline COpenFontRasterizerContext::COpenFontRasterizerContext():
|
|
2286 |
iGlyphData(NULL)
|
|
2287 |
{
|
|
2288 |
}
|
|
2289 |
|
|
2290 |
/** Start writing the glyph data.
|
|
2291 |
|
|
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.
|
|
2294 |
|
|
2295 |
@param aGlyphData A pointer to the glyph data. */
|
|
2296 |
inline void COpenFontRasterizerContext::StartGlyph(TOpenFontGlyphData* aGlyphData)
|
|
2297 |
{
|
|
2298 |
aGlyphData->SetPointersToInternalBuffers();
|
|
2299 |
iGlyphData = aGlyphData;
|
|
2300 |
iGlyphDataStart = iGlyphDataPtr = aGlyphData->BufferStart();
|
|
2301 |
// Allow 4 extra bytes; BITGDI requires this.
|
|
2302 |
iGlyphDataEnd = aGlyphData->BufferEnd() - 4;
|
|
2303 |
iGlyphBit = 1;
|
|
2304 |
*iGlyphDataPtr = 0;
|
|
2305 |
iBytesNeeded = 1;
|
|
2306 |
iOverflow = FALSE;
|
|
2307 |
}
|
|
2308 |
|
|
2309 |
/** Writes a bit to the glyph buffer.
|
|
2310 |
|
|
2311 |
Before calling this function you should first call StartGlyph().
|
|
2312 |
|
|
2313 |
@param aBit The bit to be added to the buffer. */
|
|
2314 |
inline void COpenFontRasterizerContext::WriteGlyphBit(TInt aBit)
|
|
2315 |
{
|
|
2316 |
if (aBit && !iOverflow)
|
|
2317 |
*iGlyphDataPtr |= iGlyphBit;
|
|
2318 |
iGlyphBit <<= 1;
|
|
2319 |
if (iGlyphBit == 256)
|
|
2320 |
{
|
|
2321 |
iGlyphBit = 1;
|
|
2322 |
iBytesNeeded++;
|
|
2323 |
if (++iGlyphDataPtr < iGlyphDataEnd)
|
|
2324 |
*iGlyphDataPtr = 0;
|
|
2325 |
else
|
|
2326 |
iOverflow = TRUE;
|
|
2327 |
}
|
|
2328 |
}
|
|
2329 |
|
|
2330 |
/** Writes a byte to the glyph buffer.
|
|
2331 |
|
|
2332 |
Before calling this function you should first call StartGlyph().
|
|
2333 |
|
|
2334 |
@param aByte The byte to be added to the buffer. */
|
|
2335 |
inline void COpenFontRasterizerContext::WriteGlyphByte(TInt aByte)
|
|
2336 |
{
|
|
2337 |
if (iGlyphDataPtr < iGlyphDataEnd)
|
|
2338 |
*iGlyphDataPtr++ = (TUint8)aByte;
|
|
2339 |
else
|
|
2340 |
iOverflow = TRUE;
|
|
2341 |
iBytesNeeded++;
|
|
2342 |
}
|
|
2343 |
|
|
2344 |
/** Completes writing glyph data.
|
|
2345 |
|
|
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()
|
|
2349 |
{
|
|
2350 |
// Add 4 bytes to the data size; some BITGDI functions require this.
|
|
2351 |
iGlyphData->SetBytesNeeded(iBytesNeeded + 4);
|
|
2352 |
iGlyphData = NULL;
|
|
2353 |
}
|
|
2354 |
|
|
2355 |
/** Tests whether the bitmap buffer is large enough to hold the bitmap.
|
|
2356 |
|
|
2357 |
@return ETrue if the bitmap will overflow its buffer, otherwise EFalse. */
|
|
2358 |
inline TBool TOpenFontGlyphData::Overflow() const
|
|
2359 |
{
|
|
2360 |
return iBytesNeeded > iBitmapBufferSize;
|
|
2361 |
}
|
|
2362 |
|
|
2363 |
/** Gets the number of bytes needed to store the glyph bitmap.
|
|
2364 |
|
|
2365 |
@return The number of bytes needed to store the glyph bitmap.
|
|
2366 |
@see SetBytesNeeded() */
|
|
2367 |
inline TInt TOpenFontGlyphData::BytesNeeded() const
|
|
2368 |
{
|
|
2369 |
return iBytesNeeded;
|
|
2370 |
}
|
|
2371 |
|
|
2372 |
/** Gets a constant pointer descriptor containing the bitmap this object
|
|
2373 |
represents.
|
|
2374 |
|
|
2375 |
@return Pointer descriptor for the glyph. */
|
|
2376 |
inline TPtrC8 TOpenFontGlyphData::Bitmap() const
|
|
2377 |
{
|
|
2378 |
return TPtrC8(iBitmap,iBytesNeeded);
|
|
2379 |
}
|
|
2380 |
|
|
2381 |
/** Gets a pointer to the bitmap.
|
|
2382 |
|
|
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.
|
|
2385 |
|
|
2386 |
@return A pointer to the bitmap. */
|
|
2387 |
inline const TUint8* TOpenFontGlyphData::BitmapPointer() const
|
|
2388 |
{
|
|
2389 |
return iBitmap;
|
|
2390 |
}
|
|
2391 |
|
|
2392 |
/** Gets the character's metrics.
|
|
2393 |
|
|
2394 |
@return The character's open font metrics. */
|
|
2395 |
inline const TOpenFontCharMetrics* TOpenFontGlyphData::Metrics() const
|
|
2396 |
{
|
|
2397 |
return iMetrics;
|
|
2398 |
}
|
|
2399 |
|
|
2400 |
/** Gets a pointer to the start of the bitmap buffer.
|
|
2401 |
|
|
2402 |
@return A pointer to the start of the bitmap buffer. */
|
|
2403 |
inline TUint8* TOpenFontGlyphData::BufferStart()
|
|
2404 |
{
|
|
2405 |
return iBitmapBuffer;
|
|
2406 |
}
|
|
2407 |
|
|
2408 |
/** Gets a pointer to the end of the bitmap buffer.
|
|
2409 |
|
|
2410 |
@return A pointer to the end of the bitmap buffer. */
|
|
2411 |
inline TUint8* TOpenFontGlyphData::BufferEnd()
|
|
2412 |
{
|
|
2413 |
return iBitmapBuffer + iBitmapBufferSize;
|
|
2414 |
}
|
|
2415 |
|
|
2416 |
/** Sets the number of bytes needed to store the glyph bitmap.
|
|
2417 |
|
|
2418 |
@param aBytes The number of bytes needed to store the glyph bitmap.
|
|
2419 |
@see BytesNeeded() */
|
|
2420 |
inline void TOpenFontGlyphData::SetBytesNeeded(TInt aBytes)
|
|
2421 |
{
|
|
2422 |
iBytesNeeded = aBytes;
|
|
2423 |
}
|
|
2424 |
|
|
2425 |
/** Sets the pointer to the bitmap buffer.
|
|
2426 |
|
|
2427 |
@param aBitmap The pointer to the bitmap buffer. */
|
|
2428 |
inline void TOpenFontGlyphData::SetBitmapPointer(const TUint8* aBitmap)
|
|
2429 |
{
|
|
2430 |
iBitmap = aBitmap;
|
|
2431 |
}
|
|
2432 |
|
|
2433 |
/** Sets the character's metrics, passing a pointer to a TOpenFontCharMetrics object.
|
|
2434 |
|
|
2435 |
@param aMetrics A pointer to the character's open font character metrics. */
|
|
2436 |
inline void TOpenFontGlyphData::SetMetricsPointer(const TOpenFontCharMetrics* aMetrics)
|
|
2437 |
{
|
|
2438 |
iMetrics = aMetrics;
|
|
2439 |
}
|
|
2440 |
|
|
2441 |
/** Sets the bitmap and metrics pointers to point to the internal buffers.
|
|
2442 |
|
|
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()
|
|
2446 |
{
|
|
2447 |
iBitmap = iBitmapBuffer;
|
|
2448 |
iMetrics = &iMetricsBuffer;
|
|
2449 |
}
|
|
2450 |
|
|
2451 |
/** Sets the character's metrics, passing a reference to a TOpenFontCharMetrics
|
|
2452 |
object.
|
|
2453 |
|
|
2454 |
@param aMetrics The character's open font character metrics. */
|
|
2455 |
inline void TOpenFontGlyphData::SetMetrics(TOpenFontCharMetrics& aMetrics)
|
|
2456 |
{
|
|
2457 |
iMetricsBuffer = aMetrics;
|
|
2458 |
iMetrics = &iMetricsBuffer;
|
|
2459 |
}
|
|
2460 |
|
|
2461 |
/** Sets the glyph index.
|
|
2462 |
|
|
2463 |
@param aGlyphIndex The glyph index. */
|
|
2464 |
inline void TOpenFontGlyphData::SetGlyphIndex(TInt aGlyphIndex)
|
|
2465 |
{
|
|
2466 |
iGlyphIndex = aGlyphIndex;
|
|
2467 |
}
|
|
2468 |
|
|
2469 |
/** Uses ECOM plug-in framework to instantiate the shaper factory interface
|
|
2470 |
implementation given its implementation UID.
|
|
2471 |
|
|
2472 |
@param aInterfaceImplUid The UID of the interface implementation required
|
|
2473 |
|
|
2474 |
@return CShaperFactory* A pointer to a CShaperFactory object. */
|
|
2475 |
inline CShaperFactory* CShaperFactory::NewL(TUid aInterfaceImplUid)
|
|
2476 |
{
|
|
2477 |
return reinterpret_cast <CShaperFactory*> (
|
|
2478 |
REComSession::CreateImplementationL(
|
|
2479 |
aInterfaceImplUid,
|
|
2480 |
_FOFF(CShaperFactory, iDtor_ID_Key)));
|
|
2481 |
}
|
|
2482 |
|
|
2483 |
/** Default destructor */
|
|
2484 |
inline CShaperFactory::~CShaperFactory()
|
|
2485 |
{
|
|
2486 |
REComSession::DestroyedImplementation(iDtor_ID_Key);
|
|
2487 |
}
|
|
2488 |
|
|
2489 |
#endif // __OPENFONT_H__
|