fontservices/fontstore/tfs/T_GetNearestFont.cpp
branchRCL_3
changeset 55 336bee5c2d35
parent 54 748ec5531811
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
   311 @SYMTestExpectedResults Ensure the real font, not the aliased font is returned.
   311 @SYMTestExpectedResults Ensure the real font, not the aliased font is returned.
   312 */
   312 */
   313 void CTGetNearestFont::AliasedFontCreationL()
   313 void CTGetNearestFont::AliasedFontCreationL()
   314 	{
   314 	{
   315 	TInt numTypefaces = iTfs->NumTypefaces();
   315 	TInt numTypefaces = iTfs->NumTypefaces();
   316 	if(numTypefaces <2)
   316 
   317 	    return;
   317 	TTypefaceSupport tfSupport;
   318 	
   318 
   319 	TTypefaceSupport tfSupport1;
       
   320 	
       
   321     iTfs->TypefaceSupport(tfSupport1, 0);
       
   322     INFO_PRINTF1(tfSupport1.iTypeface.iName);
       
   323 	// Get the first different typeface
   319 	// Get the first different typeface
   324     TTypefaceSupport tfSupport2;
       
   325 	while (--numTypefaces)
   320 	while (--numTypefaces)
   326 		{
   321 		{
   327 		iTfs->TypefaceSupport(tfSupport2, numTypefaces);
   322 		iTfs->TypefaceSupport(tfSupport, numTypefaces);
   328 		INFO_PRINTF1(tfSupport2.iTypeface.iName);
   323 		if (tfSupport.iTypeface.iName != KTypefaceName)
   329 		if (tfSupport2.iTypeface.iName != tfSupport1.iTypeface.iName)
       
   330 			{
   324 			{
   331 			break;
   325 			break;
   332 			}
   326 			}
   333 		}
   327 		}
   334 
   328 
   335 	// Make sure we aren't at the end of the list
   329 	// Make sure we aren't at the end of the list
   336 	TEST(numTypefaces);
   330 	TEST(numTypefaces);
       
   331 
       
   332 	TPtrC typeface = tfSupport.iTypeface.iName;
       
   333 
   337 	// Alias the other font with the same name as the original
   334 	// Alias the other font with the same name as the original
   338 	iTfs->SetFontNameAliasL(tfSupport1.iTypeface.iName, tfSupport2.iTypeface.iName);
   335 	iTfs->SetFontNameAliasL(KTypefaceName, typeface);
   339 
   336 
   340 	// Request the original font (making sure we don't get the aliased font back)
   337 	// Request the original font (making sure we don't get the aliased font back)
   341 	CFont* font = NULL;
   338 	CFont* font = NULL;
   342 	TFontSpec spec(tfSupport1.iTypeface.iName, 0);
   339 	TFontSpec spec(KTypefaceName, 0);
   343 	TInt ret = iTfs->GetNearestFontToDesignHeightInPixels(font, spec);
   340 	TInt ret = iTfs->GetNearestFontToDesignHeightInPixels(font, spec);
   344 	TEST(ret == KErrNone);
   341 	TEST(ret == KErrNone);
   345 	TFontSpec returnedSpecs = font->FontSpecInTwips();
   342 	TFontSpec returnedSpecs = font->FontSpecInTwips();
   346 	INFO_PRINTF1(returnedSpecs.iTypeface.iName);
   343 	TEST(returnedSpecs.iTypeface.iName == KTypefaceName);
   347 	TEST(returnedSpecs.iTypeface.iName == tfSupport1.iTypeface.iName);
       
   348 	iTfs->ReleaseFont(font);
   344 	iTfs->ReleaseFont(font);
   349 	}
   345 	}
   350 
   346 
   351 //--------------
   347 //--------------
   352 __CONSTRUCT_STEP__(GetNearestFont)
   348 __CONSTRUCT_STEP__(GetNearestFont)