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