os/textandloc/fontservices/fontstore/tfs/t_linkedfontscomparison.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/fontstore/tfs/t_linkedfontscomparison.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1288 @@
     1.4 +/*
     1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "FNTSTD.H"
    1.23 +#include "t_linkedfontscomparison.h"
    1.24 +#include <hal.h>
    1.25 +#include <test/thashreferenceimages.h>
    1.26 +#include <linkedfonts.h>
    1.27 +
    1.28 +/**
    1.29 +@file 
    1.30 +
    1.31 +@SYMPurpose structures used to define linked typefaces used in this test, create and 
    1.32 +use linked typefaces, and check against a hash value
    1.33 +*/
    1.34 +
    1.35 +/** this is for the group entries
    1.36 + */
    1.37 +struct TTGroup
    1.38 +	{
    1.39 +	CLinkedTypefaceGroup::TBaselineShift iBaselineShift;
    1.40 +	CLinkedTypefaceGroup::TScalingOption iScalingOption;
    1.41 +	TInt iAntiAliasThreshold; //KMinTInt for do not set;
    1.42 +	TInt iBoldnessPercentage; //KMinTInt for do not set;
    1.43 +	TInt iItalicAngle; //KMinTInt for do not set;
    1.44 +	};
    1.45 +
    1.46 +/** this is for linked font elements
    1.47 + */
    1.48 +struct TTLinkedFontElement
    1.49 +	{
    1.50 +	const TPtrC iTypefaceName;
    1.51 +	TInt iGroup;
    1.52 +	TBool iIsCanonical;
    1.53 +	};
    1.54 +
    1.55 +/** this is for the linked typeface table
    1.56 + */
    1.57 +struct TTLinkedTypeface
    1.58 +	{
    1.59 +	const TPtrC iTypefaceName;
    1.60 +	const TTLinkedFontElement* iElements;
    1.61 +	};
    1.62 +
    1.63 +/** this is a plain group
    1.64 + */ 
    1.65 +const TTGroup KPlainGroup =
    1.66 +	{
    1.67 +	CLinkedTypefaceGroup::ENoBaselineShift,
    1.68 +	CLinkedTypefaceGroup::EScalingNone,
    1.69 +	KMinTInt, //this value means do not set	
    1.70 +	KMinTInt, //this value means do not set	
    1.71 +	KMinTInt, //this value means do not set	
    1.72 +	};
    1.73 +
    1.74 +const TTGroup KGroup1 =
    1.75 +	{
    1.76 +	CLinkedTypefaceGroup::ENoBaselineShift,
    1.77 +	CLinkedTypefaceGroup::EScalingNone,
    1.78 +	KMinTInt, //this value means do not set - antialiased	
    1.79 +	KMinTInt, //this value means do not set	- boldness percentage
    1.80 +	KMinTInt, //this value means do not set	- italic angle
    1.81 +	};
    1.82 +
    1.83 +const TTGroup KGroup2 =
    1.84 +	{
    1.85 +	CLinkedTypefaceGroup::EBaselineShift,
    1.86 +	CLinkedTypefaceGroup::EScalingUp,
    1.87 +	KMinTInt, //this value means do not set	
    1.88 +	KMinTInt, //this value means do not set	
    1.89 +	KMinTInt, //this value means do not set	
    1.90 +	};
    1.91 +const TTGroup KGroup3 =
    1.92 +	{
    1.93 +	CLinkedTypefaceGroup::EBaselineShift,
    1.94 +	CLinkedTypefaceGroup::EScalingUpOrDown,
    1.95 +	KMinTInt, //this value means do not set	
    1.96 +	KMinTInt, //this value means do not set	
    1.97 +	KMinTInt, //this value means do not set	
    1.98 +	};
    1.99 +const TTGroup KGroup4 =
   1.100 +	{
   1.101 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.102 +	CLinkedTypefaceGroup::EScalingNone,
   1.103 +	14, //antialiased	
   1.104 +	KMinTInt, //this value means do not set	
   1.105 +	KMinTInt, //this value means do not set	
   1.106 +	};
   1.107 +const TTGroup KGroup5 =
   1.108 +	{
   1.109 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.110 +	CLinkedTypefaceGroup::EScalingNone,
   1.111 +	10, //antialiased	
   1.112 +	KMinTInt, //this value means do not set	
   1.113 +	KMinTInt, //this value means do not set	
   1.114 +	};
   1.115 +const TTGroup KGroup6 =
   1.116 +	{
   1.117 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.118 +	CLinkedTypefaceGroup::EScalingNone,
   1.119 +	KMinTInt, //this value means do not set	
   1.120 +	100, //boldness percentage	
   1.121 +	KMinTInt, //this value means do not set	
   1.122 +	};
   1.123 +const TTGroup KGroup7 =
   1.124 +	{
   1.125 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.126 +	CLinkedTypefaceGroup::EScalingNone,
   1.127 +	KMinTInt, //this value means do not set	
   1.128 +	10, //boldness percentage	
   1.129 +	KMinTInt, //this value means do not set	
   1.130 +	};
   1.131 +const TTGroup KGroup8 =
   1.132 +	{
   1.133 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.134 +	CLinkedTypefaceGroup::EScalingNone,
   1.135 +	KMinTInt, //this value means do not set	
   1.136 +	KMinTInt, //this value means do not set	
   1.137 +	10, //italic angle	
   1.138 +	};
   1.139 +const TTGroup KGroup9 =
   1.140 +	{
   1.141 +	CLinkedTypefaceGroup::EBaselineShift,
   1.142 +	CLinkedTypefaceGroup::EScalingNone,
   1.143 +	KMinTInt, //this value means do not set	
   1.144 +	KMinTInt, //this value means do not set	
   1.145 +	KMinTInt, //this value means do not set	
   1.146 +	};
   1.147 +const TTGroup KGroup10 =
   1.148 +	{
   1.149 +	CLinkedTypefaceGroup::ENoBaselineShift,
   1.150 +	CLinkedTypefaceGroup::EScalingNone,
   1.151 +	KMinTInt, //this value means do not set	
   1.152 +	KMinTInt, //this value means do not set	
   1.153 +	40, //large italic angle	
   1.154 +	};
   1.155 +
   1.156 +/** all the groups are added to every linked typeface
   1.157 +if there are too many groups then there may be a need for a group list
   1.158 +per linked typeface.  Can have a maximum of 12 groups
   1.159 +*/
   1.160 +const TTGroup* KGroupList[]=
   1.161 +	{
   1.162 +	&KPlainGroup, /* index 0 */	
   1.163 +	&KGroup1,
   1.164 +	&KGroup2,
   1.165 +	&KGroup3,
   1.166 +	&KGroup4,
   1.167 +	&KGroup5,
   1.168 +	&KGroup6,
   1.169 +	&KGroup7,
   1.170 +	&KGroup8,
   1.171 +	&KGroup9,
   1.172 +	&KGroup10,
   1.173 +	};
   1.174 +
   1.175 +/** typeface element definitions
   1.176 + */
   1.177 +
   1.178 +/** Latin font
   1.179 + */
   1.180 +const TTLinkedFontElement KLatinFontCanonical = 
   1.181 +	{
   1.182 +	_L("DejaVu Sans Condensed"),0, ETrue //name, group zero, is canonical
   1.183 +	};
   1.184 +	
   1.185 +/** 
   1.186 + */
   1.187 +const TTLinkedFontElement KJapaneseNotCanonical =
   1.188 +	{
   1.189 +	_L("TBKomachiG-R"), 0, EFalse	 //name, group zero, not canonical
   1.190 +	};
   1.191 +
   1.192 +/** Japanese - to be updated
   1.193 + */
   1.194 +const TTLinkedFontElement KJapaneseNotCanonicalGroup1 =
   1.195 +	{
   1.196 +	_L("TBKomachiG-R"), 1, EFalse	 //name, group , not canonical
   1.197 +	};
   1.198 +const TTLinkedFontElement KJapaneseNotCanonicalGroup3 =
   1.199 +	{
   1.200 +	_L("TBKomachiG-R"), 3, EFalse	 //name, group, not canonical
   1.201 +	};
   1.202 +const TTLinkedFontElement KJapaneseNotCanonicalGroup4 =
   1.203 +	{
   1.204 +	_L("TBKomachiG-R"), 4, EFalse	 //name, group, not canonical
   1.205 +	};
   1.206 +const TTLinkedFontElement KJapaneseNotCanonicalGroup6 =
   1.207 +	{
   1.208 +	_L("TBKomachiG-R"), 6, EFalse	 //name, group, not canonical
   1.209 +	};
   1.210 +const TTLinkedFontElement KJapaneseNotCanonicalGroup8 =
   1.211 +	{
   1.212 +	_L("TBKomachiG-R"), 8, EFalse	 //name, group, not canonical
   1.213 +	};
   1.214 +const TTLinkedFontElement KJapaneseNotCanonicalGroup9 =
   1.215 +	{
   1.216 +	_L("TBKomachiG-R"), 9, EFalse	 //name, group, not canonical
   1.217 +	};
   1.218 +const TTLinkedFontElement KJapaneseNotCanonicalGroup10 =
   1.219 +	{
   1.220 +	_L("TBKomachiG-R"), 10, EFalse	 //name, group, not canonical
   1.221 +	};
   1.222 +
   1.223 +const TTLinkedFontElement KLatinFontTTNotCanonicalGroup0 = 
   1.224 +	{
   1.225 +	_L("LinkedFontTestFont"), 0, EFalse
   1.226 +	};
   1.227 +
   1.228 +const TTLinkedFontElement KLatinFontTTCanonicalGroup0 = 
   1.229 +	{
   1.230 +	_L("LinkedFontTestFont"), 0, ETrue
   1.231 +	};
   1.232 +
   1.233 +/* for use case testing */
   1.234 +const TTLinkedFontElement KLatinFontTTCanonicalGroup2 = 
   1.235 +	{
   1.236 +	_L("LinkedFontTestFont"), 2, ETrue
   1.237 +	};
   1.238 +const TTLinkedFontElement KLatinFontTTCanonicalGroup3 = 
   1.239 +	{
   1.240 +	_L("LinkedFontTestFont"), 3, ETrue
   1.241 +	};
   1.242 +const TTLinkedFontElement KLatinFontTTCanonicalGroup5 = 
   1.243 +	{
   1.244 +	_L("LinkedFontTestFont"), 5, ETrue
   1.245 +	};
   1.246 +const TTLinkedFontElement KLatinFontTTCanonicalGroup7 = 
   1.247 +	{
   1.248 +	_L("LinkedFontTestFont"), 7, ETrue
   1.249 +	};
   1.250 +const TTLinkedFontElement KLatinFontTTCanonicalGroup8 = 
   1.251 +	{
   1.252 +	_L("LinkedFontTestFont"), 8, ETrue
   1.253 +	};
   1.254 +const TTLinkedFontElement KLatinFontTTCanonicalGroup9 = 
   1.255 +	{
   1.256 +	_L("LinkedFontTestFont"), 9, ETrue
   1.257 +	};
   1.258 +const TTLinkedFontElement KLatinFontTTCanonicalGroup10 = 
   1.259 +	{
   1.260 +	_L("LinkedFontTestFont"), 10, ETrue
   1.261 +	};
   1.262 +	
   1.263 +/** Chandas 
   1.264 + */
   1.265 +const TTLinkedFontElement KHindiCanonical = 
   1.266 +	{
   1.267 +	_L("Chandas"),  0, ETrue
   1.268 +	};
   1.269 +
   1.270 +/** Chandas 
   1.271 + */
   1.272 +const TTLinkedFontElement KHindiNotCanonical = 
   1.273 +	{
   1.274 +	_L("Chandas"),  0, EFalse
   1.275 +	};
   1.276 +
   1.277 +/** Information about linked fonts
   1.278 +TLinkedFont1.ttf
   1.279 +Typeface name: LinkedFont1
   1.280 +This will be the dominant font. It contains 178 characters.
   1.281 +Some of the characters (13) are deleted from this file and separated in to other three files.
   1.282 +Characters missing are F, D, J, M, P, S, V, X, Z, a, n, l, y.
   1.283 +
   1.284 +TLinkedFont2.ttf
   1.285 +Typeface name: LinkedFont2
   1.286 +Characters available (7):	F, J, M, S, Z, a, y.
   1.287 +
   1.288 +TLinkedFont3.ttf
   1.289 +Typeface name: LinkedFont3
   1.290 +Characters available (4):	D, P, x, l
   1.291 +
   1.292 +TLinkedFont4.ttf
   1.293 +Typeface name: LinkedFont4
   1.294 +Characters available (2):	V, n
   1.295 +
   1.296 +TWithoutLinkedFont.ttf
   1.297 +Typeface name: WithoutLinkedFont
   1.298 +Characters available:	It contains 191 characters U+0020-U+007E and U+00A0-U+00FF
   1.299 +*/	
   1.300 +
   1.301 +/** LinkedFont1TT
   1.302 + */
   1.303 +const TTLinkedFontElement KLinkedFont1TT = 
   1.304 +	{
   1.305 +	_L("LinkedFont1TT"),  0, EFalse
   1.306 +	};
   1.307 +
   1.308 +/** LinkedFont2TT
   1.309 + */
   1.310 +const TTLinkedFontElement KLinkedFont2TTCanonical = 
   1.311 +	{
   1.312 +	_L("LinkedFont2TT"),  0, ETrue
   1.313 +	};
   1.314 +
   1.315 +/** LinkedFont3TT
   1.316 + */
   1.317 +const TTLinkedFontElement KLinkedFont3TT = 
   1.318 +	{
   1.319 +	_L("LinkedFont3TT"),  0, EFalse
   1.320 +	};
   1.321 +
   1.322 +/** LinkedFont4TT
   1.323 + */
   1.324 +const TTLinkedFontElement KLinkedFont4TT = 
   1.325 +	{
   1.326 +	_L("LinkedFont4TT"),  0, EFalse
   1.327 +	};
   1.328 +
   1.329 +/** KNullDesC
   1.330 + */
   1.331 +const TTLinkedFontElement KNullElement = 
   1.332 +	{
   1.333 +	_L(""),  0, EFalse
   1.334 +	};
   1.335 +	
   1.336 +/** linked typeface, this list is terminated by KNullElement
   1.337 + */
   1.338 +const TTLinkedFontElement KLatinFontHindi[]=
   1.339 +	{
   1.340 +	KLatinFontTTNotCanonicalGroup0,
   1.341 +	KHindiCanonical,
   1.342 +	KNullElement,
   1.343 +	};
   1.344 +/** linked typeface, this list is terminated by KNullElement
   1.345 + */
   1.346 +const TTLinkedFontElement KLatinFontJapanese[]=
   1.347 +	{
   1.348 +	KLatinFontCanonical,
   1.349 +	KJapaneseNotCanonical,
   1.350 +	KNullElement
   1.351 +	};
   1.352 +/** linked typeface, this list is terminated by KNullElement
   1.353 + */
   1.354 +const TTLinkedFontElement KLinkedFontTestFonts[]=
   1.355 +	{
   1.356 +	KLinkedFont1TT,
   1.357 +	KLinkedFont2TTCanonical,
   1.358 +	KLinkedFont3TT,
   1.359 +	KLinkedFont4TT,
   1.360 +	KNullElement
   1.361 +	};
   1.362 +
   1.363 +const TTLinkedFontElement KJapaneseLatinFontTypeface1[]=
   1.364 +	{
   1.365 +	KLatinFontTTCanonicalGroup2,
   1.366 +	KJapaneseNotCanonicalGroup1,
   1.367 +	KNullElement
   1.368 +	};
   1.369 +const TTLinkedFontElement KJapaneseLatinFontTypeface2[]=
   1.370 +	{
   1.371 +	KLatinFontTTCanonicalGroup3,
   1.372 +	KJapaneseNotCanonicalGroup3,
   1.373 +	KNullElement
   1.374 +	};
   1.375 +const TTLinkedFontElement KJapaneseLatinFontTypeface3[]=
   1.376 +	{
   1.377 +	KLatinFontTTCanonicalGroup5,
   1.378 +	KJapaneseNotCanonicalGroup4,
   1.379 +	KNullElement
   1.380 +	};
   1.381 +const TTLinkedFontElement KJapaneseLatinFontTypeface4[]=
   1.382 +	{
   1.383 +	KLatinFontTTCanonicalGroup7,
   1.384 +	KJapaneseNotCanonicalGroup6,
   1.385 +	KNullElement
   1.386 +	};
   1.387 +const TTLinkedFontElement KJapaneseLatinFontTypeface5[]=
   1.388 +	{
   1.389 +	KLatinFontTTCanonicalGroup8,
   1.390 +	KJapaneseNotCanonicalGroup8,
   1.391 +	KNullElement
   1.392 +	};
   1.393 +const TTLinkedFontElement KJapaneseLatinFontTypeface6[]=
   1.394 +	{
   1.395 +	KLatinFontTTCanonicalGroup9,
   1.396 +	KJapaneseNotCanonicalGroup9,
   1.397 +	KNullElement
   1.398 +	};
   1.399 +
   1.400 +const TTLinkedFontElement KJapaneseLatinFontTypeface7[]=
   1.401 +	{
   1.402 +	KLatinFontTTCanonicalGroup10,
   1.403 +	KJapaneseNotCanonicalGroup10,
   1.404 +	KNullElement
   1.405 +	};
   1.406 +
   1.407 +const TTLinkedFontElement KEnglishJapanseHindiFont[]=
   1.408 +	{
   1.409 +	KLatinFontTTCanonicalGroup0,
   1.410 +	KJapaneseNotCanonical,
   1.411 +	KHindiNotCanonical,
   1.412 +	KNullElement
   1.413 +	};
   1.414 +
   1.415 +/** the linked typeface set, no need to null terminate, sizeof is used for this array
   1.416 + */
   1.417 +const TTLinkedTypeface KLinkedTypefaces[] =
   1.418 +	{
   1.419 +	//name, list of linked font elements
   1.420 +	{_L("LinkedFontTestFont"), KLinkedFontTestFonts},		
   1.421 +	{_L("LatinFontHindi"), KLatinFontHindi}, 
   1.422 +	{_L("LatinFontJapanese"), KLatinFontJapanese},
   1.423 +	{_L("EnglishJapaneseHindi"), KEnglishJapanseHindiFont},
   1.424 +	{_L("UseCaseFont1"), KJapaneseLatinFontTypeface1},
   1.425 +	{_L("UseCaseFont2"), KJapaneseLatinFontTypeface2},
   1.426 +	{_L("UseCaseFont3"), KJapaneseLatinFontTypeface3},
   1.427 +	{_L("UseCaseFont4"), KJapaneseLatinFontTypeface4},
   1.428 +	{_L("UseCaseFont5"), KJapaneseLatinFontTypeface5},
   1.429 +	{_L("UseCaseFont6"), KJapaneseLatinFontTypeface6},
   1.430 +	{_L("UseCaseFont7"), KJapaneseLatinFontTypeface7},
   1.431 +	};
   1.432 +
   1.433 +/** Enum which constains bitwise flags for attrbutes which can be set for each font
   1.434 + */
   1.435 +enum TFontEffectsFlags
   1.436 +	{
   1.437 +	ENoEffect = 0x0,
   1.438 +	EDropShadowOn = 0x1,
   1.439 +	EOutlineOn = 0x2,
   1.440 +	ESetMonochromeGlyphBitmap  = 0x4,
   1.441 +	ESetAntiAliasedGlyphBitmap = 0x8,
   1.442 +	ESetFourColourBlendGlyphBitmap = 0x10,
   1.443 +	EVerticalDraw = 0x20,
   1.444 +	ERotate90Degrees = 0x40,
   1.445 +	EIsStrikethroughOn = 0x80,
   1.446 +	EIsUnderlineOn = 0x100,
   1.447 +	ESoftEdgeOn = 0x200,
   1.448 +	EAlgorithmicBoldOn = 0x400,
   1.449 +	EDrawUp = 0x800,
   1.450 +	EItalicOn = 0x1000,
   1.451 +	ERegularBoldOn = 0x2000,
   1.452 +	EEndOfList = 0x80000000 //a meta flag
   1.453 +	};
   1.454 +
   1.455 +const TInt KLengthOfHashValue = 1000;
   1.456 +
   1.457 +/** table used to produce hash string from attributes 
   1.458 + */
   1.459 +const TPtrC KFontEffectsFlagsString[32]=
   1.460 +	{
   1.461 +	_L("ENoEffect"),
   1.462 +	_L("EDropShadowOn"),
   1.463 +	_L("EOutlineOn"),
   1.464 +	_L("ESetMonochromeGlyphBitmap"),
   1.465 +	_L("ESetAntiAliasedGlyphBitmap"),
   1.466 +	_L("ESetFourColourBlendGlyphBitmap"),
   1.467 +	_L("EVerticalDraw"),
   1.468 +	_L("ERotate90Degrees"),
   1.469 +	_L("EIsStrikethroughOn"),
   1.470 +	_L("EIsUnderlineOn"),
   1.471 +	_L("ESoftEdgeOn"),
   1.472 +	_L("EAlgorithmicBoldOn"),
   1.473 +	_L("EDrawUp"),
   1.474 +	_L("EItalicOn"),
   1.475 +	_L("ERegularBoldOn"),
   1.476 +	_L(""),
   1.477 +	_L(""),
   1.478 +	_L(""),
   1.479 +	_L(""),
   1.480 +	_L(""),
   1.481 +	_L(""),
   1.482 +	_L(""),
   1.483 +	_L(""),
   1.484 +	_L(""),
   1.485 +	_L(""),
   1.486 +	_L(""),
   1.487 +	_L(""),
   1.488 +	_L(""),
   1.489 +	_L(""),
   1.490 +	_L(""),
   1.491 +	_L(""),
   1.492 +	_L("EEndOfList"),
   1.493 +	};
   1.494 +
   1.495 +
   1.496 +/**this structure is used to define a test case
   1.497 + */
   1.498 +struct TTestCase
   1.499 +	{
   1.500 +	const TPtrC iTypeFaceName; //typeface name 
   1.501 +	const TDesC* iOutputString; //the output string
   1.502 +	const TDesC* iTestDecription; //test description
   1.503 +	const TPoint iPosition; //the position
   1.504 +	const TInt* iSizes; // a list of sizes
   1.505 +	const TUint32* iFontAttributes; //a list of font attrbutes (bitwise flags, see above
   1.506 +	};
   1.507 +
   1.508 +/** an array of sizes used during testing, terminated by zero
   1.509 + */
   1.510 +const TInt KFontSizeNormalTesting[]=
   1.511 +	{
   1.512 +	10,
   1.513 +	20,
   1.514 +	35,
   1.515 +	0 
   1.516 +	};
   1.517 +
   1.518 +const TInt KFontSizeUseCaseTesting[]=
   1.519 +	{
   1.520 +	8,
   1.521 +	12,
   1.522 +	16,
   1.523 +	35,
   1.524 +	0
   1.525 +	};
   1.526 +
   1.527 +/** an array of attributes used during font testing, terminated by EEndOfList
   1.528 + */
   1.529 +const TUint32 KFontAttributesNormalTest[] =// probably need to expand this with position
   1.530 +	{
   1.531 +	ENoEffect,
   1.532 +	EIsUnderlineOn,
   1.533 +	EIsStrikethroughOn,
   1.534 +	ESetFourColourBlendGlyphBitmap,
   1.535 +	EIsUnderlineOn| EIsStrikethroughOn,
   1.536 +	EAlgorithmicBoldOn,
   1.537 +	EVerticalDraw,
   1.538 +	EVerticalDraw | EIsUnderlineOn,
   1.539 +	EVerticalDraw | EIsUnderlineOn | ERotate90Degrees,
   1.540 +	EEndOfList,
   1.541 +	};
   1.542 +
   1.543 +const TUint32 KFontAttributesUseCaseTest[] =// probably need to expand this with position
   1.544 +	{
   1.545 +	ENoEffect,
   1.546 +	ERegularBoldOn,
   1.547 +	ESetAntiAliasedGlyphBitmap,
   1.548 +	EItalicOn,
   1.549 +	EEndOfList,
   1.550 +	};
   1.551 +
   1.552 +// here are the output strings which are used for testing
   1.553 +_LIT(KHindiText,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020");
   1.554 +_LIT(KEnglishText,"The quick brown fox 123");
   1.555 +_LIT(KEnglishHindiText,"TEST 123 \x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020");
   1.556 +_LIT(KEnglishJapaneseText,"T\x308a\x3093\x3054 ESghy LINKED FONTS 123");
   1.557 +_LIT(KEnglishJapaneseHindiText, "T\x308a\x3093\x3054\x306e EST FOnTS LINKED \x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020 123");
   1.558 +_LIT(KLinkedFontTestString,"lInKED FOnTS");
   1.559 +
   1.560 +
   1.561 +// test descriptions
   1.562 +_LIT(KEnglishTest,"EnglishTest");
   1.563 +_LIT(KHindiTest,"HindiTest");
   1.564 +_LIT(KEnglishHindiTest,"EnglishHindiTest");
   1.565 +_LIT(KEnglishJapaneseTest,"EnglishJapaneseTest");
   1.566 +_LIT(KLinkedFontTest1,"LinkedFontTest-withLinking");
   1.567 +_LIT(KLinkedFontTest2,"LinkedFontTest-unlinkedFont");
   1.568 +_LIT(KEnglishJapaneseHindiTest,"EnglishJapaneseHindiTest");
   1.569 +_LIT(KUseCaseTest,"UseCaseTest");
   1.570 +
   1.571 +
   1.572 +
   1.573 +_LIT(KTestName0001,"TestCase001");
   1.574 +/** this table defines the test cases:
   1.575 + font name, string, position, sizes(array), attributes(array)
   1.576 + */
   1.577 +const TTestCase KTestCases[]=
   1.578 +	{
   1.579 +	{_L("LatinFontHindi"), &KHindiText,&KHindiTest, TPoint(50,50),KFontSizeNormalTesting,	KFontAttributesNormalTest},
   1.580 +	{_L("LatinFontHindi"), &KEnglishText, &KEnglishTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.581 +	{_L("LatinFontHindi"), &KEnglishHindiText, &KEnglishHindiTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.582 +	{_L("LatinFontJapanese"),&KEnglishText, &KEnglishTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.583 +	{_L("LatinFontJapanese"),&KEnglishJapaneseText, &KEnglishJapaneseTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.584 +	{_L("LinkedFontTestFont"),&KLinkedFontTestString, &KLinkedFontTest1, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.585 +	{_L("WithoutLinkedFontTT"),&KLinkedFontTestString, &KLinkedFontTest2, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.586 +	{_L("EnglishJapaneseHindi"),&KEnglishJapaneseHindiText, &KEnglishJapaneseHindiTest, TPoint(50,50),KFontSizeNormalTesting, KFontAttributesNormalTest},
   1.587 +
   1.588 +	//use case testing
   1.589 +	{_L("UseCaseFont1"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.590 +	{_L("UseCaseFont2"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.591 +	{_L("UseCaseFont3"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.592 +	{_L("UseCaseFont4"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.593 +	{_L("UseCaseFont5"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.594 +	{_L("UseCaseFont6"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.595 +	{_L("UseCaseFont7"),&KEnglishJapaneseText, &KUseCaseTest, TPoint(50,50),KFontSizeUseCaseTesting, KFontAttributesUseCaseTest},
   1.596 +	};
   1.597 +
   1.598 +/** Class used to register the linked typefaces
   1.599 + */	
   1.600 +class CTLinkedTypefaceCreator : public CBase
   1.601 +	{
   1.602 +public:
   1.603 +	static CTLinkedTypefaceCreator* NewL(CTestStep* aStep);
   1.604 +	void CreateL(); //creates the linked typefaces - will not leave with a registration error, but try the next
   1.605 +	~CTLinkedTypefaceCreator();
   1.606 +private:
   1.607 +	CTLinkedTypefaceCreator(CTestStep* aStep);
   1.608 +	void CreateGroupsL(const TTGroup* aElement[],TInt aNumberOfElements);
   1.609 +	void CreateElementsL(const TTLinkedFontElement* aElements);
   1.610 +	void ConstructL();
   1.611 +
   1.612 +private:	
   1.613 +	CTestStep* iStep; //for recording failures, not owned
   1.614 +	RPointerArray<CLinkedTypefaceGroup> iGroups; //owned
   1.615 +	RPointerArray<CLinkedTypefaceElementSpec> iElements; //owned
   1.616 +	CFbsScreenDevice* iDev; //owned
   1.617 +	};
   1.618 +
   1.619 +/** static NewL
   1.620 +@return CTLinkedTypefaceCreator* 
   1.621 + */
   1.622 +CTLinkedTypefaceCreator* CTLinkedTypefaceCreator::NewL(CTestStep* aStep)
   1.623 +	{
   1.624 +	CTLinkedTypefaceCreator*  ptr = new (ELeave) CTLinkedTypefaceCreator(aStep);
   1.625 +	CleanupStack::PushL(ptr);
   1.626 +	ptr->ConstructL();
   1.627 +	CleanupStack::Pop();
   1.628 +	return ptr;
   1.629 +	}	
   1.630 +
   1.631 +CTLinkedTypefaceCreator::CTLinkedTypefaceCreator(CTestStep* aStep):iStep(aStep)
   1.632 +	{
   1.633 +		
   1.634 +	}
   1.635 +
   1.636 +void CTLinkedTypefaceCreator::ConstructL()
   1.637 +	{
   1.638 +	TDisplayMode mode[4]= {EColor16MAP, EColor16MA, EColor16MU, EColor64K};
   1.639 +
   1.640 +	TInt err=KErrNone;
   1.641 +	for (TInt count=0;count<(sizeof(mode)/sizeof(mode[0]));count++)
   1.642 +		{
   1.643 +		TRAP(err, iDev = CFbsScreenDevice::NewL(KNullDesC, mode[count]));
   1.644 +		if (err!=KErrNotSupported)
   1.645 +			{
   1.646 +			return;
   1.647 +			}
   1.648 +		}
   1.649 +
   1.650 +	User::LeaveIfError(err);
   1.651 +	}
   1.652 +
   1.653 +CTLinkedTypefaceCreator::~CTLinkedTypefaceCreator()
   1.654 +	{
   1.655 +	delete iDev;
   1.656 +	iGroups.ResetAndDestroy();
   1.657 +	iElements.ResetAndDestroy();
   1.658 +	}
   1.659 +	
   1.660 +/** function used to create the linked typefaces
   1.661 + */
   1.662 +void CTLinkedTypefaceCreator::CreateL()
   1.663 +	{
   1.664 +	CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
   1.665 +	CleanupStack::PushL(store);
   1.666 +
   1.667 +	for (TInt counter=0; counter< sizeof(KLinkedTypefaces)/sizeof(TTLinkedTypeface);counter++)
   1.668 +		{
   1.669 +		//creating the groups needs to be done for every typeface since ownwership is taken
   1.670 +		//after adding the group to one linked typeface specification
   1.671 +		//leave on any failure e.g. out of memory, which is not expected
   1.672 +		CreateGroupsL(KGroupList, sizeof(KGroupList)/sizeof(TTGroup*));
   1.673 +
   1.674 +		//create the linked typeface elements for this linked typeface
   1.675 +		CreateElementsL(KLinkedTypefaces[counter].iElements);
   1.676 +
   1.677 +		//add the groups and elements, but first create the spec
   1.678 +		CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaces[counter].iTypefaceName);
   1.679 +		
   1.680 +		//add the groups
   1.681 +		for (TInt groupCounter=0; groupCounter<iGroups.Count();groupCounter++)
   1.682 +			{
   1.683 +			spec->AddLinkedTypefaceGroupL(*iGroups[groupCounter]);//ownership is taken
   1.684 +			iGroups[groupCounter]=NULL;
   1.685 +			}
   1.686 +
   1.687 +		//add the elements
   1.688 +		for (TInt elementCounter=0; elementCounter<iElements.Count();elementCounter++)
   1.689 +			{
   1.690 +			spec->AddTypefaceAtBackL(*iElements[elementCounter]);//ownership is taken
   1.691 +			iElements[elementCounter]=NULL;
   1.692 +			}
   1.693 +		iElements.ResetAndDestroy();
   1.694 +		iGroups.ResetAndDestroy();
   1.695 +
   1.696 +		//register
   1.697 +		TInt err=KErrNone;
   1.698 +		TRAP(err,spec->RegisterLinkedTypefaceL(*store)); //may fail if something is wrong with the tables, want to try to continue
   1.699 +
   1.700 +		//do not report test failure if already registered
   1.701 +		iStep->testBooleanTrue(err==KErrNone || err==KErrAlreadyExists, (TText8*)__FILE__, __LINE__);
   1.702 +
   1.703 +		//delete spec
   1.704 +		CleanupStack::PopAndDestroy();
   1.705 +		}
   1.706 +	CleanupStack::PopAndDestroy();//store
   1.707 +	}
   1.708 +
   1.709 +/** function used to create the groups, note all groups are created at once, and 
   1.710 +added to all linked typefaces
   1.711 +
   1.712 +@param aElement array of pointers to groups
   1.713 +@param aNumberOfElements the number of elements in the group
   1.714 +*/
   1.715 +void CTLinkedTypefaceCreator::CreateGroupsL(const TTGroup* aElement[],TInt aNumberOfElements)
   1.716 +	{
   1.717 +	for (TInt counter =0; counter<aNumberOfElements;counter++)
   1.718 +		{
   1.719 +		CLinkedTypefaceGroup* groupPtr= CLinkedTypefaceGroup::NewLC(counter);
   1.720 +		groupPtr->SetScalingOption(aElement[counter]->iScalingOption);
   1.721 +		groupPtr->SetBaselineShift(aElement[counter]->iBaselineShift);
   1.722 +
   1.723 +		if (aElement[counter]->iBoldnessPercentage!=KMinTInt)
   1.724 +			{
   1.725 +			groupPtr->SetBoldnessPercentage(aElement[counter]->iBoldnessPercentage);
   1.726 +			}
   1.727 +		if (aElement[counter]->iItalicAngle!=KMinTInt)
   1.728 +			{
   1.729 +			groupPtr->SetItalicAngle(aElement[counter]->iItalicAngle);
   1.730 +			}	
   1.731 +		iGroups.AppendL(groupPtr);
   1.732 +		CleanupStack::Pop();//ptr is now on the RArray
   1.733 +		}
   1.734 +	}
   1.735 +
   1.736 +/** creates all the elements for one typeface
   1.737 +iElements is updated
   1.738 +
   1.739 +@param aElements pointer to a list of elements, terminated by a typeface with null name 
   1.740 +*/
   1.741 +
   1.742 +void CTLinkedTypefaceCreator::CreateElementsL(const TTLinkedFontElement* aElements)
   1.743 +	{
   1.744 +	const TTLinkedFontElement* ptrElementSpec = aElements;
   1.745 +	
   1.746 +	//need a loop to go through all the typefaces 
   1.747 +	for (;ptrElementSpec->iTypefaceName!=KNullDesC;ptrElementSpec++)
   1.748 +		{
   1.749 +		CLinkedTypefaceElementSpec* elementSpec = CLinkedTypefaceElementSpec::NewLC(ptrElementSpec->iTypefaceName,ptrElementSpec->iGroup);
   1.750 +		elementSpec->SetCanonical(ptrElementSpec->iIsCanonical);
   1.751 +		iElements.AppendL(elementSpec);
   1.752 +		CleanupStack::Pop();
   1.753 +		}
   1.754 +	}
   1.755 +
   1.756 +// Code for creating fonts, drawing text, and comparing hash value
   1.757 +
   1.758 +//Considering the intersection of the screen size for both hw and emulator so that same
   1.759 +//baselined hash can be used to test for both
   1.760 +#define	KScreenWidth 320
   1.761 +#define	KScreenHeight 240
   1.762 +
   1.763 +const TInt KNumOfDisplayModes = 12;
   1.764 +
   1.765 +/** table of strings of display modes
   1.766 + */
   1.767 +const TPtrC KDisplayModeNames[KNumOfDisplayModes] = 
   1.768 +	{
   1.769 +	_L("EGray2"),
   1.770 +	_L("EGray4"),
   1.771 +	_L("EGray16"),
   1.772 +	_L("EGray256"),
   1.773 +	_L("EColor16"),
   1.774 +	_L("EColor256"),
   1.775 +	_L("EColor64K"),
   1.776 +	_L("EColor16M"),
   1.777 +	_L("EColor4K"),
   1.778 +	_L("EColor16MU"),
   1.779 +	_L("EColor16MA"),
   1.780 +	_L("EColor16MAP"),
   1.781 +	};
   1.782 +
   1.783 +/** a mapping table index from DisplayMode into the table of strings
   1.784 +for supported colour modes.  
   1.785 +The tables of strings do not include ERgb, or ENone.  The value in the table is also
   1.786 +needed for compatibility with CTHashReferenceImages
   1.787 +*/
   1.788 +const TInt KSupportDisplayStringIndex[14] = 
   1.789 +	{
   1.790 +	0, //ENone - use EGray2 output string 
   1.791 +	0, //EGray2,
   1.792 +	1, //EGray4,
   1.793 +	2, //EGray16,
   1.794 +	3, //EGray256,
   1.795 +	4, //EColor16,
   1.796 +	5, //EColor256,
   1.797 +	6, //EColor64K,
   1.798 +	7, //EColor16M,
   1.799 +	7, //ERgb
   1.800 +	8, //EColor4K,
   1.801 +	9, //EColor16MU,
   1.802 +	10,//EColor16MA,
   1.803 +	11,//EColor16MAP,
   1.804 + 	};
   1.805 +
   1.806 +/** a helper cleanup class
   1.807 + */
   1.808 +typedef struct
   1.809 +	{
   1.810 +	CBitmapDevice* device;
   1.811 +	CFont* font;
   1.812 +	} SCleanFont;
   1.813 +
   1.814 +/** path where the output file are to be stored (if this is configured in chashreferenceimages.cpp
   1.815 +*/
   1.816 +_LIT(KPath,"c:\\fntstoretest\\%S.mbm");
   1.817 +
   1.818 +/** constructor
   1.819 +@param aStep the test step
   1.820 + */
   1.821 +CTLinkedFontsComparison::CTLinkedFontsComparison(CTestStep *aStep):CTGraphicsBase(aStep),iStep(aStep)
   1.822 +	{	
   1.823 +	}
   1.824 +
   1.825 +/** ConstructL
   1.826 + */
   1.827 +void CTLinkedFontsComparison::ConstructL()
   1.828 +	{
   1.829 +	iFbs = RFbsSession::GetSession();
   1.830 +	User::LeaveIfNull(iFbs);
   1.831 +	iHashUtil = CTHashReferenceImages::NewL(iStep,iFbs,&KPath);
   1.832 +	}
   1.833 +
   1.834 +/** Destructor
   1.835 + */
   1.836 +CTLinkedFontsComparison::~CTLinkedFontsComparison()
   1.837 +	{
   1.838 +	FreeScreenDevice();
   1.839 +	delete iHashUtil;
   1.840 +	if (iFbs)
   1.841 +		iFbs->Disconnect();
   1.842 +	}
   1.843 +	
   1.844 +/**
   1.845 +Auxilary function will be called in case of a leave to release the font
   1.846 +@param aCleanFont font to be released
   1.847 +*/
   1.848 +void CleanUpFont(TAny* aCleanFont)
   1.849 +	{
   1.850 +	SCleanFont* cleanFont= static_cast<SCleanFont*>(aCleanFont);
   1.851 +	(cleanFont->device)->ReleaseFont(cleanFont->font);
   1.852 +	}
   1.853 +
   1.854 +
   1.855 +class CFbsFontEx : public CFbsFont
   1.856 +	{
   1.857 +public:
   1.858 +	static CBitmapFont* FontAddress(CFbsFont* aFont);
   1.859 +	};
   1.860 +
   1.861 +CBitmapFont* CFbsFontEx::FontAddress(CFbsFont* aFont)
   1.862 +	{
   1.863 +	return(((CFbsFontEx*)aFont)->Address());
   1.864 +	}
   1.865 +
   1.866 +/**
   1.867 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0107
   1.868 +
   1.869 +   @SYMPREQ					PREQ2146
   1.870 +
   1.871 +   @SYMREQ					REQ10924, REQ10925, REQ10926, REQ10927, REQ10942, REQ10943, REQ10947, REQ10949
   1.872 +
   1.873 +   @SYMTestCaseDesc			This test registers linked typefaces with defintions coming from tables.
   1.874 +
   1.875 +   @SYMTestActions 			Register a number of linked typefaces which are defined in a set of tables. 
   1.876 +      				
   1.877 +      						Groups can have the following attributes:
   1.878 +      							CLinkedTypefaceGroup::TBaselineShift
   1.879 +								CLinkedTypefaceGroup::TScalingOption
   1.880 +								AntiAliasingThreshold (integer value)
   1.881 +								BoldnessPercentage (integer value)
   1.882 +								ItalicAngle (integer value)
   1.883 +
   1.884 +							Typeface elements can have the following attributes:
   1.885 +								Name
   1.886 +								Group
   1.887 +								Is canonical
   1.888 +
   1.889 +							Linked typefaces can have the following attributes:
   1.890 +								Name
   1.891 +								Linked typeface elements
   1.892 +								Groups
   1.893 + 
   1.894 + 							For each linked typeface to be created
   1.895 + 								create linked typeface specification
   1.896 + 								create groups
   1.897 + 								add groups to linked typeface specification
   1.898 + 								create linked typeface elements
   1.899 + 								add linked typeface elements to linked typeface specification
   1.900 + 								register the specification
   1.901 + 
   1.902 +   							To produce new linked typefaces it should be possible to do this by updating
   1.903 +   							the table entries.   							
   1.904 +
   1.905 +   							The linked typefaces should be valid.  This test requires that the internal test
   1.906 +   							fonts be present.
   1.907 +
   1.908 +   @SYMTestPriority			Critical
   1.909 +
   1.910 +   @SYMTestStatus			Implemented
   1.911 +
   1.912 +   @SYMTestActions			(1)For each linked typeface, create the groups, create the linked typeface elements,
   1.913 +   							create a linked typeface, add the groups and elements, and 
   1.914 +   						 	register the linked typeface with the font and bitmap server.	
   1.915 +
   1.916 +   @SYMTestExpectedResults	(1) - linked font registration succeeds with no panics or leaves.  If the test is run a
   1.917 +   								second time then KErrAlreadyExists is returned, which is not a failure.
   1.918 +*/	
   1.919 +void CTLinkedFontsComparison::RegisterLinkedTypefacesL()
   1.920 +	{
   1.921 +	CTLinkedTypefaceCreator* creator = CTLinkedTypefaceCreator::NewL(iStep);
   1.922 +	CleanupStack::PushL(creator);
   1.923 +	creator->CreateL();
   1.924 +	CleanupStack::PopAndDestroy();
   1.925 +	}
   1.926 +	
   1.927 +/** Create the screen device.
   1.928 +@param aMode display mode for which device has to be created
   1.929 +*/
   1.930 +void CTLinkedFontsComparison::CreateBitmapDeviceL(TDisplayMode aMode)
   1.931 +	{
   1.932 +	iBitmap = new(ELeave) CFbsBitmap;
   1.933 +	//Considering the intersection of the screen size for both hw and emulator so that same
   1.934 +	//baselined hash can be used to test for both
   1.935 +	iBitmap->Create(TSize(KScreenWidth, KScreenHeight), aMode);
   1.936 +	iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
   1.937 +	User::LeaveIfError(iBitmapDevice->CreateContext((CGraphicsContext*&)iGc));
   1.938 +	iHashUtil->SetScreenDeviceAndBitmap(iBitmapDevice,iBitmap,iGc);
   1.939 +	}
   1.940 +
   1.941 +/**
   1.942 +Delete the devices created and gc.
   1.943 +*/
   1.944 +void CTLinkedFontsComparison::FreeScreenDevice()
   1.945 +	{
   1.946 +	delete iBitmapDevice;
   1.947 +	delete iBitmap;
   1.948 +	delete iGc;
   1.949 +	iBitmapDevice = NULL;
   1.950 +	iBitmap = NULL;
   1.951 +	iGc = NULL;
   1.952 +	}
   1.953 +
   1.954 +/** Function to generate a meaningful hash string from the test attributes
   1.955 +
   1.956 +@param aSize the size of the font
   1.957 +@param aAttributes the attributes of the font 
   1.958 +@see TFontEffectsFlags
   1.959 +@param aTypefaceName the typeface name
   1.960 +
   1.961 +@return the buffer with a text description, used for inclusion in the hash string
   1.962 +*/
   1.963 +HBufC* CTLinkedFontsComparison::GenerateTestDescriptionLC(TInt aSize,TUint32 aAttributes, const TPtrC &aTypefaceName, const TDesC &aTestDescription)
   1.964 +	{
   1.965 +	TBuf<KLengthOfHashValue> tempBuffer;
   1.966 +		
   1.967 +	//append the name
   1.968 +	tempBuffer.Append(_L("_"));
   1.969 +	tempBuffer.Append(aTypefaceName);
   1.970 +	tempBuffer.Append(_L("_"));
   1.971 +	tempBuffer.Append(aTestDescription);
   1.972 +	tempBuffer.Append(_L("_"));
   1.973 +	
   1.974 +	//append the size 
   1.975 +	tempBuffer.AppendFormat(_L("_size-%d"),aSize);
   1.976 +	if (aAttributes == 0)
   1.977 +		{
   1.978 +		//output no attributes
   1.979 +		tempBuffer.Append(_L("_"));
   1.980 +		tempBuffer.Append(KFontEffectsFlagsString[0]); //no attributes string
   1.981 +		}
   1.982 +	else
   1.983 +		{
   1.984 +		for (TInt counter=0;counter<31;counter++)
   1.985 +			{
   1.986 +			TInt bit = 1<<counter; //1,2,4,8 etc
   1.987 +			if (bit&aAttributes)
   1.988 +				{
   1.989 +				tempBuffer.Append(_L("_"));
   1.990 +				tempBuffer.Append(KFontEffectsFlagsString[counter+1]);
   1.991 +				}
   1.992 +			}
   1.993 +		}
   1.994 +	return tempBuffer.AllocLC();	
   1.995 +	}
   1.996 +
   1.997 +/**
   1.998 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0108
   1.999 +
  1.1000 +   @SYMPREQ					PREQ2146
  1.1001 +
  1.1002 +   @SYMREQ					REQ10924, REQ10925, REQ10926, REQ10927, REQ10942, REQ10943, REQ10947, REQ10949
  1.1003 +
  1.1004 +   @SYMTestCaseDesc			This test draws fonts and compares a hash value from the output against
  1.1005 +   							a value stored in a file.
  1.1006 +   							
  1.1007 +   @SYMTestActions			The fonts used for this test come from a table, and each font can
  1.1008 +   							be tested with a different output string, size, and creation flag.
  1.1009 +   							The sizes are typically, 10, 20, 35 pixels.
  1.1010 +   							
  1.1011 +   							Steps for each font in the test table entry:
  1.1012 +   							(1)Create the font
  1.1013 +   							(2)For each size
  1.1014 +   							  	(3) For each attribute
  1.1015 +   							  		(4)Draw the text and compare against the stored hash value
  1.1016 +   								  	
  1.1017 +   							
  1.1018 +   							The font creation parameters are typically:
  1.1019 +								ENoEffect : plain font
  1.1020 +								EIsUnderlineOn : have underline
  1.1021 +								EIsStrikethroughOn : have strikethrough
  1.1022 +								ESetFourColourBlendGlyphBitmap : for shadow and outline
  1.1023 +								EIsUnderlineOn, EIsStrikethroughOn : both underline and strikethrough	
  1.1024 +								EAlgorithmicBoldOn : algorithmic bold on
  1.1025 +								EVerticalDraw : vertical text
  1.1026 +								EVerticalDraw, EIsUnderlineOn : vertical text and underline 
  1.1027 +								
  1.1028 +							If more fonts or attribute combinations are required to be tested, then this should be
  1.1029 +							achievable by adding table entries.
  1.1030 +   							
  1.1031 +   							To produce the hash values the test needs to be run with a special version 
  1.1032 +   							of test harness where APPEND_NEW_OR_MISSING_HASH_DATA and SAVEBITMAP macros are defined
  1.1033 +   							in thashreferenceimages.cpp.  The saved mbm files should be converted to bitmap 
  1.1034 +   							for manual checking.  							
  1.1035 +   							
  1.1036 +   							The fonts used for this tests should have been registered beforehand with 
  1.1037 +   							test GRAPHICS-FNTSTORE-LINKEDFONTS-0107.
  1.1038 +
  1.1039 +   @SYMTestPriority			Critical
  1.1040 +
  1.1041 +   @SYMTestStatus			Implemented
  1.1042 +
  1.1043 +   @SYMTestActions			(1) Create the font. Draw text, and compare the hash value against
  1.1044 +    							the value in the file tlinkedfontcomparison.ini.  Note that having the same hash
  1.1045 +    							value as the ini file does not necessarily mean that the output is correct. 
  1.1046 +
  1.1047 +   @SYMTestExpectedResults	(1) - font creation succeeds
  1.1048 +   							(4) - the hash values are the same for each text string output
  1.1049 +*/
  1.1050 +void CTLinkedFontsComparison::TestDrawTextUsingLinkedFontsL()
  1.1051 +	{
  1.1052 +	INFO_PRINTF1(_L("TestDrawTextUsingLinkedFontsL()"));
  1.1053 +	FreeScreenDevice();
  1.1054 +	const TDisplayMode displayMode = EColor16MAP;
  1.1055 +
  1.1056 +	CreateBitmapDeviceL(displayMode);
  1.1057 +	
  1.1058 +	INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[KSupportDisplayStringIndex[displayMode]]);
  1.1059 +
  1.1060 +	//for all the tests
  1.1061 +	TInt numberOfTestsRun=0;
  1.1062 +	for (TInt testCounter = 0; testCounter< sizeof(KTestCases)/sizeof(TTestCase); testCounter++)
  1.1063 +		{
  1.1064 +		
  1.1065 +		//for all the sizes
  1.1066 +		const TInt* ptrSizes = KTestCases[testCounter].iSizes;
  1.1067 +		for (; *ptrSizes!=0 ;ptrSizes++)
  1.1068 +			{
  1.1069 +			TInt size = *ptrSizes;
  1.1070 +			
  1.1071 +			// for all the attributes
  1.1072 +			const TUint32 *ptrAttributes = KTestCases[testCounter].iFontAttributes;
  1.1073 +			for (;*ptrAttributes!=EEndOfList;ptrAttributes++)
  1.1074 +														
  1.1075 +				{
  1.1076 +				TUint32 attributes = *ptrAttributes;
  1.1077 +				
  1.1078 +				HBufC* testDescription = GenerateTestDescriptionLC(size,attributes,KTestCases[testCounter].iTypeFaceName,*( KTestCases[testCounter].iTestDecription));
  1.1079 +				//this function is used for a fuller description
  1.1080 +				
  1.1081 +				//conversion from HBufC to TPtrC
  1.1082 +				//need this an an argument to the generate hash id function
  1.1083 +				TPtrC ptr = TPtrC(testDescription->Des());
  1.1084 +				
  1.1085 +				//construct a desriptor string, function in hashutility KTestName0001
  1.1086 +				HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC(
  1.1087 +						KTestName0001,//general name for test
  1.1088 +						numberOfTestsRun, //number of sub test
  1.1089 +						&ptr,
  1.1090 +						0, 				 //fontFaceIndex, index into the name array above, must be zero
  1.1091 +						KSupportDisplayStringIndex[static_cast<TInt>(displayMode)],//display mode, converted to text
  1.1092 +							//in the hash code this is an index to a string table, which is missing ENone and ERgb
  1.1093 +						attributes //was orientation, but just integer at end, no use attributes
  1.1094 +						);
  1.1095 +				
  1.1096 +				DoTestDrawingOutputL(*hashIdString, KTestCases[testCounter].iTypeFaceName, *(KTestCases[testCounter].iOutputString),
  1.1097 +								  KTestCases[testCounter].iPosition,size,attributes);
  1.1098 +				
  1.1099 +				numberOfTestsRun++;
  1.1100 +				CleanupStack::PopAndDestroy(2,testDescription);
  1.1101 +				}
  1.1102 +			}//sizes
  1.1103 +		}//test array
  1.1104 +	}
  1.1105 +
  1.1106 +/**
  1.1107 +Function to create a font, draw the text, and compare the hash value
  1.1108 +
  1.1109 +@param aHashId a string with the hash ID.
  1.1110 +@param aFont the font name
  1.1111 +@param aOutputString the output string
  1.1112 +@param aPosition the position where to draw the text
  1.1113 +@param aSize the height of the font in pixels
  1.1114 +@param aAttributes the attributes for the font 
  1.1115 +@see TFontEffectsFlags
  1.1116 +*/
  1.1117 +void CTLinkedFontsComparison::DoTestDrawingOutputL(const TDesC& aHashId, const TPtrC& aFont, const TDesC& aOutputString,
  1.1118 +		 TPoint aPosition, TInt aSize, TUint32 aAttributes)
  1.1119 +	{
  1.1120 +	TFontSpec fontSpec;
  1.1121 +	PrepareTestEnvironment(fontSpec, aFont, aSize, aAttributes, ETrue, ETrue);
  1.1122 +	CFont* font;
  1.1123 +	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone);
  1.1124 +	SCleanFont cleanupFont = {iBitmapDevice, font};
  1.1125 +	CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont));
  1.1126 +	
  1.1127 +	//may need to add attributes for the font
  1.1128 +	CBitmapFont* bitmapFont=CFbsFontEx::FontAddress(static_cast<CFbsFont*>(font));
  1.1129 +	if (aAttributes& EItalicOn)
  1.1130 +		{
  1.1131 +		bitmapFont->iAlgStyle.SetIsItalic(ETrue);
  1.1132 +		}
  1.1133 +	if (aAttributes& ERegularBoldOn)
  1.1134 +		{
  1.1135 +		bitmapFont->iAlgStyle.SetIsBold(ETrue);
  1.1136 +		}	
  1.1137 +	
  1.1138 +	iGc->SetBrushColor(KRgbWhite);
  1.1139 +	iGc->Clear();
  1.1140 +	iGc->SetBrushColor(KRgbYellow);
  1.1141 +	iGc->UseFont(font);
  1.1142 +	if(EVerticalDraw & aAttributes)
  1.1143 +		{
  1.1144 +		iGc->DrawTextVertical(aOutputString, aPosition, ERotate90Degrees & aAttributes);
  1.1145 +		}
  1.1146 +	else
  1.1147 +		{
  1.1148 +		iGc->DrawText(aOutputString, aPosition);
  1.1149 +		}
  1.1150 +	iHashUtil->CompareHashValuesL(aHashId);
  1.1151 +	CleanupStack::Pop();//font
  1.1152 +	iBitmapDevice->ReleaseFont(font);
  1.1153 +	iGc->DiscardFont();
  1.1154 +	}
  1.1155 +
  1.1156 +/**
  1.1157 +Sets the fontspec and gc attributes according to the flags set in STestFontParameters for the test.
  1.1158 +Before setting gc attributes it is cleared and reset.
  1.1159 +@param aFontSpec holds all effective font settings
  1.1160 +@param aSettings holds the flags for setting the fontspec and gc
  1.1161 +@param aFontIndex the fonts index of KFontFace to be set as typeface
  1.1162 +@param aSetEffects ETrue will set the effects on in fontspec if their flags are enabled. By default it is ETrue.
  1.1163 +@param aSetColors ETrue will set the colours in gc from STestFontParameters. By default it is EFalse.
  1.1164 +*/
  1.1165 +void CTLinkedFontsComparison::PrepareTestEnvironment(TFontSpec &aFontSpec, const TPtrC& aFont, TInt aSize, TUint32 aAttributes,
  1.1166 +							TBool aSetEffects, TBool aSetColors)
  1.1167 +	{
  1.1168 +	//Set the typeface from the font face array
  1.1169 +	aFontSpec.iTypeface.iName = aFont;
  1.1170 +	aFontSpec.iHeight = aSize;
  1.1171 +
  1.1172 +	//Set the effects on if any of flags for the effects are set in aSettings and aSetEffects is ETrue
  1.1173 +	if(aSetEffects)
  1.1174 +		{
  1.1175 +		aFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn & aAttributes);
  1.1176 +		aFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn & aAttributes);
  1.1177 +		aFontSpec.iFontStyle.SetEffects(FontEffect::ESoftEdge, ESoftEdgeOn & aAttributes);
  1.1178 +		aFontSpec.iFontStyle.SetEffects(FontEffect::EAlgorithmicBold, EAlgorithmicBoldOn & aAttributes);
  1.1179 +		}
  1.1180 +
  1.1181 +	iGc->Reset();
  1.1182 +	iGc->Clear();
  1.1183 +	iGc->SetPenColor(KRgbBlack);
  1.1184 +	iGc->SetStrikethroughStyle((EIsStrikethroughOn & aAttributes) ? EStrikethroughOn : EStrikethroughOff);
  1.1185 +	iGc->SetUnderlineStyle((EIsUnderlineOn & aAttributes) ? EUnderlineOn : EUnderlineOff);
  1.1186 +
  1.1187 +	//Set the glyph bitmap type
  1.1188 +	if(ESetMonochromeGlyphBitmap & aAttributes)
  1.1189 +		{
  1.1190 +		aFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap);
  1.1191 +		}
  1.1192 +	else if(ESetAntiAliasedGlyphBitmap & aAttributes)
  1.1193 +		{
  1.1194 +		aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
  1.1195 +		}
  1.1196 +
  1.1197 +	//Set the colours in gc if asked for
  1.1198 +	if(aSetColors)
  1.1199 +		{
  1.1200 +		iGc->SetBrushColor(KRgbYellow);
  1.1201 +		iGc->SetPenColor(KRgbBlack);
  1.1202 +		iGc->SetShadowColor(KRgbGray);
  1.1203 +		}
  1.1204 +	}
  1.1205 +
  1.1206 +/** Function to determine if the rasterizer has the linked typeface extended interface.
  1.1207 +
  1.1208 +@return ETrue if the linked fonts rasterizer is present. EFalse otherwise
  1.1209 +*/
  1.1210 +TBool CTLinkedFontsComparison::CheckMonoTypeInstalledL()
  1.1211 +	{
  1.1212 +	CreateBitmapDeviceL(EColor16MU); //this is just for the bitmap device to get the font
  1.1213 +
  1.1214 +	CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iBitmapDevice);
  1.1215 +	CleanupStack::PushL(store);
  1.1216 +	
  1.1217 +	// Create typeface to be linked
  1.1218 +	_LIT(KLinkedTypefaceTT, "LinkedFont1TT");
  1.1219 +
  1.1220 +	CLinkedTypefaceSpecification *typefaceSpec;
  1.1221 +	_LIT(KLinkedFont1TTLinkingTest, "LinkedFont1TTLinkingTest");
  1.1222 +		
  1.1223 +	typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFont1TTLinkingTest);
  1.1224 +	
  1.1225 +	CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
  1.1226 +	typefaceSpec->AddLinkedTypefaceGroupL(*group1);
  1.1227 +	CleanupStack::Pop();
  1.1228 +	
  1.1229 +	// Add first typeface
  1.1230 +	CLinkedTypefaceElementSpec *elementSpec1;
  1.1231 +	elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
  1.1232 +	elementSpec1->SetCanonical(ETrue);
  1.1233 +		
  1.1234 +	typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
  1.1235 +	CleanupStack::Pop(1, elementSpec1);
  1.1236 +	
  1.1237 +	// Now try regstering the linked typeface
  1.1238 +	TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
  1.1239 +	CleanupStack::PopAndDestroy(2, store);
  1.1240 +	
  1.1241 +	if (ret == KErrNone|| ret== KErrAlreadyExists)
  1.1242 +		{
  1.1243 +		return ETrue;
  1.1244 +		}
  1.1245 +	else
  1.1246 +		{
  1.1247 +		INFO_PRINTF1(_L("Linked fonts comparison: no linked fonts rasterizer found"));
  1.1248 +		return EFalse;
  1.1249 +		}
  1.1250 +	}
  1.1251 +
  1.1252 +/** regular RunTestCaseL, a virtual function called by the test framework
  1.1253 + */
  1.1254 +void CTLinkedFontsComparison::RunTestCaseL(TInt aCurTestCase)
  1.1255 +	{
  1.1256 +	((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1257 +	switch (aCurTestCase)
  1.1258 +		{
  1.1259 +		case 1:
  1.1260 +			{
  1.1261 +			((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1262 +			if (!CheckMonoTypeInstalledL())
  1.1263 +				{
  1.1264 +				TestComplete();
  1.1265 +				};
  1.1266 +			break;
  1.1267 +			}
  1.1268 +		case 2:
  1.1269 +			{
  1.1270 +			((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0107"));
  1.1271 +			RegisterLinkedTypefacesL();
  1.1272 +			break;
  1.1273 +			}
  1.1274 +		case 3:
  1.1275 +			{
  1.1276 +			((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0108"));
  1.1277 +			TestDrawTextUsingLinkedFontsL();
  1.1278 +			break;
  1.1279 +			}
  1.1280 +		default:
  1.1281 +			{
  1.1282 +			((CTLinkedFontsComparisonStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1283 +			((CTLinkedFontsComparisonStep*)iStep)->CloseTMSGraphicsStep();
  1.1284 +			TestComplete();
  1.1285 +			break;
  1.1286 +			}
  1.1287 +		}
  1.1288 +	((CTLinkedFontsComparisonStep*)iStep)->RecordTestResultL();
  1.1289 +	}
  1.1290 +
  1.1291 +__CONSTRUCT_STEP__(LinkedFontsComparison)