Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 @internalComponent Internal Symbian test code
25 #include <ecom/ecom.h>
27 #include "T_FontMetrics.h"
28 #include <graphics/openfontrasterizer.h>
29 #include <graphics/openfontconstants.h>
30 #include <graphics/gdi/glyphsample.h>
32 const TInt CTFontMetrics::KRequiredHeight = 24;
33 _LIT(KTypefaceName, "DejaVu Sans Condensed");
34 _LIT(KFontFilePath, "z:\\resource\\fonts\\DejaVuSansCondensed.ttf");
36 LOCAL_C void ResetAndDestroyRImplInfoPtrArray(TAny* aPtr)
38 RImplInfoPtrArray* array = reinterpret_cast <RImplInfoPtrArray*> (aPtr);
39 array->ResetAndDestroy();
42 CTFontMetrics::CTFontMetrics(CTestStep* aStep) :
47 void CTFontMetrics::ConstructL()
49 iHeap = UserHeap::ChunkHeap(NULL, 0x10000, 0x10000);
51 User::Leave(KErrNoMemory);
52 iHeap->__DbgMarkStart();
53 iFontStore = CFontStore::NewL(iHeap);
58 CTFontMetrics::~CTFontMetrics()
61 iHeap->__DbgMarkEnd(0);
64 REComSession::FinalClose();
68 Create a rasterizer and install it in the font store.
70 void CTFontMetrics::InstallRasterizerL()
72 RImplInfoPtrArray implementationArray;
73 TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
74 CleanupStack::PushL(cleanup);
75 const TUid uid = {KUidOpenFontRasterizerPlunginInterface};
77 TRAPD(error, REComSession::ListImplementationsL(uid, implementationArray));
78 TEST(error == KErrNone);
79 TEST(0 < implementationArray.Count());
81 COpenFontRasterizer* rasterizer =
82 COpenFontRasterizer::NewL(implementationArray[0]->ImplementationUid());
83 TRAP(error, iFontStore->InstallRasterizerL(rasterizer));
87 TEST(error == KErrNone);
89 CleanupStack::PopAndDestroy(&implementationArray);
92 void CTFontMetrics::AddFileL()
94 iFontStore->AddFileL(KFontFilePath);
97 TOpenFontSpec CTFontMetrics::GetTOpenFontSpec()
99 TOpenFontSpec openFontSpec;
100 openFontSpec.SetName(KTypefaceName);
101 openFontSpec.SetHeight(KRequiredHeight);
102 openFontSpec.SetItalic(EFalse);
103 openFontSpec.SetBold(EFalse);
107 void CTFontMetrics::RunTestCaseL(TInt aCurTestCase)
109 ((CTFontMetricsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
110 switch ( aCurTestCase )
113 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0029"));
114 FontAccessInCTypefaceStore();
117 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0002"));
118 TLanguage2GlyphSample();
121 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0003"));
122 GetNearestFontToDesignHeightInPixels();
125 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0004"));
126 GetNearestFontToMaxHeightInPixels();
129 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0030"));
133 ((CTFontMetricsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0020"));
134 TestGetNearestFontToMaxHeightInPixels();
137 ((CTFontMetricsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
138 ((CTFontMetricsStep*)iStep)->CloseTMSGraphicsStep();
142 ((CTFontMetricsStep*)iStep)->RecordTestResultL();
146 @SYMTestCaseID GRAPHICS-FNTSTORE-0002
152 @SYMTestCaseDesc Verifying GlyphSample::TLanguage2TScript and GlyphSample::TScript2GlyphSample
153 with different TLanguage values.
155 @SYMTestPriority Critical
157 @SYMTestStatus Implemented
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.
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.
171 void CTFontMetrics::TLanguage2GlyphSample()
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());
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());
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)));
253 TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangGreek)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangCyprusGreek)));
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)));
263 TEST(NULL != GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHebrew)).Ptr());
265 TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangArabic)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangFarsi)));
266 TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangArabic)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangUrdu)));
268 TEST(GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangHindi)) == GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangMarathi)));
270 TEST(NULL != GlyphSample::TScript2GlyphSample(GlyphSample::TLanguage2TScript(ELangThai)).Ptr());
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)));
279 @SYMTestCaseID GRAPHICS-FNTSTORE-0003
285 @SYMTestCaseDesc Verifying font's metrics created by CFontStore::GetNearestFontToDesignHeightInPixels
286 with different TLanguage values.
288 @SYMTestPriority Critical
290 @SYMTestStatus Implemented
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.
299 @SYMTestExpectedResults See returned values in Verify_GetNearestFontToDesignHeightInPixels.
301 void CTFontMetrics::GetNearestFontToDesignHeightInPixels()
303 INFO_PRINTF3(_L("iKPixelWidthInTwips = %d; iKPixelHeightInTwips = %d"),
304 iFontStore->iKPixelWidthInTwips, iFontStore->iKPixelHeightInTwips);
306 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
308 INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangNone"));
310 openFontSpec.SetScriptTypeForMetrics(ELangNone);
311 iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
312 Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
313 iFontStore->ReleaseFont(font);
315 INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangFinnish"));
317 openFontSpec.SetScriptTypeForMetrics(ELangFinnish);
318 iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
319 Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
320 iFontStore->ReleaseFont(font);
322 INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangGreek"));
324 openFontSpec.SetScriptTypeForMetrics(ELangGreek);
325 iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
326 Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
327 iFontStore->ReleaseFont(font);
329 INFO_PRINTF1(_L("GetNearestFontToDesignHeightInPixels().ELangRussian"));
331 openFontSpec.SetScriptTypeForMetrics(ELangRussian);
332 iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
333 Verify_GetNearestFontToDesignHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
334 iFontStore->ReleaseFont(font);
337 void CTFontMetrics::Verify_GetNearestFontToDesignHeightInPixels(const CFont& aFont, TInt aScript)
339 VerifyTypefaceNameAndID(aFont);
340 INFO_PRINTF4(_L("HeightInPixels() = %d; AscentInPixels() = %d; DescentInPixels() = %d"),
341 aFont.HeightInPixels(), aFont.AscentInPixels(), aFont.DescentInPixels());
342 INFO_PRINTF4(_L("FontCapitalAscent() = %d; FontStandardDescent() = %d; FontMaxAscent() = %d"),
343 aFont.FontCapitalAscent(), aFont.FontStandardDescent(), aFont.FontMaxAscent());
344 INFO_PRINTF4(_L("FontMaxDescent() = %d; FontMaxHeight() = %d; FontLineGap() = %d"),
345 aFont.FontMaxDescent(), aFont.FontMaxHeight(), aFont.FontLineGap());
347 TEST(KRequiredHeight == aFont.HeightInPixels());
348 TEST(19 == aFont.AscentInPixels());
349 TEST(KRequiredHeight - aFont.AscentInPixels() == aFont.DescentInPixels());
351 TEST(18 == aFont.FontCapitalAscent());
352 TEST(5 == aFont.FontStandardDescent());
353 if (GlyphSample::EScriptNone == aScript ||
354 GlyphSample::EScriptLatin == aScript ||
355 GlyphSample::EScriptGreek == aScript ||
356 GlyphSample::EScriptCyrillic == aScript)
358 TEST(28 == aFont.FontMaxAscent());
359 TEST(8 == aFont.FontMaxDescent());
360 TEST(42 == aFont.FontLineGap());
363 TEST(aFont.FontMaxAscent() + aFont.FontMaxDescent() == aFont.FontMaxHeight());
364 INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels());
368 @SYMTestCaseID GRAPHICS-FNTSTORE-0004
374 @SYMTestCaseDesc Verifying font's metrics created by CFontStore::GetNearestFontToMaxHeightInPixels
375 with different TLanguage values.
377 @SYMTestPriority Critical
379 @SYMTestStatus Implemented
381 @SYMTestActions (1) Call GetNearestFontToMaxHeightInPixels with ELangNone.
382 (2) Call CFont's HeightInPixels, AscentInPixels, DescentInPixels, FontCapitalAscent,
383 FontStandardDescent, FontMaxAscent, FontMaxDescent, FontMaxHeight, and FontLineGap
384 to verify the font metrics of the returned font object.
385 (3) Repeat (1) and (2) with a Latin-based language, a Greek-based language, and a
386 Cyrillic-based language for the TLanguage parameter.
388 @SYMTestExpectedResults See returned values in Verify_GetNearestFontToMaxHeightInPixels.
390 void CTFontMetrics::GetNearestFontToMaxHeightInPixels()
392 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
394 INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangNone"));
396 openFontSpec.SetScriptTypeForMetrics(ELangNone);
397 iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
398 Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
399 iFontStore->ReleaseFont(font);
401 INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangFinnish"));
403 openFontSpec.SetScriptTypeForMetrics(ELangFinnish);
404 iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
405 Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
406 iFontStore->ReleaseFont(font);
408 INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangGreek"));
410 openFontSpec.SetScriptTypeForMetrics(ELangGreek);
411 iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
412 Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
413 iFontStore->ReleaseFont(font);
415 INFO_PRINTF1(_L("GetNearestFontToMaxHeightInPixels().ELangRussian"));
417 openFontSpec.SetScriptTypeForMetrics(ELangRussian);
418 iFontStore->GetNearestFontToMaxHeightInPixels(font, openFontSpec, KRequiredHeight);
419 Verify_GetNearestFontToMaxHeightInPixels(*font, openFontSpec.ScriptTypeForMetrics());
420 iFontStore->ReleaseFont(font);
423 void CTFontMetrics::Verify_GetNearestFontToMaxHeightInPixels(const CFont& aFont, TInt aScript)
425 VerifyTypefaceNameAndID(aFont);
426 INFO_PRINTF4(_L("HeightInPixels() = %d; AscentInPixels() = %d; DescentInPixels() = %d"),
427 aFont.HeightInPixels(), aFont.AscentInPixels(), aFont.DescentInPixels());
428 INFO_PRINTF4(_L("FontCapitalAscent() = %d; FontStandardDescent() = %d; FontMaxAscent() = %d"),
429 aFont.FontCapitalAscent(), aFont.FontStandardDescent(), aFont.FontMaxAscent());
430 INFO_PRINTF4(_L("FontMaxDescent() = %d; FontMaxHeight() = %d; FontLineGap() = %d"),
431 aFont.FontMaxDescent(), aFont.FontMaxHeight(), aFont.FontLineGap());
432 if (GlyphSample::EScriptNone == aScript)
435 TEST(16 == aFont.HeightInPixels());
436 TEST(13 == aFont.AscentInPixels());
437 TEST(16 - 13 == aFont.DescentInPixels());
439 TEST(12 == aFont.FontCapitalAscent());
440 TEST(3 == aFont.FontStandardDescent());
441 TEST(19 == aFont.FontMaxAscent());
442 TEST(6 == aFont.FontMaxDescent());
443 TEST(KRequiredHeight + 1 == aFont.FontMaxHeight());
444 TEST(31 == aFont.FontLineGap());
446 else if (GlyphSample::EScriptLatin == aScript ||
447 GlyphSample::EScriptGreek == aScript ||
448 GlyphSample::EScriptCyrillic == aScript)
451 TEST(24 == aFont.HeightInPixels());
452 TEST(19 == aFont.AscentInPixels());
453 TEST(24 - 19 == aFont.DescentInPixels());
455 TEST(18 == aFont.FontCapitalAscent());
456 TEST(5 == aFont.FontStandardDescent());
457 TEST(28 == aFont.FontMaxAscent());
458 TEST(8 == aFont.FontMaxDescent());
459 TEST(KRequiredHeight + 12 == aFont.FontMaxHeight());
460 TEST(42 == aFont.FontLineGap());
463 INFO_PRINTF2(_L("MaxCharWidthInPixels() returns %d"), aFont.MaxCharWidthInPixels());
466 void CTFontMetrics::VerifyTypefaceNameAndID(const CFont& aFont)
468 const TUid uid = {268435523};
469 TEST(uid == aFont.TypeUid());
470 TEST(!aFont.FontSpecInTwips().iTypeface.iName.CompareC(KTypefaceName));
475 GRAPHICS-FNTSTORE-0029
478 Tests if CTypefaceStore::iFontAccess generates false positives and
479 thus prevents GetNearestFontToDesignHeightInPixels from returning the correct fonts.
482 1. Creates a TOpenFontSpec object.
483 2. Sets name, height, italic and bold
484 3. Setting design height to some arbitrary value.
485 4. Gets the font which is the nearest to the given font specification.
486 5. Checks for errors.
487 6. Verifies that existing font object created with the GetNearestFontToDesignHeightInPixels
488 (having the wrong font metrics) should not prevent us from getting a new font object
489 with the GetNearestFontToMaxHeightInPixels.
490 7. Calling the GetNearestFontToMaxHeightInPixels function with
491 different languages should still refer to the same font object,
492 unless the language has an impact on metrics.
494 @SYMTestExpectedResults
497 void CTFontMetrics::FontAccessInCTypefaceStore()
499 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
500 const TInt KMaxHeight = 24;
502 TInt rc = KErrGeneral;
504 CFont* font01 = NULL;
505 rc = iFontStore->GetNearestFontToDesignHeightInPixels(font01, openFontSpec);
506 TEST(KErrNone == rc);
507 TEST(NULL != font01);
509 CFont* font02 = NULL;
510 rc = iFontStore->GetNearestFontToDesignHeightInPixels(font02, openFontSpec);
511 TEST(KErrNone == rc);
512 TEST(NULL != font02);
514 CFont* font03 = NULL;
515 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font03, openFontSpec, KMaxHeight);
516 TEST(KErrNone == rc);
517 TEST(NULL != font03);
519 // Setting design height to some arbitrary value
520 CFont* font04 = NULL;
521 openFontSpec.SetHeight(0);
522 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font04, openFontSpec, KMaxHeight);
523 TEST(KErrNone == rc);
524 TEST(NULL != font04);
526 // Setting design height to some arbitrary value
527 CFont* font05 = NULL;
528 openFontSpec.SetHeight(font03->HeightInPixels());
529 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font05, openFontSpec, KMaxHeight);
530 TEST(KErrNone == rc);
531 TEST(NULL != font05);
533 // Setting design height to that of an old-API generated font object
534 CFont* font06 = NULL;
535 openFontSpec.SetHeight(font01->HeightInPixels());
536 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font06, openFontSpec, KMaxHeight);
537 TEST(KErrNone == rc);
538 TEST(NULL != font06);
540 CFont* font07 = NULL;
541 openFontSpec.SetScriptTypeForMetrics(ELangEnglish);
542 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font07, openFontSpec, KMaxHeight);
543 TEST(KErrNone == rc);
544 TEST(NULL != font07);
546 CFont* font08 = NULL;
547 openFontSpec.SetScriptTypeForMetrics(ELangSwedish);
548 rc = iFontStore->GetNearestFontToMaxHeightInPixels(font08, openFontSpec, KMaxHeight);
549 TEST(KErrNone == rc);
550 TEST(NULL != font08);
552 // Using the same font specifications should return font objects from cache.
553 TEST(font01 == font02);
554 TEST(font03 == font04);
555 TEST(font03 == font05);
556 // Design height should be ignored when calling the GetNearestFontToMaxHeight... API.
557 TEST(font01 != font03);
558 // The existing font object created with the GetNearestFontToDesignHeight... API
559 // (thus having the wrong font metrics) should NOT prevent us from getting a new font
560 // object with the GetNearestFontToMaxHeight... API (with improved metrics.)
561 TEST(font01 != font06);
562 // Languages belonging to the same script should return the same font object.
563 TEST(font07 == font08);
564 // Calling the GetNearestFontToMaxHeight... API with
565 // languages belonging to different scripts may refer to different font objects.
566 // (Actually different with DejaVu fonts between no script specified and latin script.)
567 TEST(font06 != font07);
569 iFontStore->ReleaseFont(font01);
570 iFontStore->ReleaseFont(font02);
571 iFontStore->ReleaseFont(font03);
572 iFontStore->ReleaseFont(font04);
573 iFontStore->ReleaseFont(font05);
574 iFontStore->ReleaseFont(font06);
575 iFontStore->ReleaseFont(font07);
576 iFontStore->ReleaseFont(font08);
581 GRAPHICS-FNTSTORE-0030
584 Tests if two loaded fonts are the same if their glyphs are the same.
585 Second request for the font with different flags should give reference to the
589 1. Creates a TOpenFontSpec object and sets name, height, italic and bold.
590 2. Gets the font which is the nearest to the given font specification.
591 3. Checks for errors.
592 4. Gets the font specification in twips.
593 5. Gets the font which is the nearest to the given font specification.
594 6. Checks for errors.
595 7. Verifies the fonts are the same.
596 8. Releases the fonts.
598 @SYMTestExpectedResults
599 The fonts should be the same.
601 void CTFontMetrics::TestINC086513()
603 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
604 CFont* theFont = NULL;
605 TInt rc = iFontStore->GetNearestFontToDesignHeightInPixels(theFont, openFontSpec);
606 TEST(KErrNone == rc);
607 TFontSpec fontSpec = theFont->FontSpecInTwips();
609 typeface.iName=fontSpec.iTypeface.iName;
610 typeface.SetIsProportional(!fontSpec.iTypeface.IsProportional());
611 CFont* theFont1 = NULL;
612 rc = iFontStore->GetNearestFontToDesignHeightInPixels(theFont1, openFontSpec);
615 TEST(theFont1==theFont);//fonts should be the same
617 iFontStore->ReleaseFont(theFont1);
618 iFontStore->ReleaseFont(theFont);
622 This test first marks a font as 'in use' and later tries to
623 delete all the fonts in the font store by sending the special
624 code KNullUid. Before this would crash the server because
625 there are still fonts in use, but now it would just return safely.
627 void CTFontMetrics::TestPDEF099034()
629 INFO_PRINTF1(_L("Trying to remove all fonts in the font store\r\n"));
631 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
633 TInt ret = iFontStore->GetNearestFontToDesignHeightInPixels(font, openFontSpec);
634 TEST(ret == KErrNone);
638 iFontStore->RemoveFile(uid);
640 iFontStore->ReleaseFont(font);
644 @SYMTestCaseID GRAPHICS-FNTSTORE-0020
648 @SYMTestCaseDesc Tests GetNearestFontToMaxHeightInPixels with boundary max height and above.
649 Tests GetNearestFontToMaxHeightInPixels with boundary min height i,e 1.
651 @SYMTestPriority High
653 @SYMTestStatus Implemented
655 @SYMTestActions 1. Call GetNearestFontToMaxHeightInPixels with max height as 1025
656 2 Call GetNearestFontToMaxHeightInPixels with max height as 1
657 3. Call GetNearestFontToMaxHeightInPixels with max height as 1024
659 CFontStore::GetNearestFontToMaxHeightInPixels()
661 @SYMTestExpectedResults 1. For first call it should return KErrTooBig
662 2. For second call it should return KErrArgument
663 3. For Third call it should create the font with out any problem
666 void CTFontMetrics::TestGetNearestFontToMaxHeightInPixels()
668 TOpenFontSpec openFontSpec = GetTOpenFontSpec();
669 CFont* theFont = NULL;
671 TInt rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1025);
672 TEST(KErrTooBig == rc);
673 TEST(NULL == theFont);
675 rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1);
676 TEST(KErrArgument == rc);
677 TEST(NULL == theFont);
679 rc = iFontStore->GetNearestFontToMaxHeightInPixels(theFont, openFontSpec, 1024);
680 TEST(NULL != theFont);
682 iFontStore->ReleaseFont(theFont);
686 __CONSTRUCT_STEP__(FontMetrics)