|
1 /* |
|
2 * Copyright (c) 2008-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "FNTSTD.H" |
|
20 #include "t_linkedfontscomparison.h" |
|
21 #include <hal.h> |
|
22 #include <test/thashreferenceimages.h> |
|
23 #include <linkedfonts.h> |
|
24 |
|
25 /** |
|
26 @file |
|
27 |
|
28 @SYMPurpose structures used to define linked typefaces used in this test, create and |
|
29 use linked typefaces, and check against a hash value |
|
30 */ |
|
31 |
|
32 /** this is for the group entries |
|
33 */ |
|
34 struct TTGroup |
|
35 { |
|
36 CLinkedTypefaceGroup::TBaselineShift iBaselineShift; |
|
37 CLinkedTypefaceGroup::TScalingOption iScalingOption; |
|
38 TInt iAntiAliasThreshold; //KMinTInt for do not set; |
|
39 TInt iBoldnessPercentage; //KMinTInt for do not set; |
|
40 TInt iItalicAngle; //KMinTInt for do not set; |
|
41 }; |
|
42 |
|
43 /** this is for linked font elements |
|
44 */ |
|
45 struct TTLinkedFontElement |
|
46 { |
|
47 const TPtrC iTypefaceName; |
|
48 TInt iGroup; |
|
49 TBool iIsCanonical; |
|
50 }; |
|
51 |
|
52 /** this is for the linked typeface table |
|
53 */ |
|
54 struct TTLinkedTypeface |
|
55 { |
|
56 const TPtrC iTypefaceName; |
|
57 const TTLinkedFontElement* iElements; |
|
58 }; |
|
59 |
|
60 /** this is a plain group |
|
61 */ |
|
62 const TTGroup KPlainGroup = |
|
63 { |
|
64 CLinkedTypefaceGroup::ENoBaselineShift, |
|
65 CLinkedTypefaceGroup::EScalingNone, |
|
66 KMinTInt, //this value means do not set |
|
67 KMinTInt, //this value means do not set |
|
68 KMinTInt, //this value means do not set |
|
69 }; |
|
70 |
|
71 const TTGroup KGroup1 = |
|
72 { |
|
73 CLinkedTypefaceGroup::ENoBaselineShift, |
|
74 CLinkedTypefaceGroup::EScalingNone, |
|
75 KMinTInt, //this value means do not set - antialiased |
|
76 KMinTInt, //this value means do not set - boldness percentage |
|
77 KMinTInt, //this value means do not set - italic angle |
|
78 }; |
|
79 |
|
80 const TTGroup KGroup2 = |
|
81 { |
|
82 CLinkedTypefaceGroup::EBaselineShift, |
|
83 CLinkedTypefaceGroup::EScalingUp, |
|
84 KMinTInt, //this value means do not set |
|
85 KMinTInt, //this value means do not set |
|
86 KMinTInt, //this value means do not set |
|
87 }; |
|
88 const TTGroup KGroup3 = |
|
89 { |
|
90 CLinkedTypefaceGroup::EBaselineShift, |
|
91 CLinkedTypefaceGroup::EScalingUpOrDown, |
|
92 KMinTInt, //this value means do not set |
|
93 KMinTInt, //this value means do not set |
|
94 KMinTInt, //this value means do not set |
|
95 }; |
|
96 const TTGroup KGroup4 = |
|
97 { |
|
98 CLinkedTypefaceGroup::ENoBaselineShift, |
|
99 CLinkedTypefaceGroup::EScalingNone, |
|
100 14, //antialiased |
|
101 KMinTInt, //this value means do not set |
|
102 KMinTInt, //this value means do not set |
|
103 }; |
|
104 const TTGroup KGroup5 = |
|
105 { |
|
106 CLinkedTypefaceGroup::ENoBaselineShift, |
|
107 CLinkedTypefaceGroup::EScalingNone, |
|
108 10, //antialiased |
|
109 KMinTInt, //this value means do not set |
|
110 KMinTInt, //this value means do not set |
|
111 }; |
|
112 const TTGroup KGroup6 = |
|
113 { |
|
114 CLinkedTypefaceGroup::ENoBaselineShift, |
|
115 CLinkedTypefaceGroup::EScalingNone, |
|
116 KMinTInt, //this value means do not set |
|
117 100, //boldness percentage |
|
118 KMinTInt, //this value means do not set |
|
119 }; |
|
120 const TTGroup KGroup7 = |
|
121 { |
|
122 CLinkedTypefaceGroup::ENoBaselineShift, |
|
123 CLinkedTypefaceGroup::EScalingNone, |
|
124 KMinTInt, //this value means do not set |
|
125 10, //boldness percentage |
|
126 KMinTInt, //this value means do not set |
|
127 }; |
|
128 const TTGroup KGroup8 = |
|
129 { |
|
130 CLinkedTypefaceGroup::ENoBaselineShift, |
|
131 CLinkedTypefaceGroup::EScalingNone, |
|
132 KMinTInt, //this value means do not set |
|
133 KMinTInt, //this value means do not set |
|
134 10, //italic angle |
|
135 }; |
|
136 const TTGroup KGroup9 = |
|
137 { |
|
138 CLinkedTypefaceGroup::EBaselineShift, |
|
139 CLinkedTypefaceGroup::EScalingNone, |
|
140 KMinTInt, //this value means do not set |
|
141 KMinTInt, //this value means do not set |
|
142 KMinTInt, //this value means do not set |
|
143 }; |
|
144 const TTGroup KGroup10 = |
|
145 { |
|
146 CLinkedTypefaceGroup::ENoBaselineShift, |
|
147 CLinkedTypefaceGroup::EScalingNone, |
|
148 KMinTInt, //this value means do not set |
|
149 KMinTInt, //this value means do not set |
|
150 40, //large italic angle |
|
151 }; |
|
152 |
|
153 /** all the groups are added to every linked typeface |
|
154 if there are too many groups then there may be a need for a group list |
|
155 per linked typeface. Can have a maximum of 12 groups |
|
156 */ |
|
157 const TTGroup* KGroupList[]= |
|
158 { |
|
159 &KPlainGroup, /* index 0 */ |
|
160 &KGroup1, |
|
161 &KGroup2, |
|
162 &KGroup3, |
|
163 &KGroup4, |
|
164 &KGroup5, |
|
165 &KGroup6, |
|
166 &KGroup7, |
|
167 &KGroup8, |
|
168 &KGroup9, |
|
169 &KGroup10, |
|
170 }; |
|
171 |
|
172 /** typeface element definitions |
|
173 */ |
|
174 |
|
175 /** Latin font |
|
176 */ |
|
177 const TTLinkedFontElement KLatinFontCanonical = |
|
178 { |
|
179 _L("DejaVu Sans Condensed"),0, ETrue //name, group zero, is canonical |
|
180 }; |
|
181 |
|
182 /** |
|
183 */ |
|
184 const TTLinkedFontElement KJapaneseNotCanonical = |
|
185 { |
|
186 _L("TBKomachiG-R"), 0, EFalse //name, group zero, not canonical |
|
187 }; |
|
188 |
|
189 /** Japanese - to be updated |
|
190 */ |
|
191 const TTLinkedFontElement KJapaneseNotCanonicalGroup1 = |
|
192 { |
|
193 _L("TBKomachiG-R"), 1, EFalse //name, group , not canonical |
|
194 }; |
|
195 const TTLinkedFontElement KJapaneseNotCanonicalGroup3 = |
|
196 { |
|
197 _L("TBKomachiG-R"), 3, EFalse //name, group, not canonical |
|
198 }; |
|
199 const TTLinkedFontElement KJapaneseNotCanonicalGroup4 = |
|
200 { |
|
201 _L("TBKomachiG-R"), 4, EFalse //name, group, not canonical |
|
202 }; |
|
203 const TTLinkedFontElement KJapaneseNotCanonicalGroup6 = |
|
204 { |
|
205 _L("TBKomachiG-R"), 6, EFalse //name, group, not canonical |
|
206 }; |
|
207 const TTLinkedFontElement KJapaneseNotCanonicalGroup8 = |
|
208 { |
|
209 _L("TBKomachiG-R"), 8, EFalse //name, group, not canonical |
|
210 }; |
|
211 const TTLinkedFontElement KJapaneseNotCanonicalGroup9 = |
|
212 { |
|
213 _L("TBKomachiG-R"), 9, EFalse //name, group, not canonical |
|
214 }; |
|
215 const TTLinkedFontElement KJapaneseNotCanonicalGroup10 = |
|
216 { |
|
217 _L("TBKomachiG-R"), 10, EFalse //name, group, not canonical |
|
218 }; |
|
219 |
|
220 const TTLinkedFontElement KLatinFontTTNotCanonicalGroup0 = |
|
221 { |
|
222 _L("LinkedFontTestFont"), 0, EFalse |
|
223 }; |
|
224 |
|
225 const TTLinkedFontElement KLatinFontTTCanonicalGroup0 = |
|
226 { |
|
227 _L("LinkedFontTestFont"), 0, ETrue |
|
228 }; |
|
229 |
|
230 /* for use case testing */ |
|
231 const TTLinkedFontElement KLatinFontTTCanonicalGroup2 = |
|
232 { |
|
233 _L("LinkedFontTestFont"), 2, ETrue |
|
234 }; |
|
235 const TTLinkedFontElement KLatinFontTTCanonicalGroup3 = |
|
236 { |
|
237 _L("LinkedFontTestFont"), 3, ETrue |
|
238 }; |
|
239 const TTLinkedFontElement KLatinFontTTCanonicalGroup5 = |
|
240 { |
|
241 _L("LinkedFontTestFont"), 5, ETrue |
|
242 }; |
|
243 const TTLinkedFontElement KLatinFontTTCanonicalGroup7 = |
|
244 { |
|
245 _L("LinkedFontTestFont"), 7, ETrue |
|
246 }; |
|
247 const TTLinkedFontElement KLatinFontTTCanonicalGroup8 = |
|
248 { |
|
249 _L("LinkedFontTestFont"), 8, ETrue |
|
250 }; |
|
251 const TTLinkedFontElement KLatinFontTTCanonicalGroup9 = |
|
252 { |
|
253 _L("LinkedFontTestFont"), 9, ETrue |
|
254 }; |
|
255 const TTLinkedFontElement KLatinFontTTCanonicalGroup10 = |
|
256 { |
|
257 _L("LinkedFontTestFont"), 10, ETrue |
|
258 }; |
|
259 |
|
260 /** Chandas |
|
261 */ |
|
262 const TTLinkedFontElement KHindiCanonical = |
|
263 { |
|
264 _L("Chandas"), 0, ETrue |
|
265 }; |
|
266 |
|
267 /** Chandas |
|
268 */ |
|
269 const TTLinkedFontElement KHindiNotCanonical = |
|
270 { |
|
271 _L("Chandas"), 0, EFalse |
|
272 }; |
|
273 |
|
274 /** Information about linked fonts |
|
275 TLinkedFont1.ttf |
|
276 Typeface name: LinkedFont1 |
|
277 This will be the dominant font. It contains 178 characters. |
|
278 Some of the characters (13) are deleted from this file and separated in to other three files. |
|
279 Characters missing are F, D, J, M, P, S, V, X, Z, a, n, l, y. |
|
280 |
|
281 TLinkedFont2.ttf |
|
282 Typeface name: LinkedFont2 |
|
283 Characters available (7): F, J, M, S, Z, a, y. |
|
284 |
|
285 TLinkedFont3.ttf |
|
286 Typeface name: LinkedFont3 |
|
287 Characters available (4): D, P, x, l |
|
288 |
|
289 TLinkedFont4.ttf |
|
290 Typeface name: LinkedFont4 |
|
291 Characters available (2): V, n |
|
292 |
|
293 TWithoutLinkedFont.ttf |
|
294 Typeface name: WithoutLinkedFont |
|
295 Characters available: It contains 191 characters U+0020-U+007E and U+00A0-U+00FF |
|
296 */ |
|
297 |
|
298 /** LinkedFont1TT |
|
299 */ |
|
300 const TTLinkedFontElement KLinkedFont1TT = |
|
301 { |
|
302 _L("LinkedFont1TT"), 0, EFalse |
|
303 }; |
|
304 |
|
305 /** LinkedFont2TT |
|
306 */ |
|
307 const TTLinkedFontElement KLinkedFont2TTCanonical = |
|
308 { |
|
309 _L("LinkedFont2TT"), 0, ETrue |
|
310 }; |
|
311 |
|
312 /** LinkedFont3TT |
|
313 */ |
|
314 const TTLinkedFontElement KLinkedFont3TT = |
|
315 { |
|
316 _L("LinkedFont3TT"), 0, EFalse |
|
317 }; |
|
318 |
|
319 /** LinkedFont4TT |
|
320 */ |
|
321 const TTLinkedFontElement KLinkedFont4TT = |
|
322 { |
|
323 _L("LinkedFont4TT"), 0, EFalse |
|
324 }; |
|
325 |
|
326 /** KNullDesC |
|
327 */ |
|
328 const TTLinkedFontElement KNullElement = |
|
329 { |
|
330 _L(""), 0, EFalse |
|
331 }; |
|
332 |
|
333 /** linked typeface, this list is terminated by KNullElement |
|
334 */ |
|
335 const TTLinkedFontElement KLatinFontHindi[]= |
|
336 { |
|
337 KLatinFontTTNotCanonicalGroup0, |
|
338 KHindiCanonical, |
|
339 KNullElement, |
|
340 }; |
|
341 /** linked typeface, this list is terminated by KNullElement |
|
342 */ |
|
343 const TTLinkedFontElement KLatinFontJapanese[]= |
|
344 { |
|
345 KLatinFontCanonical, |
|
346 KJapaneseNotCanonical, |
|
347 KNullElement |
|
348 }; |
|
349 /** linked typeface, this list is terminated by KNullElement |
|
350 */ |
|
351 const TTLinkedFontElement KLinkedFontTestFonts[]= |
|
352 { |
|
353 KLinkedFont1TT, |
|
354 KLinkedFont2TTCanonical, |
|
355 KLinkedFont3TT, |
|
356 KLinkedFont4TT, |
|
357 KNullElement |
|
358 }; |
|
359 |
|
360 const TTLinkedFontElement KJapaneseLatinFontTypeface1[]= |
|
361 { |
|
362 KLatinFontTTCanonicalGroup2, |
|
363 KJapaneseNotCanonicalGroup1, |
|
364 KNullElement |
|
365 }; |
|
366 const TTLinkedFontElement KJapaneseLatinFontTypeface2[]= |
|
367 { |
|
368 KLatinFontTTCanonicalGroup3, |
|
369 KJapaneseNotCanonicalGroup3, |
|
370 KNullElement |
|
371 }; |
|
372 const TTLinkedFontElement KJapaneseLatinFontTypeface3[]= |
|
373 { |
|
374 KLatinFontTTCanonicalGroup5, |
|
375 KJapaneseNotCanonicalGroup4, |
|
376 KNullElement |
|
377 }; |
|
378 const TTLinkedFontElement KJapaneseLatinFontTypeface4[]= |
|
379 { |
|
380 KLatinFontTTCanonicalGroup7, |
|
381 KJapaneseNotCanonicalGroup6, |
|
382 KNullElement |
|
383 }; |
|
384 const TTLinkedFontElement KJapaneseLatinFontTypeface5[]= |
|
385 { |
|
386 KLatinFontTTCanonicalGroup8, |
|
387 KJapaneseNotCanonicalGroup8, |
|
388 KNullElement |
|
389 }; |
|
390 const TTLinkedFontElement KJapaneseLatinFontTypeface6[]= |
|
391 { |
|
392 KLatinFontTTCanonicalGroup9, |
|
393 KJapaneseNotCanonicalGroup9, |
|
394 KNullElement |
|
395 }; |
|
396 |
|
397 const TTLinkedFontElement KJapaneseLatinFontTypeface7[]= |
|
398 { |
|
399 KLatinFontTTCanonicalGroup10, |
|
400 KJapaneseNotCanonicalGroup10, |
|
401 KNullElement |
|
402 }; |
|
403 |
|
404 const TTLinkedFontElement KEnglishJapanseHindiFont[]= |
|
405 { |
|
406 KLatinFontTTCanonicalGroup0, |
|
407 KJapaneseNotCanonical, |
|
408 KHindiNotCanonical, |
|
409 KNullElement |
|
410 }; |
|
411 |
|
412 /** the linked typeface set, no need to null terminate, sizeof is used for this array |
|
413 */ |
|
414 const TTLinkedTypeface KLinkedTypefaces[] = |
|
415 { |
|
416 //name, list of linked font elements |
|
417 {_L("LinkedFontTestFont"), KLinkedFontTestFonts}, |
|
418 {_L("LatinFontHindi"), KLatinFontHindi}, |
|
419 {_L("LatinFontJapanese"), KLatinFontJapanese}, |
|
420 {_L("EnglishJapaneseHindi"), KEnglishJapanseHindiFont}, |
|
421 {_L("UseCaseFont1"), KJapaneseLatinFontTypeface1}, |
|
422 {_L("UseCaseFont2"), KJapaneseLatinFontTypeface2}, |
|
423 {_L("UseCaseFont3"), KJapaneseLatinFontTypeface3}, |
|
424 {_L("UseCaseFont4"), KJapaneseLatinFontTypeface4}, |
|
425 {_L("UseCaseFont5"), KJapaneseLatinFontTypeface5}, |
|
426 {_L("UseCaseFont6"), KJapaneseLatinFontTypeface6}, |
|
427 {_L("UseCaseFont7"), KJapaneseLatinFontTypeface7}, |
|
428 }; |
|
429 |
|
430 /** Enum which constains bitwise flags for attrbutes which can be set for each font |
|
431 */ |
|
432 enum TFontEffectsFlags |
|
433 { |
|
434 ENoEffect = 0x0, |
|
435 EDropShadowOn = 0x1, |
|
436 EOutlineOn = 0x2, |
|
437 ESetMonochromeGlyphBitmap = 0x4, |
|
438 ESetAntiAliasedGlyphBitmap = 0x8, |
|
439 ESetFourColourBlendGlyphBitmap = 0x10, |
|
440 EVerticalDraw = 0x20, |
|
441 ERotate90Degrees = 0x40, |
|
442 EIsStrikethroughOn = 0x80, |
|
443 EIsUnderlineOn = 0x100, |
|
444 ESoftEdgeOn = 0x200, |
|
445 EAlgorithmicBoldOn = 0x400, |
|
446 EDrawUp = 0x800, |
|
447 EItalicOn = 0x1000, |
|
448 ERegularBoldOn = 0x2000, |
|
449 EEndOfList = 0x80000000 //a meta flag |
|
450 }; |
|
451 |
|
452 const TInt KLengthOfHashValue = 1000; |
|
453 |
|
454 /** table used to produce hash string from attributes |
|
455 */ |
|
456 const TPtrC KFontEffectsFlagsString[32]= |
|
457 { |
|
458 _L("ENoEffect"), |
|
459 _L("EDropShadowOn"), |
|
460 _L("EOutlineOn"), |
|
461 _L("ESetMonochromeGlyphBitmap"), |
|
462 _L("ESetAntiAliasedGlyphBitmap"), |
|
463 _L("ESetFourColourBlendGlyphBitmap"), |
|
464 _L("EVerticalDraw"), |
|
465 _L("ERotate90Degrees"), |
|
466 _L("EIsStrikethroughOn"), |
|
467 _L("EIsUnderlineOn"), |
|
468 _L("ESoftEdgeOn"), |
|
469 _L("EAlgorithmicBoldOn"), |
|
470 _L("EDrawUp"), |
|
471 _L("EItalicOn"), |
|
472 _L("ERegularBoldOn"), |
|
473 _L(""), |
|
474 _L(""), |
|
475 _L(""), |
|
476 _L(""), |
|
477 _L(""), |
|
478 _L(""), |
|
479 _L(""), |
|
480 _L(""), |
|
481 _L(""), |
|
482 _L(""), |
|
483 _L(""), |
|
484 _L(""), |
|
485 _L(""), |
|
486 _L(""), |
|
487 _L(""), |
|
488 _L(""), |
|
489 _L("EEndOfList"), |
|
490 }; |
|
491 |
|
492 |
|
493 /**this structure is used to define a test case |
|
494 */ |
|
495 struct TTestCase |
|
496 { |
|
497 const TPtrC iTypeFaceName; //typeface name |
|
498 const TDesC* iOutputString; //the output string |
|
499 const TDesC* iTestDecription; //test description |
|
500 const TPoint iPosition; //the position |
|
501 const TInt* iSizes; // a list of sizes |
|
502 const TUint32* iFontAttributes; //a list of font attrbutes (bitwise flags, see above |
|
503 }; |
|
504 |
|
505 /** an array of sizes used during testing, terminated by zero |
|
506 */ |
|
507 const TInt KFontSizeNormalTesting[]= |
|
508 { |
|
509 10, |
|
510 20, |
|
511 35, |
|
512 0 |
|
513 }; |
|
514 |
|
515 const TInt KFontSizeUseCaseTesting[]= |
|
516 { |
|
517 8, |
|
518 12, |
|
519 16, |
|
520 35, |
|
521 0 |
|
522 }; |
|
523 |
|
524 /** an array of attributes used during font testing, terminated by EEndOfList |
|
525 */ |
|
526 const TUint32 KFontAttributesNormalTest[] =// probably need to expand this with position |
|
527 { |
|
528 ENoEffect, |
|
529 EIsUnderlineOn, |
|
530 EIsStrikethroughOn, |
|
531 ESetFourColourBlendGlyphBitmap, |
|
532 EIsUnderlineOn| EIsStrikethroughOn, |
|
533 EAlgorithmicBoldOn, |
|
534 EVerticalDraw, |
|
535 EVerticalDraw | EIsUnderlineOn, |
|
536 EVerticalDraw | EIsUnderlineOn | ERotate90Degrees, |
|
537 EEndOfList, |
|
538 }; |
|
539 |
|
540 const TUint32 KFontAttributesUseCaseTest[] =// probably need to expand this with position |
|
541 { |
|
542 ENoEffect, |
|
543 ERegularBoldOn, |
|
544 ESetAntiAliasedGlyphBitmap, |
|
545 EItalicOn, |
|
546 EEndOfList, |
|
547 }; |
|
548 |
|
549 // here are the output strings which are used for testing |
|
550 _LIT(KHindiText,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020"); |
|
551 _LIT(KEnglishText,"The quick brown fox 123"); |
|
552 _LIT(KEnglishHindiText,"TEST 123 \x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020"); |
|
553 _LIT(KEnglishJapaneseText,"T\x308a\x3093\x3054 ESghy LINKED FONTS 123"); |
|
554 _LIT(KEnglishJapaneseHindiText, "T\x308a\x3093\x3054\x306e EST FOnTS LINKED \x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020 123"); |
|
555 _LIT(KLinkedFontTestString,"lInKED FOnTS"); |
|
556 |
|
557 |
|
558 // test descriptions |
|
559 _LIT(KEnglishTest,"EnglishTest"); |
|
560 _LIT(KHindiTest,"HindiTest"); |
|
561 _LIT(KEnglishHindiTest,"EnglishHindiTest"); |
|
562 _LIT(KEnglishJapaneseTest,"EnglishJapaneseTest"); |
|
563 _LIT(KLinkedFontTest1,"LinkedFontTest-withLinking"); |
|
564 _LIT(KLinkedFontTest2,"LinkedFontTest-unlinkedFont"); |
|
565 _LIT(KEnglishJapaneseHindiTest,"EnglishJapaneseHindiTest"); |
|
566 _LIT(KUseCaseTest,"UseCaseTest"); |
|
567 |
|
568 |
|
569 |
|
570 _LIT(KTestName0001,"TestCase001"); |
|
571 /** this table defines the test cases: |
|
572 font name, string, position, sizes(array), attributes(array) |
|
573 */ |
|
574 const TTestCase KTestCases[]= |
|
575 { |
|
576 {_L("LatinFontHindi"), &KHindiText,&KHindiTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
577 {_L("LatinFontHindi"), &KEnglishText, &KEnglishTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
578 {_L("LatinFontHindi"), &KEnglishHindiText, &KEnglishHindiTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
579 {_L("LatinFontJapanese"),&KEnglishText, &KEnglishTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
580 {_L("LatinFontJapanese"),&KEnglishJapaneseText, &KEnglishJapaneseTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
581 {_L("LinkedFontTestFont"),&KLinkedFontTestString, &KLinkedFontTest1, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
582 {_L("WithoutLinkedFontTT"),&KLinkedFontTestString, &KLinkedFontTest2, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
583 {_L("EnglishJapaneseHindi"),&KEnglishJapaneseHindiText, &KEnglishJapaneseHindiTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest}, |
|
584 |
|
585 //use case testing |
|
586 {_L("UseCaseFont1"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
587 {_L("UseCaseFont2"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
588 {_L("UseCaseFont3"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
589 {_L("UseCaseFont4"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
590 {_L("UseCaseFont5"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
591 {_L("UseCaseFont6"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
592 {_L("UseCaseFont7"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest}, |
|
593 }; |
|
594 |
|
595 /** Class used to register the linked typefaces |
|
596 */ |
|
597 class CTLinkedTypefaceCreator : public CBase |
|
598 { |
|
599 public: |
|
600 static CTLinkedTypefaceCreator* NewL(CTestStep* aStep); |
|
601 void CreateL(); //creates the linked typefaces - will not leave with a registration error, but try the next |
|
602 ~CTLinkedTypefaceCreator(); |
|
603 private: |
|
604 CTLinkedTypefaceCreator(CTestStep* aStep); |
|
605 void CreateGroupsL(const TTGroup* aElement[],TInt aNumberOfElements); |
|
606 void CreateElementsL(const TTLinkedFontElement* aElements); |
|
607 void ConstructL(); |
|
608 |
|
609 private: |
|
610 CTestStep* iStep; //for recording failures, not owned |
|
611 RPointerArray<CLinkedTypefaceGroup> iGroups; //owned |
|
612 RPointerArray<CLinkedTypefaceElementSpec> iElements; //owned |
|
613 CFbsScreenDevice* iDev; //owned |
|
614 }; |
|
615 |
|
616 /** static NewL |
|
617 @return CTLinkedTypefaceCreator* |
|
618 */ |
|
619 CTLinkedTypefaceCreator* CTLinkedTypefaceCreator::NewL(CTestStep* aStep) |
|
620 { |
|
621 CTLinkedTypefaceCreator* ptr = new (ELeave) CTLinkedTypefaceCreator(aStep); |
|
622 CleanupStack::PushL(ptr); |
|
623 ptr->ConstructL(); |
|
624 CleanupStack::Pop(); |
|
625 return ptr; |
|
626 } |
|
627 |
|
628 CTLinkedTypefaceCreator::CTLinkedTypefaceCreator(CTestStep* aStep):iStep(aStep) |
|
629 { |
|
630 |
|
631 } |
|
632 |
|
633 void CTLinkedTypefaceCreator::ConstructL() |
|
634 { |
|
635 TDisplayMode mode[4]= {EColor16MAP, EColor16MA, EColor16MU, EColor64K}; |
|
636 |
|
637 TInt err=KErrNone; |
|
638 for (TInt count=0;count<(sizeof(mode)/sizeof(mode[0]));count++) |
|
639 { |
|
640 TRAP(err, iDev = CFbsScreenDevice::NewL(KNullDesC, mode[count])); |
|
641 if (err!=KErrNotSupported) |
|
642 { |
|
643 return; |
|
644 } |
|
645 } |
|
646 |
|
647 User::LeaveIfError(err); |
|
648 } |
|
649 |
|
650 CTLinkedTypefaceCreator::~CTLinkedTypefaceCreator() |
|
651 { |
|
652 delete iDev; |
|
653 iGroups.ResetAndDestroy(); |
|
654 iElements.ResetAndDestroy(); |
|
655 } |
|
656 |
|
657 /** function used to create the linked typefaces |
|
658 */ |
|
659 void CTLinkedTypefaceCreator::CreateL() |
|
660 { |
|
661 CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev); |
|
662 CleanupStack::PushL(store); |
|
663 |
|
664 for (TInt counter=0; counter< sizeof(KLinkedTypefaces)/sizeof(TTLinkedTypeface);counter++) |
|
665 { |
|
666 //creating the groups needs to be done for every typeface since ownwership is taken |
|
667 //after adding the group to one linked typeface specification |
|
668 //leave on any failure e.g. out of memory, which is not expected |
|
669 CreateGroupsL(KGroupList, sizeof(KGroupList)/sizeof(TTGroup*)); |
|
670 |
|
671 //create the linked typeface elements for this linked typeface |
|
672 CreateElementsL(KLinkedTypefaces[counter].iElements); |
|
673 |
|
674 //add the groups and elements, but first create the spec |
|
675 CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaces[counter].iTypefaceName); |
|
676 |
|
677 //add the groups |
|
678 for (TInt groupCounter=0; groupCounter<iGroups.Count();groupCounter++) |
|
679 { |
|
680 spec->AddLinkedTypefaceGroupL(*iGroups[groupCounter]);//ownership is taken |
|
681 iGroups[groupCounter]=NULL; |
|
682 } |
|
683 |
|
684 //add the elements |
|
685 for (TInt elementCounter=0; elementCounter<iElements.Count();elementCounter++) |
|
686 { |
|
687 spec->AddTypefaceAtBackL(*iElements[elementCounter]);//ownership is taken |
|
688 iElements[elementCounter]=NULL; |
|
689 } |
|
690 iElements.ResetAndDestroy(); |
|
691 iGroups.ResetAndDestroy(); |
|
692 |
|
693 //register |
|
694 TInt err=KErrNone; |
|
695 TRAP(err,spec->RegisterLinkedTypefaceL(*store)); //may fail if something is wrong with the tables, want to try to continue |
|
696 |
|
697 //do not report test failure if already registered |
|
698 iStep->testBooleanTrue(err==KErrNone || err==KErrAlreadyExists, (TText8*)__FILE__, __LINE__); |
|
699 |
|
700 //delete spec |
|
701 CleanupStack::PopAndDestroy(); |
|
702 } |
|
703 CleanupStack::PopAndDestroy();//store |
|
704 } |
|
705 |
|
706 /** function used to create the groups, note all groups are created at once, and |
|
707 added to all linked typefaces |
|
708 |
|
709 @param aElement array of pointers to groups |
|
710 @param aNumberOfElements the number of elements in the group |
|
711 */ |
|
712 void CTLinkedTypefaceCreator::CreateGroupsL(const TTGroup* aElement[],TInt aNumberOfElements) |
|
713 { |
|
714 for (TInt counter =0; counter<aNumberOfElements;counter++) |
|
715 { |
|
716 CLinkedTypefaceGroup* groupPtr= CLinkedTypefaceGroup::NewLC(counter); |
|
717 groupPtr->SetScalingOption(aElement[counter]->iScalingOption); |
|
718 groupPtr->SetBaselineShift(aElement[counter]->iBaselineShift); |
|
719 |
|
720 if (aElement[counter]->iBoldnessPercentage!=KMinTInt) |
|
721 { |
|
722 groupPtr->SetBoldnessPercentage(aElement[counter]->iBoldnessPercentage); |
|
723 } |
|
724 if (aElement[counter]->iItalicAngle!=KMinTInt) |
|
725 { |
|
726 groupPtr->SetItalicAngle(aElement[counter]->iItalicAngle); |
|
727 } |
|
728 iGroups.AppendL(groupPtr); |
|
729 CleanupStack::Pop();//ptr is now on the RArray |
|
730 } |
|
731 } |
|
732 |
|
733 /** creates all the elements for one typeface |
|
734 iElements is updated |
|
735 |
|
736 @param aElements pointer to a list of elements, terminated by a typeface with null name |
|
737 */ |
|
738 |
|
739 void CTLinkedTypefaceCreator::CreateElementsL(const TTLinkedFontElement* aElements) |
|
740 { |
|
741 const TTLinkedFontElement* ptrElementSpec = aElements; |
|
742 |
|
743 //need a loop to go through all the typefaces |
|
744 for (;ptrElementSpec->iTypefaceName!=KNullDesC;ptrElementSpec++) |
|
745 { |
|
746 CLinkedTypefaceElementSpec* elementSpec = CLinkedTypefaceElementSpec::NewLC(ptrElementSpec->iTypefaceName,ptrElementSpec->iGroup); |
|
747 elementSpec->SetCanonical(ptrElementSpec->iIsCanonical); |
|
748 iElements.AppendL(elementSpec); |
|
749 CleanupStack::Pop(); |
|
750 } |
|
751 } |
|
752 |
|
753 // Code for creating fonts, drawing text, and comparing hash value |
|
754 |
|
755 //Considering the intersection of the screen size for both hw and emulator so that same |
|
756 //baselined hash can be used to test for both |
|
757 #define KScreenWidth 320 |
|
758 #define KScreenHeight 240 |
|
759 |
|
760 const TInt KNumOfDisplayModes = 12; |
|
761 |
|
762 /** table of strings of display modes |
|
763 */ |
|
764 const TPtrC KDisplayModeNames[KNumOfDisplayModes] = |
|
765 { |
|
766 _L("EGray2"), |
|
767 _L("EGray4"), |
|
768 _L("EGray16"), |
|
769 _L("EGray256"), |
|
770 _L("EColor16"), |
|
771 _L("EColor256"), |
|
772 _L("EColor64K"), |
|
773 _L("EColor16M"), |
|
774 _L("EColor4K"), |
|
775 _L("EColor16MU"), |
|
776 _L("EColor16MA"), |
|
777 _L("EColor16MAP"), |
|
778 }; |
|
779 |
|
780 /** a mapping table index from DisplayMode into the table of strings |
|
781 for supported colour modes. |
|
782 The tables of strings do not include ERgb, or ENone. The value in the table is also |
|
783 needed for compatibility with CTHashReferenceImages |
|
784 */ |
|
785 const TInt KSupportDisplayStringIndex[14] = |
|
786 { |
|
787 0, //ENone - use EGray2 output string |
|
788 0, //EGray2, |
|
789 1, //EGray4, |
|
790 2, //EGray16, |
|
791 3, //EGray256, |
|
792 4, //EColor16, |
|
793 5, //EColor256, |
|
794 6, //EColor64K, |
|
795 7, //EColor16M, |
|
796 7, //ERgb |
|
797 8, //EColor4K, |
|
798 9, //EColor16MU, |
|
799 10,//EColor16MA, |
|
800 11,//EColor16MAP, |
|
801 }; |
|
802 |
|
803 /** a helper cleanup class |
|
804 */ |
|
805 typedef struct |
|
806 { |
|
807 CBitmapDevice* device; |
|
808 CFont* font; |
|
809 } SCleanFont; |
|
810 |
|
811 /** path where the output file are to be stored (if this is configured in chashreferenceimages.cpp |
|
812 */ |
|
813 _LIT(KPath,"c:\\fntstoretest\\%S.mbm"); |
|
814 |
|
815 /** constructor |
|
816 @param aStep the test step |
|
817 */ |
|
818 CTLinkedFontsComparison::CTLinkedFontsComparison(CTestStep *aStep):CTGraphicsBase(aStep),iStep(aStep) |
|
819 { |
|
820 } |
|
821 |
|
822 /** ConstructL |
|
823 */ |
|
824 void CTLinkedFontsComparison::ConstructL() |
|
825 { |
|
826 iFbs = RFbsSession::GetSession(); |
|
827 User::LeaveIfNull(iFbs); |
|
828 iHashUtil = CTHashReferenceImages::NewL(iStep,iFbs,&KPath); |
|
829 } |
|
830 |
|
831 /** Destructor |
|
832 */ |
|
833 CTLinkedFontsComparison::~CTLinkedFontsComparison() |
|
834 { |
|
835 FreeScreenDevice(); |
|
836 delete iHashUtil; |
|
837 if (iFbs) |
|
838 iFbs->Disconnect(); |
|
839 } |
|
840 |
|
841 /** |
|
842 Auxilary function will be called in case of a leave to release the font |
|
843 @param aCleanFont font to be released |
|
844 */ |
|
845 void CleanUpFont(TAny* aCleanFont) |
|
846 { |
|
847 SCleanFont* cleanFont= static_cast<SCleanFont*>(aCleanFont); |
|
848 (cleanFont->device)->ReleaseFont(cleanFont->font); |
|
849 } |
|
850 |
|
851 |
|
852 class CFbsFontEx : public CFbsFont |
|
853 { |
|
854 public: |
|
855 static CBitmapFont* FontAddress(CFbsFont* aFont); |
|
856 }; |
|
857 |
|
858 CBitmapFont* CFbsFontEx::FontAddress(CFbsFont* aFont) |
|
859 { |
|
860 return(((CFbsFontEx*)aFont)->Address()); |
|
861 } |
|
862 |
|
863 /** |
|
864 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0107 |
|
865 |
|
866 @SYMPREQ PREQ2146 |
|
867 |
|
868 @SYMREQ REQ10924, REQ10925, REQ10926, REQ10927, REQ10942, REQ10943, REQ10947, REQ10949 |
|
869 |
|
870 @SYMTestCaseDesc This test registers linked typefaces with defintions coming from tables. |
|
871 |
|
872 @SYMTestActions Register a number of linked typefaces which are defined in a set of tables. |
|
873 |
|
874 Groups can have the following attributes: |
|
875 CLinkedTypefaceGroup::TBaselineShift |
|
876 CLinkedTypefaceGroup::TScalingOption |
|
877 AntiAliasingThreshold (integer value) |
|
878 BoldnessPercentage (integer value) |
|
879 ItalicAngle (integer value) |
|
880 |
|
881 Typeface elements can have the following attributes: |
|
882 Name |
|
883 Group |
|
884 Is canonical |
|
885 |
|
886 Linked typefaces can have the following attributes: |
|
887 Name |
|
888 Linked typeface elements |
|
889 Groups |
|
890 |
|
891 For each linked typeface to be created |
|
892 create linked typeface specification |
|
893 create groups |
|
894 add groups to linked typeface specification |
|
895 create linked typeface elements |
|
896 add linked typeface elements to linked typeface specification |
|
897 register the specification |
|
898 |
|
899 To produce new linked typefaces it should be possible to do this by updating |
|
900 the table entries. |
|
901 |
|
902 The linked typefaces should be valid. This test requires that the internal test |
|
903 fonts be present. |
|
904 |
|
905 @SYMTestPriority Critical |
|
906 |
|
907 @SYMTestStatus Implemented |
|
908 |
|
909 @SYMTestActions (1)For each linked typeface, create the groups, create the linked typeface elements, |
|
910 create a linked typeface, add the groups and elements, and |
|
911 register the linked typeface with the font and bitmap server. |
|
912 |
|
913 @SYMTestExpectedResults (1) - linked font registration succeeds with no panics or leaves. If the test is run a |
|
914 second time then KErrAlreadyExists is returned, which is not a failure. |
|
915 */ |
|
916 void CTLinkedFontsComparison::RegisterLinkedTypefacesL() |
|
917 { |
|
918 CTLinkedTypefaceCreator* creator = CTLinkedTypefaceCreator::NewL(iStep); |
|
919 CleanupStack::PushL(creator); |
|
920 creator->CreateL(); |
|
921 CleanupStack::PopAndDestroy(); |
|
922 } |
|
923 |
|
924 /** Create the screen device. |
|
925 @param aMode display mode for which device has to be created |
|
926 */ |
|
927 void CTLinkedFontsComparison::CreateBitmapDeviceL(TDisplayMode aMode) |
|
928 { |
|
929 iBitmap = new(ELeave) CFbsBitmap; |
|
930 //Considering the intersection of the screen size for both hw and emulator so that same |
|
931 //baselined hash can be used to test for both |
|
932 iBitmap->Create(TSize(KScreenWidth, KScreenHeight), aMode); |
|
933 iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap); |
|
934 User::LeaveIfError(iBitmapDevice->CreateContext((CGraphicsContext*&)iGc)); |
|
935 iHashUtil->SetScreenDeviceAndBitmap(iBitmapDevice,iBitmap,iGc); |
|
936 } |
|
937 |
|
938 /** |
|
939 Delete the devices created and gc. |
|
940 */ |
|
941 void CTLinkedFontsComparison::FreeScreenDevice() |
|
942 { |
|
943 delete iBitmapDevice; |
|
944 delete iBitmap; |
|
945 delete iGc; |
|
946 iBitmapDevice = NULL; |
|
947 iBitmap = NULL; |
|
948 iGc = NULL; |
|
949 } |
|
950 |
|
951 /** Function to generate a meaningful hash string from the test attributes |
|
952 |
|
953 @param aSize the size of the font |
|
954 @param aAttributes the attributes of the font |
|
955 @see TFontEffectsFlags |
|
956 @param aTypefaceName the typeface name |
|
957 |
|
958 @return the buffer with a text description, used for inclusion in the hash string |
|
959 */ |
|
960 HBufC* CTLinkedFontsComparison::GenerateTestDescriptionLC(TInt aSize,TUint32 aAttributes, const TPtrC &aTypefaceName, const TDesC &aTestDescription) |
|
961 { |
|
962 TBuf<KLengthOfHashValue> tempBuffer; |
|
963 |
|
964 //append the name |
|
965 tempBuffer.Append(_L("_")); |
|
966 tempBuffer.Append(aTypefaceName); |
|
967 tempBuffer.Append(_L("_")); |
|
968 tempBuffer.Append(aTestDescription); |
|
969 tempBuffer.Append(_L("_")); |
|
970 |
|
971 //append the size |
|
972 tempBuffer.AppendFormat(_L("_size-%d"),aSize); |
|
973 if (aAttributes == 0) |
|
974 { |
|
975 //output no attributes |
|
976 tempBuffer.Append(_L("_")); |
|
977 tempBuffer.Append(KFontEffectsFlagsString[0]); //no attributes string |
|
978 } |
|
979 else |
|
980 { |
|
981 for (TInt counter=0;counter<31;counter++) |
|
982 { |
|
983 TInt bit = 1<<counter; //1,2,4,8 etc |
|
984 if (bit&aAttributes) |
|
985 { |
|
986 tempBuffer.Append(_L("_")); |
|
987 tempBuffer.Append(KFontEffectsFlagsString[counter+1]); |
|
988 } |
|
989 } |
|
990 } |
|
991 return tempBuffer.AllocLC(); |
|
992 } |
|
993 |
|
994 /** |
|
995 @SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0108 |
|
996 |
|
997 @SYMPREQ PREQ2146 |
|
998 |
|
999 @SYMREQ REQ10924, REQ10925, REQ10926, REQ10927, REQ10942, REQ10943, REQ10947, REQ10949 |
|
1000 |
|
1001 @SYMTestCaseDesc This test draws fonts and compares a hash value from the output against |
|
1002 a value stored in a file. |
|
1003 |
|
1004 @SYMTestActions The fonts used for this test come from a table, and each font can |
|
1005 be tested with a different output string, size, and creation flag. |
|
1006 The sizes are typically, 10, 20, 35 pixels. |
|
1007 |
|
1008 Steps for each font in the test table entry: |
|
1009 (1)Create the font |
|
1010 (2)For each size |
|
1011 (3) For each attribute |
|
1012 (4)Draw the text and compare against the stored hash value |
|
1013 |
|
1014 |
|
1015 The font creation parameters are typically: |
|
1016 ENoEffect : plain font |
|
1017 EIsUnderlineOn : have underline |
|
1018 EIsStrikethroughOn : have strikethrough |
|
1019 ESetFourColourBlendGlyphBitmap : for shadow and outline |
|
1020 EIsUnderlineOn, EIsStrikethroughOn : both underline and strikethrough |
|
1021 EAlgorithmicBoldOn : algorithmic bold on |
|
1022 EVerticalDraw : vertical text |
|
1023 EVerticalDraw, EIsUnderlineOn : vertical text and underline |
|
1024 |
|
1025 If more fonts or attribute combinations are required to be tested, then this should be |
|
1026 achievable by adding table entries. |
|
1027 |
|
1028 To produce the hash values the test needs to be run with a special version |
|
1029 of test harness where APPEND_NEW_OR_MISSING_HASH_DATA and SAVEBITMAP macros are defined |
|
1030 in thashreferenceimages.cpp. The saved mbm files should be converted to bitmap |
|
1031 for manual checking. |
|
1032 |
|
1033 The fonts used for this tests should have been registered beforehand with |
|
1034 test GRAPHICS-FNTSTORE-LINKEDFONTS-0107. |
|
1035 |
|
1036 @SYMTestPriority Critical |
|
1037 |
|
1038 @SYMTestStatus Implemented |
|
1039 |
|
1040 @SYMTestActions (1) Create the font. Draw text, and compare the hash value against |
|
1041 the value in the file tlinkedfontcomparison.ini. Note that having the same hash |
|
1042 value as the ini file does not necessarily mean that the output is correct. |
|
1043 |
|
1044 @SYMTestExpectedResults (1) - font creation succeeds |
|
1045 (4) - the hash values are the same for each text string output |
|
1046 */ |
|
1047 void CTLinkedFontsComparison::TestDrawTextUsingLinkedFontsL() |
|
1048 { |
|
1049 INFO_PRINTF1(_L("TestDrawTextUsingLinkedFontsL()")); |
|
1050 FreeScreenDevice(); |
|
1051 const TDisplayMode displayMode = EColor16MAP; |
|
1052 |
|
1053 CreateBitmapDeviceL(displayMode); |
|
1054 |
|
1055 INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[KSupportDisplayStringIndex[displayMode]]); |
|
1056 |
|
1057 //for all the tests |
|
1058 TInt numberOfTestsRun=0; |
|
1059 for (TInt testCounter = 0; testCounter< sizeof(KTestCases)/sizeof(TTestCase); testCounter++) |
|
1060 { |
|
1061 |
|
1062 //for all the sizes |
|
1063 const TInt* ptrSizes = KTestCases[testCounter].iSizes; |
|
1064 for (; *ptrSizes!=0 ;ptrSizes++) |
|
1065 { |
|
1066 TInt size = *ptrSizes; |
|
1067 |
|
1068 // for all the attributes |
|
1069 const TUint32 *ptrAttributes = KTestCases[testCounter].iFontAttributes; |
|
1070 for (;*ptrAttributes!=EEndOfList;ptrAttributes++) |
|
1071 |
|
1072 { |
|
1073 TUint32 attributes = *ptrAttributes; |
|
1074 |
|
1075 HBufC* testDescription = GenerateTestDescriptionLC(size,attributes,KTestCases[testCounter].iTypeFaceName,*( KTestCases[testCounter].iTestDecription)); |
|
1076 //this function is used for a fuller description |
|
1077 |
|
1078 //conversion from HBufC to TPtrC |
|
1079 //need this an an argument to the generate hash id function |
|
1080 TPtrC ptr = TPtrC(testDescription->Des()); |
|
1081 |
|
1082 //construct a desriptor string, function in hashutility KTestName0001 |
|
1083 HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC( |
|
1084 KTestName0001,//general name for test |
|
1085 numberOfTestsRun, //number of sub test |
|
1086 &ptr, |
|
1087 0, //fontFaceIndex, index into the name array above, must be zero |
|
1088 KSupportDisplayStringIndex[static_cast<TInt>(displayMode)],//display mode, converted to text |
|
1089 //in the hash code this is an index to a string table, which is missing ENone and ERgb |
|
1090 attributes //was orientation, but just integer at end, no use attributes |
|
1091 ); |
|
1092 |
|
1093 DoTestDrawingOutputL(*hashIdString, KTestCases[testCounter].iTypeFaceName, *(KTestCases[testCounter].iOutputString), |
|
1094 KTestCases[testCounter].iPosition,size,attributes); |
|
1095 |
|
1096 numberOfTestsRun++; |
|
1097 CleanupStack::PopAndDestroy(2,testDescription); |
|
1098 } |
|
1099 }//sizes |
|
1100 }//test array |
|
1101 } |
|
1102 |
|
1103 /** |
|
1104 Function to create a font, draw the text, and compare the hash value |
|
1105 |
|
1106 @param aHashId a string with the hash ID. |
|
1107 @param aFont the font name |
|
1108 @param aOutputString the output string |
|
1109 @param aPosition the position where to draw the text |
|
1110 @param aSize the height of the font in pixels |
|
1111 @param aAttributes the attributes for the font |
|
1112 @see TFontEffectsFlags |
|
1113 */ |
|
1114 void CTLinkedFontsComparison::DoTestDrawingOutputL(const TDesC& aHashId, const TPtrC& aFont, const TDesC& aOutputString, |
|
1115 TPoint aPosition, TInt aSize, TUint32 aAttributes) |
|
1116 { |
|
1117 TFontSpec fontSpec; |
|
1118 PrepareTestEnvironment(fontSpec, aFont, aSize, aAttributes, ETrue, ETrue); |
|
1119 CFont* font; |
|
1120 TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone); |
|
1121 SCleanFont cleanupFont = {iBitmapDevice, font}; |
|
1122 CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont)); |
|
1123 |
|
1124 //may need to add attributes for the font |
|
1125 CBitmapFont* bitmapFont=CFbsFontEx::FontAddress(static_cast<CFbsFont*>(font)); |
|
1126 if (aAttributes& EItalicOn) |
|
1127 { |
|
1128 bitmapFont->iAlgStyle.SetIsItalic(ETrue); |
|
1129 } |
|
1130 if (aAttributes& ERegularBoldOn) |
|
1131 { |
|
1132 bitmapFont->iAlgStyle.SetIsBold(ETrue); |
|
1133 } |
|
1134 |
|
1135 iGc->SetBrushColor(KRgbWhite); |
|
1136 iGc->Clear(); |
|
1137 iGc->SetBrushColor(KRgbYellow); |
|
1138 iGc->UseFont(font); |
|
1139 if(EVerticalDraw & aAttributes) |
|
1140 { |
|
1141 iGc->DrawTextVertical(aOutputString, aPosition, ERotate90Degrees & aAttributes); |
|
1142 } |
|
1143 else |
|
1144 { |
|
1145 iGc->DrawText(aOutputString, aPosition); |
|
1146 } |
|
1147 iHashUtil->CompareHashValuesL(aHashId); |
|
1148 CleanupStack::Pop();//font |
|
1149 iBitmapDevice->ReleaseFont(font); |
|
1150 iGc->DiscardFont(); |
|
1151 } |
|
1152 |
|
1153 /** |
|
1154 Sets the fontspec and gc attributes according to the flags set in STestFontParameters for the test. |
|
1155 Before setting gc attributes it is cleared and reset. |
|
1156 @param aFontSpec holds all effective font settings |
|
1157 @param aSettings holds the flags for setting the fontspec and gc |
|
1158 @param aFontIndex the fonts index of KFontFace to be set as typeface |
|
1159 @param aSetEffects ETrue will set the effects on in fontspec if their flags are enabled. By default it is ETrue. |
|
1160 @param aSetColors ETrue will set the colours in gc from STestFontParameters. By default it is EFalse. |
|
1161 */ |
|
1162 void CTLinkedFontsComparison::PrepareTestEnvironment(TFontSpec &aFontSpec, const TPtrC& aFont, TInt aSize, TUint32 aAttributes, |
|
1163 TBool aSetEffects, TBool aSetColors) |
|
1164 { |
|
1165 //Set the typeface from the font face array |
|
1166 aFontSpec.iTypeface.iName = aFont; |
|
1167 aFontSpec.iHeight = aSize; |
|
1168 |
|
1169 //Set the effects on if any of flags for the effects are set in aSettings and aSetEffects is ETrue |
|
1170 if(aSetEffects) |
|
1171 { |
|
1172 aFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn & aAttributes); |
|
1173 aFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn & aAttributes); |
|
1174 aFontSpec.iFontStyle.SetEffects(FontEffect::ESoftEdge, ESoftEdgeOn & aAttributes); |
|
1175 aFontSpec.iFontStyle.SetEffects(FontEffect::EAlgorithmicBold, EAlgorithmicBoldOn & aAttributes); |
|
1176 } |
|
1177 |
|
1178 iGc->Reset(); |
|
1179 iGc->Clear(); |
|
1180 iGc->SetPenColor(KRgbBlack); |
|
1181 iGc->SetStrikethroughStyle((EIsStrikethroughOn & aAttributes) ? EStrikethroughOn : EStrikethroughOff); |
|
1182 iGc->SetUnderlineStyle((EIsUnderlineOn & aAttributes) ? EUnderlineOn : EUnderlineOff); |
|
1183 |
|
1184 //Set the glyph bitmap type |
|
1185 if(ESetMonochromeGlyphBitmap & aAttributes) |
|
1186 { |
|
1187 aFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap); |
|
1188 } |
|
1189 else if(ESetAntiAliasedGlyphBitmap & aAttributes) |
|
1190 { |
|
1191 aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
1192 } |
|
1193 |
|
1194 //Set the colours in gc if asked for |
|
1195 if(aSetColors) |
|
1196 { |
|
1197 iGc->SetBrushColor(KRgbYellow); |
|
1198 iGc->SetPenColor(KRgbBlack); |
|
1199 iGc->SetShadowColor(KRgbGray); |
|
1200 } |
|
1201 } |
|
1202 |
|
1203 /** Function to determine if the rasterizer has the linked typeface extended interface. |
|
1204 |
|
1205 @return ETrue if the linked fonts rasterizer is present. EFalse otherwise |
|
1206 */ |
|
1207 TBool CTLinkedFontsComparison::CheckMonoTypeInstalledL() |
|
1208 { |
|
1209 CreateBitmapDeviceL(EColor16MU); //this is just for the bitmap device to get the font |
|
1210 |
|
1211 CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iBitmapDevice); |
|
1212 CleanupStack::PushL(store); |
|
1213 |
|
1214 // Create typeface to be linked |
|
1215 _LIT(KLinkedTypefaceTT, "LinkedFont1TT"); |
|
1216 |
|
1217 CLinkedTypefaceSpecification *typefaceSpec; |
|
1218 _LIT(KLinkedFont1TTLinkingTest, "LinkedFont1TTLinkingTest"); |
|
1219 |
|
1220 typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFont1TTLinkingTest); |
|
1221 |
|
1222 CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1); |
|
1223 typefaceSpec->AddLinkedTypefaceGroupL(*group1); |
|
1224 CleanupStack::Pop(); |
|
1225 |
|
1226 // Add first typeface |
|
1227 CLinkedTypefaceElementSpec *elementSpec1; |
|
1228 elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1); |
|
1229 elementSpec1->SetCanonical(ETrue); |
|
1230 |
|
1231 typefaceSpec->AddTypefaceAtBackL(*elementSpec1); |
|
1232 CleanupStack::Pop(1, elementSpec1); |
|
1233 |
|
1234 // Now try regstering the linked typeface |
|
1235 TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store)); |
|
1236 CleanupStack::PopAndDestroy(2, store); |
|
1237 |
|
1238 if (ret == KErrNone|| ret== KErrAlreadyExists) |
|
1239 { |
|
1240 return ETrue; |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 INFO_PRINTF1(_L("Linked fonts comparison: no linked fonts rasterizer found")); |
|
1245 return EFalse; |
|
1246 } |
|
1247 } |
|
1248 |
|
1249 /** regular RunTestCaseL, a virtual function called by the test framework |
|
1250 */ |
|
1251 void CTLinkedFontsComparison::RunTestCaseL(TInt aCurTestCase) |
|
1252 { |
|
1253 ((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
1254 switch (aCurTestCase) |
|
1255 { |
|
1256 case 1: |
|
1257 { |
|
1258 ((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
1259 if (!CheckMonoTypeInstalledL()) |
|
1260 { |
|
1261 TestComplete(); |
|
1262 }; |
|
1263 break; |
|
1264 } |
|
1265 case 2: |
|
1266 { |
|
1267 ((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0107")); |
|
1268 RegisterLinkedTypefacesL(); |
|
1269 break; |
|
1270 } |
|
1271 case 3: |
|
1272 { |
|
1273 ((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0108")); |
|
1274 TestDrawTextUsingLinkedFontsL(); |
|
1275 break; |
|
1276 } |
|
1277 default: |
|
1278 { |
|
1279 ((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
1280 ((CTLinkedFontsComparisonStep*)iStep)->CloseTMSGraphicsStep(); |
|
1281 TestComplete(); |
|
1282 break; |
|
1283 } |
|
1284 } |
|
1285 ((CTLinkedFontsComparisonStep*)iStep)->RecordTestResultL(); |
|
1286 } |
|
1287 |
|
1288 __CONSTRUCT_STEP__(LinkedFontsComparison) |