fontservices/fontstore/tfs/T_FontMetrics.cpp
changeset 0 1fb32624e06b
child 53 11e2bb0d14ba
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @test
       
    22  @internalComponent Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include <ecom/ecom.h>
       
    26 #include <gdi.h>
       
    27 #include "T_FontMetrics.h"
       
    28 #include <graphics/openfontrasterizer.h>
       
    29 #include <graphics/openfontconstants.h>
       
    30 #include <graphics/gdi/glyphsample.h>
       
    31 
       
    32 const TInt CTFontMetrics::KRequiredHeight = 24;
       
    33 _LIT(KTypefaceName, "DejaVu Sans Condensed");
       
    34 _LIT(KFontFilePath, "z:\\resource\\fonts\\DejaVuSansCondensed.ttf");
       
    35 
       
    36 LOCAL_C void ResetAndDestroyRImplInfoPtrArray(TAny* aPtr)
       
    37 	{
       
    38 	RImplInfoPtrArray* array = reinterpret_cast <RImplInfoPtrArray*> (aPtr);
       
    39 	array->ResetAndDestroy();
       
    40 	}
       
    41 
       
    42 CTFontMetrics::CTFontMetrics(CTestStep* aStep) :
       
    43 	CTGraphicsBase(aStep)
       
    44 	{
       
    45 	}
       
    46 
       
    47 void CTFontMetrics::ConstructL()
       
    48 	{
       
    49     iHeap = UserHeap::ChunkHeap(NULL, 0x10000, 0x10000);
       
    50 	if (NULL == iHeap)
       
    51 		User::Leave(KErrNoMemory);
       
    52 	iHeap->__DbgMarkStart();
       
    53 	iFontStore = CFontStore::NewL(iHeap);
       
    54 	InstallRasterizerL();
       
    55 	AddFileL();
       
    56 	}
       
    57 
       
    58 CTFontMetrics::~CTFontMetrics()
       
    59 	{
       
    60 	delete iFontStore;
       
    61 	iHeap->__DbgMarkEnd(0);
       
    62 	iHeap->Close();
       
    63 	User::Heap().Check();
       
    64 	REComSession::FinalClose();
       
    65 	}
       
    66 
       
    67 /**
       
    68 Create a rasterizer and install it in the font store.
       
    69 */
       
    70 void CTFontMetrics::InstallRasterizerL()
       
    71 	{
       
    72 	RImplInfoPtrArray implementationArray;
       
    73 	TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
       
    74 	CleanupStack::PushL(cleanup);
       
    75 	const TUid uid = {KUidOpenFontRasterizerPlunginInterface};
       
    76 
       
    77 	TRAPD(error, REComSession::ListImplementationsL(uid, implementationArray));
       
    78 	TEST(error == KErrNone);
       
    79 	TEST(0 < implementationArray.Count());
       
    80 
       
    81 	COpenFontRasterizer* rasterizer =
       
    82 		COpenFontRasterizer::NewL(implementationArray[0]->ImplementationUid());
       
    83 	TRAP(error, iFontStore->InstallRasterizerL(rasterizer));
       
    84 	if (error)
       
    85 		{
       
    86 		delete rasterizer;
       
    87 		TEST(error == KErrNone);
       
    88 		}
       
    89 	CleanupStack::PopAndDestroy(&implementationArray); 	
       
    90 	}
       
    91 
       
    92 void CTFontMetrics::AddFileL()
       
    93 	{
       
    94 	iFontStore->AddFileL(KFontFilePath);
       
    95 	}
       
    96 
       
    97 TOpenFontSpec CTFontMetrics::GetTOpenFontSpec()
       
    98 	{
       
    99 	TOpenFontSpec openFontSpec;
       
   100 	openFontSpec.SetName(KTypefaceName);
       
   101 	openFontSpec.SetHeight(KRequiredHeight);
       
   102 	openFontSpec.SetItalic(EFalse);
       
   103 	openFontSpec.SetBold(EFalse);
       
   104 	return openFontSpec;
       
   105 	}
       
   106 
       
   107 void CTFontMetrics::RunTestCaseL(TInt aCurTestCase)
       
   108 	{
       
   109 	((CTFontMetricsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   110 	switch ( aCurTestCase )
       
   111 		{
       
   112 	case 1:
       
   113 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0029"));
       
   114 		FontAccessInCTypefaceStore();
       
   115 		break;
       
   116 	case 2:
       
   117 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0002"));
       
   118 		TLanguage2GlyphSample();
       
   119 		break;
       
   120 	case 3:
       
   121 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0003"));
       
   122 		GetNearestFontToDesignHeightInPixels();
       
   123 		break;
       
   124 	case 4:
       
   125 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0004"));
       
   126 		GetNearestFontToMaxHeightInPixels();
       
   127 		break;
       
   128 	case 5:
       
   129 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0030"));
       
   130 		TestINC086513();
       
   131 		break;
       
   132 	case 6:
       
   133 		((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0020"));
       
   134 		TestGetNearestFontToMaxHeightInPixels();
       
   135 		break;
       
   136 	case 7:
       
   137         	((CTFontMetricsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   138 		((CTFontMetricsStep*)iStep)->CloseTMSGraphicsStep();
       
   139 		TestComplete();
       
   140 		break;
       
   141 		}
       
   142 	((CTFontMetricsStep*)iStep)->RecordTestResultL();
       
   143 	}
       
   144 
       
   145 /**
       
   146    @SYMTestCaseID          GRAPHICS-FNTSTORE-0002
       
   147 
       
   148    @SYMPREQ                PREQ533
       
   149 
       
   150    @SYMREQ                 REQ3800
       
   151 
       
   152    @SYMTestCaseDesc        Verifying GlyphSample::TLanguage2TScript and GlyphSample::TScript2GlyphSample
       
   153 							with different TLanguage values.
       
   154 
       
   155    @SYMTestPriority        Critical
       
   156 
       
   157    @SYMTestStatus          Implemented
       
   158 
       
   159    @SYMTestActions         (1) Call TLanguage2TScript and then TScript2GlyphSample
       
   160 								with boundary cases ELangTest, ELangNone, ELangMaximum.
       
   161                            (2) Call TLanguage2TScript and then TScript2GlyphSample
       
   162 								with languages belonging to unsupported scripts.
       
   163                            (3) Call TLanguage2TScript and then TScript2GlyphSample
       
   164 								with languages belonging to Latin script.
       
   165                            (4) Repeat (3) for all other supported scripts.
       
   166 
       
   167    @SYMTestExpectedResults (1) and (2) - NULL
       
   168                            (3) and (4) - Languages belonging to the same script should return
       
   169 						   the same address value pointing to the same set of glyph samples.
       
   170 */
       
   171 void CTFontMetrics::TLanguage2GlyphSample()
       
   172 	{
       
   173 	// boundary cases
       
   174 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTest)).Ptr());
       
   175 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangNone)).Ptr());
       
   176 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMaximum)).Ptr());
       
   177 	// Not yet supported
       
   178 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAmharic)).Ptr());
       
   179 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTigrinya)).Ptr());
       
   180 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangArmenian)).Ptr());
       
   181 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTagalog)).Ptr());
       
   182 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBengali)).Ptr());
       
   183 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBurmese)).Ptr());
       
   184 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangGeorgian)).Ptr());
       
   185 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangGujarati)).Ptr());
       
   186 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangKannada)).Ptr());
       
   187 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangKhmer)).Ptr());
       
   188 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangLao)).Ptr());
       
   189 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMalayalam)).Ptr());
       
   190 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMongolian)).Ptr());
       
   191 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangPunjabi)).Ptr());
       
   192 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSinhalese)).Ptr());
       
   193 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTamil)).Ptr());
       
   194 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTelugu)).Ptr());
       
   195 	TEST(NULL == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTibetan)).Ptr());
       
   196 	// Latin
       
   197 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangFrench)));
       
   198 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangGerman)));
       
   199 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSpanish)));
       
   200 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangItalian)));
       
   201 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSwedish)));
       
   202 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangDanish)));
       
   203 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangNorwegian)));
       
   204 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangFinnish)));
       
   205 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAmerican)));
       
   206 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSwissFrench)));
       
   207 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSwissGerman)));
       
   208 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangPortuguese)));
       
   209 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTurkish)));
       
   210 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangIcelandic)));
       
   211 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHungarian)));
       
   212 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangDutch)));
       
   213 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBelgianFlemish)));
       
   214 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAustralian)));
       
   215 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBelgianFrench)));
       
   216 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAustrian)));
       
   217 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangNewZealand)));
       
   218 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangInternationalFrench)));
       
   219 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCzech)));
       
   220 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSlovak)));
       
   221 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangPolish)));
       
   222 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSlovenian)));
       
   223 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAfrikaans)));
       
   224 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangAlbanian)));
       
   225 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCatalan)));
       
   226 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCroatian)));
       
   227 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCanadianEnglish)));
       
   228 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangInternationalEnglish)));
       
   229 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSouthAfricanEnglish)));
       
   230 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEstonian)));
       
   231 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCanadianFrench)));
       
   232 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangScotsGaelic)));
       
   233 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangIndonesian)));
       
   234 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangIrish)));
       
   235 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSwissItalian)));
       
   236 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangLatvian)));
       
   237 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangLithuanian)));
       
   238 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMalay)));
       
   239 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMoldavian)));
       
   240 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangNorwegianNynorsk)));
       
   241 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBrazilianPortuguese)));
       
   242 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRomanian)));
       
   243 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSomali)));
       
   244 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangInternationalSpanish)));
       
   245 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangLatinAmericanSpanish)));
       
   246 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSwahili)));
       
   247 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangFinlandSwedish)));
       
   248 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCyprusTurkish)));
       
   249 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangVietnamese)));
       
   250 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangWelsh)));
       
   251 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangEnglish)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangZulu)));
       
   252 	// Greek
       
   253 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangGreek)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCyprusGreek)));
       
   254 	// Cyrillic
       
   255 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBelarussian)));
       
   256 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangBulgarian)));
       
   257 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangKazakh)));
       
   258 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMacedonian)));
       
   259 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangSerbian)));
       
   260 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTurkmen)));
       
   261 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangRussian)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangUkrainian)));
       
   262 	// Hebrew
       
   263 	TEST(NULL != GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHebrew)).Ptr());
       
   264 	// Arabic
       
   265 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangArabic)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangFarsi)));
       
   266 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangArabic)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangUrdu)));
       
   267 	// Devanagari
       
   268 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHindi)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMarathi)));
       
   269 	// Thai
       
   270 	TEST(NULL != GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangThai)).Ptr());
       
   271 	// HanIdeographs
       
   272 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTaiwanChinese)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHongKongChinese)));
       
   273 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTaiwanChinese)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangPrcChinese)));
       
   274 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTaiwanChinese)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangJapanese)));
       
   275 	TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangTaiwanChinese)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangKorean)));
       
   276 	}
       
   277 
       
   278 /**
       
   279    @SYMTestCaseID          GRAPHICS-FNTSTORE-0003
       
   280 
       
   281    @SYMPREQ                PREQ533
       
   282 
       
   283    @SYMREQ                 REQ3800
       
   284 
       
   285    @SYMTestCaseDesc        Verifying font's metrics created by CFontStore::GetNearestFontToDesignHeightInPixels
       
   286 							with different TLanguage values.
       
   287 
       
   288    @SYMTestPriority        Critical
       
   289 
       
   290    @SYMTestStatus          Implemented
       
   291 
       
   292    @SYMTestActions         (1) Call GetNearestFontToDesignHeightInPixels with ELangNone.
       
   293                            (2) Call CFont's HeightInPixels, AscentInPixels, DescentInPixels, FontCapitalAscent,
       
   294 								FontStandardDescent, FontMaxAscent, FontMaxDescent, FontMaxHeight, and FontLineGap
       
   295 								to verify the font metrics of the returned font object.
       
   296                            (3) Repeat (1) and (2) with a Latin-based language, a Greek-based language, and a
       
   297 								Cyrillic-based language for the TLanguage parameter.
       
   298 
       
   299    @SYMTestExpectedResults See returned values in Verify_GetNearestFontToDesignHeightInPixels.
       
   300 */
       
   301 void CTFontMetrics::GetNearestFontToDesignHeightInPixels()
       
   302 	{
       
   303 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   304 
       
   305 	CFont* font = NULL;
       
   306 	openFontSpec.SetScriptTypeForMetrics(ELangNone);
       
   307 	iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
       
   308 	Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   309 	iFontStore->ReleaseFont(font);
       
   310 
       
   311 	font = NULL;
       
   312 	openFontSpec.SetScriptTypeForMetrics(ELangFinnish);
       
   313 	iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
       
   314 	Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   315 	iFontStore->ReleaseFont(font);
       
   316 
       
   317 	font = NULL;
       
   318 	openFontSpec.SetScriptTypeForMetrics(ELangGreek);
       
   319 	iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
       
   320 	Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   321 	iFontStore->ReleaseFont(font);
       
   322 
       
   323 	font = NULL;
       
   324 	openFontSpec.SetScriptTypeForMetrics(ELangRussian);
       
   325 	iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
       
   326 	Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   327 	iFontStore->ReleaseFont(font);
       
   328 	}
       
   329 
       
   330 void CTFontMetrics::Verify_GetNearestFontToDesignHeightInPixels(const CFont& aFont, TInt aScript)
       
   331 	{
       
   332 	VerifyTypefaceNameAndID(aFont);
       
   333 	// Old metrics
       
   334 	TEST(KRequiredHeight == aFont.HeightInPixels());
       
   335 	TEST(19 == aFont.AscentInPixels());
       
   336 	TEST(KRequiredHeight - aFont.AscentInPixels() == aFont.DescentInPixels());
       
   337 	// New metrics
       
   338 	TEST(18 == aFont.FontCapitalAscent());
       
   339 	TEST(5  == aFont.FontStandardDescent());
       
   340 	if (GlyphSample::EScriptNone == aScript)
       
   341 		{
       
   342 		TEST(28 == aFont.FontMaxAscent());
       
   343 		TEST(8 	== aFont.FontMaxDescent());
       
   344 		TEST(42 == aFont.FontLineGap());
       
   345 		}
       
   346 	else if (GlyphSample::EScriptLatin == aScript)
       
   347 		{
       
   348 		TEST(24 == aFont.FontMaxAscent());
       
   349 		TEST(5 	== aFont.FontMaxDescent());
       
   350 		TEST(35 == aFont.FontLineGap());
       
   351 		}
       
   352 	else if (GlyphSample::EScriptGreek == aScript)
       
   353 		{
       
   354 		TEST(22 == aFont.FontMaxAscent());
       
   355 		TEST(5 	== aFont.FontMaxDescent());
       
   356 		TEST(33 == aFont.FontLineGap());
       
   357 		}
       
   358 	else if (GlyphSample::EScriptCyrillic == aScript)
       
   359 		{
       
   360 		TEST(23 == aFont.FontMaxAscent());
       
   361 		TEST(5 	== aFont.FontMaxDescent());
       
   362 		TEST(34 == aFont.FontLineGap());
       
   363 		}
       
   364 	else TEST(1 == 0);
       
   365 	TEST(aFont.FontMaxAscent() + aFont.FontMaxDescent() == aFont.FontMaxHeight());
       
   366 	INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels());
       
   367 	}
       
   368 
       
   369 /**
       
   370    @SYMTestCaseID          GRAPHICS-FNTSTORE-0004
       
   371 
       
   372    @SYMPREQ                PREQ533
       
   373 
       
   374    @SYMREQ                 REQ3800
       
   375 
       
   376    @SYMTestCaseDesc        Verifying font's metrics created by CFontStore::GetNearestFontToMaxHeightInPixels
       
   377 							with different TLanguage values.
       
   378 
       
   379    @SYMTestPriority        Critical
       
   380 
       
   381    @SYMTestStatus          Implemented
       
   382 
       
   383    @SYMTestActions         (1) Call GetNearestFontToMaxHeightInPixels with ELangNone.
       
   384                            (2) Call CFont's HeightInPixels, AscentInPixels, DescentInPixels, FontCapitalAscent,
       
   385 								FontStandardDescent, FontMaxAscent, FontMaxDescent, FontMaxHeight, and FontLineGap
       
   386 								to verify the font metrics of the returned font object.
       
   387                            (3) Repeat (1) and (2) with a Latin-based language, a Greek-based language, and a
       
   388 								Cyrillic-based language for the TLanguage parameter.
       
   389 
       
   390    @SYMTestExpectedResults See returned values in Verify_GetNearestFontToMaxHeightInPixels.
       
   391 */
       
   392 void CTFontMetrics::GetNearestFontToMaxHeightInPixels()
       
   393 	{
       
   394 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   395 
       
   396 	CFont* font = NULL;
       
   397 	openFontSpec.SetScriptTypeForMetrics(ELangNone);
       
   398 	iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
       
   399 	Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   400 	iFontStore->ReleaseFont(font);
       
   401 
       
   402 	font = NULL;
       
   403 	openFontSpec.SetScriptTypeForMetrics(ELangFinnish);
       
   404 	iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
       
   405 	Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   406 	iFontStore->ReleaseFont(font);
       
   407 
       
   408 	font = NULL;
       
   409 	openFontSpec.SetScriptTypeForMetrics(ELangGreek);
       
   410 	iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
       
   411 	Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   412 	iFontStore->ReleaseFont(font);
       
   413 
       
   414 	font = NULL;
       
   415 	openFontSpec.SetScriptTypeForMetrics(ELangRussian);
       
   416 	iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
       
   417 	Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
       
   418 	iFontStore->ReleaseFont(font);
       
   419 	}
       
   420 
       
   421 void CTFontMetrics::Verify_GetNearestFontToMaxHeightInPixels(const CFont& aFont, TInt aScript)
       
   422 	{
       
   423 	VerifyTypefaceNameAndID(aFont);
       
   424 	if (GlyphSample::EScriptNone == aScript)
       
   425 		{
       
   426 		// Old metrics
       
   427 		TEST(15 == aFont.HeightInPixels());
       
   428 		TEST(12 == aFont.AscentInPixels());
       
   429 		TEST(15 - 12 == aFont.DescentInPixels());
       
   430 		// New metrics
       
   431 		TEST(11 == aFont.FontCapitalAscent());
       
   432 		TEST(3  == aFont.FontStandardDescent());
       
   433 		TEST(18 == aFont.FontMaxAscent());
       
   434 		TEST(5 	== aFont.FontMaxDescent());
       
   435 		TEST(KRequiredHeight - 1 == aFont.FontMaxHeight());
       
   436 		TEST(29 == aFont.FontLineGap());
       
   437 		}
       
   438 	else if (GlyphSample::EScriptLatin == aScript)
       
   439 		{
       
   440 		// Old metrics
       
   441 		TEST(20 == aFont.HeightInPixels());
       
   442 		TEST(16 == aFont.AscentInPixels());
       
   443 		TEST(20 - 16 == aFont.DescentInPixels());
       
   444 		// New metrics
       
   445 		TEST(15 == aFont.FontCapitalAscent());
       
   446 		TEST(4  == aFont.FontStandardDescent());
       
   447 		TEST(20 == aFont.FontMaxAscent());
       
   448 		TEST(4 	== aFont.FontMaxDescent());
       
   449 		TEST(KRequiredHeight == aFont.FontMaxHeight());
       
   450 		TEST(30 == aFont.FontLineGap());
       
   451 		}
       
   452 	else if (GlyphSample::EScriptGreek == aScript)
       
   453 		{
       
   454 		// Old metrics
       
   455 		TEST(20 == aFont.HeightInPixels());
       
   456 		TEST(16 == aFont.AscentInPixels());
       
   457 		TEST(20 - 16 == aFont.DescentInPixels());
       
   458 		// New metrics
       
   459 		TEST(15 == aFont.FontCapitalAscent());
       
   460 		TEST(4  == aFont.FontStandardDescent());
       
   461 		TEST(18 == aFont.FontMaxAscent());
       
   462 		TEST(5 	== aFont.FontMaxDescent());
       
   463 		TEST(KRequiredHeight - 1 == aFont.FontMaxHeight());
       
   464 		TEST(29 == aFont.FontLineGap());
       
   465 		}
       
   466 	else if (GlyphSample::EScriptCyrillic == aScript)
       
   467 		{
       
   468 		// Old metrics
       
   469 		TEST(21 == aFont.HeightInPixels());
       
   470 		TEST(16 == aFont.AscentInPixels());
       
   471 		TEST(21 - 16 == aFont.DescentInPixels());
       
   472 		// New metrics
       
   473 		TEST(16 == aFont.FontCapitalAscent());
       
   474 		TEST(4  == aFont.FontStandardDescent());
       
   475 		TEST(20 == aFont.FontMaxAscent());
       
   476 		TEST(4 	== aFont.FontMaxDescent());
       
   477 		TEST(KRequiredHeight == aFont.FontMaxHeight());
       
   478 		TEST(30 == aFont.FontLineGap());
       
   479 		}
       
   480 	else TEST(1 == 0);
       
   481 	INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels());
       
   482 	}
       
   483 
       
   484 void CTFontMetrics::VerifyTypefaceNameAndID(const CFont& aFont)
       
   485 	{
       
   486 	const TUid uid = {268435523};
       
   487 	TEST(uid == aFont.TypeUid());
       
   488 	TEST(!aFont.FontSpecInTwips().iTypeface.iName.CompareC(KTypefaceName));
       
   489 	}
       
   490 
       
   491 /**
       
   492 	@SYMTestCaseID
       
   493 	GRAPHICS-FNTSTORE-0029
       
   494 
       
   495 	@SYMTestCaseDesc
       
   496 	Tests if CTypefaceStore::iFontAccess generates false positives and
       
   497 	thus prevents GetNearestFontToDesignHeightInPixels from returning the correct fonts.
       
   498 	
       
   499 	@SYMTestActions
       
   500 	1. Creates a TOpenFontSpec object.
       
   501 	2. Sets name, height, italic and bold
       
   502 	3. Setting design height to some arbitrary value.
       
   503 	4. Gets the font which is the nearest to the given font specification.
       
   504 	5. Checks for errors.	
       
   505 	6. Verifies that existing font object created with the GetNearestFontToDesignHeightInPixels
       
   506 	   (having the wrong font metrics) should not prevent us from getting a new font object 
       
   507 	   with the GetNearestFontToMaxHeightInPixels.
       
   508 	7. Calling the GetNearestFontToMaxHeightInPixels function with
       
   509 	   different languages should still refer to the same font object,
       
   510 	   unless the language has an impact on metrics.
       
   511 	 
       
   512 	@SYMTestExpectedResults
       
   513 	Test should pass
       
   514 */
       
   515 void CTFontMetrics::FontAccessInCTypefaceStore()
       
   516 	{
       
   517 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   518 	const TInt KMaxHeight = 24;
       
   519 
       
   520 	TInt rc = KErrGeneral;
       
   521 
       
   522 	CFont* font01 = NULL;
       
   523 	rc = iFontStore->GetNearestFontToDesignHeightInPixels(font01, openFontSpec);
       
   524 	TEST(KErrNone == rc);
       
   525 	TEST(NULL != font01);
       
   526 
       
   527 	CFont* font02 = NULL;
       
   528 	rc = iFontStore->GetNearestFontToDesignHeightInPixels(font02, openFontSpec);
       
   529 	TEST(KErrNone == rc);
       
   530 	TEST(NULL != font02);
       
   531 
       
   532 	CFont* font03 = NULL;
       
   533 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font03, openFontSpec, KMaxHeight);
       
   534 	TEST(KErrNone == rc);
       
   535 	TEST(NULL != font03);
       
   536 
       
   537 	// Setting design height to some arbitrary value
       
   538 	CFont* font04 = NULL;
       
   539 	openFontSpec.SetHeight(0);
       
   540 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font04, openFontSpec, KMaxHeight);
       
   541 	TEST(KErrNone == rc);
       
   542 	TEST(NULL != font04);
       
   543 
       
   544 	// Setting design height to some arbitrary value
       
   545 	CFont* font05 = NULL;
       
   546 	openFontSpec.SetHeight(font03->HeightInPixels());
       
   547 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font05, openFontSpec, KMaxHeight);
       
   548 	TEST(KErrNone == rc);
       
   549 	TEST(NULL != font05);
       
   550 
       
   551 	// Setting design height to that of an old-API generated font object
       
   552 	CFont* font06 = NULL;
       
   553 	openFontSpec.SetHeight(font01->HeightInPixels());
       
   554 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font06, openFontSpec, KMaxHeight);
       
   555 	TEST(KErrNone == rc);
       
   556 	TEST(NULL != font06);
       
   557 
       
   558 	CFont* font07 = NULL;
       
   559 	openFontSpec.SetScriptTypeForMetrics(ELangEnglish);
       
   560 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font07, openFontSpec, KMaxHeight);
       
   561 	TEST(KErrNone == rc);
       
   562 	TEST(NULL != font07);
       
   563 
       
   564 	CFont* font08 = NULL;
       
   565 	openFontSpec.SetScriptTypeForMetrics(ELangSwedish);
       
   566 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(font08, openFontSpec, KMaxHeight);
       
   567 	TEST(KErrNone == rc);
       
   568 	TEST(NULL != font08);
       
   569 
       
   570 	// Using the same font specifications should return font objects from cache.
       
   571 	TEST(font01 == font02);
       
   572 	TEST(font03 == font04);
       
   573 	TEST(font03 == font05);
       
   574 	// Design height should be ignored when calling the GetNearestFontToMaxHeight... API.
       
   575 	TEST(font01 != font03);
       
   576 	// The existing font object created with the GetNearestFontToDesignHeight... API
       
   577 	// (thus having the wrong font metrics) should NOT prevent us from getting a new font
       
   578 	// object with the GetNearestFontToMaxHeight... API (with improved metrics.)
       
   579 	TEST(font01 != font06);
       
   580 	// Languages belonging to the same script should return the same font object.
       
   581 	TEST(font07 == font08);
       
   582 	// Calling the GetNearestFontToMaxHeight... API with
       
   583 	// languages belonging to different scripts may refer to different font objects.
       
   584 	// (Actually different with DejaVu fonts between no script specified and latin script.)
       
   585 	TEST(font06 != font07);
       
   586 
       
   587 	iFontStore->ReleaseFont(font01);
       
   588 	iFontStore->ReleaseFont(font02);
       
   589 	iFontStore->ReleaseFont(font03);
       
   590 	iFontStore->ReleaseFont(font04);
       
   591 	iFontStore->ReleaseFont(font05);
       
   592 	iFontStore->ReleaseFont(font06);
       
   593 	iFontStore->ReleaseFont(font07);
       
   594 	iFontStore->ReleaseFont(font08);
       
   595 	}
       
   596 
       
   597 /**
       
   598 	@SYMTestCaseID
       
   599 	GRAPHICS-FNTSTORE-0030
       
   600 
       
   601 	@SYMTestCaseDesc
       
   602 	Tests if two loaded fonts are the same if their glyphs are the same. 
       
   603 	Second request for the font with different flags should give reference to the 
       
   604 	same font.
       
   605 
       
   606 	@SYMTestActions
       
   607 	1. Creates a TOpenFontSpec object and sets name, height, italic and bold.
       
   608 	2. Gets the font which is the nearest to the given font specification.
       
   609 	3. Checks for errors.
       
   610 	4. Gets the font specification in twips.
       
   611 	5. Gets the font which is the nearest to the given font specification.
       
   612 	6. Checks for errors.
       
   613 	7. Verifies the fonts are the same.
       
   614 	8. Releases the fonts.
       
   615 	
       
   616 	@SYMTestExpectedResults
       
   617 	The fonts should be the same.
       
   618 */
       
   619 void CTFontMetrics::TestINC086513()
       
   620 	{
       
   621 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   622 	CFont* theFont = NULL;
       
   623 	TInt rc = iFontStore->GetNearestFontToDesignHeightInPixels(theFont, openFontSpec);
       
   624 	TEST(KErrNone == rc);
       
   625 	TFontSpec fontSpec = theFont->FontSpecInTwips();
       
   626 	TTypeface typeface;
       
   627 	typeface.iName=fontSpec.iTypeface.iName;
       
   628 	typeface.SetIsProportional(!fontSpec.iTypeface.IsProportional());
       
   629 	CFont* theFont1 = NULL;
       
   630 	rc = iFontStore->GetNearestFontToDesignHeightInPixels(theFont1, openFontSpec);
       
   631 	TEST(rc==KErrNone);
       
   632 
       
   633 	TEST(theFont1==theFont);//fonts should be the same
       
   634 
       
   635 	iFontStore->ReleaseFont(theFont1);
       
   636 	iFontStore->ReleaseFont(theFont);
       
   637 	}
       
   638 	
       
   639 /*
       
   640 This test first marks a font as 'in use' and later tries to 
       
   641 delete all the fonts in the font store by sending the special
       
   642 code KNullUid. Before this would crash the server because 
       
   643 there are still fonts in use, but now it would just return safely.
       
   644 */
       
   645 void CTFontMetrics::TestPDEF099034()
       
   646 	{
       
   647 	INFO_PRINTF1(_L("Trying to remove all fonts in the font store\r\n"));
       
   648 	
       
   649 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   650 	CFont* font = NULL;
       
   651 	TInt ret = iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
       
   652 	TEST(ret == KErrNone);
       
   653 	
       
   654 	TUid uid;
       
   655 	uid.iUid=0;
       
   656 	iFontStore->RemoveFile(uid);
       
   657 	
       
   658 	iFontStore->ReleaseFont(font);
       
   659 	}
       
   660 
       
   661 /**
       
   662 	@SYMTestCaseID GRAPHICS-FNTSTORE-0020
       
   663 	
       
   664 	@SYMDEF DEF101441
       
   665 
       
   666 	@SYMTestCaseDesc Tests GetNearestFontToMaxHeightInPixels with boundary max height and above.
       
   667 					 Tests GetNearestFontToMaxHeightInPixels with boundary min height i,e 1.
       
   668 
       
   669 	@SYMTestPriority High
       
   670 	
       
   671 	@SYMTestStatus Implemented
       
   672 
       
   673 	@SYMTestActions 1. Call GetNearestFontToMaxHeightInPixels with max height as 1025
       
   674 					2  Call GetNearestFontToMaxHeightInPixels with max height as 1
       
   675 					3. Call GetNearestFontToMaxHeightInPixels with max height as 1024
       
   676 	API Calls:
       
   677 	CFontStore::GetNearestFontToMaxHeightInPixels()
       
   678 
       
   679 	@SYMTestExpectedResults 1. For first call it should return KErrTooBig
       
   680 							2. For second call it should return KErrArgument
       
   681 							3. For Third call it should create the font with out any problem
       
   682 							return KErrNone.
       
   683 */
       
   684 void CTFontMetrics::TestGetNearestFontToMaxHeightInPixels()
       
   685 	{
       
   686 	TOpenFontSpec openFontSpec = GetTOpenFontSpec();
       
   687 	CFont* theFont = NULL;
       
   688 	
       
   689 	TInt rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1025);
       
   690 	TEST(KErrTooBig == rc);
       
   691 	TEST(NULL == theFont);
       
   692 
       
   693 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1);
       
   694 	TEST(KErrArgument == rc);
       
   695 	TEST(NULL == theFont);
       
   696 
       
   697 	rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1024);
       
   698 	TEST(NULL != theFont);
       
   699 
       
   700 	iFontStore->ReleaseFont(theFont);
       
   701 	}
       
   702 
       
   703 //--------------
       
   704 __CONSTRUCT_STEP__(FontMetrics)