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