|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <gdi.h> |
|
17 #include <openfont.h> |
|
18 #include "GlyphSel.h" |
|
19 #include "FontThai.h" |
|
20 #include "FontArabic.h" |
|
21 #include "FontIndic.h" |
|
22 #include "GDIPANIC.h" |
|
23 #include "glyphsample.h" |
|
24 #include "gdiinline.inl" |
|
25 #include "gdistructs.h" |
|
26 #include "gdiconsts.h" |
|
27 |
|
28 /** |
|
29 Names holds the types & data associated with the glyph selection |
|
30 algorithm in CFont::GetCharacterPosition(). |
|
31 @internalComponent |
|
32 */ |
|
33 namespace GlyphSelection |
|
34 { |
|
35 |
|
36 typedef TBool (*ProcessFunc)(TGlyphSelectionState& aGss, RShapeInfo&); |
|
37 |
|
38 /** |
|
39 This structure defines the fields present in each row of the GlyphTable |
|
40 datat table below. |
|
41 @internalComponent |
|
42 */ |
|
43 struct TTableEntry |
|
44 { |
|
45 TUint iLow; |
|
46 TUint iHigh; |
|
47 ProcessFunc iProcessFunc; |
|
48 }; |
|
49 |
|
50 /** |
|
51 This table encodes the Unicode character ranges and the glyph selector |
|
52 classes to be used for each character range when processing characters |
|
53 into glyph clusters in CFont::GetCharacterPosition(). |
|
54 New glyph selection classes must make sure they are listed in this |
|
55 table to ensure they are invoked as required. |
|
56 A '0' iProcessFunc entry tells the algorithm to skip the character. |
|
57 @internalComponent |
|
58 */ |
|
59 static const TTableEntry Table[] = |
|
60 { |
|
61 // iLow, iHigh, iProcessFunc |
|
62 { 0x0000, 0x00AC, GlyphSelector_Default::Process}, |
|
63 { 0x00AD, 0x00AD, GlyphSelector_SoftHyphen::Process}, |
|
64 { 0x00AE, 0x05FF, GlyphSelector_Default::Process}, |
|
65 { 0x0600, 0x06FF, GlyphSelector_Arabic::Process}, |
|
66 { 0x0700, 0x08FF, GlyphSelector_Default::Process}, |
|
67 { 0x0900, 0x0970, GlyphSelector_Devanagari::Process}, |
|
68 { 0x0980, 0x09FF, GlyphSelector_Bengali::Process}, |
|
69 { 0x0A00, 0x0A7F, GlyphSelector_Gurmukhi::Process}, |
|
70 { 0x0A80, 0x0AFF, GlyphSelector_Gujarati::Process}, |
|
71 { 0x0B80, 0x0BFF, GlyphSelector_Tamil::Process}, |
|
72 { 0x0C00, 0x0C7F, GlyphSelector_Telugu::Process}, |
|
73 { 0x0C80, 0x0CFF, GlyphSelector_Kannada::Process}, |
|
74 { 0x0D00, 0x0D7F, GlyphSelector_Malayalam::Process}, |
|
75 { 0x0D80, 0x0DFF, GlyphSelector_Default::Process}, |
|
76 { 0x0E00, 0x0E32, GlyphSelector_Thai::Process}, |
|
77 { 0x0E33, 0x0E33, GlyphSelector_ThaiSaraAm::Process}, |
|
78 { 0x0E34, 0x0E7F, GlyphSelector_Thai::Process}, |
|
79 { 0x0E80, 0x200B, GlyphSelector_Default::Process}, |
|
80 { 0x200C, 0x200F, 0}, |
|
81 { 0x2010, 0x2029, GlyphSelector_Default::Process}, |
|
82 { 0x202A, 0x202E, 0}, |
|
83 { 0x202F, 0xFFFD, GlyphSelector_Default::Process}, |
|
84 { 0xFFFE, 0xFFFF, 0}, |
|
85 { 0x10000, 0x10FFFF, GlyphSelector_Default::Process}, |
|
86 {0xFFFFFFFF,0xFFFFFFFF, 0} |
|
87 }; |
|
88 } |
|
89 |
|
90 /** Find appropriate processor function for the given character. |
|
91 @param aChar Character for processing. |
|
92 @return processor function or 0 if the character is to be skipped. |
|
93 @internalComponent */ |
|
94 GlyphSelection::ProcessFunc CharacterToProcessFunction(TInt aChar) |
|
95 { |
|
96 for (const GlyphSelection::TTableEntry* glyphSel = GlyphSelection::Table; |
|
97 glyphSel->iLow != 0xFFFFFFFF; glyphSel++) |
|
98 { |
|
99 if ((glyphSel->iLow <= aChar) && (aChar <= glyphSel->iHigh)) |
|
100 return glyphSel->iProcessFunc; |
|
101 } |
|
102 return 0; |
|
103 } |
|
104 |
|
105 /** |
|
106 @internalTechnology For use by TFontStyle/TOpenFontSpec. |
|
107 */ |
|
108 EXPORT_C TBool FontEffect::IsEffectOn(TEffect aEffect, TUint32 aFontEffect) |
|
109 { |
|
110 return aEffect & aFontEffect; |
|
111 } |
|
112 |
|
113 /** |
|
114 @internalTechnology For use by TFontStyle/TOpenFontSpec. |
|
115 */ |
|
116 EXPORT_C void FontEffect::SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect) |
|
117 { |
|
118 if (aOn) |
|
119 aFontEffect |= aEffect; |
|
120 else |
|
121 aFontEffect &= ~aEffect; |
|
122 } |
|
123 |
|
124 |
|
125 // |
|
126 // TFontStyle |
|
127 // |
|
128 |
|
129 /** Default C++ constructor. */ |
|
130 EXPORT_C TFontStyle::TFontStyle(): |
|
131 iFlags(0), iReserved1(0), iReserved2(0) |
|
132 {} |
|
133 |
|
134 |
|
135 /** Constructs a TFontStyle object with the specified attributes. |
|
136 @param aPost The posture attribute. |
|
137 @param aStrWgt The stroke weight attribute. |
|
138 @param aPrintPos The print position attribute. */ |
|
139 EXPORT_C TFontStyle::TFontStyle(TFontPosture aPostr,TFontStrokeWeight aWgt,TFontPrintPosition aPos): |
|
140 iFlags(0), iReserved1(0), iReserved2(0) |
|
141 { |
|
142 if (aPostr == EPostureItalic) |
|
143 { |
|
144 iFlags |= EItalic; |
|
145 } |
|
146 if (aWgt == EStrokeWeightBold) |
|
147 { |
|
148 iFlags |= EBold; |
|
149 } |
|
150 if (aPos == EPrintPosSuperscript) |
|
151 { |
|
152 iFlags |= ESuper; |
|
153 } |
|
154 else if (aPos == EPrintPosSubscript) |
|
155 { |
|
156 iFlags |= ESub; |
|
157 } |
|
158 } |
|
159 |
|
160 |
|
161 EXPORT_C void TFontStyle::InternalizeL(RReadStream& aStream) |
|
162 /** Internalises a font style from a read stream. |
|
163 |
|
164 The presence of this function means that the standard templated operator>>() |
|
165 (defined in s32strm.h) is available to internalise objects of this class. |
|
166 |
|
167 @param aStream The stream from which the font style is to be internalised |
|
168 @leave KErrNoMemory If there is a problem reading from the stream. |
|
169 If internalisation causes an out of memory error. */ |
|
170 { |
|
171 iFlags = aStream.ReadUint32L(); |
|
172 } |
|
173 |
|
174 |
|
175 EXPORT_C void TFontStyle::ExternalizeL(RWriteStream& aStream) const |
|
176 /** Externalises the font style to a write stream. |
|
177 |
|
178 The presence of this function means that the standard templated operator<<() |
|
179 (defined in s32strm.h) is available to externalise objects of this class. |
|
180 |
|
181 @param aStream The stream to which the font style is to be externalised. |
|
182 @leave KErrNoMemory This function may leave, if the write action causes the |
|
183 stream's resources to be exhausted. */ |
|
184 { |
|
185 aStream.WriteUint32L(iFlags); |
|
186 } |
|
187 |
|
188 |
|
189 EXPORT_C TFontPosture TFontStyle::Posture() const |
|
190 /** Gets the posture attribute. |
|
191 |
|
192 @return The font style's posture. */ |
|
193 { |
|
194 if(iFlags&EItalic) return(EPostureItalic); |
|
195 return(EPostureUpright); |
|
196 } |
|
197 |
|
198 |
|
199 EXPORT_C TFontStrokeWeight TFontStyle::StrokeWeight() const |
|
200 /** Gets the stroke weight attribute. |
|
201 |
|
202 @return The font style's stroke weight. */ |
|
203 { |
|
204 if(iFlags&EBold) return(EStrokeWeightBold); |
|
205 return(EStrokeWeightNormal); |
|
206 } |
|
207 |
|
208 |
|
209 EXPORT_C TFontPrintPosition TFontStyle::PrintPosition() const |
|
210 /** Gets the print position attribute. |
|
211 |
|
212 @return The font style's print position. */ |
|
213 { |
|
214 if((iFlags&ESuper) && !(iFlags&ESub)) return(EPrintPosSuperscript); |
|
215 else if((iFlags&ESub) && !(iFlags&ESuper)) return(EPrintPosSubscript); |
|
216 return(EPrintPosNormal); |
|
217 } |
|
218 |
|
219 |
|
220 EXPORT_C void TFontStyle::SetPosture(TFontPosture aPosture) |
|
221 /** Sets the posture attribute. |
|
222 |
|
223 @param aPosture The posture to be set. */ |
|
224 { |
|
225 if(aPosture==EPostureItalic) iFlags|=EItalic; |
|
226 else iFlags&=~EItalic; |
|
227 } |
|
228 |
|
229 |
|
230 EXPORT_C void TFontStyle::SetStrokeWeight(TFontStrokeWeight aStrokeWeight) |
|
231 /** Sets the stroke weight attribute. |
|
232 |
|
233 @param aStrokeWeight The stroke weight to be set. */ |
|
234 { |
|
235 if(aStrokeWeight==EStrokeWeightBold) iFlags|=EBold; |
|
236 else iFlags&=~EBold; |
|
237 } |
|
238 |
|
239 |
|
240 EXPORT_C void TFontStyle::SetPrintPosition(TFontPrintPosition aPrintPosition) |
|
241 /** Sets the print position attribute. |
|
242 |
|
243 @param aPrintPosition The print position to be set. */ |
|
244 { |
|
245 switch(aPrintPosition) |
|
246 { |
|
247 case EPrintPosSuperscript: |
|
248 { |
|
249 iFlags|=ESuper; |
|
250 iFlags&=~ESub; |
|
251 break; |
|
252 } |
|
253 case EPrintPosSubscript: |
|
254 { |
|
255 iFlags&=~ESuper; |
|
256 iFlags|=ESub; |
|
257 break; |
|
258 } |
|
259 default: |
|
260 { |
|
261 iFlags&=~ESuper; |
|
262 iFlags&=~ESub; |
|
263 } |
|
264 } |
|
265 } |
|
266 |
|
267 /** Gets the font effects flags. |
|
268 @publishedAll |
|
269 @released |
|
270 @return The font effects flags. |
|
271 @see TFontStyle::SetEffects() |
|
272 */ |
|
273 EXPORT_C TUint32 TFontStyle::Effects() const |
|
274 { |
|
275 return 0xFFF0 & iFlags; |
|
276 } |
|
277 |
|
278 /** Checks if a font effect is on. |
|
279 @publishedAll |
|
280 @released |
|
281 @return True represents the specified font effect is on, otherwise off. |
|
282 @param aEffect The font effect to be checked. |
|
283 @see TFontStyle::SetEffects() |
|
284 */ |
|
285 EXPORT_C TBool TFontStyle::IsEffectOn(FontEffect::TEffect aEffect) const |
|
286 { |
|
287 return FontEffect::IsEffectOn(aEffect, iFlags); |
|
288 } |
|
289 |
|
290 /** Sets the font effects flags. |
|
291 @publishedAll |
|
292 @released |
|
293 @param aEffect The font effects flags to be set. |
|
294 @see TFontStyle::Effects() |
|
295 */ |
|
296 EXPORT_C void TFontStyle::SetEffects(TUint32 aEffects) |
|
297 { |
|
298 iFlags &= 0xFFFF000F; |
|
299 iFlags |= 0xFFF0 & aEffects; |
|
300 } |
|
301 |
|
302 /** Sets a font effect to the given state. |
|
303 @publishedAll |
|
304 @released |
|
305 @param aEffect The font effect to be set. |
|
306 @param aOn True represents on, otherwise off. |
|
307 @see TFontStyle::IsEffectOn() |
|
308 */ |
|
309 EXPORT_C void TFontStyle::SetEffects(FontEffect::TEffect aEffect, TBool aOn) |
|
310 { |
|
311 FontEffect::SetEffect(aEffect, aOn, iFlags); |
|
312 } |
|
313 |
|
314 /** Compares a font style for equality. |
|
315 @publishedAll |
|
316 @released |
|
317 @param aFontStyle The font style to be compared with this font style. |
|
318 @return ETrue, if this TFontStyle is equal to aFontStyle, EFalse, otherwise. |
|
319 */ |
|
320 EXPORT_C TBool TFontStyle::operator==(const TFontStyle& aFontStyle) const |
|
321 { |
|
322 return iFlags == aFontStyle.iFlags; |
|
323 } |
|
324 |
|
325 // |
|
326 // TFontSpec |
|
327 // |
|
328 EXPORT_C TFontSpec::TFontSpec(): |
|
329 iTypeface(), |
|
330 iHeight(0), |
|
331 iFontStyle() |
|
332 /** Default constructor. |
|
333 |
|
334 The object's font style is set to the default: EPostureUpright, EStrokeWeightNormal, |
|
335 and EPrintPosNormal. */ |
|
336 {} |
|
337 |
|
338 |
|
339 EXPORT_C TFontSpec::TFontSpec(const TDesC& aTypefaceName,TInt aHeight): |
|
340 iTypeface(), |
|
341 iHeight(aHeight), |
|
342 iFontStyle(EPostureUpright,EStrokeWeightNormal,EPrintPosNormal) |
|
343 /** Constructs a TFontSpec object with the specified typeface and height. |
|
344 |
|
345 The object's font style is set to the default: EPostureUpright, EStrokeWeightNormal, |
|
346 and EPrintPosNormal. |
|
347 |
|
348 @param aTypefaceName The name of the typeface (e.g. "Roman"). |
|
349 @param aHeight The height of the typeface, in twips. */ |
|
350 { |
|
351 iTypeface.iName=aTypefaceName; |
|
352 } |
|
353 |
|
354 |
|
355 EXPORT_C TBool TFontSpec::operator==(const TFontSpec& aFontSpec) const |
|
356 /** Compares this font specification with another. |
|
357 @param aFontSpec The font specification to be compared with this one. |
|
358 @return ETrue, if the TFontSpecs are identical, EFalse otherwise. |
|
359 */ |
|
360 { |
|
361 return |
|
362 iHeight == aFontSpec.iHeight && |
|
363 iFontStyle == aFontSpec.iFontStyle && |
|
364 iTypeface == aFontSpec.iTypeface; |
|
365 } |
|
366 |
|
367 |
|
368 EXPORT_C void TFontSpec::InternalizeL(RReadStream& aStream) |
|
369 /** Internalises a font specification from a read stream. |
|
370 |
|
371 The presence of this function means that the standard templated operator>>() |
|
372 (defined in s32strm.h) is available to internalise objects of this class. |
|
373 |
|
374 @param aStream The stream from which the font specification is to be internalised. |
|
375 @leave KErrNoMemory If internalisation causes an out of memory error. */ |
|
376 { |
|
377 iTypeface.InternalizeL(aStream); |
|
378 iHeight=aStream.ReadUint16L(); |
|
379 iFontStyle.InternalizeL(aStream); |
|
380 } |
|
381 |
|
382 |
|
383 EXPORT_C void TFontSpec::ExternalizeL(RWriteStream& aStream) const |
|
384 /** Externalises the font specification to a write stream. |
|
385 |
|
386 The presence of this function means that the standard templated operator<<() |
|
387 (defined in s32strm.h) is available to externalise objects of this class. |
|
388 |
|
389 @param aStream The stream to which the font specification is to be externalised |
|
390 |
|
391 @leave KErrNoMemory If the write action causes the stream's resources to be |
|
392 exhausted. */ |
|
393 { |
|
394 iTypeface.ExternalizeL(aStream); |
|
395 aStream.WriteUint16L(iHeight); |
|
396 iFontStyle.ExternalizeL(aStream); |
|
397 } |
|
398 |
|
399 EXPORT_C void TFontSpec::SetScriptTypeForMetrics(TLanguage aLanguage) |
|
400 /** Specifies the script with which font metrics calculation will be based on. |
|
401 @param aLanguage The language used to derive the required script. |
|
402 @publishedAll |
|
403 @released |
|
404 */ |
|
405 { |
|
406 iTypeface.SetScriptTypeForMetrics(aLanguage); |
|
407 } |
|
408 |
|
409 EXPORT_C TInt TFontSpec::ScriptTypeForMetrics() const |
|
410 /** Returns the script with which font metrics calculation will be based on. |
|
411 @internalTechnology |
|
412 */ |
|
413 { |
|
414 return iTypeface.ScriptTypeForMetrics(); |
|
415 } |
|
416 |
|
417 // |
|
418 // TTypeface |
|
419 // |
|
420 static const TInt KTTypefaceBitsNumAttrib = 3; |
|
421 static const TInt KTTypefaceBitsNumScript = 4; |
|
422 static const TInt KTTypefaceMaskAttrib = (1 << KTTypefaceBitsNumAttrib) - 1; |
|
423 static const TInt KTTypefaceMaskScript = ((1 << KTTypefaceBitsNumScript) - 1) << KTTypefaceBitsNumAttrib; |
|
424 EXPORT_C TTypeface::TTypeface(): |
|
425 iName(), |
|
426 iFlags(0) |
|
427 /** Default C++ constructor. */ |
|
428 {} |
|
429 |
|
430 /** |
|
431 @internalComponent |
|
432 */ |
|
433 void TTypeface::ResetAttributes() |
|
434 { |
|
435 iFlags &= KTTypefaceMaskScript; |
|
436 } |
|
437 |
|
438 /** |
|
439 @internalComponent |
|
440 */ |
|
441 void TTypeface::ResetScriptType() |
|
442 { |
|
443 iFlags &= KTTypefaceMaskAttrib; |
|
444 } |
|
445 |
|
446 EXPORT_C void TTypeface::InternalizeL(RReadStream& aStream) |
|
447 /** Internalises a typeface from a read stream. |
|
448 |
|
449 The presence of this function means that the standard templated operator>>() |
|
450 (defined in s32strm.h) is available to internalise objects of this class. |
|
451 |
|
452 @param aStream Stream from which the typeface is to be internalised. */ |
|
453 { |
|
454 TBuf<KMaxTypefaceNameLength> tempname; |
|
455 aStream >> tempname; |
|
456 new(&iName) TBufC<KMaxTypefaceNameLength>(tempname); |
|
457 iFlags = aStream.ReadInt8L(); |
|
458 } |
|
459 |
|
460 |
|
461 EXPORT_C void TTypeface::ExternalizeL(RWriteStream& aStream) const |
|
462 /** Externalises a typeface to a write stream. |
|
463 |
|
464 The presence of this function means that the standard templated operator<<() |
|
465 (defined in s32strm.h) is available to externalise objects of this class. |
|
466 |
|
467 @param aStream The stream to which the typeface is to be externalised. */ |
|
468 { |
|
469 aStream << iName; |
|
470 aStream.WriteInt8L(static_cast<TInt8>(iFlags)); |
|
471 } |
|
472 |
|
473 |
|
474 EXPORT_C TBool TTypeface::operator==(const TTypeface& aTypeface) const |
|
475 /** Compares two typefaces for equality. |
|
476 |
|
477 @param aTypeface The typeface to be compared with. |
|
478 @return ETrue, if this TTypeface is equal to aTypeface, otherwise EFalse. */ |
|
479 { |
|
480 return |
|
481 iFlags == aTypeface.iFlags && |
|
482 iName == aTypeface.iName; |
|
483 } |
|
484 |
|
485 EXPORT_C void TTypeface::SetAttributes(TInt aAttributes) |
|
486 /** Set the combination of attributes for this typeface. |
|
487 |
|
488 @param aAttributes A bitmap defining the combination of attributes. */ |
|
489 { |
|
490 ResetAttributes(); |
|
491 iFlags |= KTTypefaceMaskAttrib & aAttributes & (EProportional | ESerif | ESymbol); |
|
492 } |
|
493 |
|
494 |
|
495 EXPORT_C void TTypeface::SetIsProportional(TBool aIsProportional) |
|
496 /** Sets the typeface's proportional attribute. |
|
497 |
|
498 @param aIsProportional ETrue if the typeface is a proportional typeface, otherwise |
|
499 EFalse. */ |
|
500 { |
|
501 if (aIsProportional) |
|
502 { |
|
503 iFlags |= EProportional; |
|
504 } |
|
505 else |
|
506 { |
|
507 iFlags &= ~EProportional; |
|
508 } |
|
509 } |
|
510 |
|
511 |
|
512 EXPORT_C void TTypeface::SetIsSerif(TBool aIsSerif) |
|
513 /** Sets the typeface's serif attribute. |
|
514 |
|
515 @param aIsSerif ETrue if the typeface is a serif typeface, otherwise EFalse. */ |
|
516 { |
|
517 if (aIsSerif) |
|
518 { |
|
519 iFlags |= ESerif; |
|
520 } |
|
521 else |
|
522 { |
|
523 iFlags &= ~ESerif; |
|
524 } |
|
525 } |
|
526 |
|
527 |
|
528 EXPORT_C void TTypeface::SetIsSymbol(TBool aIsSymbol) |
|
529 /** Sets the typeface's symbol attribute. |
|
530 |
|
531 @param aIsSymbol ETrue if the typeface is a symbol typeface, otherwise EFalse. */ |
|
532 { |
|
533 if (aIsSymbol) |
|
534 { |
|
535 iFlags |= ESymbol; |
|
536 } |
|
537 else |
|
538 { |
|
539 iFlags &= ~ESymbol; |
|
540 } |
|
541 } |
|
542 |
|
543 |
|
544 EXPORT_C TInt TTypeface::Attributes() const |
|
545 /** Gets the combination of attributes of the typeface. |
|
546 |
|
547 @return The combination of attributes of the typeface. */ |
|
548 { |
|
549 return KTTypefaceMaskAttrib & iFlags; |
|
550 } |
|
551 |
|
552 |
|
553 EXPORT_C TBool TTypeface::IsProportional() const |
|
554 /** Gets the typeface's proportional attribute. |
|
555 |
|
556 @return ETrue if the typeface is proportional, EFalse otherwise. */ |
|
557 { |
|
558 return KTTypefaceMaskAttrib & iFlags & EProportional; |
|
559 } |
|
560 |
|
561 |
|
562 EXPORT_C TBool TTypeface::IsSerif() const |
|
563 /** Gets the typeface's serif attribute. |
|
564 |
|
565 @return ETrue if the typeface is a serif typeface, EFalse otherwise */ |
|
566 { |
|
567 return KTTypefaceMaskAttrib & iFlags & ESerif; |
|
568 } |
|
569 |
|
570 |
|
571 EXPORT_C TBool TTypeface::IsSymbol() const |
|
572 /** Gets the typeface's symbol attribute. |
|
573 |
|
574 @return ETrue if the typeface is a symbol typeface, EFalse otherwise */ |
|
575 { |
|
576 return KTTypefaceMaskAttrib & iFlags & ESymbol; |
|
577 } |
|
578 |
|
579 |
|
580 /** Specifies the script with which font metrics calculation will be based on. |
|
581 @param aLanguage The language used to derive the required script. |
|
582 @internalTechnology |
|
583 */ |
|
584 EXPORT_C void TTypeface::SetScriptTypeForMetrics(TLanguage aLanguage) |
|
585 { |
|
586 SetScriptTypeForMetrics(GlyphSample::TLanguage2TScript(aLanguage)); |
|
587 } |
|
588 |
|
589 /** Specifies the script with which font metrics calculation will be based on. |
|
590 @param aScript The script. |
|
591 @internalTechnology |
|
592 */ |
|
593 EXPORT_C void TTypeface::SetScriptTypeForMetrics(TInt aScript) |
|
594 { |
|
595 ResetScriptType(); |
|
596 iFlags |= KTTypefaceMaskScript & (aScript << KTTypefaceBitsNumAttrib); |
|
597 } |
|
598 |
|
599 /** Gets the script with which font metrics calculation will be based on. |
|
600 @return The script. |
|
601 @internalTechnology |
|
602 */ |
|
603 EXPORT_C TInt TTypeface::ScriptTypeForMetrics() const |
|
604 { |
|
605 return (KTTypefaceMaskScript & iFlags) >> KTTypefaceBitsNumAttrib; |
|
606 } |
|
607 |
|
608 |
|
609 // |
|
610 // CFont |
|
611 // |
|
612 |
|
613 /** Default destructor. */ |
|
614 EXPORT_C CFont::~CFont() |
|
615 {} |
|
616 |
|
617 _LIT(KGdiZeroCharacter,"0"); |
|
618 |
|
619 /** Gets the width of the zero character of this font in pixels. |
|
620 |
|
621 This function is provided as the "0" character is roughly the average width |
|
622 of the characters of any font. |
|
623 |
|
624 @return The width of the "0" character, in pixels. */ |
|
625 EXPORT_C TInt CFont::WidthZeroInPixels() const |
|
626 { |
|
627 return(TextWidthInPixels(KGdiZeroCharacter)); |
|
628 } |
|
629 |
|
630 |
|
631 /** Gets the font descent in pixels. |
|
632 It is defined to be HeightInPixels() minus AscentInPixels(). |
|
633 Note that this deprecated function is replaced by the new @c FontMaxDescent() |
|
634 or in some cases @c FontStandardDescent(). |
|
635 |
|
636 @return The font descent in pixels. |
|
637 @see FontStandardDescent() |
|
638 @see FontMaxDescent() |
|
639 @deprecated */ |
|
640 EXPORT_C TInt CFont::DoDescentInPixels() const |
|
641 { |
|
642 return HeightInPixels() - AscentInPixels(); |
|
643 } |
|
644 |
|
645 |
|
646 /** Checks to see if the pen position needs to be included in the bounds |
|
647 calculation for purposes of considering side-bearings in the line break point |
|
648 |
|
649 @param aInput The input block. Contains the check flag and maxbounds. |
|
650 @param aPenPos The current value of the pen position. |
|
651 @param aBoundsBR Bottom-right bounds value. |
|
652 @param aBoundsTL Top-left bounds value. |
|
653 @return Whether or not MaxBounds has been exceeded |
|
654 */ |
|
655 LOCAL_C TBool BoundsExceeded(const CFont::TMeasureTextInput& aInput, |
|
656 const TInt& aPenPos, TInt& aBoundsBR, TInt& aBoundsTL) |
|
657 { |
|
658 if (aInput.iFlags & CFont::TMeasureTextInput::EFIncludePenPositionInBoundsCheck) |
|
659 { |
|
660 if (aInput.iFlags & CFont::TMeasureTextInput::EFVisualOrderRightToLeft) |
|
661 { |
|
662 aBoundsTL = Min(aBoundsTL, aPenPos); |
|
663 } |
|
664 else |
|
665 { |
|
666 aBoundsBR = Max(aBoundsBR, aPenPos); |
|
667 } |
|
668 } |
|
669 return (aBoundsBR - aBoundsTL > aInput.iMaxBounds); |
|
670 } |
|
671 |
|
672 |
|
673 /** Text measurement function. |
|
674 |
|
675 This is a powerful text measurement function underlying all the |
|
676 other text measurement functions. It takes optional input and output |
|
677 parameter blocks, which may be null, and returns the advance |
|
678 width (change in pen position when drawn horizontally) of the text, or the advance |
|
679 height, if the text is drawn vertically. |
|
680 |
|
681 Some of the functions that can be performed using this |
|
682 function are listed below. Many of them are used by the Text Views |
|
683 API to do its typographic layout. |
|
684 - Get the advance width or advance height (return value). |
|
685 The advance width is the amount by which the pen advances when drawing |
|
686 the text horizontally, while the advance height is the amount by which |
|
687 the pen advances when drawing the text vertically. |
|
688 - Measure some text in context, so that shaping behaviour |
|
689 (e.g. in Arabic) can be affected by what comes before and after the |
|
690 text. Do this using TMeasureTextInput::iStartInputChar and |
|
691 TMeasureTextInput::iEndInputChar to tell the function where to start and end |
|
692 in the supplied descriptor. |
|
693 - Determine how much text fits a given size by setting |
|
694 TMeasureTextInput::iMaxAdvance or TMeasureTextInput::iMaxBounds. |
|
695 - Specify letter spacing and word spacing using TMeasureTextInput::iCharJustNum, |
|
696 TMeasureTextInput::iCharJustExcess, |
|
697 TMeasureTextInput::iWordJustNum and |
|
698 TMeasureTextInput::iWordJustExcess. |
|
699 - Get the number of characters drawn in TMeasureTextOutput::iChars |
|
700 when applying the various constraints in TMeasureTextInput. |
|
701 - Get the number of glyphs drawn in TMeasureTextOutput::iGlyphs. |
|
702 - Get the number of groups (formed by ligation or diacritic placement) in |
|
703 TMeasureTextOutput::iGroups. Groups are units of cursor |
|
704 movement: the cursor hops over a character-plus-accent group or an |
|
705 Arabic or other ligature in one go. |
|
706 - Get the number of word spaces in TMeasureTextOutput::iSpaces. |
|
707 - Get the bounds of the inked-in pixels in TMeasureTextOutput::iBounds. |
|
708 - Get the size of the biggest glyph that would be drawn in TMeasureTextOutput::iMaxGlyphSize. |
|
709 |
|
710 @param aText The text to be measured. |
|
711 @param aInput The input block. This may be NULL. |
|
712 @param aOutput The output block. This may be NULL. |
|
713 @return The advance width if the text is drawn horizontally or the advance |
|
714 height if the text is drawn vertically. |
|
715 |
|
716 @panic GDI 1 In debug builds only, if TMeasureTextInput::iStartInputChar is negative. |
|
717 */ |
|
718 EXPORT_C TInt CFont::MeasureText(const TDesC& aText,const TMeasureTextInput* aInput,TMeasureTextOutput* aOutput) const |
|
719 { |
|
720 TMeasureTextInput input; |
|
721 if (aInput) |
|
722 input = *aInput; |
|
723 if (aOutput) |
|
724 { |
|
725 Mem::FillZ(aOutput,sizeof(*aOutput)); |
|
726 aOutput->iChars = input.iStartInputChar; |
|
727 } |
|
728 TPositionParam param; |
|
729 param.iDirection = input.iDirection; |
|
730 |
|
731 TBool vertical = param.iDirection == EVertical; |
|
732 TBool penMovesLeft = EFalse; |
|
733 if (input.iFlags & TMeasureTextInput::EFVisualOrderRightToLeft) |
|
734 { |
|
735 if (!vertical) |
|
736 penMovesLeft = ETrue; |
|
737 param.iFlags |= TPositionParam::EFLogicalOrder; |
|
738 } |
|
739 else if (!(input.iFlags & TMeasureTextInput::EFVisualOrder)) |
|
740 param.iFlags |= TPositionParam::EFLogicalOrder; |
|
741 |
|
742 |
|
743 param.iText.Set(aText); |
|
744 |
|
745 int advance = 0; |
|
746 int groups = 0; |
|
747 int spaces = 0; |
|
748 param.iPosInText = input.iStartInputChar; |
|
749 int end_char = Min(aText.Length(),input.iEndInputChar); |
|
750 TRect bounds; |
|
751 // Total advance if pen is moving left. Positive. |
|
752 TInt rightToLeftAdvance = 0; |
|
753 // Shaping information of the text |
|
754 RShapeInfo shapeInfo; |
|
755 while (param.iPosInText < end_char) |
|
756 { |
|
757 if (!GetCharacterPosition2(param, shapeInfo)) |
|
758 { |
|
759 if (aOutput) |
|
760 aOutput->iChars = param.iPosInText; |
|
761 continue; |
|
762 } |
|
763 |
|
764 int new_advance = vertical ? param.iPen.iY : param.iPen.iX; |
|
765 if (input.iCharJustExcess != 0) |
|
766 new_advance += CGraphicsContext::JustificationInPixels(input.iCharJustExcess,input.iCharJustNum,groups,1); |
|
767 groups++; |
|
768 // Allow justification to occur at spaces |
|
769 if (param.iOutput[0].iCode == 0x0020) |
|
770 { |
|
771 if (input.iWordJustExcess != 0) |
|
772 new_advance += CGraphicsContext::JustificationInPixels(input.iWordJustExcess,input.iWordJustNum,spaces,1); |
|
773 spaces++; |
|
774 } |
|
775 if (vertical) |
|
776 param.iPen.iY = new_advance; |
|
777 else |
|
778 param.iPen.iX = new_advance; |
|
779 |
|
780 if (penMovesLeft) |
|
781 { |
|
782 // If the pen is moving left, we will begin each cluster at (0,0) |
|
783 // and shift the bounds to the right to compensate. |
|
784 bounds.iTl.iX += param.iPen.iX; |
|
785 bounds.iBr.iX += param.iPen.iX; |
|
786 bounds.iTl.iY += param.iPen.iY; |
|
787 bounds.iBr.iY += param.iPen.iY; |
|
788 rightToLeftAdvance += param.iPen.iX; |
|
789 new_advance = rightToLeftAdvance; |
|
790 param.iPen.iX = 0; |
|
791 param.iPen.iY = 0; |
|
792 } |
|
793 |
|
794 if (aInput || aOutput) |
|
795 { |
|
796 const TPositionParam::TOutput* output = param.iOutput; |
|
797 for (int i = 0; i < param.iOutputGlyphs; i++, output++) |
|
798 { |
|
799 //if (!output->iBounds.IsEmpty()) -- optimized to: |
|
800 if (output->iBounds.iTl.iX != output->iBounds.iBr.iX |
|
801 || output->iBounds.iTl.iY != output->iBounds.iBr.iY) |
|
802 { |
|
803 if (aOutput) |
|
804 { |
|
805 // increase iMaxGlyphSize if either dimension smaller than |
|
806 // current glyph |
|
807 TInt boundsDim = output->iBounds.iBr.iX - output->iBounds.iTl.iX; |
|
808 aOutput->iMaxGlyphSize.iWidth = aOutput->iMaxGlyphSize.iWidth < boundsDim? |
|
809 boundsDim : aOutput->iMaxGlyphSize.iWidth; |
|
810 boundsDim = output->iBounds.iBr.iY - output->iBounds.iTl.iY; |
|
811 aOutput->iMaxGlyphSize.iHeight = aOutput->iMaxGlyphSize.iHeight < boundsDim? |
|
812 boundsDim : aOutput->iMaxGlyphSize.iHeight; |
|
813 } |
|
814 //bounds.BoundingRect(output->iBounds); -- optimized to: |
|
815 if (output->iBounds.iTl.iX < bounds.iTl.iX) |
|
816 bounds.iTl.iX = output->iBounds.iTl.iX; |
|
817 if (bounds.iBr.iX < output->iBounds.iBr.iX) |
|
818 bounds.iBr.iX = output->iBounds.iBr.iX; |
|
819 if (output->iBounds.iTl.iY < bounds.iTl.iY) |
|
820 bounds.iTl.iY = output->iBounds.iTl.iY; |
|
821 if (bounds.iBr.iY < output->iBounds.iBr.iY) |
|
822 bounds.iBr.iY = output->iBounds.iBr.iY; |
|
823 } |
|
824 } |
|
825 |
|
826 // Would any limits be exceeded by adding this group? |
|
827 if (param.iPosInText > end_char) |
|
828 break; |
|
829 if (new_advance > input.iMaxAdvance) |
|
830 break; |
|
831 if (vertical) |
|
832 { |
|
833 if (BoundsExceeded(input, param.iPen.iY, bounds.iBr.iY, bounds.iTl.iY)) |
|
834 break; |
|
835 } |
|
836 else |
|
837 { |
|
838 if (BoundsExceeded(input, param.iPen.iX, bounds.iBr.iX, bounds.iTl.iX)) |
|
839 break; |
|
840 } |
|
841 |
|
842 if (aOutput) |
|
843 { |
|
844 aOutput->iChars = param.iPosInText; // should this not be aOutput->iChars = param.iPosInText - input.iShartInputChar;? |
|
845 aOutput->iGlyphs += param.iOutputGlyphs; |
|
846 aOutput->iGroups = groups; |
|
847 aOutput->iSpaces = spaces; |
|
848 aOutput->iBounds = bounds; |
|
849 } |
|
850 } |
|
851 |
|
852 advance = new_advance; |
|
853 } |
|
854 if(shapeInfo.IsOpen()) |
|
855 shapeInfo.Close(); |
|
856 return advance; |
|
857 } |
|
858 |
|
859 // These 3 functions should probably be moved to E32/Euser as part of TChar or |
|
860 // similar as there seem to be several local copies of similar functions in |
|
861 // various OS modules so we should remove duplication |
|
862 |
|
863 TUint16 HighSurrogate(TUint aCode) |
|
864 { |
|
865 GDI_ASSERT_DEBUG(aCode > 0xFFFF, EGdiPanic_InvalidInputParam); |
|
866 return STATIC_CAST(TUint16, 0xD7C0 + (aCode >> 10)); |
|
867 } |
|
868 |
|
869 TUint16 LowSurrogate(TUint aCode) |
|
870 { |
|
871 GDI_ASSERT_DEBUG(aCode > 0xFFFF, EGdiPanic_InvalidInputParam); |
|
872 return STATIC_CAST(TUint16, 0xDC00 | (aCode & 0x3FF)); |
|
873 } |
|
874 |
|
875 TUint CombineSurrogates(TUint aHighSurrogate, TUint aLowSurrogate) |
|
876 { |
|
877 GDI_ASSERT_DEBUG((0xD800 == (aHighSurrogate & 0xF800)), EGdiPanic_InvalidInputParam); |
|
878 GDI_ASSERT_DEBUG((0xD800 == (aHighSurrogate & 0xFC00)), EGdiPanic_InvalidInputParam); |
|
879 GDI_ASSERT_DEBUG((0xDC00 == (aLowSurrogate & 0xFC00)), EGdiPanic_InvalidInputParam); |
|
880 return ((aHighSurrogate - 0xD7F7) << 10) + aLowSurrogate; |
|
881 } |
|
882 |
|
883 |
|
884 /** Overridable function innards of GetCharacterPosition and |
|
885 GetCharacterPosition2. It is generally not useful to override this function. |
|
886 @publishedAll |
|
887 @see GetCharacterPosition |
|
888 @see GetCharacterPosition2 |
|
889 */ |
|
890 EXPORT_C TBool CFont::DoGetCharacterPosition(TPositionParam& aParam) const |
|
891 { |
|
892 RShapeInfo shapeInfo; |
|
893 TBool r = GetCharacterPosition2(aParam, shapeInfo); |
|
894 if (shapeInfo.IsOpen()) |
|
895 shapeInfo.Close(); |
|
896 return r; |
|
897 } |
|
898 |
|
899 // Find the script (and hence the correct process function) that any punctuation or digit may belong to |
|
900 LOCAL_C GlyphSelection::ProcessFunc FindContextualProcessFunc(RShapeInfo& aShapeInfo, const TGlyphSelectionState aGss) |
|
901 { |
|
902 GlyphSelection::ProcessFunc processFunc = CharacterToProcessFunction(aGss.iCodeChar); |
|
903 GlyphSelection::ProcessFunc contextProcessFunc = (GlyphSelection::ProcessFunc)aShapeInfo.GetContext(); |
|
904 |
|
905 // If context or prevCode is NULL, use processFunc, |
|
906 // else use function of context or prevCode |
|
907 if ((aGss.iCodeChar.IsDigit() || aGss.iCodeChar.IsPunctuation()) && !QuoteOrBracketPair(aGss.iCodeChar) && processFunc!=GlyphSelector_SoftHyphen::Process) |
|
908 { |
|
909 // If context is not set, check the previous char for context. |
|
910 if (contextProcessFunc == NULL) |
|
911 { |
|
912 if (aGss.iParam.iPosInText > 0) |
|
913 { |
|
914 TChar prevCode = aGss.iText.Get(-1); |
|
915 GlyphSelection::ProcessFunc prevProcessFunc = CharacterToProcessFunction(prevCode); |
|
916 if (prevProcessFunc != NULL && (prevCode.IsAlpha() || prevProcessFunc != GlyphSelector_Default::Process)) |
|
917 { |
|
918 aShapeInfo.SetContext((TAny *)prevProcessFunc); |
|
919 return prevProcessFunc; |
|
920 } |
|
921 } |
|
922 } |
|
923 else |
|
924 return contextProcessFunc; |
|
925 |
|
926 return processFunc; |
|
927 } |
|
928 |
|
929 // set the context with current processFunc only if current char is not ignored for context. |
|
930 if (processFunc != NULL && (aGss.iCodeChar.IsAlpha() || processFunc != GlyphSelector_Default::Process)) |
|
931 aShapeInfo.SetContext((TAny *)processFunc); |
|
932 return processFunc; |
|
933 } |
|
934 |
|
935 /** Takes Unicode text and produces the glyph cluster for the first character |
|
936 in that text plus any combining mark characters, or for the first indic |
|
937 syllable. It is responsible for contextual glyph selection, ligature creation |
|
938 and diacritic placement. |
|
939 |
|
940 @param aParam |
|
941 The input/output parameter of the text/glyph data for the algorithm. |
|
942 @param aShapeInfo |
|
943 The function will cache "shaped" text (e.g. complex scripts such as |
|
944 Devanagari) here. aShapeInfo must be freshly-constructed or closed for each |
|
945 new piece of text in aParam.iText. If aParam.iText is unchanged between |
|
946 calls, aShapeInfo should be passed back in unchanged as well. |
|
947 @return |
|
948 ETrue if glyphs for supplied text have been produced, EFalse in failure. |
|
949 @see CFont::TPositionParam |
|
950 @publishedAll |
|
951 @released */ |
|
952 EXPORT_C TBool CFont::GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const |
|
953 { |
|
954 GDI_ASSERT_DEBUG(aParam.iPosInText>=0, EGdiPanic_InvalidInputParam); |
|
955 GDI_ASSERT_DEBUG(aParam.iText.Ptr(), EGdiPanic_InvalidInputParam); |
|
956 |
|
957 aParam.iOutputGlyphs = 0; |
|
958 TInt textLen = aParam.iText.Length(); |
|
959 TBool outputOk = ETrue; |
|
960 TPoint penCopy = aParam.iPen; |
|
961 |
|
962 // Verify input parameters are sane |
|
963 if (aParam.iPosInText >= textLen) |
|
964 return EFalse; |
|
965 |
|
966 // Setup glyph selection algorithm data |
|
967 TUtf32Iterator textIter(aParam.iText.Ptr(), aParam.iText.Ptr()+textLen, aParam.iPosInText); |
|
968 if (textIter.AtEnd()) |
|
969 { |
|
970 aParam.iPosInText = textIter.LengthToStart(); |
|
971 return outputOk; |
|
972 } |
|
973 |
|
974 // Process each character in the text in turn until we reach the end of |
|
975 // the iterator, the next base (non-mark/combining) character or reach |
|
976 // the limit in a glyph cluster. |
|
977 GlyphSelection::ProcessFunc firstProcessFn = 0; |
|
978 TGlyphSelectionState gss(textIter, this, aParam); |
|
979 do |
|
980 { |
|
981 // Retrieve character info for processing. |
|
982 gss.iCodePt = gss.iCodeChar = textIter.Get(); |
|
983 gss.iCombCls = gss.iCodeChar.GetCombiningClass(); |
|
984 gss.iCats = gss.iCodeChar.GetCategory(); |
|
985 gss.iClusterState = TGlyphSelectionState::EGClusterNotComplete; |
|
986 gss.iPen = TGlyphSelectionState::EPenAdvance_No; |
|
987 |
|
988 // Find the correct processesing function for the script being used. |
|
989 // If gss.iCodePt is a strongly directional character, then simply map it in TTableEntry Table[] |
|
990 // and use the returned process function pointer. |
|
991 // If gss.iCodePt is a punctuation or a digit, then use a context character in the text (if |
|
992 // available) to find the contextual script being rendered and use its process function pointer. |
|
993 GlyphSelection::ProcessFunc processFn = FindContextualProcessFunc(aShapeInfo, gss); |
|
994 |
|
995 if (!firstProcessFn) |
|
996 firstProcessFn = processFn; |
|
997 |
|
998 if (processFn) |
|
999 { |
|
1000 if (firstProcessFn == processFn) |
|
1001 outputOk = processFn(gss, aShapeInfo); |
|
1002 else |
|
1003 break; |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 // Table entry blank, unicode char to be skipped |
|
1008 outputOk = ETrue; |
|
1009 textIter.Next(); |
|
1010 gss.iClusterState = |
|
1011 (!textIter.AtEnd() && |
|
1012 ((textIter.Get().GetCategory() & 0xF0) |
|
1013 == TChar::EMarkGroup)) ? |
|
1014 TGlyphSelectionState::EGClusterNotComplete : TGlyphSelectionState::EGClusterComplete; |
|
1015 } |
|
1016 |
|
1017 // Abort if no class was available to process the character or if |
|
1018 // processing failed. |
|
1019 if (!outputOk) |
|
1020 { |
|
1021 aParam.iPosInText = textIter.LengthToStart(); |
|
1022 return outputOk; |
|
1023 } |
|
1024 |
|
1025 // Did the glyph selector that processed the character want the |
|
1026 // pen to advance? |
|
1027 if (gss.iPen == TGlyphSelectionState::EPenAdvance_Yes) |
|
1028 { |
|
1029 aParam.iPen.iX += gss.iAdvance.iWidth; |
|
1030 aParam.iPen.iY += gss.iAdvance.iHeight; |
|
1031 gss.iPen = TGlyphSelectionState::EPenAdvance_No; |
|
1032 } |
|
1033 |
|
1034 // Here we assume the Process() methods have advanced the iterator as |
|
1035 // they consume characters they handle so that it now points to the |
|
1036 // character to process next time around the loop. |
|
1037 } |
|
1038 while (!textIter.AtEnd() // We still have more text to process |
|
1039 && (gss.iClusterState == TGlyphSelectionState::EGClusterNotComplete) // Glyph cluster !complete |
|
1040 && (aParam.iOutputGlyphs < TPositionParam::EMaxOutputGlyphs)); // Room for another glyph entry |
|
1041 |
|
1042 // If a complete glyph cluster has been identified then we should try to |
|
1043 // compose it as fully as possible. Obviously, if it only contains one |
|
1044 // character then it is already fully composed so we can ignore it. |
|
1045 // Skip this if any language-specific processing has taken place. |
|
1046 if (gss.iGlyphPostCombine == TGlyphSelectionState::EGPostCombine_Yes |
|
1047 && gss.iClusterState == TGlyphSelectionState::EGClusterComplete) |
|
1048 { |
|
1049 // Leave room to handle surrogates - Decompose() outputs UTF-16 |
|
1050 // The max that can come out of the previous stage is TPositionParam::EMaxOutputGlyphs |
|
1051 // long with only one base char at the start. Even if that base char decomposed to the |
|
1052 // max it could only be MaxOutputGlyphs long, giving a total of (2 * MaxOutputGlyphs)-1 |
|
1053 // Conceivably the use of surrogates throughout could double that when converting to UTF-16 |
|
1054 TBuf<TPositionParam::EMaxOutputGlyphs * 4> decomposeArray; |
|
1055 TBool success = ETrue; |
|
1056 // Go through the glyph cluster one char at a time |
|
1057 for (TInt i = 0; i < aParam.iOutputGlyphs; i++) |
|
1058 { |
|
1059 TChar singleChar(aParam.iOutput[i].iCode); |
|
1060 // If first character try to decompose it otherwise just take the character |
|
1061 TBool decomposed = EFalse; |
|
1062 TPtrC16 decomposition; |
|
1063 if (i == 0) |
|
1064 decomposed = singleChar.Decompose(decomposition); |
|
1065 if (decomposed) |
|
1066 { // Pick up the sequence of characters |
|
1067 decomposeArray.Append(decomposition); |
|
1068 } |
|
1069 else |
|
1070 { // Keep the original character |
|
1071 if (singleChar > 0xFFFF) |
|
1072 { // Above the BMP so we need a surrogate pair for UTF-16 |
|
1073 // This calculation really ought to go into a separate routine - probably part of TChar |
|
1074 decomposeArray.Append(HighSurrogate(singleChar)); |
|
1075 decomposeArray.Append(LowSurrogate(singleChar)); |
|
1076 } |
|
1077 else |
|
1078 { // It's not a surrogate so we just need to cast it down (since it's safe) |
|
1079 decomposeArray.Append(singleChar); |
|
1080 } |
|
1081 } |
|
1082 // Guard against bad input overflowing the array and causing a panic |
|
1083 if (decomposeArray.Length() > (TPositionParam::EMaxOutputGlyphs * 4) - 2) |
|
1084 { // too long to be a viable composition so don't try |
|
1085 success = EFalse; |
|
1086 break; |
|
1087 } |
|
1088 } |
|
1089 TUint composedChar = 0; |
|
1090 TOpenFontCharMetrics metrics; |
|
1091 TPositionParam::TOutput output; |
|
1092 TSize advance; // gets initialized to 0,0 |
|
1093 if (success) |
|
1094 { |
|
1095 //Now try and compose the string to a single character |
|
1096 success = TChar::Compose(composedChar, decomposeArray); |
|
1097 } |
|
1098 if (success) |
|
1099 { |
|
1100 // if single char is not in font or can't get char metrics for it |
|
1101 // N.B. This will probably always return metrics because if the |
|
1102 // char is not in the font this will usually return the substitute |
|
1103 // "missing" glyph (and its metrics). There should be a function to |
|
1104 // really tell you if a glyph is in the font - but there isn't. |
|
1105 if (GetCharacterData(composedChar, metrics, output.iBitmap, output.iBitmapSize) == CFont::ENoCharacterData) |
|
1106 success = EFalse; |
|
1107 } |
|
1108 if (success) |
|
1109 { |
|
1110 // We should replace the glyph cluster made from multiple chars |
|
1111 // with the correct single char and fix up the rest of the output |
|
1112 // parameters as well |
|
1113 output.iCode = composedChar; |
|
1114 // Set the glyph's bounds and record pen advancement. |
|
1115 if (aParam.iDirection == CFont::EVertical) |
|
1116 { |
|
1117 metrics.GetVertBounds(output.iBounds); |
|
1118 advance.iHeight = metrics.VertAdvance(); |
|
1119 } |
|
1120 else |
|
1121 { |
|
1122 metrics.GetHorizBounds(output.iBounds); |
|
1123 advance.iWidth = metrics.HorizAdvance(); |
|
1124 } |
|
1125 // Adjust the glyph's bounding box to offset it from the pen |
|
1126 // position (origin of drawing). For speed increment directly. |
|
1127 output.iBounds.iTl.iX += penCopy.iX; |
|
1128 output.iBounds.iBr.iX += penCopy.iX; |
|
1129 output.iBounds.iTl.iY += penCopy.iY; |
|
1130 output.iBounds.iBr.iY += penCopy.iY; |
|
1131 // Set penCopy, the copy of aParam.iPen that we made |
|
1132 penCopy.iX += advance.iWidth; |
|
1133 penCopy.iY += advance.iHeight; |
|
1134 // Overwrite the original output parameters for the glyph cluster |
|
1135 // with the values for the single composed character |
|
1136 aParam.iOutput[0] = output; |
|
1137 aParam.iOutputGlyphs = 1; |
|
1138 aParam.iPen = penCopy; |
|
1139 } |
|
1140 } |
|
1141 |
|
1142 // Exit routine with result and increment position in text to |
|
1143 // where we reached during processing to avoid any caller loops from |
|
1144 // infinite execution. |
|
1145 aParam.iPosInText = textIter.LengthToStart(); |
|
1146 return outputOk; |
|
1147 } |
|
1148 |
|
1149 /** Gets the character metrics for a character. |
|
1150 |
|
1151 @param aCode The character code. |
|
1152 @param aMetrics On return, contains the character bitmap. |
|
1153 @param aBitmap On return, this points to NULL. |
|
1154 @param aBitmapSize On return, this has a size of (0,0). |
|
1155 @return ECharacterWidthOnly |
|
1156 */ |
|
1157 EXPORT_C CFont::TCharacterDataAvailability CFont::DoGetCharacterData(TUint aCode,TOpenFontCharMetrics& aMetrics, |
|
1158 const TUint8*& aBinaryData,TSize& aBitmapSize) const |
|
1159 { |
|
1160 int width = CharWidthInPixels(aCode); |
|
1161 aMetrics.SetHorizAdvance(width); |
|
1162 aBinaryData = NULL; |
|
1163 // For speed set to 0 directly rather than call SetSize() |
|
1164 aBitmapSize.iWidth = 0; |
|
1165 aBitmapSize.iHeight = 0; |
|
1166 |
|
1167 /* |
|
1168 Set the other metrics using the width and font metrics. |
|
1169 This allows derived classes that don't override this function, like CInfoFont, |
|
1170 to give usable results for TextWidthInPixels and MeasureText. |
|
1171 */ |
|
1172 aMetrics.SetWidth(width); |
|
1173 int height = HeightInPixels(); |
|
1174 aMetrics.SetHeight(height); |
|
1175 aMetrics.SetVertAdvance(height); |
|
1176 aMetrics.SetHorizBearingX(0); |
|
1177 aMetrics.SetHorizBearingY(AscentInPixels()); |
|
1178 aMetrics.SetVertBearingX(0); |
|
1179 aMetrics.SetVertBearingY(0); |
|
1180 |
|
1181 return CFont::ECharacterWidthOnly; |
|
1182 } |
|
1183 |
|
1184 |
|
1185 /** Determines if aLeftCharacter and aRightCharacter affect each other's |
|
1186 contextual glyph form if placed next to each other. If either character |
|
1187 is a combining character, EFalse will be returned, which is not generally |
|
1188 useful information. Pass in base characters ignoring intervening combining |
|
1189 characters. |
|
1190 @param aLeftCharacter Unicode code for the character that stands on the left. |
|
1191 @param aRightCharacter Unicode code for the character that stands on the right. |
|
1192 @return EFalse if the characters do not affect the contextual glyphs that are |
|
1193 be chosen when the two are rendered together, compared to being separated |
|
1194 (for example by a space). */ |
|
1195 EXPORT_C TBool CFont::CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter) |
|
1196 { |
|
1197 return GlyphSelector_Arabic::CharactersJoin(aLeftCharacter, aRightCharacter); |
|
1198 } |
|
1199 |
|
1200 /** API extension system that enables the caller to access a particular API |
|
1201 extension function. N.B. Any overload of this function in a derived class |
|
1202 should call its immediate parent implementation for any extension function Uid |
|
1203 that it does not recognize and handle. |
|
1204 @param aInterfaceId UID of the required extension function |
|
1205 @param aParam Pointer to an arbitrary parameter block that can be used to |
|
1206 provide and/or return information to/from the particular extension function, |
|
1207 defaults to NULL. |
|
1208 @return Integer return value from extension function |
|
1209 @internalTechnology |
|
1210 @released |
|
1211 */ |
|
1212 EXPORT_C TInt CFont::DoExtendedFunction(TUid aFunctionId, TAny* /* aParam */) const |
|
1213 { |
|
1214 if (KFontCapitalAscent == aFunctionId || |
|
1215 KFontMaxAscent == aFunctionId) |
|
1216 { |
|
1217 return AscentInPixels(); |
|
1218 } |
|
1219 else if (KFontStandardDescent == aFunctionId || |
|
1220 KFontMaxDescent == aFunctionId) |
|
1221 { |
|
1222 return DescentInPixels(); |
|
1223 } |
|
1224 else if (KFontLineGap == aFunctionId) |
|
1225 { // 1.2 of em height (rounded) is reasonable approximation of interline gap |
|
1226 return (HeightInPixels() * 12 + 5) / 10; |
|
1227 } |
|
1228 return KErrNotFound; |
|
1229 } |
|
1230 |
|
1231 EXPORT_C TUid CFont::TypeUid() const |
|
1232 { |
|
1233 return DoTypeUid(); |
|
1234 } |
|
1235 |
|
1236 EXPORT_C TInt CFont::HeightInPixels() const |
|
1237 { |
|
1238 return DoHeightInPixels(); |
|
1239 } |
|
1240 |
|
1241 EXPORT_C TInt CFont::AscentInPixels() const |
|
1242 { |
|
1243 return DoAscentInPixels(); |
|
1244 } |
|
1245 |
|
1246 EXPORT_C TInt CFont::DescentInPixels() const |
|
1247 { |
|
1248 return DoDescentInPixels(); |
|
1249 } |
|
1250 |
|
1251 EXPORT_C TInt CFont::CharWidthInPixels(TChar aChar) const |
|
1252 { |
|
1253 return DoCharWidthInPixels(aChar); |
|
1254 } |
|
1255 |
|
1256 EXPORT_C TInt CFont::TextWidthInPixels(const TDesC& aText) const |
|
1257 { |
|
1258 return DoTextWidthInPixels(aText); |
|
1259 } |
|
1260 |
|
1261 EXPORT_C TInt CFont::BaselineOffsetInPixels() const |
|
1262 { |
|
1263 return DoBaselineOffsetInPixels(); |
|
1264 } |
|
1265 |
|
1266 EXPORT_C TInt CFont::TextCount(const TDesC& aText,TInt aWidthInPixels) const |
|
1267 { |
|
1268 return DoTextCount(aText, aWidthInPixels); |
|
1269 } |
|
1270 |
|
1271 EXPORT_C TInt CFont::TextCount(const TDesC& aText, TInt aWidthInPixels, TInt& aExcessWidthInPixels) const |
|
1272 { |
|
1273 return DoTextCount(aText, aWidthInPixels, aExcessWidthInPixels); |
|
1274 } |
|
1275 |
|
1276 EXPORT_C TInt CFont::MaxCharWidthInPixels() const |
|
1277 { |
|
1278 return DoMaxCharWidthInPixels(); |
|
1279 } |
|
1280 |
|
1281 EXPORT_C TInt CFont::MaxNormalCharWidthInPixels() const |
|
1282 { |
|
1283 return DoMaxNormalCharWidthInPixels(); |
|
1284 } |
|
1285 |
|
1286 EXPORT_C TFontSpec CFont::FontSpecInTwips() const |
|
1287 { |
|
1288 return DoFontSpecInTwips(); |
|
1289 } |
|
1290 |
|
1291 /** Gets the character metrics for a character. |
|
1292 |
|
1293 @param aCode The character code. |
|
1294 @param aMetrics On return, contains the character bitmap. |
|
1295 @param aBitmap On return, this points to NULL. |
|
1296 @param aBitmapSize On return, this has a size of (0,0). |
|
1297 @return ECharacterWidthOnly |
|
1298 */ |
|
1299 EXPORT_C CFont::TCharacterDataAvailability CFont::GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics, const TUint8*& aBitmap, TSize& aBitmapSize) const |
|
1300 { |
|
1301 return DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize); |
|
1302 } |
|
1303 |
|
1304 /** Transforms one cluster of characters (base character plus combining marks, |
|
1305 ligature or indic syllable) into one cluster of glyphs together with their |
|
1306 positions. Repeated calls of this function (for the same input text) are |
|
1307 considerably slower than repeated calls of GetCharacterPosition2 for Indic text |
|
1308 (such as Hindi), as GetCharacterPosition2 can cache information between calls. |
|
1309 @param aParam Input and output parameters |
|
1310 @return True for success |
|
1311 @see GetCharacterPosition2 |
|
1312 @publishedAll */ |
|
1313 EXPORT_C TBool CFont::GetCharacterPosition(TPositionParam& aParam) const |
|
1314 { |
|
1315 return DoGetCharacterPosition(aParam); |
|
1316 } |
|
1317 |
|
1318 /** Enables the caller to access a particular API |
|
1319 extension function. N.B. Any overload of this function in a derived class |
|
1320 should call its immediate parent implementation for any extension function UID |
|
1321 that it does not recognize and handle. |
|
1322 @param aFunctionId UID of the required extension function |
|
1323 @param aParam Pointer to an arbitrary parameter block that can be used to |
|
1324 provide and/or return information to/from the particular extension function, |
|
1325 defaults to NULL. |
|
1326 @return Integer return value from extension function |
|
1327 */ |
|
1328 EXPORT_C TInt CFont::ExtendedFunction(TUid aFunctionId, TAny* aParam) const |
|
1329 { |
|
1330 return DoExtendedFunction(aFunctionId, aParam); |
|
1331 } |
|
1332 |
|
1333 EXPORT_C TInt CFont::TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const |
|
1334 { |
|
1335 TTextWidthInternal context; |
|
1336 TTextWidthInternal* contextPtr = &context; |
|
1337 contextPtr->iText.Set(aText); |
|
1338 contextPtr->iParam.iStartInputChar = aParam->iStartInputChar; |
|
1339 contextPtr->iParam.iEndInputChar = aParam->iEndInputChar; |
|
1340 return DoExtendedFunction(KTextInContextWidthInPixelsUid, (TAny*)contextPtr); |
|
1341 } |
|
1342 |
|
1343 /** |
|
1344 Maps TLanguage to TScript. |
|
1345 |
|
1346 EScriptOther represents languages not yet supported in KTScript2GlyphSample. |
|
1347 This array does not handle ELangNone and ELangMaximum to save storage space. |
|
1348 */ |
|
1349 const TInt GlyphSample::KTLanguage2TScript[] = |
|
1350 { |
|
1351 EScriptNone, // 00 ELangTest |
|
1352 EScriptLatin, // 01 ELangEnglish |
|
1353 EScriptLatin, // 02 ELangFrench |
|
1354 EScriptLatin, // 03 ELangGerman |
|
1355 EScriptLatin, // 04 ELangSpanish |
|
1356 EScriptLatin, // 05 ELangItalian |
|
1357 EScriptLatin, // 06 ELangSwedish |
|
1358 EScriptLatin, // 07 ELangDanish |
|
1359 EScriptLatin, // 08 ELangNorwegian |
|
1360 EScriptLatin, // 09 ELangFinnish |
|
1361 EScriptLatin, // 10 ELangAmerican |
|
1362 EScriptLatin, // 11 ELangSwissFrench |
|
1363 EScriptLatin, // 12 ELangSwissGerman |
|
1364 EScriptLatin, // 13 ELangPortuguese |
|
1365 EScriptLatin, // 14 ELangTurkish |
|
1366 EScriptLatin, // 15 ELangIcelandic |
|
1367 EScriptCyrillic, // 16 ELangRussian |
|
1368 EScriptLatin, // 17 ELangHungarian |
|
1369 EScriptLatin, // 18 ELangDutch |
|
1370 EScriptLatin, // 19 ELangBelgianFlemish |
|
1371 EScriptLatin, // 20 ELangAustralian |
|
1372 EScriptLatin, // 21 ELangBelgianFrench |
|
1373 EScriptLatin, // 22 ELangAustrian |
|
1374 EScriptLatin, // 23 ELangNewZealand |
|
1375 EScriptLatin, // 24 ELangInternationalFrench |
|
1376 EScriptLatin, // 25 ELangCzech |
|
1377 EScriptLatin, // 26 ELangSlovak |
|
1378 EScriptLatin, // 27 ELangPolish |
|
1379 EScriptLatin, // 28 ELangSlovenian |
|
1380 EScriptHanIdeographs, // 29 ELangTaiwanChinese |
|
1381 EScriptHanIdeographs, // 30 ELangHongKongChinese |
|
1382 EScriptHanIdeographs, // 31 ELangPrcChinese |
|
1383 EScriptHanIdeographs, // 32 ELangJapanese |
|
1384 EScriptThai, // 33 ELangThai |
|
1385 EScriptLatin, // 34 ELangAfrikaans |
|
1386 EScriptLatin, // 35 ELangAlbanian |
|
1387 EScriptOther, // 36 ELangAmharic |
|
1388 EScriptArabic, // 37 ELangArabic |
|
1389 EScriptOther, // 38 ELangArmenian |
|
1390 EScriptOther, // 39 ELangTagalog |
|
1391 EScriptCyrillic, // 40 ELangBelarussian |
|
1392 EScriptOther, // 41 ELangBengali |
|
1393 EScriptCyrillic, // 42 ELangBulgarian |
|
1394 EScriptOther, // 43 ELangBurmese |
|
1395 EScriptLatin, // 44 ELangCatalan |
|
1396 EScriptLatin, // 45 ELangCroatian |
|
1397 EScriptLatin, // 46 ELangCanadianEnglish |
|
1398 EScriptLatin, // 47 ELangInternationalEnglish |
|
1399 EScriptLatin, // 48 ELangSouthAfricanEnglish |
|
1400 EScriptLatin, // 49 ELangEstonian |
|
1401 EScriptArabic, // 50 ELangFarsi |
|
1402 EScriptLatin, // 51 ELangCanadianFrench |
|
1403 EScriptLatin, // 52 ELangScotsGaelic |
|
1404 EScriptOther, // 53 ELangGeorgian |
|
1405 EScriptGreek, // 54 ELangGreek |
|
1406 EScriptGreek, // 55 ELangCyprusGreek |
|
1407 EScriptOther, // 56 ELangGujarati |
|
1408 EScriptHebrew, // 57 ELangHebrew |
|
1409 EScriptDevanagari, // 58 ELangHindi |
|
1410 EScriptLatin, // 59 ELangIndonesian |
|
1411 EScriptLatin, // 60 ELangIrish |
|
1412 EScriptLatin, // 61 ELangSwissItalian |
|
1413 EScriptOther, // 62 ELangKannada |
|
1414 EScriptCyrillic, // 63 ELangKazakh |
|
1415 EScriptOther, // 64 ELangKhmer |
|
1416 EScriptHanIdeographs, // 65 ELangKorean |
|
1417 EScriptOther, // 66 ELangLao |
|
1418 EScriptLatin, // 67 ELangLatvian |
|
1419 EScriptLatin, // 68 ELangLithuanian |
|
1420 EScriptCyrillic, // 69 ELangMacedonian |
|
1421 EScriptLatin, // 70 ELangMalay |
|
1422 EScriptOther, // 71 ELangMalayalam |
|
1423 EScriptDevanagari, // 72 ELangMarathi |
|
1424 EScriptLatin, // 73 ELangMoldavian |
|
1425 EScriptOther, // 74 ELangMongolian |
|
1426 EScriptLatin, // 75 ELangNorwegianNynorsk |
|
1427 EScriptLatin, // 76 ELangBrazilianPortuguese |
|
1428 EScriptOther, // 77 ELangPunjabi |
|
1429 EScriptLatin, // 78 ELangRomanian |
|
1430 EScriptCyrillic, // 79 ELangSerbian |
|
1431 EScriptOther, // 80 ELangSinhalese |
|
1432 EScriptLatin, // 81 ELangSomali |
|
1433 EScriptLatin, // 82 ELangInternationalSpanish |
|
1434 EScriptLatin, // 83 ELangLatinAmericanSpanish |
|
1435 EScriptLatin, // 84 ELangSwahili |
|
1436 EScriptLatin, // 85 ELangFinlandSwedish |
|
1437 EScriptNone, // 86 ELangReserved1 |
|
1438 EScriptOther, // 87 ELangTamil |
|
1439 EScriptOther, // 88 ELangTelugu |
|
1440 EScriptOther, // 89 ELangTibetan |
|
1441 EScriptOther, // 90 ELangTigrinya |
|
1442 EScriptLatin, // 91 ELangCyprusTurkish |
|
1443 EScriptCyrillic, // 92 ELangTurkmen |
|
1444 EScriptCyrillic, // 93 ELangUkrainian |
|
1445 EScriptArabic, // 94 ELangUrdu |
|
1446 EScriptNone, // 95 ELangReserved2 |
|
1447 EScriptLatin, // 96 ELangVietnamese |
|
1448 EScriptLatin, // 97 ELangWelsh |
|
1449 EScriptLatin, // 98 ELangZulu |
|
1450 }; |
|
1451 |
|
1452 /** |
|
1453 Maps TScript to glyph samples. |
|
1454 |
|
1455 The order of samples definition has to follow the script order in TScript. |
|
1456 |
|
1457 Supported scripts Fonts used to experiment/determine glyph samples |
|
1458 |
|
1459 Latin Arial, Times, Century |
|
1460 Greek Ditto |
|
1461 Cyrillic Ditto |
|
1462 Hebrew Aharoni, David, FrankRuehl, Levenim MT, Miriam, Narkisim, Rod |
|
1463 Arabic Andalus, Arabic Transparent, Simplified Arabic, Traditional Arabic |
|
1464 Devanagari Mangal |
|
1465 Thai Angsana New, Browallia, Cordia New, DilleniaUPC, EucrosiaUPC, |
|
1466 FreesiaUPC, IrisUPC, JasmineUPC, KodchiangUPC, LilyUPC |
|
1467 HanIdeographs Chinese : SimSun, SimHei (Simplified) / MingLiU (Traditional) |
|
1468 Japanese: MS Mincho, MS Gothic |
|
1469 Korean : Batang, Gulim |
|
1470 */ |
|
1471 const TText* const GlyphSample::KTScript2GlyphSample[] = |
|
1472 { |
|
1473 // |
|
1474 // 02 EScriptLatin |
|
1475 // |
|
1476 // 0x00C0 - Ascent : Capital letter A with grave (Latin-1 Supplement) |
|
1477 // 0x013A - Ascent : Small letter l with acute (Latin Extended A) |
|
1478 // 0x1EA2 - Ascent : Capital letter A with hook above (Latin Extended Additional) |
|
1479 // 0x00C7 - Descent: Capital letter C with cedilla (Latin-1 Supplement) |
|
1480 // 0x0163 - Descent: Small letter t with cedilla (Latin Extended A) |
|
1481 // |
|
1482 _S("\x00C0\x013A\x1EA2\x00C7\x0163"), |
|
1483 // |
|
1484 // 03 EScriptGreek |
|
1485 // |
|
1486 // 0x03AA - Ascent : Capital letter iota with dialytika |
|
1487 // 0x03AB - Ascent : Capital letter upsilon with dialytika |
|
1488 // 0x03AE - Descent: Small letter eta with tonos |
|
1489 // 0x03B2 - Descent: Small letter beta |
|
1490 // 0x03C8 - Descent: Small letter psi |
|
1491 // |
|
1492 _S("\x03AA\x03AB\x03AE\x03B2\x03C8"), |
|
1493 // |
|
1494 // 04 EScriptCyrillic |
|
1495 // |
|
1496 // 0x0403 - Ascent : Capital letter gje |
|
1497 // 0x0419 - Ascent : Capital letter short i |
|
1498 // 0x0440 - Descent: Small letter er |
|
1499 // 0x0452 - Descent: Small letter dje |
|
1500 // 0x0458 - Descent: Small letter je |
|
1501 // |
|
1502 _S("\x0403\x0419\x0440\x0452\x0458"), |
|
1503 // |
|
1504 // 05 EScriptHebrew |
|
1505 // |
|
1506 // 0x05BE - Ascent : Punctuation maqaf |
|
1507 // 0x05DC - Ascent : Letter lamed |
|
1508 // 0x05B0 - Descent: Point sheva |
|
1509 // 0x05BD - Descent: Point meteg |
|
1510 // 0x05E7 - Descent: Letter qof |
|
1511 // |
|
1512 _S("\x05BE\x05DC\x05B0\x05BD\x05E7"), |
|
1513 // |
|
1514 // 06 EScriptArabic |
|
1515 // |
|
1516 // 0x0670 - Ascent : Alef above (Arabic) |
|
1517 // 0x0671 - Ascent : Hamzat Wasl on Alef isolated form |
|
1518 // 0x064D - Descent: Kasratan (Arabic) |
|
1519 // 0xFB7B - Descent: Final form of 0686 |
|
1520 // 0xFBF2 - Descent: Final form of 064A |
|
1521 // |
|
1522 //PDEF120737: EScriptArabic value has been changed for this defect & tested using the font file provided by client (i.e. kamelion arabic font). |
|
1523 //The client's font file can't be used for IPR reasons. Thus the test code to demonstrate this defect |
|
1524 //is not added. Also, there was no other font file available that reproduces this defect. |
|
1525 // |
|
1526 _S("\x0670\x0671\x064D\xFB7B\xFBF2"), |
|
1527 // |
|
1528 // 07 EScriptDevanagari |
|
1529 // |
|
1530 // 0x0914 - Ascent : Letter au |
|
1531 // 0x0951 - Ascent : Stress sign udatta |
|
1532 // 0x0941 - Descent: Vowel sign u |
|
1533 // 0x0944 - Descent: Vowel sign rr |
|
1534 // 0x0963 - Descent: Vowel sign vocalic ll |
|
1535 // |
|
1536 _S("\x0914\x0951\x0941\x0944\x0963"), |
|
1537 // |
|
1538 // 08 EScriptThai |
|
1539 // |
|
1540 // 0x0E49 - Ascent : Character mai tho |
|
1541 // 0x0E4B - Ascent : Character mai chattawa |
|
1542 // 0x0E0E - Descent: Character do chada |
|
1543 // 0x0E24 - Descent: Character ru |
|
1544 // 0x0E39 - Descent: Character sara uu |
|
1545 // |
|
1546 _S("\x0E49\x0E4B\x0E0E\x0E24\x0E39"), |
|
1547 // |
|
1548 // 09 EScriptHanIdeographs |
|
1549 // |
|
1550 // 0x1100 - Ascent/Descent: Korean |
|
1551 // 0x4E1C - Ascent/Descent: Chinese Simplified |
|
1552 // 0x5283 - Ascent/Descent: Japanese |
|
1553 // 0x758A - Ascent : Chinese Traditional |
|
1554 // 0x7BEA - Descent: Chinese Traditional |
|
1555 // |
|
1556 _S("\x1100\x4E1C\x5283\x758A\x7BEA"), |
|
1557 }; |
|
1558 |
|
1559 /** |
|
1560 Maps a TLanguage type to the TScript type. |
|
1561 @internalTechnology |
|
1562 @param aLanguage The language. |
|
1563 @return A TInt representing the script, or |
|
1564 EScriptNone if its not defined for aLanguage. |
|
1565 */ |
|
1566 EXPORT_C TInt GlyphSample::TLanguage2TScript(TLanguage aLanguage) |
|
1567 { |
|
1568 if (ELangNone == aLanguage || ELangMaximum == aLanguage || aLanguage >= (sizeof(KTLanguage2TScript)/sizeof(KTLanguage2TScript[0]))) |
|
1569 { |
|
1570 return EScriptNone; |
|
1571 } |
|
1572 return KTLanguage2TScript[aLanguage]; |
|
1573 } |
|
1574 |
|
1575 /** |
|
1576 Maps a TScript type to some glyph samples which are stored as Unicode. |
|
1577 @internalTechnology |
|
1578 @param aScript The script. |
|
1579 @return A TPtrC pointing to the first glyph sample, |
|
1580 or empty if no samples is defined for aScript. |
|
1581 */ |
|
1582 EXPORT_C const TPtrC GlyphSample::TScript2GlyphSample(TInt aScript) |
|
1583 { |
|
1584 if (EScriptOther >= aScript) |
|
1585 { |
|
1586 return TPtrC(); |
|
1587 } |
|
1588 // -3 to offset EScriptDefault, EScriptNone and EScriptOther |
|
1589 // being the first three elements in TScript. |
|
1590 return TPtrC(KTScript2GlyphSample[aScript - 3]); |
|
1591 } |