os/graphics/graphicsdeviceinterface/bitgdi/tbit/TFONT.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code 
    20 */
    21 
    22 
    23 #include <e32hal.h>
    24 #include <e32std.h>
    25 #include <e32test.h>
    26 #include <s32mem.h>
    27 #include <bitstd.h>
    28 #include <bitdev.h>
    29 #include <fntstore.h>
    30 #include <fbs.h>
    31 #include <hal.h>
    32 #include <gdi.h>
    33 #include <graphics/fbsdefs.h>
    34 
    35 #include "TFont.h"
    36 
    37 const TInt KTextBufferLength = 256;
    38 
    39 //If you want to do font tests with scaled device - change KScalingFactorX, KScalingFactorY, KScalingOriginPt.
    40 const TInt KScalingFactorX = 1;
    41 const TInt KScalingFactorY = 1;
    42 const TPoint KScalingOriginPt(0, 0);
    43 
    44 //--------------------------------------------------------------
    45 
    46 CBitmapFont* CFbsFontEx::FontAddress(CFbsFont* aFont)
    47 	{
    48 	return(((CFbsFontEx*)aFont)->Address());
    49 	}
    50 
    51 //--------------------------------------------------------------
    52 
    53 #ifdef __WINS__
    54 template<class C> XTCallCounter<C>::XTCallCounter(CTGraphicsBase& aTestBase)
    55 	: iTestBase(aTestBase), iVFCallsOutsideFBServ(0)
    56 	{}
    57 
    58 template<class C> void XTCallCounter<C>::ExecuteShellcode(TInt aFromFunction)
    59 	{
    60 	const TUint32 KFBServId = 0x10003A16;
    61 	const TUint32 KTBitgdiServerId = 0x10273362;
    62 	TSecureId id = RProcess().SecureId();
    63 	if (id != KFBServId)
    64 		{
    65 		User::LockedInc(iVFCallsOutsideFBServ);
    66 		if (id == KTBitgdiServerId)
    67 			{
    68 			TBuf<128> name;
    69 			XVtableInjector<C>::GetVirtualFunctionName(aFromFunction, name);
    70 			iTestBase.INFO_PRINTF2(_L("Virtual function call to %S from outside FBServ"), &name);
    71 			}
    72 		}
    73 	}
    74 #endif
    75 
    76 //--------------------------------------------------------------
    77 
    78 CTFont::CTFont(CTestStep* aStep) :
    79 	CTGraphicsBase(aStep),
    80 	iFont(NULL),
    81 	iGc(NULL),
    82 	iDev(NULL)
    83 #ifdef __WINS__
    84 	, iFontCallCounter(*this), iOpenFontCallCounter(*this)
    85 #endif
    86 	{
    87 	}
    88 
    89 CTFont::~CTFont()
    90 	{
    91 	delete iGc;
    92 	delete iDev;
    93 	}
    94 
    95 void CTFont::ConstructL()
    96 	{
    97 	TRAPD(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor256));
    98 	if (err == KErrNotSupported)
    99 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MU));
   100 	if (err == KErrNotSupported)
   101 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor4K));
   102 	if (err == KErrNotSupported)
   103 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16M));
   104 	if (err == KErrNotSupported)
   105 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor64K));
   106 	if (err == KErrNotSupported)
   107 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray256));
   108 	if (err == KErrNotSupported)
   109 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray16));
   110 	if (err == KErrNotSupported)
   111 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray4));
   112 	if (err == KErrNotSupported)
   113 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray2));
   114 	if (err == KErrNotSupported)
   115 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16));
   116 	if (err == KErrNotSupported)
   117 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MA));
   118 	if (err == KErrNotSupported)
   119 		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MAP));
   120 	if (err!=KErrNone)
   121 		{
   122 		_LIT(KLog,"Failed to create screen device, last returned error %d");
   123 		INFO_PRINTF2(KLog,err);
   124 		}
   125 
   126 	User::LeaveIfError(err);
   127 	iDev->ChangeScreenDevice(NULL);
   128 	iDev->SetAutoUpdate(ETrue);
   129 	iDev->CreateContext(iGc);
   130 	iDev->SetScalingFactor(KScalingOriginPt, KScalingFactorX, KScalingFactorY, 1, 1);
   131 	iGc->Activate(iDev);
   132 	}
   133 
   134 /**
   135   @SYMTestCaseID GRAPHICS-BITGDI-0074
   136  
   137   @SYMDEF             
   138 
   139   @SYMTestCaseDesc Anti-aliased text
   140    
   141   @SYMTestPriority High
   142 
   143   @SYMTestStatus Implemented
   144 
   145   @SYMTestActions Draws some text in an antialiased manner
   146  
   147   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   148 */
   149 void CTFont::DoAntiAliasedTextL()
   150 	{
   151 	int typefaces = iDev->NumTypefaces();
   152 	static const TUint32 colour[15] =
   153 		{ 
   154 		0x000000,
   155 		0x555555,
   156 		0x000080,
   157 		0x008000,
   158 		0x008080,
   159 		0x800000,
   160 		0x800080,
   161 		0x808000,
   162 		0x0000ff,
   163 		0x00ff00,
   164 		0x00ffff,
   165 		0xff0000,
   166 		0xff00ff,
   167 		0xffff00,
   168 		0xaaaaaa
   169 		};
   170 	int colour_index = 0;
   171 	for (int i = 0; i < typefaces; i++)
   172 		{
   173 		TTypefaceSupport typeface_support;
   174 		iDev->TypefaceSupport(typeface_support,i);
   175 		if (typeface_support.iIsScalable)
   176 			{
   177 			ResetGc();
   178 			TPoint pos(300,0);
   179 			int vertical_x = 300;
   180 			for (int j = 6; j < 32; j += 2)
   181 				{
   182 				iGc->SetPenColor(colour[colour_index]);
   183 				colour_index = (++colour_index) % 15;
   184 				TFontSpec fs;
   185 				fs.iTypeface = typeface_support.iTypeface;
   186 				fs.iHeight = j;
   187 				fs.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   188 		 		User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   189 				int ascent = iFont->AscentInPixels();
   190 				int descent = iFont->DescentInPixels();
   191 				iGc->UseFont(iFont);
   192 				pos.iY += ascent;
   193 				iGc->DrawText(_L("pack my box with five dozen liquor jugs"),pos);
   194 				pos.iY += descent;
   195 				vertical_x -= ascent;
   196 				TPoint down_pos(vertical_x,0);
   197 				iGc->DrawTextVertical(_L("pack my box with five dozen liquor jugs"),down_pos,FALSE);
   198 				vertical_x -= descent * 2;
   199 				TPoint up_pos(vertical_x,iDev->SizeInPixels().iHeight);
   200 				iGc->DrawTextVertical(_L("pack my box with five dozen liquor jugs"),up_pos,TRUE);
   201 				vertical_x -= ascent;
   202 				iDev->ReleaseFont(iFont);
   203 				iGc->DiscardFont();
   204 				}
   205 			//TheTest.Getch();
   206 			}
   207 		}
   208 	}
   209 /**
   210   @SYMTestCaseID GRAPHICS-BITGDI-0075
   211  
   212   @SYMDEF             
   213 
   214   @SYMTestCaseDesc tests all fonts
   215    
   216   @SYMTestPriority High
   217 
   218   @SYMTestStatus Implemented
   219 
   220   @SYMTestActions tests all fonts (typeface and heights) by writing them to a gc
   221  
   222   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   223 */
   224 void CTFont::DoAllFontsL()
   225 	{
   226 	TFontSpec fs;
   227 	TInt typefaces = iDev->NumTypefaces();
   228 	TTypefaceSupport info;
   229 
   230 	//used below in for loop (line 177)
   231 	TInt topNew=0;
   232 	TInt bottomNew=0;
   233 	TInt top=0;
   234 	TInt bottom=0;
   235 
   236 	// Maximum height of font allowed by iType rasteriser
   237 	const TInt KMaxITypeHeightInPixels = 256;
   238 
   239 	for (TInt count = 0; count < typefaces; count++)
   240 		{
   241 		iDev->TypefaceSupport(info,count);
   242 
   243 		for (TInt index = 0; index < info.iNumHeights; index++)
   244 			{
   245 			TInt height = iDev->FontHeightInPixels(count,index);
   246 			if (height > KMaxITypeHeightInPixels)
   247 				{
   248 				continue;
   249 				}
   250 			fs.iTypeface = info.iTypeface;
   251 			fs.iHeight = height;
   252 
   253 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   254 			TInt heightInPixels = iFont->HeightInPixels();
   255 			if ( heightInPixels == height )
   256 				{
   257 				TEST( ETrue );
   258 				}
   259 			else
   260 				{
   261 				TOpenFontFaceAttrib attrib;
   262 				if( iFont->GetFaceAttrib( attrib ) )
   263 					{
   264 					_LIT(KErrorMessageWithFontName, "Font: %S, pixel height requested: %d, pixel height of font: %d");
   265 					INFO_PRINTF4(KErrorMessageWithFontName, &attrib.FullName(), height, heightInPixels);
   266 					}
   267 				else
   268 					{
   269 					_LIT(KErrorMessage, "Pixel height requested: %d, pixel height of font: %d");
   270 					INFO_PRINTF3(KErrorMessage, height, heightInPixels);
   271 					}
   272 				TEST( EFalse );
   273 				}
   274 
   275 			if (height >= 5)
   276 				{
   277 				iGc->UseFont(iFont);
   278 				
   279 				//Testing the new replaced GetUnderlineMetrics
   280 				//Debug can be used to monitor underline sizes as font chanegs
   281 				iGc->GetUnderlineMetrics(top, bottom);
   282 				TEST( top !=0 && bottom !=0 );
   283 				/*cast the pointer iGc to the base class CGraphicsContext
   284 				should still behave correctly meaning any valid class can 
   285 				GetUnderlineMetrics through CGC as is exported and public.*/
   286 				CGraphicsContext* baseGc = (CGraphicsContext*)iGc;
   287 				baseGc->GetUnderlineMetrics(topNew, bottomNew);
   288 				TEST( top !=0 && bottom !=0 );
   289 				TEST( topNew == top && bottomNew == bottom );
   290 
   291 				DisplayAsciiCharSet(info.iTypeface.iName);
   292 				DisplayBoldItalic(info.iTypeface.iName);
   293 				iGc->DiscardFont();
   294 				}
   295 
   296 						
   297 			iDev->ReleaseFont(iFont);
   298 
   299 			height = iDev->FontHeightInTwips(count,index);
   300 			fs.iHeight = height;
   301 			User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fs));
   302 // Commented out test because it fails for true type fonts
   303 //			if (Abs(iFont->FontSpecInTwips().iHeight - height) > 1)
   304 //				User::Panic(_L("Heights don't match"),KErrGeneral);
   305 			iDev->ReleaseFont(iFont);
   306 			}
   307 		}
   308 	}
   309 
   310 TInt CTFont::TestFontL(const TFontSpec &aFontSpec)
   311 	{
   312 	const TSize devSize(iDev->SizeInPixels());
   313 	TInt midHgtOffset=devSize.iHeight/2;
   314 	TRect devRect1(0,0,devSize.iWidth,midHgtOffset);
   315 	TRect devRect2(0,midHgtOffset,devSize.iWidth,midHgtOffset*2);
   316 //
   317 	ResetGc();
   318 	TInt loadErr=GetNearestFontToDesignHeightInTwips(iFont,aFontSpec);
   319 	if (loadErr)
   320 		return(loadErr);
   321 	CBufStore *store=CBufStore::NewLC(1024);
   322 	TFontSpec fSpec1=iFont->FontSpecInTwips();
   323 	TEST(fSpec1.iHeight>0);	// If returns zero height will fail on externalize/internalize
   324 	const TInt ascent=iFont->AscentInPixels();
   325 	iGc->UseFont(iFont);
   326 	iDev->ReleaseFont(iFont);
   327 // Useful when watching test code, but too much logging for actual test runs
   328 //	INFO_PRINTF4(_L("Testing, %S hgt=%d/%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight,fSpec1.iHeight);
   329 //
   330 	iGc->SetClippingRect(devRect1);
   331 	iGc->DrawText(_L("0123456789abcdefghiABCDEFGHI"),TPoint(0,ascent));
   332 //
   333 	RStoreWriteStream writeStream;
   334 	TStreamId id=writeStream.CreateLC(*store);
   335 	iGc->ExternalizeL(writeStream);
   336 	CleanupStack::PopAndDestroy(&writeStream);
   337 	iGc->DiscardFont();
   338 //
   339 	RStoreReadStream readStream;
   340 	readStream.OpenLC(*store,id);
   341 	iGc->InternalizeL(readStream);
   342 	CleanupStack::PopAndDestroy(&readStream);
   343 	TBool fontUsed=iGc->IsFontUsed();
   344 	if (!iGc->IsFontUsed())
   345 		{
   346 		INFO_PRINTF3(_L("Font externalize/internalize used check failed, %S hgt=%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight);
   347 		TEST(EFalse);
   348 		}
   349 	else
   350 		{
   351 		iGc->SetClippingRect(devRect2);
   352 		iGc->DrawText(_L("0123456789abcdefghiABCDEFGHI"),TPoint(0,midHgtOffset+ascent));
   353 		TBool rectCompare=iDev->RectCompare(devRect1,*iDev,devRect2);
   354 		if (!rectCompare)
   355 			{
   356 			INFO_PRINTF3(_L("Font externalize/internalize screen check failed, %S hgt=%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight);
   357 			TEST(EFalse);
   358 			}
   359 		}
   360 	CleanupStack::PopAndDestroy(store);
   361 	iGc->CancelClippingRect();
   362 	iGc->DiscardFont();
   363 	return(KErrNone);
   364 	}
   365 
   366 void CTFont::FontExternalizeL()
   367 	{
   368 	TFontSpec fsp;
   369 	const TInt typefaceCount=iDev->NumTypefaces();
   370 	for (TInt typeface=0;typeface<typefaceCount;typeface++)
   371 		{
   372 		TTypefaceSupport info;
   373 		iDev->TypefaceSupport(info,typeface);
   374 		fsp.iTypeface = info.iTypeface;
   375 		TInt baseHeight=iDev->FontHeightInTwips(typeface,0);
   376 		_LIT(KTxtNotScalable,"");
   377 		_LIT(KTxtScalable,"Scalable");
   378 		INFO_PRINTF5(_L("Testing, %S min/max=%d/%d %S"), &fsp.iTypeface.iName,info.iMinHeightInTwips,info.iMaxHeightInTwips,info.iIsScalable?&KTxtScalable:&KTxtNotScalable);
   379 		for(TInt hgtIndex=0;hgtIndex<info.iNumHeights;hgtIndex++)
   380 			{	// Test official specced heights
   381 			fsp.iHeight=iDev->FontHeightInTwips(typeface,hgtIndex);
   382 			TEST(TestFontL(fsp)==KErrNone);
   383 			}
   384 		for(fsp.iHeight=0;fsp.iHeight<info.iMaxHeightInTwips*2;fsp.iHeight=(fsp.iHeight+1)*11/10)
   385 			{
   386 			TInt err=TestFontL(fsp);
   387 			if (err!=KErrNone)
   388 				{	// Should not get an error within allowable font size
   389 				TEST(fsp.iHeight>info.iMaxHeightInTwips);	// Over speced max size is ok to get error loading.
   390 				}
   391 			}
   392 		}
   393 	}
   394 
   395 void CTFont::DisplayAsciiCharSet(const TDesC& aTypefaceName)
   396 	{
   397 	ResetGc();
   398 
   399 	TBuf<KTextBufferLength> textBuffer;
   400 	textBuffer.SetLength(KTextBufferLength);
   401 	for (TInt count = 0; count < KTextBufferLength; count++)
   402 		textBuffer[count] = TText(count);
   403 
   404 	TPoint textPos = TPoint(50,iFont->AscentInPixels() + 5);
   405 	iGc->DrawText(aTypefaceName,textPos);
   406 	TInt fontHeight = iFont->HeightInPixels() + 5;
   407 	textPos.iX = 0;
   408 	textPos.iY += fontHeight;
   409 	TInt start = 0;
   410 	TInt screenWidth = iDev->SizeInPixels().iWidth;
   411 
   412 	while (start < KTextBufferLength)
   413 		{
   414 		TInt numChars = iFont->TextCount(textBuffer.Mid(start),screenWidth);
   415 		iGc->DrawText(textBuffer.Mid(start,numChars),textPos);
   416 		textPos.iY += fontHeight;
   417 		start += numChars;
   418 		}
   419 	}
   420 
   421 void CTFont::DisplayBoldItalic(const TDesC& aTypefaceName)
   422 	{
   423 	ResetGc();
   424 
   425 	TBuf<64> textBuffer;
   426 	TInt height = iFont->HeightInPixels();
   427 	CBitmapFont* bmpfon=CFbsFontEx::FontAddress(iFont);
   428 
   429 	TInt level=iFont->AscentInPixels();
   430 	iGc->DrawText(aTypefaceName,TPoint(50,level));
   431 
   432 	textBuffer=_L("0123456789abcdefghiABCDEFGHI");
   433 	level += height;
   434 	iGc->DrawText(textBuffer,TPoint(0,level));
   435 	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   436 
   437 	bmpfon->iAlgStyle.SetIsBold(ETrue);
   438 	level += height;
   439 	iGc->DrawText(textBuffer,TPoint(0,level));
   440 	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   441 
   442 	bmpfon->iAlgStyle.SetIsBold(EFalse);
   443 	bmpfon->iAlgStyle.SetIsItalic(ETrue);
   444 	level += height;
   445 	iGc->DrawText(textBuffer,TPoint(0,level));
   446 	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   447 
   448 	bmpfon->iAlgStyle.SetIsBold(ETrue);
   449 	level += height;
   450 	iGc->DrawText(textBuffer,TPoint(0,level));
   451 	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   452 	}
   453 
   454 /**
   455   @SYMTestCaseID GRAPHICS-BITGDI-0076
   456  
   457   @SYMDEF             
   458 
   459   @SYMTestCaseDesc Text formatting
   460    
   461   @SYMTestPriority High
   462 
   463   @SYMTestStatus Implemented
   464 
   465   @SYMTestActions Tests drawing of justified/clipped/underlined text to a gc 
   466  
   467   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   468 */
   469 void CTFont::DoTextFormatsL()
   470 	{
   471 	ResetGc();
   472 
   473 	TFontSpec fsp;
   474 	fsp.iTypeface.iName=_L("Swiss");
   475 	fsp.iHeight=200;
   476 
   477 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
   478 	iGc->UseFont(iFont);
   479 
   480 	Box();
   481 	//TheTest.Getch();
   482 
   483 	Justification();
   484 	//TheTest.Getch();
   485 
   486 	Clipping();
   487 	//TheTest.Getch();
   488 
   489 	Underline();
   490 	//TheTest.Getch();
   491 
   492 	iGc->DiscardFont();
   493 	iDev->ReleaseFont(iFont);
   494 	}
   495 
   496 void CTFont::Box()
   497 	{
   498 	iGc->SetPenSize(TSize(0,0));
   499 	iGc->SetBrushColor(KRgbWhite);
   500 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   501 	iGc->Clear();
   502 	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   503 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,40));
   504 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   505 	iGc->DrawText(_L("Box text (left aligned)"),TRect(20,50,320,70),14,CGraphicsContext::ELeft);
   506 	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(20,70,320,90),14,CGraphicsContext::ELeft,50);
   507 	iGc->DrawText(_L("Box text (centred)"),TRect(20,90,320,110),14,CGraphicsContext::ECenter);
   508 	iGc->DrawText(_L("Box text (right aligned)"),TRect(20,110,320,130),14,CGraphicsContext::ERight);
   509 	iGc->DrawText(_L("Box text (right aligned with margin)"),TRect(20,130,320,150),14,CGraphicsContext::ERight,30);
   510 	iGc->DrawText(_L("(Boxes drawn afterwards)"),TPoint(20,165));
   511 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   512 	iGc->DrawRect(TRect(20,50,320,70));
   513 	iGc->DrawRect(TRect(20,70,320,90));
   514 	iGc->DrawRect(TRect(20,90,320,110));
   515 	iGc->DrawRect(TRect(20,110,320,130));
   516 
   517 	iGc->SetBrushColor(TRgb(128,128,128));
   518 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   519 	iGc->DrawText(_L("Box text (left aligned)"),TRect(320,50,620,70),14,CGraphicsContext::ELeft);
   520 	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(320,70,620,90),14,CGraphicsContext::ELeft,50);
   521 	iGc->DrawText(_L("Box text (centred)"),TRect(320,90,620,110),14,CGraphicsContext::ECenter);
   522 	iGc->DrawText(_L("Box text (right aligned)"),TRect(320,110,620,130),14,CGraphicsContext::ERight);
   523 	iGc->DrawText(_L("Box text (right aligned with margin)"),TRect(320,130,620,150),14,CGraphicsContext::ERight,30);
   524 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   525 	iGc->DrawRect(TRect(320,50,620,70));
   526 	iGc->DrawRect(TRect(320,70,620,90));
   527 	iGc->DrawRect(TRect(320,90,620,110));
   528 	iGc->DrawRect(TRect(320,110,620,130));
   529 
   530 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   531 	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
   532 	iGc->DrawText(_L("Box text"),TRect(20,150,620,170),14,width);
   533 	iGc->DrawText(_L(" followed by positionless text."));
   534 	iGc->DrawText(_L("Box text"),TRect(20,170,620,190),14,width,CGraphicsContext::ELeft,20);
   535 	iGc->DrawText(_L(" followed by positionless text."));
   536 	iGc->DrawText(_L("Box text"),TRect(20,190,620,210),14,width,CGraphicsContext::ECenter);
   537 	iGc->DrawText(_L(" followed by positionless text."));
   538 	iGc->DrawText(_L("Box text"),TRect(20,210,620,230),14,width,CGraphicsContext::ERight,20);
   539 	iGc->DrawText(_L(" followed by positionless text."));
   540 	iGc->DrawText(_L(""),TRect(20,230,620,250),14,width);
   541 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   542 	iGc->DrawRect(TRect(20,150,620,170));
   543 	iGc->DrawRect(TRect(20,170,620,190));
   544 	iGc->DrawRect(TRect(20,190,620,210));
   545 	iGc->DrawRect(TRect(20,210,620,230));
   546 	}
   547 
   548 void CTFont::Underline()
   549 	{
   550 	ResetGc();
   551 
   552 	iGc->SetUnderlineStyle(EUnderlineOn);
   553 	iGc->SetStrikethroughStyle(EStrikethroughOn);
   554 
   555 	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   556 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,40));
   557 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   558 	iGc->DrawText(_L("Box text (left aligned)"),TRect(20,50,320,70),14,CGraphicsContext::ELeft);
   559 	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(20,70,320,90),14,CGraphicsContext::ELeft,50);
   560 	iGc->DrawText(_L("Box text (centred)"),TRect(20,90,320,110),14,CGraphicsContext::ECenter);
   561 	iGc->DrawText(_L("Box text (right aligned)"),TRect(20,110,320,130),14,CGraphicsContext::ERight);
   562 	iGc->DrawText(_L("Box text (left aligned)"),TRect(320,50,620,70),14,CGraphicsContext::ELeft);
   563 	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(320,70,620,90),14,CGraphicsContext::ELeft,50);
   564 	iGc->DrawText(_L("Box text (centred)"),TRect(320,90,620,110),14,CGraphicsContext::ECenter);
   565 	iGc->DrawText(_L("Box text (right aligned)"),TRect(320,110,620,130),14,CGraphicsContext::ERight);
   566 	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
   567 	iGc->DrawText(_L("Box text"),TRect(20,130,620,150),14,width);
   568 	iGc->DrawText(_L(" followed by positionless text."));
   569 	iGc->DrawText(_L("Box text"),TRect(20,150,620,170),14,width,CGraphicsContext::ELeft,20);
   570 	iGc->DrawText(_L(" followed by positionless text."));
   571 	iGc->DrawText(_L("Box text"),TRect(20,170,620,190),14,width,CGraphicsContext::ECenter);
   572 	iGc->DrawText(_L(" followed by positionless text."));
   573 	iGc->DrawText(_L("Box text"),TRect(20,190,620,210),14,width,CGraphicsContext::ERight);
   574 	iGc->DrawText(_L(" followed by positionless text."));
   575 	iGc->DrawText(_L(""),TRect(20,210,620,230),14,width);
   576 
   577 	iGc->SetUnderlineStyle(EUnderlineOff);
   578 	iGc->SetStrikethroughStyle(EStrikethroughOff);
   579 	}
   580 
   581 void CTFont::Justification()
   582 	{
   583 	iGc->SetUnderlineStyle(EUnderlineOff);
   584 	iGc->SetStrikethroughStyle(EStrikethroughOff);
   585 	iGc->SetPenSize(TSize(0,0));
   586 	iGc->SetBrushColor(KRgbWhite);
   587 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   588 	iGc->Clear();
   589 	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   590 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,40));
   591 	iGc->SetCharJustification(18,6);
   592 	iGc->SetWordJustification(0,0);
   593 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,60));
   594 	iGc->SetCharJustification(0,0);
   595 	iGc->SetWordJustification(30,6);
   596 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,80));
   597 	iGc->SetCharJustification(18,6);
   598 	iGc->SetWordJustification(30,6);
   599 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,100));
   600 	iGc->UpdateJustification(_L("Normal text printing in one whole line"));
   601 //
   602 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,120));
   603 	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   604 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   605 	iGc->UpdateJustification(_L("tionless printing (halfway thro' posi-tionless)."));
   606 	iGc->SetCharJustification(18,6);
   607 	iGc->SetWordJustification(0,0);
   608 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,140));
   609 	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   610 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   611 	iGc->SetCharJustification(0,0);
   612 	iGc->SetWordJustification(30,6);
   613 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,160));
   614 	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   615 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   616 	iGc->SetCharJustification(18,6);
   617 	iGc->SetWordJustification(30,6);
   618 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,180));
   619 	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   620 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   621 	iGc->SetCharJustification(150,50);
   622 	iGc->SetWordJustification(50,10);
   623 	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,200));
   624 	iGc->UpdateJustification(_L("Normal text printing in one whole line,"));
   625 	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,220));
   626 	iGc->SetCharJustification(0,0);
   627 	iGc->SetWordJustification(0,0);
   628 	}
   629 
   630 void CTFont::Clipping()
   631 	{
   632 	iGc->SetUnderlineStyle(EUnderlineOff);
   633 	iGc->SetStrikethroughStyle(EStrikethroughOff);
   634 	iGc->SetPenSize(TSize(0,0));
   635 	iGc->SetBrushColor(KRgbWhite);
   636 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   637 	iGc->Clear();
   638 	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   639 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,40));
   640 	iGc->SetCharJustification(-6,6);
   641 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,60));
   642 	iGc->SetCharJustification(-12,6);
   643 	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,80));
   644 	iGc->SetCharJustification(0,0);
   645 //
   646 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,120));
   647 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   648 	iGc->SetCharJustification(-50,50);
   649 	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,140));
   650 	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   651 	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   652 	iGc->SetCharJustification(0,0);
   653 	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,160));
   654 	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,180));
   655 	iGc->SetCharJustification(-90,90);
   656 	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,200));
   657 	iGc->UpdateJustification(_L("Normal text printing in one whole line,"));
   658 	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,220));
   659 	iGc->SetCharJustification(0,0);
   660 	}
   661 
   662 /**
   663   @SYMTestCaseID GRAPHICS-BITGDI-0077
   664  
   665   @SYMDEF             
   666 
   667   @SYMTestCaseDesc Check text drawing
   668    
   669   @SYMTestPriority High
   670 
   671   @SYMTestStatus Implemented
   672 
   673   @SYMTestActions Tests aspects of drawing text to the screen
   674  
   675   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   676 */
   677 void CTFont::DoBitAlignmentL()
   678 	{
   679 	ResetGc();
   680 	TInt ret=KErrNone;
   681 	
   682 	const TUint8 testchars[2]={'M', 'W'};
   683 	TFontSpec fsp;
   684 	TInt xpos=0;
   685 	TInt stringwidth=0;
   686 	TBuf<224> letters;
   687 	fsp.iTypeface.iName=_L("Swiss");
   688 	fsp.iHeight=300;
   689 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
   690 	iGc->UseFont(iFont);
   691 	TInt ascent=iFont->AscentInPixels();
   692 	TInt descent=iFont->DescentInPixels();
   693 	TInt charvertpos=ascent+descent+20;
   694 	TRgb refcolour(0,0,0);
   695 	TRgb charcolour(0,0,0);
   696 	TInt charnum=0;
   697 	TBuf<1> letterdesc;
   698 	letterdesc.SetLength(1);
   699 	for(;charnum<2;charnum++)
   700 		{
   701 		letterdesc[0]=testchars[charnum];
   702 		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   703 		if(!letterwidth) continue;
   704 		for(xpos=10;xpos<43;xpos++)
   705 			{
   706 			iGc->Clear();
   707 			TPoint refpt(10,ascent+10);
   708 			TPoint charpt(xpos,ascent+charvertpos);
   709 			iGc->SetDitherOrigin(refpt);
   710 			iGc->DrawText(letterdesc,refpt);
   711 			iGc->SetDitherOrigin(charpt);
   712 			iGc->DrawText(letterdesc,charpt);
   713 			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   714 				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   715 					{
   716 					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   717 					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   718 					TEST(refcolour==charcolour);
   719 					if(refcolour!=charcolour)
   720 						{
   721 						ret=KErrGeneral;
   722 						goto end;
   723 						}
   724 					}
   725 			}
   726 		}
   727 	iGc->SetPenColor(TRgb(128,128,128));
   728 	for(charnum=0;charnum<2;charnum++)
   729 		{
   730 		letterdesc[0]=testchars[charnum];
   731 		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   732 		if(!letterwidth) continue;
   733 		for(xpos=10;xpos<43;xpos++)
   734 			{
   735 			iGc->Clear();
   736 			TPoint refpt(10,ascent+10);
   737 			TPoint charpt(xpos,ascent+charvertpos);
   738 			iGc->SetDitherOrigin(TPoint(refpt.iX,0));
   739 			iGc->DrawText(letterdesc,refpt);
   740 			iGc->SetDitherOrigin(TPoint(charpt.iX,0));
   741 			iGc->DrawText(letterdesc,charpt);
   742 			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   743 				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   744 					{
   745 					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   746 					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   747 					TEST(refcolour==charcolour);
   748 					if(refcolour!=charcolour)
   749 						{
   750 						ret=KErrGeneral;
   751 						goto end;
   752 						}
   753 					}
   754 			}
   755 		}
   756 	iGc->SetPenColor(KRgbBlack);
   757 	letters.SetLength(224);
   758 	for(charnum=32;charnum<256;charnum++)
   759 		letters[charnum-32]=TUint8(charnum);
   760 	letters.SetLength(iFont->TextCount(letters,iDev->SizeInPixels().iWidth-45));
   761 	stringwidth=iFont->TextWidthInPixels(letters);
   762 	for(xpos=10;xpos<43;xpos++)
   763 		{
   764 		iGc->Clear();
   765 		TPoint refpt(10,ascent+10);
   766 		TPoint charpt(xpos,ascent+charvertpos);
   767 		iGc->DrawText(letters,refpt);
   768 		charnum=0;
   769 		letterdesc[0]=letters[charnum];
   770 		charnum++;
   771 		iGc->DrawText(letterdesc,charpt);
   772 		for(;charnum<letters.Length();charnum++)
   773 			{
   774 			letterdesc[0]=letters[charnum];
   775 			iGc->DrawText(letterdesc);
   776 			}
   777 		for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   778 			for(TInt xcheck=0;xcheck<stringwidth;xcheck+=2)
   779 				{
   780 				iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   781 				iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   782 				TEST(refcolour==charcolour);
   783 				if(refcolour!=charcolour)
   784 					{
   785 					ret=KErrGeneral;
   786 					goto end;
   787 					}
   788 				}
   789 		}
   790 	for(charnum=0;charnum<2;charnum++)
   791 		{
   792 		letterdesc[0]=testchars[charnum];
   793 		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   794 		if(!letterwidth) continue;
   795 		for(xpos=10;xpos<43;xpos++)
   796 			{
   797 			iGc->Clear();
   798 			TPoint refpt(10,ascent+10);
   799 			TPoint charpt(xpos,ascent+charvertpos);
   800 			iGc->DrawText(letterdesc,TRect(refpt.iX,refpt.iY-ascent,refpt.iX+letterwidth,refpt.iY+descent),ascent);
   801 			iGc->DrawText(letterdesc,TRect(charpt.iX,charpt.iY-ascent,charpt.iX+letterwidth,charpt.iY+descent),ascent);
   802 			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   803 				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   804 					{
   805 					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   806 					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   807 					TEST(refcolour==charcolour);
   808 					if(refcolour!=charcolour)
   809 						{
   810 						ret=KErrGeneral;
   811 						goto end;
   812 						}
   813 					}
   814 			}
   815 		}
   816 	iGc->SetPenColor(TRgb(128,128,128));
   817 	for(charnum=0;charnum<2;charnum++)
   818 		{
   819 		letterdesc[0]=testchars[charnum];
   820 		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   821 		if(!letterwidth) continue;
   822 		for(xpos=10;xpos<43;xpos++)
   823 			{
   824 			iGc->Clear();
   825 			TPoint refpt(10,ascent+10);
   826 			TPoint charpt(xpos,ascent+charvertpos);
   827 			iGc->SetDitherOrigin(TPoint(refpt.iX,0));
   828 			iGc->DrawText(letterdesc,TRect(refpt.iX,refpt.iY-ascent,refpt.iX+letterwidth,refpt.iY+descent),ascent);
   829 			iGc->SetDitherOrigin(TPoint(charpt.iX,0));
   830 			iGc->DrawText(letterdesc,TRect(charpt.iX,charpt.iY-ascent,charpt.iX+letterwidth,charpt.iY+descent),ascent);
   831 			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   832 				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   833 					{
   834 					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   835 					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   836 					TEST(refcolour==charcolour);
   837 					if(refcolour!=charcolour)
   838 						{
   839 						ret=KErrGeneral;
   840 						goto end;
   841 						}
   842 					}
   843 			}
   844 		}
   845 end:
   846 	iGc->DiscardFont();
   847 	iDev->ReleaseFont(iFont);
   848 	//TheTest.Getch();
   849 	User::LeaveIfError(ret);
   850 	}
   851 
   852 /**
   853   @SYMTestCaseID GRAPHICS-BITGDI-0078
   854  
   855   @SYMDEF             
   856 
   857   @SYMTestCaseDesc Large fonts
   858    
   859   @SYMTestPriority High
   860 
   861   @SYMTestStatus Implemented
   862 
   863   @SYMTestActions draws text to a gc with different weight and posture with a large height
   864  
   865   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   866 */
   867 void CTFont::DoLargeFontsL()
   868 	{
   869 	TInt typefaces = iDev->NumTypefaces();
   870 	TInt height = 0;
   871 
   872 	for (TInt count = 0; count < typefaces; count++)
   873 		{
   874 		TTypefaceSupport info;
   875 		iDev->TypefaceSupport(info,count);
   876 
   877 		for (TInt index = 0; index < info.iNumHeights; index++)
   878 			{
   879 			height = iDev->FontHeightInPixels(count,index);
   880 			if (height <= 32)
   881 				continue;
   882 
   883 			TFontSpec fs;
   884 			fs.iTypeface=info.iTypeface;
   885 			fs.iHeight=height;
   886 			fs.iFontStyle.SetPosture(EPostureUpright);
   887 			fs.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
   888 
   889 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   890 			DisplayLargeChars();
   891 			iDev->ReleaseFont(iFont);
   892 			//TheTest.Getch();
   893 
   894 			fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   895 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   896 			DisplayLargeChars();
   897 			iDev->ReleaseFont(iFont);
   898 			//TheTest.Getch();
   899 
   900 			fs.iFontStyle.SetPosture(EPostureItalic);
   901 			fs.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
   902 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   903 			DisplayLargeChars();
   904 			iDev->ReleaseFont(iFont);
   905 			//TheTest.Getch();
   906 
   907 			fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   908 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   909 			DisplayLargeChars();
   910 			iDev->ReleaseFont(iFont);
   911 			//TheTest.Getch();
   912 			}
   913 		}
   914 	}
   915 
   916 // Draw a character and its glyph and character bounding boxes. Return the rightmost point drawn.
   917 TInt CTFont::DisplayCharAndBounds(TInt aChar,TPoint aPos,TBool aVertical,TBool aUp)
   918 	{
   919 	TOpenFontCharMetrics cm;
   920 	const TUint8* bitmap;
   921 	TSize size;
   922 	if (!iFont->GetCharacterData(aChar,cm,bitmap,size))
   923 		return 0;
   924 	TOpenFontMetrics fm;
   925 	if (!iFont->GetFontMetrics(fm))
   926 		return 0;
   927 	TRect glyph_bounds, char_bounds;
   928 	if (aVertical)
   929 		{
   930 		if (aUp)
   931 			{
   932 			glyph_bounds.iTl.iX = aPos.iX - cm.HorizBearingY();
   933 			char_bounds.iTl.iX = aPos.iX - fm.MaxHeight();
   934 			glyph_bounds.iTl.iY = aPos.iY - cm.HorizBearingX() - cm.Width();
   935 			char_bounds.iTl.iY = aPos.iY - cm.HorizAdvance();
   936 			}
   937 		else
   938 			{
   939 			glyph_bounds.iTl.iX = aPos.iX + cm.HorizBearingY() - cm.Height() + 1;
   940 			char_bounds.iTl.iX = aPos.iX - fm.MaxDepth() + 1;
   941 			glyph_bounds.iTl.iY = aPos.iY + cm.HorizBearingX();
   942 			char_bounds.iTl.iY = aPos.iY;
   943 			}
   944 		glyph_bounds.iBr = glyph_bounds.iTl + TSize(cm.Height(),cm.Width());
   945 		char_bounds.iBr = char_bounds.iTl + TSize(fm.MaxHeight() + fm.MaxDepth(),cm.HorizAdvance());
   946 		}
   947 	else
   948 		{
   949 		glyph_bounds.iTl.iX = aPos.iX + cm.HorizBearingX();
   950 		char_bounds.iTl.iX = aPos.iX;
   951 		glyph_bounds.iTl.iY = aPos.iY - cm.HorizBearingY();
   952 		char_bounds.iTl.iY = aPos.iY - fm.MaxHeight();
   953 		glyph_bounds.iBr = glyph_bounds.iTl + TSize(cm.Width(),cm.Height());
   954 		char_bounds.iBr = char_bounds.iTl + TSize(cm.HorizAdvance(),fm.MaxHeight() + fm.MaxDepth());
   955 		}
   956 
   957 	TInt x_offset = aPos.iX - Min(glyph_bounds.iTl.iX,char_bounds.iTl.iX);
   958 	aPos.iX += x_offset;
   959 	glyph_bounds.Move(x_offset,0);
   960 	char_bounds.Move(x_offset,0);
   961 	TText text_buffer[1];
   962 	text_buffer[0] = (TText)aChar;
   963 	TPtrC text(text_buffer,1);
   964 	if (aVertical)
   965 		iGc->DrawTextVertical(text,aPos,aUp);
   966 	else
   967 		iGc->DrawText(text,aPos);
   968 	iGc->DrawRect(glyph_bounds);
   969 	iGc->DrawRect(char_bounds);
   970 
   971 	return Max(glyph_bounds.iBr.iX,char_bounds.iBr.iX);
   972 	}
   973 
   974 void CTFont::DisplayLargeChars()
   975 	{
   976 	ResetGc();
   977 	iGc->UseFont(iFont);
   978 
   979 	TPoint pos(20,iDev->SizeInPixels().iHeight / 2);
   980 
   981 	pos.iX = DisplayCharAndBounds('G',pos,FALSE,FALSE) + 20;
   982 	pos.iX = DisplayCharAndBounds('p',pos,FALSE,FALSE) + 20;
   983 	pos.iX = DisplayCharAndBounds('G',pos,TRUE,TRUE) + 20;
   984 	pos.iX = DisplayCharAndBounds('p',pos,TRUE,TRUE) + 20;
   985 	pos.iX = DisplayCharAndBounds('G',pos,TRUE,FALSE) + 20;
   986 	pos.iX = DisplayCharAndBounds('p',pos,TRUE,FALSE) + 20;
   987 
   988 	iGc->SetPenStyle(CGraphicsContext::EDottedPen);
   989 	iGc->SetPenColor(KRgbGray);
   990 
   991 	iGc->DiscardFont();
   992 	}
   993 
   994 /**
   995   @SYMTestCaseID GRAPHICS-BITGDI-0079
   996  
   997   @SYMDEF             
   998 
   999   @SYMTestCaseDesc Vertical text
  1000    
  1001   @SYMTestPriority High
  1002 
  1003   @SYMTestStatus Implemented
  1004 
  1005   @SYMTestActions Draws text in varied weight and typeface to a gc in a vertical manner
  1006  
  1007   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1008 */
  1009 void CTFont::DoVerticalText()
  1010 	{
  1011 	TFontSpec fs;
  1012 	TInt typefaces=iDev->NumTypefaces();
  1013 	TTypefaceSupport info;
  1014 	TPoint pos(0,0);
  1015 	TBool dir=ETrue;
  1016 	TInt count=0;
  1017 	for(;count<typefaces;count++)
  1018 		{
  1019 		iDev->TypefaceSupport(info,count);
  1020 		pos.SetXY(0,0);
  1021 		dir=ETrue;
  1022 		ResetGc();
  1023 		for(TInt index=0;index<info.iNumHeights;index++)
  1024 			{
  1025 			TInt height=iDev->FontHeightInPixels(count,index);
  1026 			if(height<5) continue;
  1027 			fs.iTypeface=info.iTypeface;
  1028 			fs.iHeight=height;
  1029 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
  1030 			iGc->UseFont(iFont);
  1031 			if(dir) pos.iY=iDev->SizeInPixels().iHeight;
  1032 			else pos.iY=0;
  1033 			if(dir)
  1034 				pos.iX+=iFont->AscentInPixels()+1;
  1035 			else
  1036 				pos.iX+=iFont->HeightInPixels()-1-iFont->AscentInPixels();
  1037 			iGc->DrawTextVertical(_L("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),pos,dir);
  1038 			if(dir)
  1039 				pos.iX+=iFont->HeightInPixels()+1-iFont->AscentInPixels();
  1040 			else
  1041 				pos.iX+=iFont->AscentInPixels()+3;
  1042 			dir=!dir;
  1043 			iDev->ReleaseFont(iFont);
  1044 			iGc->DiscardFont();
  1045 			if (pos.iX > iDev->SizeInPixels().iWidth)
  1046 				break;
  1047 			}
  1048 		//TheTest.Getch();
  1049 		}
  1050 
  1051 	for(count=0;count<typefaces;count++)
  1052 		{
  1053 		iDev->TypefaceSupport(info,count);
  1054 		pos.SetXY(0,0);
  1055 		dir=ETrue;
  1056 		ResetGc();
  1057 		iGc->SetUnderlineStyle(EUnderlineOn);
  1058 		iGc->SetStrikethroughStyle(EStrikethroughOn);
  1059 		for(TInt index=0;index<info.iNumHeights;index++)
  1060 			{
  1061 			TInt height=iDev->FontHeightInPixels(count,index);
  1062 			if(height<5) continue;
  1063 			fs.iTypeface=info.iTypeface;
  1064 			fs.iHeight=height;
  1065 			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
  1066 			iGc->UseFont(iFont);
  1067 			if(dir) pos.iY=iDev->SizeInPixels().iHeight;
  1068 			else pos.iY=0;
  1069 			if(dir)
  1070 				pos.iX+=iFont->AscentInPixels()+3;
  1071 			else
  1072 				pos.iX+=iFont->HeightInPixels()+1-iFont->AscentInPixels();
  1073 			iGc->DrawTextVertical(_L("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),pos,dir);
  1074 			if(dir)
  1075 				pos.iX+=iFont->HeightInPixels()+3-iFont->AscentInPixels();
  1076 			else
  1077 				pos.iX+=iFont->AscentInPixels()+5;
  1078 			dir=!dir;
  1079 			iDev->ReleaseFont(iFont);
  1080 			iGc->DiscardFont();
  1081 			if (pos.iX > iDev->SizeInPixels().iWidth)
  1082 				break;
  1083 			}
  1084 		//TheTest.Getch();
  1085 		}
  1086 	}
  1087 
  1088 /**
  1089   @SYMTestCaseID GRAPHICS-BITGDI-0080
  1090  
  1091   @SYMDEF             
  1092 
  1093   @SYMTestCaseDesc Vertical Text in a box
  1094    
  1095   @SYMTestPriority High
  1096 
  1097   @SYMTestStatus Implemented
  1098 
  1099   @SYMTestActions Draws text in varied weight and typeface to a gc in a vertical manner within a rect
  1100  
  1101   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1102 */
  1103 void CTFont::DoVerticalBoxL()
  1104 	{
  1105 	ResetGc();
  1106 
  1107 	TFontSpec fsp;
  1108 	fsp.iTypeface.iName=_L("Swiss");
  1109 	fsp.iHeight=200;
  1110 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1111 	iGc->UseFont(iFont);
  1112 
  1113 	TInt t = 20;
  1114 	TInt b = iDev->SizeInPixels().iHeight - 20;
  1115 	TRect r1(60,t,80,b);
  1116 	TRect r2(100,t,120,b);
  1117 	TRect r3(140,t,160,b);
  1118 	TRect r4(180,t,200,b);
  1119 	TRect r5(220,t,240,b);
  1120 
  1121 	TRect r6(440,t,460,b);
  1122 	TRect r7(400,t,420,b);
  1123 	TRect r8(360,t,380,b);
  1124 	TRect r9(320,t,340,b);
  1125 	TRect r10(280,t,300,b);
  1126 
  1127 	iGc->DrawTextVertical(_L("Font test code:"),TPoint(t,b),ETrue);
  1128 	iGc->DrawTextVertical(_L("Left aligned"),r1,14,ETrue,CGraphicsContext::ELeft);
  1129 	iGc->DrawTextVertical(_L("With margin"),r2,14,ETrue,CGraphicsContext::ELeft,50);
  1130 	iGc->DrawTextVertical(_L("Centred"),r3,14,ETrue,CGraphicsContext::ECenter);
  1131 	iGc->DrawTextVertical(_L("Right aligned"),r4,14,ETrue,CGraphicsContext::ERight);
  1132 	iGc->DrawTextVertical(_L("With margin"),r5,14,ETrue,CGraphicsContext::ERight,30);
  1133 
  1134 	iGc->DrawTextVertical(_L("Font test code:"),TPoint(r6.iBr.iX + t,t),EFalse);
  1135 	iGc->DrawTextVertical(_L("Left aligned"),r6,14,EFalse,CGraphicsContext::ELeft);
  1136 	iGc->DrawTextVertical(_L("With margin"),r7,14,EFalse,CGraphicsContext::ELeft,50);
  1137 	iGc->DrawTextVertical(_L("Centred"),r8,14,EFalse,CGraphicsContext::ECenter);
  1138 	iGc->DrawTextVertical(_L("Right aligned"),r9,14,EFalse,CGraphicsContext::ERight);
  1139 	iGc->DrawTextVertical(_L("With margin"),r10,14,EFalse,CGraphicsContext::ERight,30);
  1140 
  1141 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1142 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1143 	iGc->SetPenSize(TSize(1,1));
  1144 	iGc->DrawRect(r1);
  1145 	iGc->DrawRect(r2);
  1146 	iGc->DrawRect(r3);
  1147 	iGc->DrawRect(r4);
  1148 	iGc->DrawRect(r5);
  1149 	iGc->DrawRect(r6);
  1150 	iGc->DrawRect(r7);
  1151 	iGc->DrawRect(r8);
  1152 	iGc->DrawRect(r9);
  1153 	iGc->DrawRect(r10);
  1154 
  1155 	iGc->DiscardFont();
  1156 	iDev->ReleaseFont(iFont);
  1157 	//TheTest.Getch();
  1158 	}
  1159 
  1160 /**
  1161   @SYMTestCaseID GRAPHICS-BITGDI-0081
  1162  
  1163   @SYMDEF             
  1164 
  1165   @SYMTestCaseDesc Super/subscript
  1166    
  1167   @SYMTestPriority High
  1168 
  1169   @SYMTestStatus Implemented
  1170 
  1171   @SYMTestActions tests the drawing of super and subscript fonts to the gc 
  1172  
  1173   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1174 */
  1175 void CTFont::DoSuperSubScriptL()
  1176 	{
  1177 	ResetGc();
  1178 
  1179 	TInt separation = iDev->SizeInPixels().iHeight / 6;
  1180 	TPoint textPos(20,separation);
  1181 
  1182 	CFbsFont* fnorm=NULL;
  1183 	CFbsFont* fsuper=NULL;
  1184 	CFbsFont* fsub=NULL;
  1185 
  1186 	TFontSpec fsp;
  1187 	fsp.iTypeface.iName=_L("Swiss");
  1188 	fsp.iHeight=300;
  1189 
  1190 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fnorm,fsp));
  1191 	fsp.iFontStyle.SetPrintPosition(EPrintPosSuperscript);
  1192 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fsuper,fsp));
  1193 	fsp.iFontStyle.SetPrintPosition(EPrintPosSubscript);
  1194 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fsub,fsp));
  1195 
  1196 	iGc->UseFont(fnorm);
  1197 	iGc->DrawText(_L("H"),textPos);
  1198 	iGc->UseFont(fsub);
  1199 	iGc->DrawText(_L("2"));
  1200 	iGc->UseFont(fnorm);
  1201 	iGc->DrawText(_L("O"));
  1202 
  1203 	textPos.iY += separation;
  1204 	iGc->DrawText(_L("X"),textPos);
  1205 	iGc->UseFont(fsuper);
  1206 	iGc->DrawText(_L("2"));
  1207 	iGc->UseFont(fnorm);
  1208 	iGc->DrawText(_L("+Y"));
  1209 	iGc->UseFont(fsuper);
  1210 	iGc->DrawText(_L("2"));
  1211 	iGc->UseFont(fnorm);
  1212 	iGc->DrawText(_L("=Z"));
  1213 	iGc->UseFont(fsuper);
  1214 	iGc->DrawText(_L("2"));
  1215 
  1216 	textPos.iY += separation;
  1217 	iGc->UseFont(fnorm);
  1218 	iGc->DrawText(_L("S"),textPos);
  1219 	iGc->UseFont(fsuper);
  1220 	iGc->DrawText(_L("uper"));
  1221 	iGc->UseFont(fnorm);
  1222 	iGc->DrawText(_L("S"));
  1223 	iGc->UseFont(fsuper);
  1224 	iGc->DrawText(_L("cript"));
  1225 
  1226 	textPos.iY += separation;
  1227 	iGc->UseFont(fnorm);
  1228 	iGc->DrawText(_L("S"),textPos);
  1229 	iGc->UseFont(fsub);
  1230 	iGc->DrawText(_L("ub"));
  1231 	iGc->UseFont(fnorm);
  1232 	iGc->DrawText(_L("S"));
  1233 	iGc->UseFont(fsub);
  1234 	iGc->DrawText(_L("cript"));
  1235 
  1236 	textPos.iY += separation;
  1237 	iGc->UseFont(fnorm);
  1238 	iGc->DrawText(_L("Normal"),textPos);
  1239 
  1240 	iGc->DiscardFont();
  1241 	iDev->ReleaseFont(fnorm);
  1242 	iDev->ReleaseFont(fsuper);
  1243 	iDev->ReleaseFont(fsub);
  1244 	//TheTest.Getch();
  1245 	}
  1246 
  1247 /**
  1248   @SYMTestCaseID GRAPHICS-BITGDI-0082
  1249  
  1250   @SYMDEF             
  1251 
  1252   @SYMTestCaseDesc Underlining/strikethrough
  1253    
  1254   @SYMTestPriority High
  1255 
  1256   @SYMTestStatus Implemented
  1257 
  1258   @SYMTestActions tests the drawing of Underlining and strikethrough fonts to the gc  
  1259  
  1260   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1261 */
  1262 void CTFont::DoUlStL()
  1263 	{
  1264 	iGc->SetPenColor(KRgbBlack);
  1265 	iGc->SetBrushColor(KRgbWhite);
  1266 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1267 	iGc->Clear();
  1268 	iGc->SetUnderlineStyle(EUnderlineOn);
  1269 	iGc->SetStrikethroughStyle(EStrikethroughOn);
  1270 	TFontSpec fsp;
  1271 	fsp.iTypeface.iName=_L("Swiss");
  1272 	fsp.iHeight=15;
  1273 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1274 	iGc->UseFont(iFont);
  1275 	iDev->ReleaseFont(iFont);
  1276 	iGc->DrawText(_L(" "),TPoint(10,iDev->SizeInPixels().iHeight/3));
  1277 	TInt height=50;
  1278 	for(;height<1000;height+=50)
  1279 		{
  1280 		fsp.iHeight=height;
  1281 		User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1282 		iGc->UseFont(iFont);
  1283 		iDev->ReleaseFont(iFont);
  1284 		TBuf<4> num;
  1285 		num.Num(height/20);
  1286 		iGc->DrawText(_L(" "));
  1287 		iGc->DrawText(num);
  1288 		}
  1289 	fsp.iHeight=15;
  1290 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1291 	iGc->UseFont(iFont);
  1292 	iDev->ReleaseFont(iFont);
  1293 	iGc->DrawText(_L(" "),TPoint(10,iDev->SizeInPixels().iHeight*3/4));
  1294 	for(;height<2000;height+=50)
  1295 		{
  1296 		fsp.iHeight=height;
  1297 		User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1298 		iGc->UseFont(iFont);
  1299 		iDev->ReleaseFont(iFont);
  1300 		TBuf<4> num;
  1301 		num.Num(height/20);
  1302 		iGc->DrawText(_L(" "));
  1303 		iGc->DrawText(num);
  1304 		}
  1305 	iGc->SetUnderlineStyle(EUnderlineOff);
  1306 	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1307 	iGc->DiscardFont();
  1308 	//TheTest.Getch();
  1309 	}
  1310 
  1311 /**
  1312   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4006
  1313  
  1314   @SYMDEF             
  1315 
  1316   @SYMTestCaseDesc Text drawing in context
  1317    
  1318   @SYMTestPriority High
  1319 
  1320   @SYMTestStatus Implemented
  1321 
  1322   @SYMTestActions Tests drawing ,mainly punctuation marks in context to a gc 
  1323  
  1324   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn to the screen, and all punctuations should be drawn to the horizontal baseline of the script of the character that preceded the punctuation marks.
  1325 */
  1326 void CTFont::DrawTextInContext()
  1327 	{
  1328 	ResetGc();
  1329 
  1330 	TFontSpec fsp;
  1331 	fsp.iTypeface.iName=_L("Series 60 Sans");
  1332 	fsp.iHeight=250;
  1333 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1334 	iGc->UseFont(iFont);
  1335 	
  1336 	TInt ascent=iFont->AscentInPixels();
  1337 	TPoint pt(10,ascent+10);
  1338 	CGraphicsContext::TTextParameters param;
  1339 	param.iStart = 0;
  1340 	param.iEnd = 32;
  1341 	iGc->DrawText(_L("Punctuations in various scripts:"),&param,pt);
  1342 
  1343 	iGc->DiscardFont();
  1344 	fsp.iHeight=430;
  1345 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1346 	iGc->UseFont(iFont);
  1347 	
  1348 	param.iStart = 27;
  1349 	param.iEnd = 60;
  1350 	pt+=TPoint(0,50);	
  1351 	iGc->DrawText(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"),&param,pt);
  1352 	pt+=TPoint(0,50);
  1353 	param.iEnd = 60;
  1354 	iGc->DrawText(_L("This text will not be drawn\x0915.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Hindi This text will not be drawn"),&param,pt);
  1355 	pt+=TPoint(0,50);
  1356 	param.iEnd = 62;
  1357 	iGc->DrawText(_L("This text will not be drawn\x0C85.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Kannada This text will not be drawn"),&param,pt);
  1358 	
  1359 	iGc->DiscardFont();
  1360 	iDev->ReleaseFont(iFont);
  1361 	
  1362 	}
  1363 /**
  1364   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4005
  1365  
  1366   @SYMDEF             
  1367 
  1368   @SYMTestCaseDesc Text drawing in a box in context - 1
  1369    
  1370   @SYMTestPriority High
  1371 
  1372   @SYMTestStatus Implemented
  1373 
  1374   @SYMTestActions Tests drawing of boxed text,mainly punctuation marks in context to a gc 
  1375  
  1376   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn in boxes to the screen, and all punctuations should be drawn to the horizontal baseline of the script of the character that preceded the punctuation marks.
  1377 */
  1378 void CTFont::DrawTextInContextBox()
  1379 	{
  1380 	ResetGc();
  1381 
  1382 	TFontSpec fsp;
  1383 	fsp.iTypeface.iName=_L("Series 60 Sans");
  1384 	fsp.iHeight=250;
  1385 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1386 	iGc->UseFont(iFont);
  1387 	
  1388 	TInt ascent=iFont->AscentInPixels();
  1389 	TPoint pt(10,ascent+10);
  1390 	CGraphicsContext::TTextParameters param;
  1391 	param.iStart = 0;
  1392 	param.iEnd = 41;
  1393 	iGc->DrawText(_L("Punctuations in various scripts in a box:"),&param,pt);
  1394 	
  1395 	iGc->DiscardFont();
  1396 	iDev->ReleaseFont(iFont);
  1397 	fsp.iHeight=430;
  1398 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1399 	iGc->UseFont(iFont);
  1400 	//ResetGc();
  1401 	param.iStart = 27;
  1402 	param.iEnd = 60;
  1403 	iGc->DrawText(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"),&param,TRect(10,50,640,120),40,CGraphicsContext::ELeft);
  1404 	param.iEnd = 60;
  1405 	iGc->DrawText(_L("This text will not be drawn\x0915.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Hindi This text will not be drawn"),&param,TRect(10,100,640,170),40,CGraphicsContext::ELeft);
  1406 	param.iEnd = 62;
  1407 	iGc->DrawText(_L("This text will not be drawn\x0C85.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Kannada This text will not be drawn"),&param,TRect(10,150,640,220),40,CGraphicsContext::ELeft);
  1408 	User::After(TTimeIntervalMicroSeconds32(8000000));
  1409 	
  1410 	iGc->DiscardFont();
  1411 	iDev->ReleaseFont(iFont);
  1412 	}
  1413 	
  1414 /**
  1415   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4004
  1416  
  1417   @SYMDEF             
  1418 
  1419   @SYMTestCaseDesc Vertical drawing of text in context
  1420    
  1421   @SYMTestPriority High
  1422 
  1423   @SYMTestStatus Implemented
  1424 
  1425   @SYMTestActions Tests vertical drawing of text, mainly punctuation marks, in context to a gc 
  1426  
  1427   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn vertically to the screen, and all punctuations should be drawn to the vertical baseline of the script of the character that preceded the punctuation marks.
  1428 */
  1429 void CTFont::DrawTextInContextVertical()
  1430 	{
  1431 	ResetGc();
  1432 
  1433 	TFontSpec fsp;
  1434 	fsp.iTypeface.iName=_L("Series 60 Sans");
  1435 	fsp.iHeight=300;
  1436 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1437 	iGc->UseFont(iFont);
  1438 	
  1439 	TInt descent=iFont->DescentInPixels();
  1440 	TPoint pt(descent+10,10);
  1441 	CGraphicsContext::TTextParameters param;
  1442 	
  1443 	param.iStart = 27;
  1444 	param.iEnd = 60;	
  1445 	iGc->DrawTextVertical(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"),&param,pt,EFalse);
  1446 	User::After(TTimeIntervalMicroSeconds32(400000));
  1447 	pt+=TPoint(30,0);
  1448 	param.iEnd = 60;
  1449 	iGc->DrawTextVertical(_L("This text will not be drawn\x0915.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Hindi This text will not be drawn"),&param,pt,EFalse);
  1450 	User::After(TTimeIntervalMicroSeconds32(400000));
  1451 	pt+=TPoint(30,0);
  1452 	param.iEnd = 62;
  1453 	iGc->DrawTextVertical(_L("This text will not be drawn\x0C85.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Kannada This text will not be drawn"),&param,pt,EFalse);
  1454 	
  1455 	iGc->DiscardFont();
  1456 	iDev->ReleaseFont(iFont);
  1457 	}
  1458 	
  1459 /**
  1460   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4003
  1461  
  1462   @SYMDEF             
  1463 
  1464   @SYMTestCaseDesc Text drawing in a box in context - 2
  1465    
  1466   @SYMTestPriority High
  1467 
  1468   @SYMTestStatus Implemented
  1469 
  1470   @SYMTestActions Tests drawing of boxed text in context to a gc 
  1471  
  1472   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn in boxes to the screen
  1473 */
  1474 void CTFont::BoxInContext()
  1475 	{
  1476 	iGc->SetPenSize(TSize(0,0));
  1477 	iGc->SetBrushColor(KRgbWhite);
  1478 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1479 	iGc->Clear();
  1480 	CGraphicsContext::TTextParameters param;
  1481 	param.iStart = 29;
  1482 	param.iEnd = 44;
  1483 	iGc->DrawText(_L("(This text will not be drawn)Font test code:(This text will not be drawn)"),&param,TPoint(20,20));
  1484 	param.iEnd = 67;
  1485 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param,TPoint(20,40));
  1486 	param.iEnd = 77;
  1487 	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1488 	param.iEnd = 52;
  1489 	iGc->DrawText(_L("(This text will not be drawn)Box text (left aligned)(This text will not be drawn)"),&param,TRect(20,50,320,70),14,CGraphicsContext::ELeft);
  1490 	param.iEnd = 64;
  1491 	iGc->DrawText(_L("(This text will not be drawn)Box text (left aligned with margin)(This text will not be drawn)"),&param,TRect(20,70,320,90),14,CGraphicsContext::ELeft,50);
  1492 	param.iEnd = 47;
  1493 	iGc->DrawText(_L("(This text will not be drawn)Box text (centred)(This text will not be drawn)"),&param,TRect(20,90,320,110),14,CGraphicsContext::ECenter);
  1494 	param.iEnd = 53;
  1495 	iGc->DrawText(_L("(This text will not be drawn)Box text (right aligned)(This text will not be drawn)"),&param,TRect(20,110,320,130),14,CGraphicsContext::ERight);
  1496 	param.iEnd = 65;
  1497 	iGc->DrawText(_L("(This text will not be drawn)Box text (right aligned with margin)(This text will not be drawn)"),&param,TRect(20,130,320,150),14,CGraphicsContext::ERight,30);
  1498 	param.iEnd = 53;
  1499 	iGc->DrawText(_L("(This text will not be drawn)(Boxes drawn afterwards)(This text will not be drawn)"),&param,TPoint(20,165));
  1500 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1501 	iGc->DrawRect(TRect(20,50,320,70));
  1502 	iGc->DrawRect(TRect(20,70,320,90));
  1503 	iGc->DrawRect(TRect(20,90,320,110));
  1504 	iGc->DrawRect(TRect(20,110,320,130));
  1505 
  1506 	iGc->SetBrushColor(TRgb(128,128,128));
  1507 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1508 	param.iEnd = 52;
  1509 	iGc->DrawText(_L("(This text will not be drawn)Box text (left aligned)(This text will not be drawn)"),&param,TRect(320,50,620,70),14,CGraphicsContext::ELeft);
  1510 	param.iEnd = 64;
  1511 	iGc->DrawText(_L("(This text will not be drawn)Box text (left aligned with margin)(This text will not be drawn)"),&param,TRect(320,70,620,90),14,CGraphicsContext::ELeft,50);
  1512 	param.iEnd = 47;
  1513 	iGc->DrawText(_L("(This text will not be drawn)Box text (centred)(This text will not be drawn)"),&param,TRect(320,90,620,110),14,CGraphicsContext::ECenter);
  1514 	param.iEnd = 53;
  1515 	iGc->DrawText(_L("(This text will not be drawn)Box text (right aligned)(This text will not be drawn)"),&param,TRect(320,110,620,130),14,CGraphicsContext::ERight);
  1516 	param.iEnd = 65;
  1517 	iGc->DrawText(_L("(This text will not be drawn)Box text (right aligned with margin)(This text will not be drawn)"),&param,TRect(320,130,620,150),14,CGraphicsContext::ERight,30);
  1518 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1519 	iGc->DrawRect(TRect(320,50,620,70));
  1520 	iGc->DrawRect(TRect(320,70,620,90));
  1521 	iGc->DrawRect(TRect(320,90,620,110));
  1522 	iGc->DrawRect(TRect(320,110,620,130));
  1523 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1524 	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
  1525 	param.iEnd = 37;
  1526 	iGc->DrawText(_L("(This text will not be drawn)Box text(This text will not be drawn)"),&param,TRect(20,150,620,170),14,width);
  1527 	param.iEnd = 60;
  1528 	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1529 	param.iEnd = 37;
  1530 	iGc->DrawText(_L("(This text will not be drawn)Box text(This text will not be drawn)"),&param,TRect(20,170,620,190),14,width,CGraphicsContext::ELeft,20);
  1531 	param.iEnd = 60;
  1532 	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1533 	param.iEnd = 37;
  1534 	iGc->DrawText(_L("(This text will not be drawn)Box text(This text will not be drawn)"),&param,TRect(20,190,620,210),14,width,CGraphicsContext::ECenter);
  1535 	param.iEnd = 60;
  1536 	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1537 	param.iEnd = 37;
  1538 	iGc->DrawText(_L("(This text will not be drawn)Box text(This text will not be drawn)"),&param,TRect(20,210,620,230),14,width,CGraphicsContext::ERight,20);
  1539 	param.iEnd = 60;
  1540 	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1541 	iGc->DrawText(_L(""),TRect(20,230,620,250),14,width);
  1542 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1543 	iGc->DrawRect(TRect(20,150,620,170));
  1544 	iGc->DrawRect(TRect(20,170,620,190));
  1545 	iGc->DrawRect(TRect(20,190,620,210));
  1546 	iGc->DrawRect(TRect(20,210,620,230));
  1547 	}
  1548 
  1549 /**
  1550   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4002
  1551  
  1552   @SYMDEF             
  1553 
  1554   @SYMTestCaseDesc Text drawing and justification in context
  1555    
  1556   @SYMTestPriority High
  1557 
  1558   @SYMTestStatus Implemented
  1559 
  1560   @SYMTestActions Tests drawing of justified text in context to a gc 
  1561  
  1562   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn to the screen, and it should be justified within the context
  1563 */
  1564 void CTFont::JustificationInContext()
  1565 	{
  1566 	iGc->SetUnderlineStyle(EUnderlineOff);
  1567 	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1568 	iGc->SetPenSize(TSize(0,0));
  1569 	iGc->SetBrushColor(KRgbWhite);
  1570 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1571 	iGc->Clear();
  1572 	CGraphicsContext::TTextParameters param;
  1573 	param.iStart = 29;
  1574 	param.iEnd = 44;
  1575 	iGc->DrawText(_L("(This text will not be drawn)Font test code:(This text will not be drawn)"),&param,TPoint(20,20));
  1576 	param.iEnd = 67;
  1577 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"),&param,TPoint(20,40));
  1578 	iGc->SetCharJustification(18,6);
  1579 	iGc->SetWordJustification(0,0);
  1580 	param.iEnd = 67;
  1581 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"),&param,TPoint(20,60));
  1582 	iGc->SetCharJustification(0,0);
  1583 	iGc->SetWordJustification(30,6);
  1584 	param.iEnd = 67;
  1585 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"),&param,TPoint(20,80));
  1586 	iGc->SetCharJustification(18,6);
  1587 	iGc->SetWordJustification(30,6);
  1588 	param.iEnd = 67;
  1589 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"),&param,TPoint(20,100));
  1590 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"));
  1591 	param.iEnd = 67;
  1592 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param,TPoint(20,120));
  1593 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1594 	param.iEnd = 77;
  1595 	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1596 	iGc->UpdateJustification(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1597 	iGc->SetCharJustification(18,6);
  1598 	iGc->SetWordJustification(0,0);
  1599 	param.iEnd = 67;
  1600 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param,TPoint(20,140));
  1601 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1602 	param.iEnd = 77;
  1603 	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1604 	iGc->SetCharJustification(0,0);
  1605 	iGc->SetWordJustification(30,6);
  1606 	param.iEnd = 67;
  1607 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param,TPoint(20,160));
  1608 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1609 	param.iEnd = 77;
  1610 	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1611 	iGc->SetCharJustification(18,6);
  1612 	iGc->SetWordJustification(30,6);
  1613 	param.iEnd = 67;
  1614 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param,TPoint(20,180));
  1615 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1616 	param.iEnd = 77;
  1617 	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1618 	iGc->SetCharJustification(150,50);
  1619 	iGc->SetWordJustification(50,10);
  1620 	param.iEnd = 68;
  1621 	iGc->DrawText(_L("(This text will not be drawn)Normal text printing in one whole line,(This text will not be drawn)"),&param,TPoint(20,200));
  1622 	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing in one whole line,(This text will not be drawn)"),&param);
  1623 	param.iEnd = 80;
  1624 	iGc->DrawText(_L("(This text will not be drawn)followed by more text, carrying over justification.(This text will not be drawn)"),&param,TPoint(20,220));
  1625 	iGc->SetCharJustification(0,0);
  1626 	iGc->SetWordJustification(0,0);
  1627 	}
  1628 		
  1629 /**
  1630   @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4001
  1631  
  1632   @SYMDEF             
  1633 
  1634   @SYMTestCaseDesc Text drawing in context
  1635    
  1636   @SYMTestPriority High
  1637 
  1638   @SYMTestStatus Implemented
  1639 
  1640   @SYMTestActions Tests drawing of normal/justified/vertical/boxed text in context to a gc 
  1641  
  1642   @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn to the screen
  1643 */
  1644 void CTFont::DoTextFormatsInContextL()
  1645 	{
  1646 	ResetGc();
  1647 	
  1648 	TFontSpec fsp;
  1649 	fsp.iTypeface.iName=_L("Series 60 Sans");
  1650 	fsp.iHeight=300;
  1651 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1652 	iGc->UseFont(iFont);
  1653 	
  1654 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4006"));
  1655 	DrawTextInContext();
  1656 	((CTFontStep*)iStep)->RecordTestResultL();
  1657 	//TheTest.Getch();
  1658 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4005"));
  1659 	DrawTextInContextBox();
  1660 	((CTFontStep*)iStep)->RecordTestResultL();
  1661 	//TheTest.Getch();
  1662 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4004"));
  1663 	DrawTextInContextVertical();
  1664 	((CTFontStep*)iStep)->RecordTestResultL();
  1665 	//TheTest.Getch();
  1666 	
  1667 	iGc->DiscardFont();
  1668 	iDev->ReleaseFont(iFont);
  1669 
  1670 	fsp.iTypeface.iName=_L("Swiss");
  1671 	fsp.iHeight=200;
  1672 
  1673 	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1674 	iGc->UseFont(iFont);
  1675 
  1676 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4003"));
  1677 	BoxInContext();
  1678 	((CTFontStep*)iStep)->RecordTestResultL();
  1679 	//TheTest.Getch();
  1680 
  1681 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4002"));
  1682 	JustificationInContext();
  1683 	((CTFontStep*)iStep)->RecordTestResultL();
  1684 	//TheTest.Getch();
  1685 
  1686 	iGc->DiscardFont();
  1687 	iDev->ReleaseFont(iFont);
  1688 	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4001"));
  1689 	}
  1690 	
  1691 void CTFont::ResetGc()
  1692 	{
  1693 	iGc->SetUnderlineStyle(EUnderlineOff);
  1694 	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1695 	iGc->SetPenSize(TSize(1,1));
  1696 	iGc->SetPenColor(KRgbBlack);
  1697 	iGc->SetBrushColor(KRgbWhite);
  1698 	iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1699 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1700 	iGc->Clear();
  1701 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1702 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1703 	}
  1704 
  1705 TInt CTFont::GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec)
  1706 	{
  1707 	TInt ret = iDev->GetNearestFontToDesignHeightInPixels((CFont*&)aFont, aFontSpec);
  1708 	if (ret != KErrNone)
  1709 		{
  1710 		return ret;
  1711 		}
  1712 #ifdef __WINS__
  1713 	CBitmapFont* bitmapFont = CFbsFontEx::FontAddress(aFont);
  1714 	iFontCallCounter.iInjector.InjectShellcode(bitmapFont, &iFontCallCounter);
  1715 	if (bitmapFont->IsOpenFont())
  1716 		{
  1717 		iOpenFontCallCounter.iInjector.InjectShellcode(bitmapFont->OpenFont(), &iOpenFontCallCounter);
  1718 		}
  1719 #endif
  1720 	return KErrNone;
  1721 	}
  1722 
  1723 TInt CTFont::GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec)
  1724 	{
  1725 	TInt ret = iDev->GetNearestFontToDesignHeightInTwips((CFont*&)aFont, aFontSpec);
  1726 	if (ret != KErrNone)
  1727 		{
  1728 		return ret;
  1729 		}
  1730 #ifdef __WINS__
  1731 	CBitmapFont* bitmapFont = CFbsFontEx::FontAddress(aFont);
  1732 	iFontCallCounter.iInjector.InjectShellcode(bitmapFont, &iFontCallCounter);
  1733 	if (bitmapFont->IsOpenFont())
  1734 		{
  1735 		iOpenFontCallCounter.iInjector.InjectShellcode(bitmapFont->OpenFont(), &iOpenFontCallCounter);
  1736 		}
  1737 #endif
  1738 	return KErrNone;
  1739 	}
  1740 
  1741 void CTFont::RunTestCaseL(TInt aCurTestCase)
  1742 	{
  1743 	((CTFontStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1744 	switch(aCurTestCase)
  1745 		{
  1746 		case 1:
  1747 			{
  1748 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0075"));
  1749             INFO_PRINTF1(_L("All fonts"));
  1750 			TRAPD(ret, DoAllFontsL());
  1751 			TEST(ret == KErrNone);
  1752             INFO_PRINTF2(_L("Test case 'All fonts' ended with ret='%d'\n"), ret);
  1753 			break;
  1754 			}
  1755 		case 2:
  1756 			{
  1757 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0076"));
  1758 	 		INFO_PRINTF1(_L("Text formatting"));
  1759 			TRAPD(ret, DoTextFormatsL());
  1760 			TEST(ret == KErrNone);
  1761             INFO_PRINTF2(_L("Test case 'Text formatting' ended with ret='%d'\n"), ret);
  1762 			break;
  1763 			}
  1764 		case 3:
  1765 			{
  1766 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0077"));
  1767             INFO_PRINTF1(_L("Check text drawing"));
  1768 			TRAPD(ret, DoBitAlignmentL());
  1769 			TEST(ret == KErrNone);
  1770             INFO_PRINTF2(_L("Test case 'Check text drawing' ended with ret='%d'\n"), ret);
  1771 			break;
  1772 			}
  1773 		case 4:
  1774 			{
  1775 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0078"));
  1776             INFO_PRINTF1(_L("Large fonts"));
  1777 			TRAPD(ret, DoLargeFontsL());
  1778 			TEST(ret == KErrNone);
  1779             INFO_PRINTF2(_L("Test case 'Large fonts' ended with ret='%d'\n"), ret);
  1780 			break;
  1781 			}
  1782 		case 5:
  1783 			{
  1784 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0080"));
  1785             INFO_PRINTF1(_L("Vertical text"));
  1786 			TRAPD(ret, DoVerticalText();
  1787 			((CTFontStep*)iStep)->RecordTestResultL();
  1788 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0079"));
  1789 					   DoVerticalBoxL());
  1790 			TEST(ret == KErrNone);
  1791             INFO_PRINTF2(_L("Test case 'Vertical text' ended with ret='%d'\n"), ret);
  1792 			break;
  1793 			}
  1794 		case 6:
  1795 			{
  1796 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0081"));
  1797          	INFO_PRINTF1(_L("Super/subscript"));
  1798 			TRAPD(ret, DoSuperSubScriptL());
  1799 			TEST(ret == KErrNone);
  1800             INFO_PRINTF2(_L("Test case 'Super/subscript' ended with ret='%d'\n"), ret);
  1801 			break;
  1802 			}
  1803 		case 7:
  1804 			{
  1805 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0082"));
  1806 			INFO_PRINTF1(_L("Underlining/strikethrough"));
  1807 			TRAPD(ret, DoUlStL());
  1808 			TEST(ret == KErrNone);
  1809             INFO_PRINTF2(_L("Test case 'Underlining/strikethrough' ended with ret='%d'\n"), ret);
  1810 			break;
  1811 			}
  1812 		case 8:
  1813 			{
  1814 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0074"));
  1815             INFO_PRINTF1(_L("Anti-aliased text"));
  1816 			TRAPD(ret, DoAntiAliasedTextL());
  1817 			TEST(ret == KErrNone);
  1818             INFO_PRINTF2(_L("Test case 'Anti-aliased text' ended with ret='%d'\n"), ret);
  1819 			break;
  1820 			}
  1821 		case 9:
  1822 			{
  1823 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0075"));
  1824         	INFO_PRINTF1(_L("FaceCache Performance text"));
  1825 
  1826 			TInt64 starttime = User::FastCounter();
  1827 			TRAPD(ret, DoAllFontsL());
  1828 			TInt64 endtime = User::FastCounter();
  1829 			TEST(ret == KErrNone);
  1830 
  1831 			TInt freq;
  1832 			User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, freq));
  1833 			TInt64 diff = (1000000*(endtime - starttime)) / (TInt64)freq;
  1834 
  1835             INFO_PRINTF3(_L("Test case 'FaceCache Performance text' ended in '%Ld' usec with ret='%d'\n"), diff, ret);
  1836 			break;
  1837 			}
  1838 		case 10:
  1839 			{
  1840 /**
  1841   @SYMTestCaseID GRAPHICS-BITGDI-0116
  1842 */
  1843 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0116"));
  1844 			INFO_PRINTF1(_L("Font Externalize/Internalize"));
  1845 			TRAPD(ret, FontExternalizeL());
  1846 			TEST(ret==KErrNone);
  1847 			INFO_PRINTF2(_L("Test case 'Font Externalize/Internalize' ended with ret='%d'\n"), ret);
  1848 			break;
  1849 			}
  1850 		case 11:
  1851 			{
  1852 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4001"));
  1853 	 		INFO_PRINTF1(_L("Text formatting"));
  1854 			TRAPD(ret, DoTextFormatsInContextL());
  1855 			TEST(ret == KErrNone);
  1856             INFO_PRINTF2(_L("Test case 'Text formatting' ended with ret='%d'\n"), ret);
  1857 			break;
  1858 			}
  1859 		case 12:
  1860 			{
  1861 /**
  1862 @SYMTestCaseID		GRAPHICS-BITGDI-0118
  1863 @SYMTestPriority	High
  1864 @SYMTestType		UT
  1865 @SYMTestStatus		Implemented
  1866 @SYMDEF				EI0014
  1867 
  1868 @SYMTestCaseDesc
  1869 	Tests that there are no virtual function calls to objects in FBServ's shared heap from outside
  1870 	the FBServ process. Such function calls only work if DLLs are guaranteed to be mapped at the
  1871 	same logical address in every process. This is not necessarily true for all memory models.
  1872 
  1873 @SYMTestActions
  1874 	Intercepts the VF table in the CBitmapFont and COpenFont objects corresponding to the fonts used in the
  1875 	preceding BitGDI tests so that virtual function calls from outside the FBServ process are recorded.
  1876 
  1877 @SYMTestExpectedResults
  1878 	Number of virtual function calls to CBitmapFont and COpenFont from outside FBServ is 0
  1879 */
  1880 			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0118"));
  1881 			// this one should always be the last test, since it checks the final virtual function call count
  1882 #ifdef __WINS__
  1883 			INFO_PRINTF1(_L("Test no virtual function calls to objects in FBServ's shared heap from outside FBServ process"));
  1884 			TEST(iFontCallCounter.iVFCallsOutsideFBServ == 0);
  1885 			TEST(iOpenFontCallCounter.iVFCallsOutsideFBServ == 0);
  1886 #else
  1887 			INFO_PRINTF1(_L("Test no virtual function calls to objects in FBServ's shared heap from outside FBServ process - skipped on target"));
  1888 #endif
  1889 			break;
  1890 			}
  1891 		case 13:
  1892 			{
  1893 			((CTFontStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1894 			((CTFontStep*)iStep)->CloseTMSGraphicsStep();
  1895 			TestComplete();		
  1896 			break;
  1897 			}
  1898 		}
  1899 	((CTFontStep*)iStep)->RecordTestResultL();
  1900 	}
  1901 
  1902 
  1903 //--------------------------------------------------------------
  1904 
  1905 __CONSTRUCT_STEP__(Font)
  1906 
  1907 void CTFontStep::TestSetupL()
  1908 	{
  1909 	FbsStartup();
  1910 	User::LeaveIfError(RFbsSession::Connect());
  1911 	}
  1912 	
  1913 void CTFontStep::TestClose()
  1914 	{
  1915 	RFbsSession::Disconnect();
  1916 	}