os/graphics/graphicsdeviceinterface/bitgdi/tbit/TFONT.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/TFONT.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1916 @@
     1.4 +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code 
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +#include <e32hal.h>
    1.27 +#include <e32std.h>
    1.28 +#include <e32test.h>
    1.29 +#include <s32mem.h>
    1.30 +#include <bitstd.h>
    1.31 +#include <bitdev.h>
    1.32 +#include <fntstore.h>
    1.33 +#include <fbs.h>
    1.34 +#include <hal.h>
    1.35 +#include <gdi.h>
    1.36 +#include <graphics/fbsdefs.h>
    1.37 +
    1.38 +#include "TFont.h"
    1.39 +
    1.40 +const TInt KTextBufferLength = 256;
    1.41 +
    1.42 +//If you want to do font tests with scaled device - change KScalingFactorX, KScalingFactorY, KScalingOriginPt.
    1.43 +const TInt KScalingFactorX = 1;
    1.44 +const TInt KScalingFactorY = 1;
    1.45 +const TPoint KScalingOriginPt(0, 0);
    1.46 +
    1.47 +//--------------------------------------------------------------
    1.48 +
    1.49 +CBitmapFont* CFbsFontEx::FontAddress(CFbsFont* aFont)
    1.50 +	{
    1.51 +	return(((CFbsFontEx*)aFont)->Address());
    1.52 +	}
    1.53 +
    1.54 +//--------------------------------------------------------------
    1.55 +
    1.56 +#ifdef __WINS__
    1.57 +template<class C> XTCallCounter<C>::XTCallCounter(CTGraphicsBase& aTestBase)
    1.58 +	: iTestBase(aTestBase), iVFCallsOutsideFBServ(0)
    1.59 +	{}
    1.60 +
    1.61 +template<class C> void XTCallCounter<C>::ExecuteShellcode(TInt aFromFunction)
    1.62 +	{
    1.63 +	const TUint32 KFBServId = 0x10003A16;
    1.64 +	const TUint32 KTBitgdiServerId = 0x10273362;
    1.65 +	TSecureId id = RProcess().SecureId();
    1.66 +	if (id != KFBServId)
    1.67 +		{
    1.68 +		User::LockedInc(iVFCallsOutsideFBServ);
    1.69 +		if (id == KTBitgdiServerId)
    1.70 +			{
    1.71 +			TBuf<128> name;
    1.72 +			XVtableInjector<C>::GetVirtualFunctionName(aFromFunction, name);
    1.73 +			iTestBase.INFO_PRINTF2(_L("Virtual function call to %S from outside FBServ"), &name);
    1.74 +			}
    1.75 +		}
    1.76 +	}
    1.77 +#endif
    1.78 +
    1.79 +//--------------------------------------------------------------
    1.80 +
    1.81 +CTFont::CTFont(CTestStep* aStep) :
    1.82 +	CTGraphicsBase(aStep),
    1.83 +	iFont(NULL),
    1.84 +	iGc(NULL),
    1.85 +	iDev(NULL)
    1.86 +#ifdef __WINS__
    1.87 +	, iFontCallCounter(*this), iOpenFontCallCounter(*this)
    1.88 +#endif
    1.89 +	{
    1.90 +	}
    1.91 +
    1.92 +CTFont::~CTFont()
    1.93 +	{
    1.94 +	delete iGc;
    1.95 +	delete iDev;
    1.96 +	}
    1.97 +
    1.98 +void CTFont::ConstructL()
    1.99 +	{
   1.100 +	TRAPD(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor256));
   1.101 +	if (err == KErrNotSupported)
   1.102 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MU));
   1.103 +	if (err == KErrNotSupported)
   1.104 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor4K));
   1.105 +	if (err == KErrNotSupported)
   1.106 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16M));
   1.107 +	if (err == KErrNotSupported)
   1.108 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor64K));
   1.109 +	if (err == KErrNotSupported)
   1.110 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray256));
   1.111 +	if (err == KErrNotSupported)
   1.112 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray16));
   1.113 +	if (err == KErrNotSupported)
   1.114 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray4));
   1.115 +	if (err == KErrNotSupported)
   1.116 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EGray2));
   1.117 +	if (err == KErrNotSupported)
   1.118 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16));
   1.119 +	if (err == KErrNotSupported)
   1.120 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MA));
   1.121 +	if (err == KErrNotSupported)
   1.122 +		TRAP(err,iDev = CFbsScreenDevice::NewL(KNullDesC,EColor16MAP));
   1.123 +	if (err!=KErrNone)
   1.124 +		{
   1.125 +		_LIT(KLog,"Failed to create screen device, last returned error %d");
   1.126 +		INFO_PRINTF2(KLog,err);
   1.127 +		}
   1.128 +
   1.129 +	User::LeaveIfError(err);
   1.130 +	iDev->ChangeScreenDevice(NULL);
   1.131 +	iDev->SetAutoUpdate(ETrue);
   1.132 +	iDev->CreateContext(iGc);
   1.133 +	iDev->SetScalingFactor(KScalingOriginPt, KScalingFactorX, KScalingFactorY, 1, 1);
   1.134 +	iGc->Activate(iDev);
   1.135 +	}
   1.136 +
   1.137 +/**
   1.138 +  @SYMTestCaseID GRAPHICS-BITGDI-0074
   1.139 + 
   1.140 +  @SYMDEF             
   1.141 +
   1.142 +  @SYMTestCaseDesc Anti-aliased text
   1.143 +   
   1.144 +  @SYMTestPriority High
   1.145 +
   1.146 +  @SYMTestStatus Implemented
   1.147 +
   1.148 +  @SYMTestActions Draws some text in an antialiased manner
   1.149 + 
   1.150 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.151 +*/
   1.152 +void CTFont::DoAntiAliasedTextL()
   1.153 +	{
   1.154 +	int typefaces = iDev->NumTypefaces();
   1.155 +	static const TUint32 colour[15] =
   1.156 +		{ 
   1.157 +		0x000000,
   1.158 +		0x555555,
   1.159 +		0x000080,
   1.160 +		0x008000,
   1.161 +		0x008080,
   1.162 +		0x800000,
   1.163 +		0x800080,
   1.164 +		0x808000,
   1.165 +		0x0000ff,
   1.166 +		0x00ff00,
   1.167 +		0x00ffff,
   1.168 +		0xff0000,
   1.169 +		0xff00ff,
   1.170 +		0xffff00,
   1.171 +		0xaaaaaa
   1.172 +		};
   1.173 +	int colour_index = 0;
   1.174 +	for (int i = 0; i < typefaces; i++)
   1.175 +		{
   1.176 +		TTypefaceSupport typeface_support;
   1.177 +		iDev->TypefaceSupport(typeface_support,i);
   1.178 +		if (typeface_support.iIsScalable)
   1.179 +			{
   1.180 +			ResetGc();
   1.181 +			TPoint pos(300,0);
   1.182 +			int vertical_x = 300;
   1.183 +			for (int j = 6; j < 32; j += 2)
   1.184 +				{
   1.185 +				iGc->SetPenColor(colour[colour_index]);
   1.186 +				colour_index = (++colour_index) % 15;
   1.187 +				TFontSpec fs;
   1.188 +				fs.iTypeface = typeface_support.iTypeface;
   1.189 +				fs.iHeight = j;
   1.190 +				fs.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
   1.191 +		 		User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.192 +				int ascent = iFont->AscentInPixels();
   1.193 +				int descent = iFont->DescentInPixels();
   1.194 +				iGc->UseFont(iFont);
   1.195 +				pos.iY += ascent;
   1.196 +				iGc->DrawText(_L("pack my box with five dozen liquor jugs"),pos);
   1.197 +				pos.iY += descent;
   1.198 +				vertical_x -= ascent;
   1.199 +				TPoint down_pos(vertical_x,0);
   1.200 +				iGc->DrawTextVertical(_L("pack my box with five dozen liquor jugs"),down_pos,FALSE);
   1.201 +				vertical_x -= descent * 2;
   1.202 +				TPoint up_pos(vertical_x,iDev->SizeInPixels().iHeight);
   1.203 +				iGc->DrawTextVertical(_L("pack my box with five dozen liquor jugs"),up_pos,TRUE);
   1.204 +				vertical_x -= ascent;
   1.205 +				iDev->ReleaseFont(iFont);
   1.206 +				iGc->DiscardFont();
   1.207 +				}
   1.208 +			//TheTest.Getch();
   1.209 +			}
   1.210 +		}
   1.211 +	}
   1.212 +/**
   1.213 +  @SYMTestCaseID GRAPHICS-BITGDI-0075
   1.214 + 
   1.215 +  @SYMDEF             
   1.216 +
   1.217 +  @SYMTestCaseDesc tests all fonts
   1.218 +   
   1.219 +  @SYMTestPriority High
   1.220 +
   1.221 +  @SYMTestStatus Implemented
   1.222 +
   1.223 +  @SYMTestActions tests all fonts (typeface and heights) by writing them to a gc
   1.224 + 
   1.225 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.226 +*/
   1.227 +void CTFont::DoAllFontsL()
   1.228 +	{
   1.229 +	TFontSpec fs;
   1.230 +	TInt typefaces = iDev->NumTypefaces();
   1.231 +	TTypefaceSupport info;
   1.232 +
   1.233 +	//used below in for loop (line 177)
   1.234 +	TInt topNew=0;
   1.235 +	TInt bottomNew=0;
   1.236 +	TInt top=0;
   1.237 +	TInt bottom=0;
   1.238 +
   1.239 +	// Maximum height of font allowed by iType rasteriser
   1.240 +	const TInt KMaxITypeHeightInPixels = 256;
   1.241 +
   1.242 +	for (TInt count = 0; count < typefaces; count++)
   1.243 +		{
   1.244 +		iDev->TypefaceSupport(info,count);
   1.245 +
   1.246 +		for (TInt index = 0; index < info.iNumHeights; index++)
   1.247 +			{
   1.248 +			TInt height = iDev->FontHeightInPixels(count,index);
   1.249 +			if (height > KMaxITypeHeightInPixels)
   1.250 +				{
   1.251 +				continue;
   1.252 +				}
   1.253 +			fs.iTypeface = info.iTypeface;
   1.254 +			fs.iHeight = height;
   1.255 +
   1.256 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.257 +			TInt heightInPixels = iFont->HeightInPixels();
   1.258 +			if ( heightInPixels == height )
   1.259 +				{
   1.260 +				TEST( ETrue );
   1.261 +				}
   1.262 +			else
   1.263 +				{
   1.264 +				TOpenFontFaceAttrib attrib;
   1.265 +				if( iFont->GetFaceAttrib( attrib ) )
   1.266 +					{
   1.267 +					_LIT(KErrorMessageWithFontName, "Font: %S, pixel height requested: %d, pixel height of font: %d");
   1.268 +					INFO_PRINTF4(KErrorMessageWithFontName, &attrib.FullName(), height, heightInPixels);
   1.269 +					}
   1.270 +				else
   1.271 +					{
   1.272 +					_LIT(KErrorMessage, "Pixel height requested: %d, pixel height of font: %d");
   1.273 +					INFO_PRINTF3(KErrorMessage, height, heightInPixels);
   1.274 +					}
   1.275 +				TEST( EFalse );
   1.276 +				}
   1.277 +
   1.278 +			if (height >= 5)
   1.279 +				{
   1.280 +				iGc->UseFont(iFont);
   1.281 +				
   1.282 +				//Testing the new replaced GetUnderlineMetrics
   1.283 +				//Debug can be used to monitor underline sizes as font chanegs
   1.284 +				iGc->GetUnderlineMetrics(top, bottom);
   1.285 +				TEST( top !=0 && bottom !=0 );
   1.286 +				/*cast the pointer iGc to the base class CGraphicsContext
   1.287 +				should still behave correctly meaning any valid class can 
   1.288 +				GetUnderlineMetrics through CGC as is exported and public.*/
   1.289 +				CGraphicsContext* baseGc = (CGraphicsContext*)iGc;
   1.290 +				baseGc->GetUnderlineMetrics(topNew, bottomNew);
   1.291 +				TEST( top !=0 && bottom !=0 );
   1.292 +				TEST( topNew == top && bottomNew == bottom );
   1.293 +
   1.294 +				DisplayAsciiCharSet(info.iTypeface.iName);
   1.295 +				DisplayBoldItalic(info.iTypeface.iName);
   1.296 +				iGc->DiscardFont();
   1.297 +				}
   1.298 +
   1.299 +						
   1.300 +			iDev->ReleaseFont(iFont);
   1.301 +
   1.302 +			height = iDev->FontHeightInTwips(count,index);
   1.303 +			fs.iHeight = height;
   1.304 +			User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fs));
   1.305 +// Commented out test because it fails for true type fonts
   1.306 +//			if (Abs(iFont->FontSpecInTwips().iHeight - height) > 1)
   1.307 +//				User::Panic(_L("Heights don't match"),KErrGeneral);
   1.308 +			iDev->ReleaseFont(iFont);
   1.309 +			}
   1.310 +		}
   1.311 +	}
   1.312 +
   1.313 +TInt CTFont::TestFontL(const TFontSpec &aFontSpec)
   1.314 +	{
   1.315 +	const TSize devSize(iDev->SizeInPixels());
   1.316 +	TInt midHgtOffset=devSize.iHeight/2;
   1.317 +	TRect devRect1(0,0,devSize.iWidth,midHgtOffset);
   1.318 +	TRect devRect2(0,midHgtOffset,devSize.iWidth,midHgtOffset*2);
   1.319 +//
   1.320 +	ResetGc();
   1.321 +	TInt loadErr=GetNearestFontToDesignHeightInTwips(iFont,aFontSpec);
   1.322 +	if (loadErr)
   1.323 +		return(loadErr);
   1.324 +	CBufStore *store=CBufStore::NewLC(1024);
   1.325 +	TFontSpec fSpec1=iFont->FontSpecInTwips();
   1.326 +	TEST(fSpec1.iHeight>0);	// If returns zero height will fail on externalize/internalize
   1.327 +	const TInt ascent=iFont->AscentInPixels();
   1.328 +	iGc->UseFont(iFont);
   1.329 +	iDev->ReleaseFont(iFont);
   1.330 +// Useful when watching test code, but too much logging for actual test runs
   1.331 +//	INFO_PRINTF4(_L("Testing, %S hgt=%d/%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight,fSpec1.iHeight);
   1.332 +//
   1.333 +	iGc->SetClippingRect(devRect1);
   1.334 +	iGc->DrawText(_L("0123456789abcdefghiABCDEFGHI"),TPoint(0,ascent));
   1.335 +//
   1.336 +	RStoreWriteStream writeStream;
   1.337 +	TStreamId id=writeStream.CreateLC(*store);
   1.338 +	iGc->ExternalizeL(writeStream);
   1.339 +	CleanupStack::PopAndDestroy(&writeStream);
   1.340 +	iGc->DiscardFont();
   1.341 +//
   1.342 +	RStoreReadStream readStream;
   1.343 +	readStream.OpenLC(*store,id);
   1.344 +	iGc->InternalizeL(readStream);
   1.345 +	CleanupStack::PopAndDestroy(&readStream);
   1.346 +	TBool fontUsed=iGc->IsFontUsed();
   1.347 +	if (!iGc->IsFontUsed())
   1.348 +		{
   1.349 +		INFO_PRINTF3(_L("Font externalize/internalize used check failed, %S hgt=%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight);
   1.350 +		TEST(EFalse);
   1.351 +		}
   1.352 +	else
   1.353 +		{
   1.354 +		iGc->SetClippingRect(devRect2);
   1.355 +		iGc->DrawText(_L("0123456789abcdefghiABCDEFGHI"),TPoint(0,midHgtOffset+ascent));
   1.356 +		TBool rectCompare=iDev->RectCompare(devRect1,*iDev,devRect2);
   1.357 +		if (!rectCompare)
   1.358 +			{
   1.359 +			INFO_PRINTF3(_L("Font externalize/internalize screen check failed, %S hgt=%d"), &aFontSpec.iTypeface.iName,aFontSpec.iHeight);
   1.360 +			TEST(EFalse);
   1.361 +			}
   1.362 +		}
   1.363 +	CleanupStack::PopAndDestroy(store);
   1.364 +	iGc->CancelClippingRect();
   1.365 +	iGc->DiscardFont();
   1.366 +	return(KErrNone);
   1.367 +	}
   1.368 +
   1.369 +void CTFont::FontExternalizeL()
   1.370 +	{
   1.371 +	TFontSpec fsp;
   1.372 +	const TInt typefaceCount=iDev->NumTypefaces();
   1.373 +	for (TInt typeface=0;typeface<typefaceCount;typeface++)
   1.374 +		{
   1.375 +		TTypefaceSupport info;
   1.376 +		iDev->TypefaceSupport(info,typeface);
   1.377 +		fsp.iTypeface = info.iTypeface;
   1.378 +		TInt baseHeight=iDev->FontHeightInTwips(typeface,0);
   1.379 +		_LIT(KTxtNotScalable,"");
   1.380 +		_LIT(KTxtScalable,"Scalable");
   1.381 +		INFO_PRINTF5(_L("Testing, %S min/max=%d/%d %S"), &fsp.iTypeface.iName,info.iMinHeightInTwips,info.iMaxHeightInTwips,info.iIsScalable?&KTxtScalable:&KTxtNotScalable);
   1.382 +		for(TInt hgtIndex=0;hgtIndex<info.iNumHeights;hgtIndex++)
   1.383 +			{	// Test official specced heights
   1.384 +			fsp.iHeight=iDev->FontHeightInTwips(typeface,hgtIndex);
   1.385 +			TEST(TestFontL(fsp)==KErrNone);
   1.386 +			}
   1.387 +		for(fsp.iHeight=0;fsp.iHeight<info.iMaxHeightInTwips*2;fsp.iHeight=(fsp.iHeight+1)*11/10)
   1.388 +			{
   1.389 +			TInt err=TestFontL(fsp);
   1.390 +			if (err!=KErrNone)
   1.391 +				{	// Should not get an error within allowable font size
   1.392 +				TEST(fsp.iHeight>info.iMaxHeightInTwips);	// Over speced max size is ok to get error loading.
   1.393 +				}
   1.394 +			}
   1.395 +		}
   1.396 +	}
   1.397 +
   1.398 +void CTFont::DisplayAsciiCharSet(const TDesC& aTypefaceName)
   1.399 +	{
   1.400 +	ResetGc();
   1.401 +
   1.402 +	TBuf<KTextBufferLength> textBuffer;
   1.403 +	textBuffer.SetLength(KTextBufferLength);
   1.404 +	for (TInt count = 0; count < KTextBufferLength; count++)
   1.405 +		textBuffer[count] = TText(count);
   1.406 +
   1.407 +	TPoint textPos = TPoint(50,iFont->AscentInPixels() + 5);
   1.408 +	iGc->DrawText(aTypefaceName,textPos);
   1.409 +	TInt fontHeight = iFont->HeightInPixels() + 5;
   1.410 +	textPos.iX = 0;
   1.411 +	textPos.iY += fontHeight;
   1.412 +	TInt start = 0;
   1.413 +	TInt screenWidth = iDev->SizeInPixels().iWidth;
   1.414 +
   1.415 +	while (start < KTextBufferLength)
   1.416 +		{
   1.417 +		TInt numChars = iFont->TextCount(textBuffer.Mid(start),screenWidth);
   1.418 +		iGc->DrawText(textBuffer.Mid(start,numChars),textPos);
   1.419 +		textPos.iY += fontHeight;
   1.420 +		start += numChars;
   1.421 +		}
   1.422 +	}
   1.423 +
   1.424 +void CTFont::DisplayBoldItalic(const TDesC& aTypefaceName)
   1.425 +	{
   1.426 +	ResetGc();
   1.427 +
   1.428 +	TBuf<64> textBuffer;
   1.429 +	TInt height = iFont->HeightInPixels();
   1.430 +	CBitmapFont* bmpfon=CFbsFontEx::FontAddress(iFont);
   1.431 +
   1.432 +	TInt level=iFont->AscentInPixels();
   1.433 +	iGc->DrawText(aTypefaceName,TPoint(50,level));
   1.434 +
   1.435 +	textBuffer=_L("0123456789abcdefghiABCDEFGHI");
   1.436 +	level += height;
   1.437 +	iGc->DrawText(textBuffer,TPoint(0,level));
   1.438 +	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   1.439 +
   1.440 +	bmpfon->iAlgStyle.SetIsBold(ETrue);
   1.441 +	level += height;
   1.442 +	iGc->DrawText(textBuffer,TPoint(0,level));
   1.443 +	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   1.444 +
   1.445 +	bmpfon->iAlgStyle.SetIsBold(EFalse);
   1.446 +	bmpfon->iAlgStyle.SetIsItalic(ETrue);
   1.447 +	level += height;
   1.448 +	iGc->DrawText(textBuffer,TPoint(0,level));
   1.449 +	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   1.450 +
   1.451 +	bmpfon->iAlgStyle.SetIsBold(ETrue);
   1.452 +	level += height;
   1.453 +	iGc->DrawText(textBuffer,TPoint(0,level));
   1.454 +	iGc->DrawLine(TPoint(iFont->TextWidthInPixels(textBuffer),level-8),TPoint(iFont->TextWidthInPixels(textBuffer),level+2));
   1.455 +	}
   1.456 +
   1.457 +/**
   1.458 +  @SYMTestCaseID GRAPHICS-BITGDI-0076
   1.459 + 
   1.460 +  @SYMDEF             
   1.461 +
   1.462 +  @SYMTestCaseDesc Text formatting
   1.463 +   
   1.464 +  @SYMTestPriority High
   1.465 +
   1.466 +  @SYMTestStatus Implemented
   1.467 +
   1.468 +  @SYMTestActions Tests drawing of justified/clipped/underlined text to a gc 
   1.469 + 
   1.470 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.471 +*/
   1.472 +void CTFont::DoTextFormatsL()
   1.473 +	{
   1.474 +	ResetGc();
   1.475 +
   1.476 +	TFontSpec fsp;
   1.477 +	fsp.iTypeface.iName=_L("Swiss");
   1.478 +	fsp.iHeight=200;
   1.479 +
   1.480 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
   1.481 +	iGc->UseFont(iFont);
   1.482 +
   1.483 +	Box();
   1.484 +	//TheTest.Getch();
   1.485 +
   1.486 +	Justification();
   1.487 +	//TheTest.Getch();
   1.488 +
   1.489 +	Clipping();
   1.490 +	//TheTest.Getch();
   1.491 +
   1.492 +	Underline();
   1.493 +	//TheTest.Getch();
   1.494 +
   1.495 +	iGc->DiscardFont();
   1.496 +	iDev->ReleaseFont(iFont);
   1.497 +	}
   1.498 +
   1.499 +void CTFont::Box()
   1.500 +	{
   1.501 +	iGc->SetPenSize(TSize(0,0));
   1.502 +	iGc->SetBrushColor(KRgbWhite);
   1.503 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.504 +	iGc->Clear();
   1.505 +	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   1.506 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,40));
   1.507 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.508 +	iGc->DrawText(_L("Box text (left aligned)"),TRect(20,50,320,70),14,CGraphicsContext::ELeft);
   1.509 +	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(20,70,320,90),14,CGraphicsContext::ELeft,50);
   1.510 +	iGc->DrawText(_L("Box text (centred)"),TRect(20,90,320,110),14,CGraphicsContext::ECenter);
   1.511 +	iGc->DrawText(_L("Box text (right aligned)"),TRect(20,110,320,130),14,CGraphicsContext::ERight);
   1.512 +	iGc->DrawText(_L("Box text (right aligned with margin)"),TRect(20,130,320,150),14,CGraphicsContext::ERight,30);
   1.513 +	iGc->DrawText(_L("(Boxes drawn afterwards)"),TPoint(20,165));
   1.514 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.515 +	iGc->DrawRect(TRect(20,50,320,70));
   1.516 +	iGc->DrawRect(TRect(20,70,320,90));
   1.517 +	iGc->DrawRect(TRect(20,90,320,110));
   1.518 +	iGc->DrawRect(TRect(20,110,320,130));
   1.519 +
   1.520 +	iGc->SetBrushColor(TRgb(128,128,128));
   1.521 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.522 +	iGc->DrawText(_L("Box text (left aligned)"),TRect(320,50,620,70),14,CGraphicsContext::ELeft);
   1.523 +	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(320,70,620,90),14,CGraphicsContext::ELeft,50);
   1.524 +	iGc->DrawText(_L("Box text (centred)"),TRect(320,90,620,110),14,CGraphicsContext::ECenter);
   1.525 +	iGc->DrawText(_L("Box text (right aligned)"),TRect(320,110,620,130),14,CGraphicsContext::ERight);
   1.526 +	iGc->DrawText(_L("Box text (right aligned with margin)"),TRect(320,130,620,150),14,CGraphicsContext::ERight,30);
   1.527 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.528 +	iGc->DrawRect(TRect(320,50,620,70));
   1.529 +	iGc->DrawRect(TRect(320,70,620,90));
   1.530 +	iGc->DrawRect(TRect(320,90,620,110));
   1.531 +	iGc->DrawRect(TRect(320,110,620,130));
   1.532 +
   1.533 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.534 +	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
   1.535 +	iGc->DrawText(_L("Box text"),TRect(20,150,620,170),14,width);
   1.536 +	iGc->DrawText(_L(" followed by positionless text."));
   1.537 +	iGc->DrawText(_L("Box text"),TRect(20,170,620,190),14,width,CGraphicsContext::ELeft,20);
   1.538 +	iGc->DrawText(_L(" followed by positionless text."));
   1.539 +	iGc->DrawText(_L("Box text"),TRect(20,190,620,210),14,width,CGraphicsContext::ECenter);
   1.540 +	iGc->DrawText(_L(" followed by positionless text."));
   1.541 +	iGc->DrawText(_L("Box text"),TRect(20,210,620,230),14,width,CGraphicsContext::ERight,20);
   1.542 +	iGc->DrawText(_L(" followed by positionless text."));
   1.543 +	iGc->DrawText(_L(""),TRect(20,230,620,250),14,width);
   1.544 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   1.545 +	iGc->DrawRect(TRect(20,150,620,170));
   1.546 +	iGc->DrawRect(TRect(20,170,620,190));
   1.547 +	iGc->DrawRect(TRect(20,190,620,210));
   1.548 +	iGc->DrawRect(TRect(20,210,620,230));
   1.549 +	}
   1.550 +
   1.551 +void CTFont::Underline()
   1.552 +	{
   1.553 +	ResetGc();
   1.554 +
   1.555 +	iGc->SetUnderlineStyle(EUnderlineOn);
   1.556 +	iGc->SetStrikethroughStyle(EStrikethroughOn);
   1.557 +
   1.558 +	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   1.559 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,40));
   1.560 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.561 +	iGc->DrawText(_L("Box text (left aligned)"),TRect(20,50,320,70),14,CGraphicsContext::ELeft);
   1.562 +	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(20,70,320,90),14,CGraphicsContext::ELeft,50);
   1.563 +	iGc->DrawText(_L("Box text (centred)"),TRect(20,90,320,110),14,CGraphicsContext::ECenter);
   1.564 +	iGc->DrawText(_L("Box text (right aligned)"),TRect(20,110,320,130),14,CGraphicsContext::ERight);
   1.565 +	iGc->DrawText(_L("Box text (left aligned)"),TRect(320,50,620,70),14,CGraphicsContext::ELeft);
   1.566 +	iGc->DrawText(_L("Box text (left aligned with margin)"),TRect(320,70,620,90),14,CGraphicsContext::ELeft,50);
   1.567 +	iGc->DrawText(_L("Box text (centred)"),TRect(320,90,620,110),14,CGraphicsContext::ECenter);
   1.568 +	iGc->DrawText(_L("Box text (right aligned)"),TRect(320,110,620,130),14,CGraphicsContext::ERight);
   1.569 +	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
   1.570 +	iGc->DrawText(_L("Box text"),TRect(20,130,620,150),14,width);
   1.571 +	iGc->DrawText(_L(" followed by positionless text."));
   1.572 +	iGc->DrawText(_L("Box text"),TRect(20,150,620,170),14,width,CGraphicsContext::ELeft,20);
   1.573 +	iGc->DrawText(_L(" followed by positionless text."));
   1.574 +	iGc->DrawText(_L("Box text"),TRect(20,170,620,190),14,width,CGraphicsContext::ECenter);
   1.575 +	iGc->DrawText(_L(" followed by positionless text."));
   1.576 +	iGc->DrawText(_L("Box text"),TRect(20,190,620,210),14,width,CGraphicsContext::ERight);
   1.577 +	iGc->DrawText(_L(" followed by positionless text."));
   1.578 +	iGc->DrawText(_L(""),TRect(20,210,620,230),14,width);
   1.579 +
   1.580 +	iGc->SetUnderlineStyle(EUnderlineOff);
   1.581 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
   1.582 +	}
   1.583 +
   1.584 +void CTFont::Justification()
   1.585 +	{
   1.586 +	iGc->SetUnderlineStyle(EUnderlineOff);
   1.587 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
   1.588 +	iGc->SetPenSize(TSize(0,0));
   1.589 +	iGc->SetBrushColor(KRgbWhite);
   1.590 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.591 +	iGc->Clear();
   1.592 +	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   1.593 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,40));
   1.594 +	iGc->SetCharJustification(18,6);
   1.595 +	iGc->SetWordJustification(0,0);
   1.596 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,60));
   1.597 +	iGc->SetCharJustification(0,0);
   1.598 +	iGc->SetWordJustification(30,6);
   1.599 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,80));
   1.600 +	iGc->SetCharJustification(18,6);
   1.601 +	iGc->SetWordJustification(30,6);
   1.602 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,100));
   1.603 +	iGc->UpdateJustification(_L("Normal text printing in one whole line"));
   1.604 +//
   1.605 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,120));
   1.606 +	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   1.607 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.608 +	iGc->UpdateJustification(_L("tionless printing (halfway thro' posi-tionless)."));
   1.609 +	iGc->SetCharJustification(18,6);
   1.610 +	iGc->SetWordJustification(0,0);
   1.611 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,140));
   1.612 +	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   1.613 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.614 +	iGc->SetCharJustification(0,0);
   1.615 +	iGc->SetWordJustification(30,6);
   1.616 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,160));
   1.617 +	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   1.618 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.619 +	iGc->SetCharJustification(18,6);
   1.620 +	iGc->SetWordJustification(30,6);
   1.621 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,180));
   1.622 +	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   1.623 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.624 +	iGc->SetCharJustification(150,50);
   1.625 +	iGc->SetWordJustification(50,10);
   1.626 +	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,200));
   1.627 +	iGc->UpdateJustification(_L("Normal text printing in one whole line,"));
   1.628 +	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,220));
   1.629 +	iGc->SetCharJustification(0,0);
   1.630 +	iGc->SetWordJustification(0,0);
   1.631 +	}
   1.632 +
   1.633 +void CTFont::Clipping()
   1.634 +	{
   1.635 +	iGc->SetUnderlineStyle(EUnderlineOff);
   1.636 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
   1.637 +	iGc->SetPenSize(TSize(0,0));
   1.638 +	iGc->SetBrushColor(KRgbWhite);
   1.639 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.640 +	iGc->Clear();
   1.641 +	iGc->DrawText(_L("Font test code:"),TPoint(20,20));
   1.642 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,40));
   1.643 +	iGc->SetCharJustification(-6,6);
   1.644 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,60));
   1.645 +	iGc->SetCharJustification(-12,6);
   1.646 +	iGc->DrawText(_L("Normal text printing in one whole line"),TPoint(20,80));
   1.647 +	iGc->SetCharJustification(0,0);
   1.648 +//
   1.649 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,120));
   1.650 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.651 +	iGc->SetCharJustification(-50,50);
   1.652 +	iGc->DrawText(_L("Normal text printing, followed by posi"),TPoint(20,140));
   1.653 +	iGc->UpdateJustification(_L("Normal text printing, followed by posi"));
   1.654 +	iGc->DrawText(_L("tionless printing (halfway thro' posi-tionless)."));
   1.655 +	iGc->SetCharJustification(0,0);
   1.656 +	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,160));
   1.657 +	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,180));
   1.658 +	iGc->SetCharJustification(-90,90);
   1.659 +	iGc->DrawText(_L("Normal text printing in one whole line,"),TPoint(20,200));
   1.660 +	iGc->UpdateJustification(_L("Normal text printing in one whole line,"));
   1.661 +	iGc->DrawText(_L("followed by more text, carrying over justification."),TPoint(20,220));
   1.662 +	iGc->SetCharJustification(0,0);
   1.663 +	}
   1.664 +
   1.665 +/**
   1.666 +  @SYMTestCaseID GRAPHICS-BITGDI-0077
   1.667 + 
   1.668 +  @SYMDEF             
   1.669 +
   1.670 +  @SYMTestCaseDesc Check text drawing
   1.671 +   
   1.672 +  @SYMTestPriority High
   1.673 +
   1.674 +  @SYMTestStatus Implemented
   1.675 +
   1.676 +  @SYMTestActions Tests aspects of drawing text to the screen
   1.677 + 
   1.678 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.679 +*/
   1.680 +void CTFont::DoBitAlignmentL()
   1.681 +	{
   1.682 +	ResetGc();
   1.683 +	TInt ret=KErrNone;
   1.684 +	
   1.685 +	const TUint8 testchars[2]={'M', 'W'};
   1.686 +	TFontSpec fsp;
   1.687 +	TInt xpos=0;
   1.688 +	TInt stringwidth=0;
   1.689 +	TBuf<224> letters;
   1.690 +	fsp.iTypeface.iName=_L("Swiss");
   1.691 +	fsp.iHeight=300;
   1.692 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
   1.693 +	iGc->UseFont(iFont);
   1.694 +	TInt ascent=iFont->AscentInPixels();
   1.695 +	TInt descent=iFont->DescentInPixels();
   1.696 +	TInt charvertpos=ascent+descent+20;
   1.697 +	TRgb refcolour(0,0,0);
   1.698 +	TRgb charcolour(0,0,0);
   1.699 +	TInt charnum=0;
   1.700 +	TBuf<1> letterdesc;
   1.701 +	letterdesc.SetLength(1);
   1.702 +	for(;charnum<2;charnum++)
   1.703 +		{
   1.704 +		letterdesc[0]=testchars[charnum];
   1.705 +		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   1.706 +		if(!letterwidth) continue;
   1.707 +		for(xpos=10;xpos<43;xpos++)
   1.708 +			{
   1.709 +			iGc->Clear();
   1.710 +			TPoint refpt(10,ascent+10);
   1.711 +			TPoint charpt(xpos,ascent+charvertpos);
   1.712 +			iGc->SetDitherOrigin(refpt);
   1.713 +			iGc->DrawText(letterdesc,refpt);
   1.714 +			iGc->SetDitherOrigin(charpt);
   1.715 +			iGc->DrawText(letterdesc,charpt);
   1.716 +			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   1.717 +				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   1.718 +					{
   1.719 +					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   1.720 +					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   1.721 +					TEST(refcolour==charcolour);
   1.722 +					if(refcolour!=charcolour)
   1.723 +						{
   1.724 +						ret=KErrGeneral;
   1.725 +						goto end;
   1.726 +						}
   1.727 +					}
   1.728 +			}
   1.729 +		}
   1.730 +	iGc->SetPenColor(TRgb(128,128,128));
   1.731 +	for(charnum=0;charnum<2;charnum++)
   1.732 +		{
   1.733 +		letterdesc[0]=testchars[charnum];
   1.734 +		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   1.735 +		if(!letterwidth) continue;
   1.736 +		for(xpos=10;xpos<43;xpos++)
   1.737 +			{
   1.738 +			iGc->Clear();
   1.739 +			TPoint refpt(10,ascent+10);
   1.740 +			TPoint charpt(xpos,ascent+charvertpos);
   1.741 +			iGc->SetDitherOrigin(TPoint(refpt.iX,0));
   1.742 +			iGc->DrawText(letterdesc,refpt);
   1.743 +			iGc->SetDitherOrigin(TPoint(charpt.iX,0));
   1.744 +			iGc->DrawText(letterdesc,charpt);
   1.745 +			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   1.746 +				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   1.747 +					{
   1.748 +					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   1.749 +					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   1.750 +					TEST(refcolour==charcolour);
   1.751 +					if(refcolour!=charcolour)
   1.752 +						{
   1.753 +						ret=KErrGeneral;
   1.754 +						goto end;
   1.755 +						}
   1.756 +					}
   1.757 +			}
   1.758 +		}
   1.759 +	iGc->SetPenColor(KRgbBlack);
   1.760 +	letters.SetLength(224);
   1.761 +	for(charnum=32;charnum<256;charnum++)
   1.762 +		letters[charnum-32]=TUint8(charnum);
   1.763 +	letters.SetLength(iFont->TextCount(letters,iDev->SizeInPixels().iWidth-45));
   1.764 +	stringwidth=iFont->TextWidthInPixels(letters);
   1.765 +	for(xpos=10;xpos<43;xpos++)
   1.766 +		{
   1.767 +		iGc->Clear();
   1.768 +		TPoint refpt(10,ascent+10);
   1.769 +		TPoint charpt(xpos,ascent+charvertpos);
   1.770 +		iGc->DrawText(letters,refpt);
   1.771 +		charnum=0;
   1.772 +		letterdesc[0]=letters[charnum];
   1.773 +		charnum++;
   1.774 +		iGc->DrawText(letterdesc,charpt);
   1.775 +		for(;charnum<letters.Length();charnum++)
   1.776 +			{
   1.777 +			letterdesc[0]=letters[charnum];
   1.778 +			iGc->DrawText(letterdesc);
   1.779 +			}
   1.780 +		for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   1.781 +			for(TInt xcheck=0;xcheck<stringwidth;xcheck+=2)
   1.782 +				{
   1.783 +				iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   1.784 +				iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   1.785 +				TEST(refcolour==charcolour);
   1.786 +				if(refcolour!=charcolour)
   1.787 +					{
   1.788 +					ret=KErrGeneral;
   1.789 +					goto end;
   1.790 +					}
   1.791 +				}
   1.792 +		}
   1.793 +	for(charnum=0;charnum<2;charnum++)
   1.794 +		{
   1.795 +		letterdesc[0]=testchars[charnum];
   1.796 +		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   1.797 +		if(!letterwidth) continue;
   1.798 +		for(xpos=10;xpos<43;xpos++)
   1.799 +			{
   1.800 +			iGc->Clear();
   1.801 +			TPoint refpt(10,ascent+10);
   1.802 +			TPoint charpt(xpos,ascent+charvertpos);
   1.803 +			iGc->DrawText(letterdesc,TRect(refpt.iX,refpt.iY-ascent,refpt.iX+letterwidth,refpt.iY+descent),ascent);
   1.804 +			iGc->DrawText(letterdesc,TRect(charpt.iX,charpt.iY-ascent,charpt.iX+letterwidth,charpt.iY+descent),ascent);
   1.805 +			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   1.806 +				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   1.807 +					{
   1.808 +					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   1.809 +					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   1.810 +					TEST(refcolour==charcolour);
   1.811 +					if(refcolour!=charcolour)
   1.812 +						{
   1.813 +						ret=KErrGeneral;
   1.814 +						goto end;
   1.815 +						}
   1.816 +					}
   1.817 +			}
   1.818 +		}
   1.819 +	iGc->SetPenColor(TRgb(128,128,128));
   1.820 +	for(charnum=0;charnum<2;charnum++)
   1.821 +		{
   1.822 +		letterdesc[0]=testchars[charnum];
   1.823 +		TInt letterwidth=iFont->TextWidthInPixels(letterdesc);
   1.824 +		if(!letterwidth) continue;
   1.825 +		for(xpos=10;xpos<43;xpos++)
   1.826 +			{
   1.827 +			iGc->Clear();
   1.828 +			TPoint refpt(10,ascent+10);
   1.829 +			TPoint charpt(xpos,ascent+charvertpos);
   1.830 +			iGc->SetDitherOrigin(TPoint(refpt.iX,0));
   1.831 +			iGc->DrawText(letterdesc,TRect(refpt.iX,refpt.iY-ascent,refpt.iX+letterwidth,refpt.iY+descent),ascent);
   1.832 +			iGc->SetDitherOrigin(TPoint(charpt.iX,0));
   1.833 +			iGc->DrawText(letterdesc,TRect(charpt.iX,charpt.iY-ascent,charpt.iX+letterwidth,charpt.iY+descent),ascent);
   1.834 +			for(TInt ycheck=0;ycheck<ascent+descent;ycheck+=2)
   1.835 +				for(TInt xcheck=0;xcheck<letterwidth;xcheck+=2)
   1.836 +					{
   1.837 +					iDev->GetPixel(refcolour,TPoint(xcheck+10,ycheck+10));
   1.838 +					iDev->GetPixel(charcolour,TPoint(xcheck+xpos,ycheck+charvertpos));
   1.839 +					TEST(refcolour==charcolour);
   1.840 +					if(refcolour!=charcolour)
   1.841 +						{
   1.842 +						ret=KErrGeneral;
   1.843 +						goto end;
   1.844 +						}
   1.845 +					}
   1.846 +			}
   1.847 +		}
   1.848 +end:
   1.849 +	iGc->DiscardFont();
   1.850 +	iDev->ReleaseFont(iFont);
   1.851 +	//TheTest.Getch();
   1.852 +	User::LeaveIfError(ret);
   1.853 +	}
   1.854 +
   1.855 +/**
   1.856 +  @SYMTestCaseID GRAPHICS-BITGDI-0078
   1.857 + 
   1.858 +  @SYMDEF             
   1.859 +
   1.860 +  @SYMTestCaseDesc Large fonts
   1.861 +   
   1.862 +  @SYMTestPriority High
   1.863 +
   1.864 +  @SYMTestStatus Implemented
   1.865 +
   1.866 +  @SYMTestActions draws text to a gc with different weight and posture with a large height
   1.867 + 
   1.868 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
   1.869 +*/
   1.870 +void CTFont::DoLargeFontsL()
   1.871 +	{
   1.872 +	TInt typefaces = iDev->NumTypefaces();
   1.873 +	TInt height = 0;
   1.874 +
   1.875 +	for (TInt count = 0; count < typefaces; count++)
   1.876 +		{
   1.877 +		TTypefaceSupport info;
   1.878 +		iDev->TypefaceSupport(info,count);
   1.879 +
   1.880 +		for (TInt index = 0; index < info.iNumHeights; index++)
   1.881 +			{
   1.882 +			height = iDev->FontHeightInPixels(count,index);
   1.883 +			if (height <= 32)
   1.884 +				continue;
   1.885 +
   1.886 +			TFontSpec fs;
   1.887 +			fs.iTypeface=info.iTypeface;
   1.888 +			fs.iHeight=height;
   1.889 +			fs.iFontStyle.SetPosture(EPostureUpright);
   1.890 +			fs.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
   1.891 +
   1.892 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.893 +			DisplayLargeChars();
   1.894 +			iDev->ReleaseFont(iFont);
   1.895 +			//TheTest.Getch();
   1.896 +
   1.897 +			fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.898 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.899 +			DisplayLargeChars();
   1.900 +			iDev->ReleaseFont(iFont);
   1.901 +			//TheTest.Getch();
   1.902 +
   1.903 +			fs.iFontStyle.SetPosture(EPostureItalic);
   1.904 +			fs.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
   1.905 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.906 +			DisplayLargeChars();
   1.907 +			iDev->ReleaseFont(iFont);
   1.908 +			//TheTest.Getch();
   1.909 +
   1.910 +			fs.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
   1.911 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
   1.912 +			DisplayLargeChars();
   1.913 +			iDev->ReleaseFont(iFont);
   1.914 +			//TheTest.Getch();
   1.915 +			}
   1.916 +		}
   1.917 +	}
   1.918 +
   1.919 +// Draw a character and its glyph and character bounding boxes. Return the rightmost point drawn.
   1.920 +TInt CTFont::DisplayCharAndBounds(TInt aChar,TPoint aPos,TBool aVertical,TBool aUp)
   1.921 +	{
   1.922 +	TOpenFontCharMetrics cm;
   1.923 +	const TUint8* bitmap;
   1.924 +	TSize size;
   1.925 +	if (!iFont->GetCharacterData(aChar,cm,bitmap,size))
   1.926 +		return 0;
   1.927 +	TOpenFontMetrics fm;
   1.928 +	if (!iFont->GetFontMetrics(fm))
   1.929 +		return 0;
   1.930 +	TRect glyph_bounds, char_bounds;
   1.931 +	if (aVertical)
   1.932 +		{
   1.933 +		if (aUp)
   1.934 +			{
   1.935 +			glyph_bounds.iTl.iX = aPos.iX - cm.HorizBearingY();
   1.936 +			char_bounds.iTl.iX = aPos.iX - fm.MaxHeight();
   1.937 +			glyph_bounds.iTl.iY = aPos.iY - cm.HorizBearingX() - cm.Width();
   1.938 +			char_bounds.iTl.iY = aPos.iY - cm.HorizAdvance();
   1.939 +			}
   1.940 +		else
   1.941 +			{
   1.942 +			glyph_bounds.iTl.iX = aPos.iX + cm.HorizBearingY() - cm.Height() + 1;
   1.943 +			char_bounds.iTl.iX = aPos.iX - fm.MaxDepth() + 1;
   1.944 +			glyph_bounds.iTl.iY = aPos.iY + cm.HorizBearingX();
   1.945 +			char_bounds.iTl.iY = aPos.iY;
   1.946 +			}
   1.947 +		glyph_bounds.iBr = glyph_bounds.iTl + TSize(cm.Height(),cm.Width());
   1.948 +		char_bounds.iBr = char_bounds.iTl + TSize(fm.MaxHeight() + fm.MaxDepth(),cm.HorizAdvance());
   1.949 +		}
   1.950 +	else
   1.951 +		{
   1.952 +		glyph_bounds.iTl.iX = aPos.iX + cm.HorizBearingX();
   1.953 +		char_bounds.iTl.iX = aPos.iX;
   1.954 +		glyph_bounds.iTl.iY = aPos.iY - cm.HorizBearingY();
   1.955 +		char_bounds.iTl.iY = aPos.iY - fm.MaxHeight();
   1.956 +		glyph_bounds.iBr = glyph_bounds.iTl + TSize(cm.Width(),cm.Height());
   1.957 +		char_bounds.iBr = char_bounds.iTl + TSize(cm.HorizAdvance(),fm.MaxHeight() + fm.MaxDepth());
   1.958 +		}
   1.959 +
   1.960 +	TInt x_offset = aPos.iX - Min(glyph_bounds.iTl.iX,char_bounds.iTl.iX);
   1.961 +	aPos.iX += x_offset;
   1.962 +	glyph_bounds.Move(x_offset,0);
   1.963 +	char_bounds.Move(x_offset,0);
   1.964 +	TText text_buffer[1];
   1.965 +	text_buffer[0] = (TText)aChar;
   1.966 +	TPtrC text(text_buffer,1);
   1.967 +	if (aVertical)
   1.968 +		iGc->DrawTextVertical(text,aPos,aUp);
   1.969 +	else
   1.970 +		iGc->DrawText(text,aPos);
   1.971 +	iGc->DrawRect(glyph_bounds);
   1.972 +	iGc->DrawRect(char_bounds);
   1.973 +
   1.974 +	return Max(glyph_bounds.iBr.iX,char_bounds.iBr.iX);
   1.975 +	}
   1.976 +
   1.977 +void CTFont::DisplayLargeChars()
   1.978 +	{
   1.979 +	ResetGc();
   1.980 +	iGc->UseFont(iFont);
   1.981 +
   1.982 +	TPoint pos(20,iDev->SizeInPixels().iHeight / 2);
   1.983 +
   1.984 +	pos.iX = DisplayCharAndBounds('G',pos,FALSE,FALSE) + 20;
   1.985 +	pos.iX = DisplayCharAndBounds('p',pos,FALSE,FALSE) + 20;
   1.986 +	pos.iX = DisplayCharAndBounds('G',pos,TRUE,TRUE) + 20;
   1.987 +	pos.iX = DisplayCharAndBounds('p',pos,TRUE,TRUE) + 20;
   1.988 +	pos.iX = DisplayCharAndBounds('G',pos,TRUE,FALSE) + 20;
   1.989 +	pos.iX = DisplayCharAndBounds('p',pos,TRUE,FALSE) + 20;
   1.990 +
   1.991 +	iGc->SetPenStyle(CGraphicsContext::EDottedPen);
   1.992 +	iGc->SetPenColor(KRgbGray);
   1.993 +
   1.994 +	iGc->DiscardFont();
   1.995 +	}
   1.996 +
   1.997 +/**
   1.998 +  @SYMTestCaseID GRAPHICS-BITGDI-0079
   1.999 + 
  1.1000 +  @SYMDEF             
  1.1001 +
  1.1002 +  @SYMTestCaseDesc Vertical text
  1.1003 +   
  1.1004 +  @SYMTestPriority High
  1.1005 +
  1.1006 +  @SYMTestStatus Implemented
  1.1007 +
  1.1008 +  @SYMTestActions Draws text in varied weight and typeface to a gc in a vertical manner
  1.1009 + 
  1.1010 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1011 +*/
  1.1012 +void CTFont::DoVerticalText()
  1.1013 +	{
  1.1014 +	TFontSpec fs;
  1.1015 +	TInt typefaces=iDev->NumTypefaces();
  1.1016 +	TTypefaceSupport info;
  1.1017 +	TPoint pos(0,0);
  1.1018 +	TBool dir=ETrue;
  1.1019 +	TInt count=0;
  1.1020 +	for(;count<typefaces;count++)
  1.1021 +		{
  1.1022 +		iDev->TypefaceSupport(info,count);
  1.1023 +		pos.SetXY(0,0);
  1.1024 +		dir=ETrue;
  1.1025 +		ResetGc();
  1.1026 +		for(TInt index=0;index<info.iNumHeights;index++)
  1.1027 +			{
  1.1028 +			TInt height=iDev->FontHeightInPixels(count,index);
  1.1029 +			if(height<5) continue;
  1.1030 +			fs.iTypeface=info.iTypeface;
  1.1031 +			fs.iHeight=height;
  1.1032 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
  1.1033 +			iGc->UseFont(iFont);
  1.1034 +			if(dir) pos.iY=iDev->SizeInPixels().iHeight;
  1.1035 +			else pos.iY=0;
  1.1036 +			if(dir)
  1.1037 +				pos.iX+=iFont->AscentInPixels()+1;
  1.1038 +			else
  1.1039 +				pos.iX+=iFont->HeightInPixels()-1-iFont->AscentInPixels();
  1.1040 +			iGc->DrawTextVertical(_L("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),pos,dir);
  1.1041 +			if(dir)
  1.1042 +				pos.iX+=iFont->HeightInPixels()+1-iFont->AscentInPixels();
  1.1043 +			else
  1.1044 +				pos.iX+=iFont->AscentInPixels()+3;
  1.1045 +			dir=!dir;
  1.1046 +			iDev->ReleaseFont(iFont);
  1.1047 +			iGc->DiscardFont();
  1.1048 +			if (pos.iX > iDev->SizeInPixels().iWidth)
  1.1049 +				break;
  1.1050 +			}
  1.1051 +		//TheTest.Getch();
  1.1052 +		}
  1.1053 +
  1.1054 +	for(count=0;count<typefaces;count++)
  1.1055 +		{
  1.1056 +		iDev->TypefaceSupport(info,count);
  1.1057 +		pos.SetXY(0,0);
  1.1058 +		dir=ETrue;
  1.1059 +		ResetGc();
  1.1060 +		iGc->SetUnderlineStyle(EUnderlineOn);
  1.1061 +		iGc->SetStrikethroughStyle(EStrikethroughOn);
  1.1062 +		for(TInt index=0;index<info.iNumHeights;index++)
  1.1063 +			{
  1.1064 +			TInt height=iDev->FontHeightInPixels(count,index);
  1.1065 +			if(height<5) continue;
  1.1066 +			fs.iTypeface=info.iTypeface;
  1.1067 +			fs.iHeight=height;
  1.1068 +			User::LeaveIfError(GetNearestFontToDesignHeightInPixels(iFont,fs));
  1.1069 +			iGc->UseFont(iFont);
  1.1070 +			if(dir) pos.iY=iDev->SizeInPixels().iHeight;
  1.1071 +			else pos.iY=0;
  1.1072 +			if(dir)
  1.1073 +				pos.iX+=iFont->AscentInPixels()+3;
  1.1074 +			else
  1.1075 +				pos.iX+=iFont->HeightInPixels()+1-iFont->AscentInPixels();
  1.1076 +			iGc->DrawTextVertical(_L("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),pos,dir);
  1.1077 +			if(dir)
  1.1078 +				pos.iX+=iFont->HeightInPixels()+3-iFont->AscentInPixels();
  1.1079 +			else
  1.1080 +				pos.iX+=iFont->AscentInPixels()+5;
  1.1081 +			dir=!dir;
  1.1082 +			iDev->ReleaseFont(iFont);
  1.1083 +			iGc->DiscardFont();
  1.1084 +			if (pos.iX > iDev->SizeInPixels().iWidth)
  1.1085 +				break;
  1.1086 +			}
  1.1087 +		//TheTest.Getch();
  1.1088 +		}
  1.1089 +	}
  1.1090 +
  1.1091 +/**
  1.1092 +  @SYMTestCaseID GRAPHICS-BITGDI-0080
  1.1093 + 
  1.1094 +  @SYMDEF             
  1.1095 +
  1.1096 +  @SYMTestCaseDesc Vertical Text in a box
  1.1097 +   
  1.1098 +  @SYMTestPriority High
  1.1099 +
  1.1100 +  @SYMTestStatus Implemented
  1.1101 +
  1.1102 +  @SYMTestActions Draws text in varied weight and typeface to a gc in a vertical manner within a rect
  1.1103 + 
  1.1104 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1105 +*/
  1.1106 +void CTFont::DoVerticalBoxL()
  1.1107 +	{
  1.1108 +	ResetGc();
  1.1109 +
  1.1110 +	TFontSpec fsp;
  1.1111 +	fsp.iTypeface.iName=_L("Swiss");
  1.1112 +	fsp.iHeight=200;
  1.1113 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1114 +	iGc->UseFont(iFont);
  1.1115 +
  1.1116 +	TInt t = 20;
  1.1117 +	TInt b = iDev->SizeInPixels().iHeight - 20;
  1.1118 +	TRect r1(60,t,80,b);
  1.1119 +	TRect r2(100,t,120,b);
  1.1120 +	TRect r3(140,t,160,b);
  1.1121 +	TRect r4(180,t,200,b);
  1.1122 +	TRect r5(220,t,240,b);
  1.1123 +
  1.1124 +	TRect r6(440,t,460,b);
  1.1125 +	TRect r7(400,t,420,b);
  1.1126 +	TRect r8(360,t,380,b);
  1.1127 +	TRect r9(320,t,340,b);
  1.1128 +	TRect r10(280,t,300,b);
  1.1129 +
  1.1130 +	iGc->DrawTextVertical(_L("Font test code:"),TPoint(t,b),ETrue);
  1.1131 +	iGc->DrawTextVertical(_L("Left aligned"),r1,14,ETrue,CGraphicsContext::ELeft);
  1.1132 +	iGc->DrawTextVertical(_L("With margin"),r2,14,ETrue,CGraphicsContext::ELeft,50);
  1.1133 +	iGc->DrawTextVertical(_L("Centred"),r3,14,ETrue,CGraphicsContext::ECenter);
  1.1134 +	iGc->DrawTextVertical(_L("Right aligned"),r4,14,ETrue,CGraphicsContext::ERight);
  1.1135 +	iGc->DrawTextVertical(_L("With margin"),r5,14,ETrue,CGraphicsContext::ERight,30);
  1.1136 +
  1.1137 +	iGc->DrawTextVertical(_L("Font test code:"),TPoint(r6.iBr.iX + t,t),EFalse);
  1.1138 +	iGc->DrawTextVertical(_L("Left aligned"),r6,14,EFalse,CGraphicsContext::ELeft);
  1.1139 +	iGc->DrawTextVertical(_L("With margin"),r7,14,EFalse,CGraphicsContext::ELeft,50);
  1.1140 +	iGc->DrawTextVertical(_L("Centred"),r8,14,EFalse,CGraphicsContext::ECenter);
  1.1141 +	iGc->DrawTextVertical(_L("Right aligned"),r9,14,EFalse,CGraphicsContext::ERight);
  1.1142 +	iGc->DrawTextVertical(_L("With margin"),r10,14,EFalse,CGraphicsContext::ERight,30);
  1.1143 +
  1.1144 +	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1145 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1146 +	iGc->SetPenSize(TSize(1,1));
  1.1147 +	iGc->DrawRect(r1);
  1.1148 +	iGc->DrawRect(r2);
  1.1149 +	iGc->DrawRect(r3);
  1.1150 +	iGc->DrawRect(r4);
  1.1151 +	iGc->DrawRect(r5);
  1.1152 +	iGc->DrawRect(r6);
  1.1153 +	iGc->DrawRect(r7);
  1.1154 +	iGc->DrawRect(r8);
  1.1155 +	iGc->DrawRect(r9);
  1.1156 +	iGc->DrawRect(r10);
  1.1157 +
  1.1158 +	iGc->DiscardFont();
  1.1159 +	iDev->ReleaseFont(iFont);
  1.1160 +	//TheTest.Getch();
  1.1161 +	}
  1.1162 +
  1.1163 +/**
  1.1164 +  @SYMTestCaseID GRAPHICS-BITGDI-0081
  1.1165 + 
  1.1166 +  @SYMDEF             
  1.1167 +
  1.1168 +  @SYMTestCaseDesc Super/subscript
  1.1169 +   
  1.1170 +  @SYMTestPriority High
  1.1171 +
  1.1172 +  @SYMTestStatus Implemented
  1.1173 +
  1.1174 +  @SYMTestActions tests the drawing of super and subscript fonts to the gc 
  1.1175 + 
  1.1176 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1177 +*/
  1.1178 +void CTFont::DoSuperSubScriptL()
  1.1179 +	{
  1.1180 +	ResetGc();
  1.1181 +
  1.1182 +	TInt separation = iDev->SizeInPixels().iHeight / 6;
  1.1183 +	TPoint textPos(20,separation);
  1.1184 +
  1.1185 +	CFbsFont* fnorm=NULL;
  1.1186 +	CFbsFont* fsuper=NULL;
  1.1187 +	CFbsFont* fsub=NULL;
  1.1188 +
  1.1189 +	TFontSpec fsp;
  1.1190 +	fsp.iTypeface.iName=_L("Swiss");
  1.1191 +	fsp.iHeight=300;
  1.1192 +
  1.1193 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fnorm,fsp));
  1.1194 +	fsp.iFontStyle.SetPrintPosition(EPrintPosSuperscript);
  1.1195 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fsuper,fsp));
  1.1196 +	fsp.iFontStyle.SetPrintPosition(EPrintPosSubscript);
  1.1197 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(fsub,fsp));
  1.1198 +
  1.1199 +	iGc->UseFont(fnorm);
  1.1200 +	iGc->DrawText(_L("H"),textPos);
  1.1201 +	iGc->UseFont(fsub);
  1.1202 +	iGc->DrawText(_L("2"));
  1.1203 +	iGc->UseFont(fnorm);
  1.1204 +	iGc->DrawText(_L("O"));
  1.1205 +
  1.1206 +	textPos.iY += separation;
  1.1207 +	iGc->DrawText(_L("X"),textPos);
  1.1208 +	iGc->UseFont(fsuper);
  1.1209 +	iGc->DrawText(_L("2"));
  1.1210 +	iGc->UseFont(fnorm);
  1.1211 +	iGc->DrawText(_L("+Y"));
  1.1212 +	iGc->UseFont(fsuper);
  1.1213 +	iGc->DrawText(_L("2"));
  1.1214 +	iGc->UseFont(fnorm);
  1.1215 +	iGc->DrawText(_L("=Z"));
  1.1216 +	iGc->UseFont(fsuper);
  1.1217 +	iGc->DrawText(_L("2"));
  1.1218 +
  1.1219 +	textPos.iY += separation;
  1.1220 +	iGc->UseFont(fnorm);
  1.1221 +	iGc->DrawText(_L("S"),textPos);
  1.1222 +	iGc->UseFont(fsuper);
  1.1223 +	iGc->DrawText(_L("uper"));
  1.1224 +	iGc->UseFont(fnorm);
  1.1225 +	iGc->DrawText(_L("S"));
  1.1226 +	iGc->UseFont(fsuper);
  1.1227 +	iGc->DrawText(_L("cript"));
  1.1228 +
  1.1229 +	textPos.iY += separation;
  1.1230 +	iGc->UseFont(fnorm);
  1.1231 +	iGc->DrawText(_L("S"),textPos);
  1.1232 +	iGc->UseFont(fsub);
  1.1233 +	iGc->DrawText(_L("ub"));
  1.1234 +	iGc->UseFont(fnorm);
  1.1235 +	iGc->DrawText(_L("S"));
  1.1236 +	iGc->UseFont(fsub);
  1.1237 +	iGc->DrawText(_L("cript"));
  1.1238 +
  1.1239 +	textPos.iY += separation;
  1.1240 +	iGc->UseFont(fnorm);
  1.1241 +	iGc->DrawText(_L("Normal"),textPos);
  1.1242 +
  1.1243 +	iGc->DiscardFont();
  1.1244 +	iDev->ReleaseFont(fnorm);
  1.1245 +	iDev->ReleaseFont(fsuper);
  1.1246 +	iDev->ReleaseFont(fsub);
  1.1247 +	//TheTest.Getch();
  1.1248 +	}
  1.1249 +
  1.1250 +/**
  1.1251 +  @SYMTestCaseID GRAPHICS-BITGDI-0082
  1.1252 + 
  1.1253 +  @SYMDEF             
  1.1254 +
  1.1255 +  @SYMTestCaseDesc Underlining/strikethrough
  1.1256 +   
  1.1257 +  @SYMTestPriority High
  1.1258 +
  1.1259 +  @SYMTestStatus Implemented
  1.1260 +
  1.1261 +  @SYMTestActions tests the drawing of Underlining and strikethrough fonts to the gc  
  1.1262 + 
  1.1263 +  @SYMTestExpectedResults Test should perform graphics operations succesfully. 
  1.1264 +*/
  1.1265 +void CTFont::DoUlStL()
  1.1266 +	{
  1.1267 +	iGc->SetPenColor(KRgbBlack);
  1.1268 +	iGc->SetBrushColor(KRgbWhite);
  1.1269 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1270 +	iGc->Clear();
  1.1271 +	iGc->SetUnderlineStyle(EUnderlineOn);
  1.1272 +	iGc->SetStrikethroughStyle(EStrikethroughOn);
  1.1273 +	TFontSpec fsp;
  1.1274 +	fsp.iTypeface.iName=_L("Swiss");
  1.1275 +	fsp.iHeight=15;
  1.1276 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1277 +	iGc->UseFont(iFont);
  1.1278 +	iDev->ReleaseFont(iFont);
  1.1279 +	iGc->DrawText(_L(" "),TPoint(10,iDev->SizeInPixels().iHeight/3));
  1.1280 +	TInt height=50;
  1.1281 +	for(;height<1000;height+=50)
  1.1282 +		{
  1.1283 +		fsp.iHeight=height;
  1.1284 +		User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1285 +		iGc->UseFont(iFont);
  1.1286 +		iDev->ReleaseFont(iFont);
  1.1287 +		TBuf<4> num;
  1.1288 +		num.Num(height/20);
  1.1289 +		iGc->DrawText(_L(" "));
  1.1290 +		iGc->DrawText(num);
  1.1291 +		}
  1.1292 +	fsp.iHeight=15;
  1.1293 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1294 +	iGc->UseFont(iFont);
  1.1295 +	iDev->ReleaseFont(iFont);
  1.1296 +	iGc->DrawText(_L(" "),TPoint(10,iDev->SizeInPixels().iHeight*3/4));
  1.1297 +	for(;height<2000;height+=50)
  1.1298 +		{
  1.1299 +		fsp.iHeight=height;
  1.1300 +		User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1301 +		iGc->UseFont(iFont);
  1.1302 +		iDev->ReleaseFont(iFont);
  1.1303 +		TBuf<4> num;
  1.1304 +		num.Num(height/20);
  1.1305 +		iGc->DrawText(_L(" "));
  1.1306 +		iGc->DrawText(num);
  1.1307 +		}
  1.1308 +	iGc->SetUnderlineStyle(EUnderlineOff);
  1.1309 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1.1310 +	iGc->DiscardFont();
  1.1311 +	//TheTest.Getch();
  1.1312 +	}
  1.1313 +
  1.1314 +/**
  1.1315 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4006
  1.1316 + 
  1.1317 +  @SYMDEF             
  1.1318 +
  1.1319 +  @SYMTestCaseDesc Text drawing in context
  1.1320 +   
  1.1321 +  @SYMTestPriority High
  1.1322 +
  1.1323 +  @SYMTestStatus Implemented
  1.1324 +
  1.1325 +  @SYMTestActions Tests drawing ,mainly punctuation marks in context to a gc 
  1.1326 + 
  1.1327 +  @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.
  1.1328 +*/
  1.1329 +void CTFont::DrawTextInContext()
  1.1330 +	{
  1.1331 +	ResetGc();
  1.1332 +
  1.1333 +	TFontSpec fsp;
  1.1334 +	fsp.iTypeface.iName=_L("Series 60 Sans");
  1.1335 +	fsp.iHeight=250;
  1.1336 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1337 +	iGc->UseFont(iFont);
  1.1338 +	
  1.1339 +	TInt ascent=iFont->AscentInPixels();
  1.1340 +	TPoint pt(10,ascent+10);
  1.1341 +	CGraphicsContext::TTextParameters param;
  1.1342 +	param.iStart = 0;
  1.1343 +	param.iEnd = 32;
  1.1344 +	iGc->DrawText(_L("Punctuations in various scripts:"),&param,pt);
  1.1345 +
  1.1346 +	iGc->DiscardFont();
  1.1347 +	fsp.iHeight=430;
  1.1348 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1349 +	iGc->UseFont(iFont);
  1.1350 +	
  1.1351 +	param.iStart = 27;
  1.1352 +	param.iEnd = 60;
  1.1353 +	pt+=TPoint(0,50);	
  1.1354 +	iGc->DrawText(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"),&param,pt);
  1.1355 +	pt+=TPoint(0,50);
  1.1356 +	param.iEnd = 60;
  1.1357 +	iGc->DrawText(_L("This text will not be drawn\x0915.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Hindi This text will not be drawn"),&param,pt);
  1.1358 +	pt+=TPoint(0,50);
  1.1359 +	param.iEnd = 62;
  1.1360 +	iGc->DrawText(_L("This text will not be drawn\x0C85.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Kannada This text will not be drawn"),&param,pt);
  1.1361 +	
  1.1362 +	iGc->DiscardFont();
  1.1363 +	iDev->ReleaseFont(iFont);
  1.1364 +	
  1.1365 +	}
  1.1366 +/**
  1.1367 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4005
  1.1368 + 
  1.1369 +  @SYMDEF             
  1.1370 +
  1.1371 +  @SYMTestCaseDesc Text drawing in a box in context - 1
  1.1372 +   
  1.1373 +  @SYMTestPriority High
  1.1374 +
  1.1375 +  @SYMTestStatus Implemented
  1.1376 +
  1.1377 +  @SYMTestActions Tests drawing of boxed text,mainly punctuation marks in context to a gc 
  1.1378 + 
  1.1379 +  @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.
  1.1380 +*/
  1.1381 +void CTFont::DrawTextInContextBox()
  1.1382 +	{
  1.1383 +	ResetGc();
  1.1384 +
  1.1385 +	TFontSpec fsp;
  1.1386 +	fsp.iTypeface.iName=_L("Series 60 Sans");
  1.1387 +	fsp.iHeight=250;
  1.1388 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1389 +	iGc->UseFont(iFont);
  1.1390 +	
  1.1391 +	TInt ascent=iFont->AscentInPixels();
  1.1392 +	TPoint pt(10,ascent+10);
  1.1393 +	CGraphicsContext::TTextParameters param;
  1.1394 +	param.iStart = 0;
  1.1395 +	param.iEnd = 41;
  1.1396 +	iGc->DrawText(_L("Punctuations in various scripts in a box:"),&param,pt);
  1.1397 +	
  1.1398 +	iGc->DiscardFont();
  1.1399 +	iDev->ReleaseFont(iFont);
  1.1400 +	fsp.iHeight=430;
  1.1401 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1402 +	iGc->UseFont(iFont);
  1.1403 +	//ResetGc();
  1.1404 +	param.iStart = 27;
  1.1405 +	param.iEnd = 60;
  1.1406 +	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);
  1.1407 +	param.iEnd = 60;
  1.1408 +	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);
  1.1409 +	param.iEnd = 62;
  1.1410 +	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);
  1.1411 +	User::After(TTimeIntervalMicroSeconds32(8000000));
  1.1412 +	
  1.1413 +	iGc->DiscardFont();
  1.1414 +	iDev->ReleaseFont(iFont);
  1.1415 +	}
  1.1416 +	
  1.1417 +/**
  1.1418 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4004
  1.1419 + 
  1.1420 +  @SYMDEF             
  1.1421 +
  1.1422 +  @SYMTestCaseDesc Vertical drawing of text in context
  1.1423 +   
  1.1424 +  @SYMTestPriority High
  1.1425 +
  1.1426 +  @SYMTestStatus Implemented
  1.1427 +
  1.1428 +  @SYMTestActions Tests vertical drawing of text, mainly punctuation marks, in context to a gc 
  1.1429 + 
  1.1430 +  @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.
  1.1431 +*/
  1.1432 +void CTFont::DrawTextInContextVertical()
  1.1433 +	{
  1.1434 +	ResetGc();
  1.1435 +
  1.1436 +	TFontSpec fsp;
  1.1437 +	fsp.iTypeface.iName=_L("Series 60 Sans");
  1.1438 +	fsp.iHeight=300;
  1.1439 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1440 +	iGc->UseFont(iFont);
  1.1441 +	
  1.1442 +	TInt descent=iFont->DescentInPixels();
  1.1443 +	TPoint pt(descent+10,10);
  1.1444 +	CGraphicsContext::TTextParameters param;
  1.1445 +	
  1.1446 +	param.iStart = 27;
  1.1447 +	param.iEnd = 60;	
  1.1448 +	iGc->DrawTextVertical(_L("This text will not be drawnK.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Latin This text will not be drawn"),&param,pt,EFalse);
  1.1449 +	User::After(TTimeIntervalMicroSeconds32(400000));
  1.1450 +	pt+=TPoint(30,0);
  1.1451 +	param.iEnd = 60;
  1.1452 +	iGc->DrawTextVertical(_L("This text will not be drawn\x0915.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Hindi This text will not be drawn"),&param,pt,EFalse);
  1.1453 +	User::After(TTimeIntervalMicroSeconds32(400000));
  1.1454 +	pt+=TPoint(30,0);
  1.1455 +	param.iEnd = 62;
  1.1456 +	iGc->DrawTextVertical(_L("This text will not be drawn\x0C85.,!\"\x00A3$%^&*()_+-=;'#:@~/<>? Kannada This text will not be drawn"),&param,pt,EFalse);
  1.1457 +	
  1.1458 +	iGc->DiscardFont();
  1.1459 +	iDev->ReleaseFont(iFont);
  1.1460 +	}
  1.1461 +	
  1.1462 +/**
  1.1463 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4003
  1.1464 + 
  1.1465 +  @SYMDEF             
  1.1466 +
  1.1467 +  @SYMTestCaseDesc Text drawing in a box in context - 2
  1.1468 +   
  1.1469 +  @SYMTestPriority High
  1.1470 +
  1.1471 +  @SYMTestStatus Implemented
  1.1472 +
  1.1473 +  @SYMTestActions Tests drawing of boxed text in context to a gc 
  1.1474 + 
  1.1475 +  @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn in boxes to the screen
  1.1476 +*/
  1.1477 +void CTFont::BoxInContext()
  1.1478 +	{
  1.1479 +	iGc->SetPenSize(TSize(0,0));
  1.1480 +	iGc->SetBrushColor(KRgbWhite);
  1.1481 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1482 +	iGc->Clear();
  1.1483 +	CGraphicsContext::TTextParameters param;
  1.1484 +	param.iStart = 29;
  1.1485 +	param.iEnd = 44;
  1.1486 +	iGc->DrawText(_L("(This text will not be drawn)Font test code:(This text will not be drawn)"),&param,TPoint(20,20));
  1.1487 +	param.iEnd = 67;
  1.1488 +	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));
  1.1489 +	param.iEnd = 77;
  1.1490 +	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1491 +	param.iEnd = 52;
  1.1492 +	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);
  1.1493 +	param.iEnd = 64;
  1.1494 +	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);
  1.1495 +	param.iEnd = 47;
  1.1496 +	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);
  1.1497 +	param.iEnd = 53;
  1.1498 +	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);
  1.1499 +	param.iEnd = 65;
  1.1500 +	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);
  1.1501 +	param.iEnd = 53;
  1.1502 +	iGc->DrawText(_L("(This text will not be drawn)(Boxes drawn afterwards)(This text will not be drawn)"),&param,TPoint(20,165));
  1.1503 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1504 +	iGc->DrawRect(TRect(20,50,320,70));
  1.1505 +	iGc->DrawRect(TRect(20,70,320,90));
  1.1506 +	iGc->DrawRect(TRect(20,90,320,110));
  1.1507 +	iGc->DrawRect(TRect(20,110,320,130));
  1.1508 +
  1.1509 +	iGc->SetBrushColor(TRgb(128,128,128));
  1.1510 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1511 +	param.iEnd = 52;
  1.1512 +	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);
  1.1513 +	param.iEnd = 64;
  1.1514 +	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);
  1.1515 +	param.iEnd = 47;
  1.1516 +	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);
  1.1517 +	param.iEnd = 53;
  1.1518 +	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);
  1.1519 +	param.iEnd = 65;
  1.1520 +	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);
  1.1521 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1522 +	iGc->DrawRect(TRect(320,50,620,70));
  1.1523 +	iGc->DrawRect(TRect(320,70,620,90));
  1.1524 +	iGc->DrawRect(TRect(320,90,620,110));
  1.1525 +	iGc->DrawRect(TRect(320,110,620,130));
  1.1526 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1527 +	TInt width=iFont->TextWidthInPixels(_L("Box text followed by positionless text."));
  1.1528 +	param.iEnd = 37;
  1.1529 +	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);
  1.1530 +	param.iEnd = 60;
  1.1531 +	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1.1532 +	param.iEnd = 37;
  1.1533 +	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);
  1.1534 +	param.iEnd = 60;
  1.1535 +	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1.1536 +	param.iEnd = 37;
  1.1537 +	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);
  1.1538 +	param.iEnd = 60;
  1.1539 +	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1.1540 +	param.iEnd = 37;
  1.1541 +	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);
  1.1542 +	param.iEnd = 60;
  1.1543 +	iGc->DrawText(_L("(This text will not be drawn) followed by positionless text.(This text will not be drawn)"),&param);
  1.1544 +	iGc->DrawText(_L(""),TRect(20,230,620,250),14,width);
  1.1545 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1546 +	iGc->DrawRect(TRect(20,150,620,170));
  1.1547 +	iGc->DrawRect(TRect(20,170,620,190));
  1.1548 +	iGc->DrawRect(TRect(20,190,620,210));
  1.1549 +	iGc->DrawRect(TRect(20,210,620,230));
  1.1550 +	}
  1.1551 +
  1.1552 +/**
  1.1553 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4002
  1.1554 + 
  1.1555 +  @SYMDEF             
  1.1556 +
  1.1557 +  @SYMTestCaseDesc Text drawing and justification in context
  1.1558 +   
  1.1559 +  @SYMTestPriority High
  1.1560 +
  1.1561 +  @SYMTestStatus Implemented
  1.1562 +
  1.1563 +  @SYMTestActions Tests drawing of justified text in context to a gc 
  1.1564 + 
  1.1565 +  @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
  1.1566 +*/
  1.1567 +void CTFont::JustificationInContext()
  1.1568 +	{
  1.1569 +	iGc->SetUnderlineStyle(EUnderlineOff);
  1.1570 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1.1571 +	iGc->SetPenSize(TSize(0,0));
  1.1572 +	iGc->SetBrushColor(KRgbWhite);
  1.1573 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1574 +	iGc->Clear();
  1.1575 +	CGraphicsContext::TTextParameters param;
  1.1576 +	param.iStart = 29;
  1.1577 +	param.iEnd = 44;
  1.1578 +	iGc->DrawText(_L("(This text will not be drawn)Font test code:(This text will not be drawn)"),&param,TPoint(20,20));
  1.1579 +	param.iEnd = 67;
  1.1580 +	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));
  1.1581 +	iGc->SetCharJustification(18,6);
  1.1582 +	iGc->SetWordJustification(0,0);
  1.1583 +	param.iEnd = 67;
  1.1584 +	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));
  1.1585 +	iGc->SetCharJustification(0,0);
  1.1586 +	iGc->SetWordJustification(30,6);
  1.1587 +	param.iEnd = 67;
  1.1588 +	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));
  1.1589 +	iGc->SetCharJustification(18,6);
  1.1590 +	iGc->SetWordJustification(30,6);
  1.1591 +	param.iEnd = 67;
  1.1592 +	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));
  1.1593 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing in one whole line(This text will not be drawn)"));
  1.1594 +	param.iEnd = 67;
  1.1595 +	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));
  1.1596 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1.1597 +	param.iEnd = 77;
  1.1598 +	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1599 +	iGc->UpdateJustification(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1600 +	iGc->SetCharJustification(18,6);
  1.1601 +	iGc->SetWordJustification(0,0);
  1.1602 +	param.iEnd = 67;
  1.1603 +	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));
  1.1604 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1.1605 +	param.iEnd = 77;
  1.1606 +	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1607 +	iGc->SetCharJustification(0,0);
  1.1608 +	iGc->SetWordJustification(30,6);
  1.1609 +	param.iEnd = 67;
  1.1610 +	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));
  1.1611 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1.1612 +	param.iEnd = 77;
  1.1613 +	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1614 +	iGc->SetCharJustification(18,6);
  1.1615 +	iGc->SetWordJustification(30,6);
  1.1616 +	param.iEnd = 67;
  1.1617 +	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));
  1.1618 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing, followed by posi(This text will not be drawn)"),&param);
  1.1619 +	param.iEnd = 77;
  1.1620 +	iGc->DrawText(_L("(This text will not be drawn)tionless printing (halfway thro' posi-tionless).(This text will not be drawn)"),&param);
  1.1621 +	iGc->SetCharJustification(150,50);
  1.1622 +	iGc->SetWordJustification(50,10);
  1.1623 +	param.iEnd = 68;
  1.1624 +	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));
  1.1625 +	iGc->UpdateJustification(_L("(This text will not be drawn)Normal text printing in one whole line,(This text will not be drawn)"),&param);
  1.1626 +	param.iEnd = 80;
  1.1627 +	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));
  1.1628 +	iGc->SetCharJustification(0,0);
  1.1629 +	iGc->SetWordJustification(0,0);
  1.1630 +	}
  1.1631 +		
  1.1632 +/**
  1.1633 +  @SYMTestCaseID GRAPHICS-SYSLIB-BITGDI-UT-4001
  1.1634 + 
  1.1635 +  @SYMDEF             
  1.1636 +
  1.1637 +  @SYMTestCaseDesc Text drawing in context
  1.1638 +   
  1.1639 +  @SYMTestPriority High
  1.1640 +
  1.1641 +  @SYMTestStatus Implemented
  1.1642 +
  1.1643 +  @SYMTestActions Tests drawing of normal/justified/vertical/boxed text in context to a gc 
  1.1644 + 
  1.1645 +  @SYMTestExpectedResults Test should perform graphics operations succesfully, i.e. only text within the context should be drawn to the screen
  1.1646 +*/
  1.1647 +void CTFont::DoTextFormatsInContextL()
  1.1648 +	{
  1.1649 +	ResetGc();
  1.1650 +	
  1.1651 +	TFontSpec fsp;
  1.1652 +	fsp.iTypeface.iName=_L("Series 60 Sans");
  1.1653 +	fsp.iHeight=300;
  1.1654 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1655 +	iGc->UseFont(iFont);
  1.1656 +	
  1.1657 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4006"));
  1.1658 +	DrawTextInContext();
  1.1659 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1660 +	//TheTest.Getch();
  1.1661 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4005"));
  1.1662 +	DrawTextInContextBox();
  1.1663 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1664 +	//TheTest.Getch();
  1.1665 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4004"));
  1.1666 +	DrawTextInContextVertical();
  1.1667 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1668 +	//TheTest.Getch();
  1.1669 +	
  1.1670 +	iGc->DiscardFont();
  1.1671 +	iDev->ReleaseFont(iFont);
  1.1672 +
  1.1673 +	fsp.iTypeface.iName=_L("Swiss");
  1.1674 +	fsp.iHeight=200;
  1.1675 +
  1.1676 +	User::LeaveIfError(GetNearestFontToDesignHeightInTwips(iFont,fsp));
  1.1677 +	iGc->UseFont(iFont);
  1.1678 +
  1.1679 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4003"));
  1.1680 +	BoxInContext();
  1.1681 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1682 +	//TheTest.Getch();
  1.1683 +
  1.1684 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4002"));
  1.1685 +	JustificationInContext();
  1.1686 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1687 +	//TheTest.Getch();
  1.1688 +
  1.1689 +	iGc->DiscardFont();
  1.1690 +	iDev->ReleaseFont(iFont);
  1.1691 +	((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4001"));
  1.1692 +	}
  1.1693 +	
  1.1694 +void CTFont::ResetGc()
  1.1695 +	{
  1.1696 +	iGc->SetUnderlineStyle(EUnderlineOff);
  1.1697 +	iGc->SetStrikethroughStyle(EStrikethroughOff);
  1.1698 +	iGc->SetPenSize(TSize(1,1));
  1.1699 +	iGc->SetPenColor(KRgbBlack);
  1.1700 +	iGc->SetBrushColor(KRgbWhite);
  1.1701 +	iGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1702 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1703 +	iGc->Clear();
  1.1704 +	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1705 +	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1706 +	}
  1.1707 +
  1.1708 +TInt CTFont::GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec)
  1.1709 +	{
  1.1710 +	TInt ret = iDev->GetNearestFontToDesignHeightInPixels((CFont*&)aFont, aFontSpec);
  1.1711 +	if (ret != KErrNone)
  1.1712 +		{
  1.1713 +		return ret;
  1.1714 +		}
  1.1715 +#ifdef __WINS__
  1.1716 +	CBitmapFont* bitmapFont = CFbsFontEx::FontAddress(aFont);
  1.1717 +	iFontCallCounter.iInjector.InjectShellcode(bitmapFont, &iFontCallCounter);
  1.1718 +	if (bitmapFont->IsOpenFont())
  1.1719 +		{
  1.1720 +		iOpenFontCallCounter.iInjector.InjectShellcode(bitmapFont->OpenFont(), &iOpenFontCallCounter);
  1.1721 +		}
  1.1722 +#endif
  1.1723 +	return KErrNone;
  1.1724 +	}
  1.1725 +
  1.1726 +TInt CTFont::GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec)
  1.1727 +	{
  1.1728 +	TInt ret = iDev->GetNearestFontToDesignHeightInTwips((CFont*&)aFont, aFontSpec);
  1.1729 +	if (ret != KErrNone)
  1.1730 +		{
  1.1731 +		return ret;
  1.1732 +		}
  1.1733 +#ifdef __WINS__
  1.1734 +	CBitmapFont* bitmapFont = CFbsFontEx::FontAddress(aFont);
  1.1735 +	iFontCallCounter.iInjector.InjectShellcode(bitmapFont, &iFontCallCounter);
  1.1736 +	if (bitmapFont->IsOpenFont())
  1.1737 +		{
  1.1738 +		iOpenFontCallCounter.iInjector.InjectShellcode(bitmapFont->OpenFont(), &iOpenFontCallCounter);
  1.1739 +		}
  1.1740 +#endif
  1.1741 +	return KErrNone;
  1.1742 +	}
  1.1743 +
  1.1744 +void CTFont::RunTestCaseL(TInt aCurTestCase)
  1.1745 +	{
  1.1746 +	((CTFontStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1747 +	switch(aCurTestCase)
  1.1748 +		{
  1.1749 +		case 1:
  1.1750 +			{
  1.1751 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0075"));
  1.1752 +            INFO_PRINTF1(_L("All fonts"));
  1.1753 +			TRAPD(ret, DoAllFontsL());
  1.1754 +			TEST(ret == KErrNone);
  1.1755 +            INFO_PRINTF2(_L("Test case 'All fonts' ended with ret='%d'\n"), ret);
  1.1756 +			break;
  1.1757 +			}
  1.1758 +		case 2:
  1.1759 +			{
  1.1760 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0076"));
  1.1761 +	 		INFO_PRINTF1(_L("Text formatting"));
  1.1762 +			TRAPD(ret, DoTextFormatsL());
  1.1763 +			TEST(ret == KErrNone);
  1.1764 +            INFO_PRINTF2(_L("Test case 'Text formatting' ended with ret='%d'\n"), ret);
  1.1765 +			break;
  1.1766 +			}
  1.1767 +		case 3:
  1.1768 +			{
  1.1769 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0077"));
  1.1770 +            INFO_PRINTF1(_L("Check text drawing"));
  1.1771 +			TRAPD(ret, DoBitAlignmentL());
  1.1772 +			TEST(ret == KErrNone);
  1.1773 +            INFO_PRINTF2(_L("Test case 'Check text drawing' ended with ret='%d'\n"), ret);
  1.1774 +			break;
  1.1775 +			}
  1.1776 +		case 4:
  1.1777 +			{
  1.1778 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0078"));
  1.1779 +            INFO_PRINTF1(_L("Large fonts"));
  1.1780 +			TRAPD(ret, DoLargeFontsL());
  1.1781 +			TEST(ret == KErrNone);
  1.1782 +            INFO_PRINTF2(_L("Test case 'Large fonts' ended with ret='%d'\n"), ret);
  1.1783 +			break;
  1.1784 +			}
  1.1785 +		case 5:
  1.1786 +			{
  1.1787 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0080"));
  1.1788 +            INFO_PRINTF1(_L("Vertical text"));
  1.1789 +			TRAPD(ret, DoVerticalText();
  1.1790 +			((CTFontStep*)iStep)->RecordTestResultL();
  1.1791 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0079"));
  1.1792 +					   DoVerticalBoxL());
  1.1793 +			TEST(ret == KErrNone);
  1.1794 +            INFO_PRINTF2(_L("Test case 'Vertical text' ended with ret='%d'\n"), ret);
  1.1795 +			break;
  1.1796 +			}
  1.1797 +		case 6:
  1.1798 +			{
  1.1799 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0081"));
  1.1800 +         	INFO_PRINTF1(_L("Super/subscript"));
  1.1801 +			TRAPD(ret, DoSuperSubScriptL());
  1.1802 +			TEST(ret == KErrNone);
  1.1803 +            INFO_PRINTF2(_L("Test case 'Super/subscript' ended with ret='%d'\n"), ret);
  1.1804 +			break;
  1.1805 +			}
  1.1806 +		case 7:
  1.1807 +			{
  1.1808 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0082"));
  1.1809 +			INFO_PRINTF1(_L("Underlining/strikethrough"));
  1.1810 +			TRAPD(ret, DoUlStL());
  1.1811 +			TEST(ret == KErrNone);
  1.1812 +            INFO_PRINTF2(_L("Test case 'Underlining/strikethrough' ended with ret='%d'\n"), ret);
  1.1813 +			break;
  1.1814 +			}
  1.1815 +		case 8:
  1.1816 +			{
  1.1817 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0074"));
  1.1818 +            INFO_PRINTF1(_L("Anti-aliased text"));
  1.1819 +			TRAPD(ret, DoAntiAliasedTextL());
  1.1820 +			TEST(ret == KErrNone);
  1.1821 +            INFO_PRINTF2(_L("Test case 'Anti-aliased text' ended with ret='%d'\n"), ret);
  1.1822 +			break;
  1.1823 +			}
  1.1824 +		case 9:
  1.1825 +			{
  1.1826 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0075"));
  1.1827 +        	INFO_PRINTF1(_L("FaceCache Performance text"));
  1.1828 +
  1.1829 +			TInt64 starttime = User::FastCounter();
  1.1830 +			TRAPD(ret, DoAllFontsL());
  1.1831 +			TInt64 endtime = User::FastCounter();
  1.1832 +			TEST(ret == KErrNone);
  1.1833 +
  1.1834 +			TInt freq;
  1.1835 +			User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, freq));
  1.1836 +			TInt64 diff = (1000000*(endtime - starttime)) / (TInt64)freq;
  1.1837 +
  1.1838 +            INFO_PRINTF3(_L("Test case 'FaceCache Performance text' ended in '%Ld' usec with ret='%d'\n"), diff, ret);
  1.1839 +			break;
  1.1840 +			}
  1.1841 +		case 10:
  1.1842 +			{
  1.1843 +/**
  1.1844 +  @SYMTestCaseID GRAPHICS-BITGDI-0116
  1.1845 +*/
  1.1846 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0116"));
  1.1847 +			INFO_PRINTF1(_L("Font Externalize/Internalize"));
  1.1848 +			TRAPD(ret, FontExternalizeL());
  1.1849 +			TEST(ret==KErrNone);
  1.1850 +			INFO_PRINTF2(_L("Test case 'Font Externalize/Internalize' ended with ret='%d'\n"), ret);
  1.1851 +			break;
  1.1852 +			}
  1.1853 +		case 11:
  1.1854 +			{
  1.1855 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-BITGDI-UT-4001"));
  1.1856 +	 		INFO_PRINTF1(_L("Text formatting"));
  1.1857 +			TRAPD(ret, DoTextFormatsInContextL());
  1.1858 +			TEST(ret == KErrNone);
  1.1859 +            INFO_PRINTF2(_L("Test case 'Text formatting' ended with ret='%d'\n"), ret);
  1.1860 +			break;
  1.1861 +			}
  1.1862 +		case 12:
  1.1863 +			{
  1.1864 +/**
  1.1865 +@SYMTestCaseID		GRAPHICS-BITGDI-0118
  1.1866 +@SYMTestPriority	High
  1.1867 +@SYMTestType		UT
  1.1868 +@SYMTestStatus		Implemented
  1.1869 +@SYMDEF				EI0014
  1.1870 +
  1.1871 +@SYMTestCaseDesc
  1.1872 +	Tests that there are no virtual function calls to objects in FBServ's shared heap from outside
  1.1873 +	the FBServ process. Such function calls only work if DLLs are guaranteed to be mapped at the
  1.1874 +	same logical address in every process. This is not necessarily true for all memory models.
  1.1875 +
  1.1876 +@SYMTestActions
  1.1877 +	Intercepts the VF table in the CBitmapFont and COpenFont objects corresponding to the fonts used in the
  1.1878 +	preceding BitGDI tests so that virtual function calls from outside the FBServ process are recorded.
  1.1879 +
  1.1880 +@SYMTestExpectedResults
  1.1881 +	Number of virtual function calls to CBitmapFont and COpenFont from outside FBServ is 0
  1.1882 +*/
  1.1883 +			((CTFontStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0118"));
  1.1884 +			// this one should always be the last test, since it checks the final virtual function call count
  1.1885 +#ifdef __WINS__
  1.1886 +			INFO_PRINTF1(_L("Test no virtual function calls to objects in FBServ's shared heap from outside FBServ process"));
  1.1887 +			TEST(iFontCallCounter.iVFCallsOutsideFBServ == 0);
  1.1888 +			TEST(iOpenFontCallCounter.iVFCallsOutsideFBServ == 0);
  1.1889 +#else
  1.1890 +			INFO_PRINTF1(_L("Test no virtual function calls to objects in FBServ's shared heap from outside FBServ process - skipped on target"));
  1.1891 +#endif
  1.1892 +			break;
  1.1893 +			}
  1.1894 +		case 13:
  1.1895 +			{
  1.1896 +			((CTFontStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1897 +			((CTFontStep*)iStep)->CloseTMSGraphicsStep();
  1.1898 +			TestComplete();		
  1.1899 +			break;
  1.1900 +			}
  1.1901 +		}
  1.1902 +	((CTFontStep*)iStep)->RecordTestResultL();
  1.1903 +	}
  1.1904 +
  1.1905 +
  1.1906 +//--------------------------------------------------------------
  1.1907 +
  1.1908 +__CONSTRUCT_STEP__(Font)
  1.1909 +
  1.1910 +void CTFontStep::TestSetupL()
  1.1911 +	{
  1.1912 +	FbsStartup();
  1.1913 +	User::LeaveIfError(RFbsSession::Connect());
  1.1914 +	}
  1.1915 +	
  1.1916 +void CTFontStep::TestClose()
  1.1917 +	{
  1.1918 +	RFbsSession::Disconnect();
  1.1919 +	}