fontservices/fontstore/src/FNTSTORE.CPP
changeset 44 601ab138ba0b
parent 32 8b9155204a54
child 49 4d76f1414957
child 51 a7c938434754
equal deleted inserted replaced
37:6be019398652 44:601ab138ba0b
    32 #include <openfontlinkedtypefaceelementspec.h>
    32 #include <openfontlinkedtypefaceelementspec.h>
    33 #include <graphics/openfontlinkedtypefaceextension.h>
    33 #include <graphics/openfontlinkedtypefaceextension.h>
    34 #include <graphics/openfontlinkedtypefacespecification.h>
    34 #include <graphics/openfontlinkedtypefacespecification.h>
    35 #include <graphics/openfontrasterizer.h>
    35 #include <graphics/openfontrasterizer.h>
    36 #include <graphics/openfontconstants.h>
    36 #include <graphics/openfontconstants.h>
       
    37 
       
    38 #include "OstTraceDefinitions.h"
       
    39 #ifdef OST_TRACE_COMPILER_IN_USE
       
    40 #include "FNTSTORETraces.h"
       
    41 #endif
       
    42 
    37 
    43 
    38 static const TUint32 KOutlineGlyphIdHashMask = 0x0000ffff;
    44 static const TUint32 KOutlineGlyphIdHashMask = 0x0000ffff;
    39 static const TUint32 KOutlineFileUidHashMask = 0x00ff0000;
    45 static const TUint32 KOutlineFileUidHashMask = 0x00ff0000;
    40 static const TUint32 KOutlineFaceIndexHashMask = 0x0f000000;
    46 static const TUint32 KOutlineFaceIndexHashMask = 0x0f000000;
    41 static const TUint32 KOutlineFontPtrHashMask = 0x0fff0000;
    47 static const TUint32 KOutlineFontPtrHashMask = 0x0fff0000;
  1058 		TRAPD(err, shaper = (*shaperFactoryList)[index]->NewShaperL(this,
  1064 		TRAPD(err, shaper = (*shaperFactoryList)[index]->NewShaperL(this,
  1059 				aShaperInput.iScript, aShaperInput.iLanguage,  iHeap));
  1065 				aShaperInput.iScript, aShaperInput.iLanguage,  iHeap));
  1060 		if (err == KErrNone)
  1066 		if (err == KErrNone)
  1061 			{
  1067 			{
  1062 			aOpenFont->SetShaper(shaper);
  1068 			aOpenFont->SetShaper(shaper);
       
  1069 			OstTrace0( TRACE_IMPORTANT, CBITMAPFONT_INSTALLOPENFONTSHAPER, "A shaper is installed" );
  1063 			break;
  1070 			break;
  1064 			}
  1071 			}
  1065 		}
  1072 		}
  1066 	}
  1073 	}
  1067 
  1074 
  1077 		//as the entry in cache can still be reused by other client
  1084 		//as the entry in cache can still be reused by other client
  1078 		//only in the case where the memory is full, the freeing will
  1085 		//only in the case where the memory is full, the freeing will
  1079 		//delete any cache entry that is not referenced at all
  1086 		//delete any cache entry that is not referenced at all
  1080 		TInt ret=OpenFont()->DecrementCachedRefCount(aSessionHandle,aHeader);
  1087 		TInt ret=OpenFont()->DecrementCachedRefCount(aSessionHandle,aHeader);
  1081 		//panic in debug mode if trying to delete something that is not there.
  1088 		//panic in debug mode if trying to delete something that is not there.
  1082 		__ASSERT_DEBUG(ret==KErrNone || ret==KErrNotFound, User::Invariant());
  1089 		if ((ret != KErrNone) && (ret != KErrNotFound))
       
  1090 		    {
       
  1091 		    OstTrace1( TRACE_FATAL, CBITMAPFONT_DELETESHAPE, "OpenFont()->DecrementCachedRefCount() return %d, Invariant", ret);
       
  1092 		    __ASSERT_DEBUG(0, User::Invariant());
       
  1093 		    }
  1083 		}
  1094 		}
  1084 	}
  1095 	}
  1085 
  1096 
  1086 EXPORT_C void CBitmapFont::operator delete(TAny *aThis)
  1097 EXPORT_C void CBitmapFont::operator delete(TAny *aThis)
  1087 	{
  1098 	{
  1102 	}
  1113 	}
  1103 
  1114 
  1104 CFontBitmap* CBitmapFont::FontBitmap() const
  1115 CFontBitmap* CBitmapFont::FontBitmap() const
  1105 /** This member is private and not intended for use. */
  1116 /** This member is private and not intended for use. */
  1106 	{
  1117 	{
  1107     __ASSERT_ALWAYS(!IsOpenFont(),Panic(EFntTypefaceHasNoFontBitmaps));
  1118 	if (IsOpenFont())
       
  1119 	    {
       
  1120 	    OstTrace0( TRACE_FATAL, CBITMAPFONT_FONTBITMAP, "Panic(EFntTypefaceHasNoFontBitmaps)" );
       
  1121 	    __ASSERT_ALWAYS(0, Panic(EFntTypefaceHasNoFontBitmaps));
       
  1122 	    }
  1108     if(iFontBitmapOffset)
  1123     if(iFontBitmapOffset)
  1109         return reinterpret_cast<CFontBitmap*>(reinterpret_cast<TInt>(this)+iFontBitmapOffset);
  1124         return reinterpret_cast<CFontBitmap*>(reinterpret_cast<TInt>(this)+iFontBitmapOffset);
  1110     else
  1125     else
  1111         return NULL;
  1126         return NULL;
  1112 	}
  1127 	}
  2324 void ReadFromFileL(RFile& aFile, TDes8& aDes, TInt aLength)
  2339 void ReadFromFileL(RFile& aFile, TDes8& aDes, TInt aLength)
  2325 	{
  2340 	{
  2326 	User::LeaveIfError(aFile.Read(aDes, aLength));
  2341 	User::LeaveIfError(aFile.Read(aDes, aLength));
  2327 	if (aDes.Length() != aLength)
  2342 	if (aDes.Length() != aLength)
  2328 		{
  2343 		{
  2329 #ifdef _DEBUG
  2344 		OstTrace0( TRACE_DUMP, _READFROMFILEL, "EOF reading structure from font file, Leave(KErrCorrupt)" );
  2330 		RDebug::Print(_L("EOF reading structure from font file\n"));
       
  2331 #endif
       
  2332 		User::Leave(KErrCorrupt);
  2345 		User::Leave(KErrCorrupt);
  2333 		}
  2346 		}
  2334 	}
  2347 	}
  2335 
  2348 
  2336 // local function(s) to read values from buffer & validate them
  2349 // local function(s) to read values from buffer & validate them
  2341 		{
  2354 		{
  2342 		TUint temp = static_cast<TUint>(aDes[index++]);
  2355 		TUint temp = static_cast<TUint>(aDes[index++]);
  2343 		// must be ASCII character between 32 & 126 inclusive (per Apple's TTF specification document)
  2356 		// must be ASCII character between 32 & 126 inclusive (per Apple's TTF specification document)
  2344 		if ( (temp < 32) || (temp > 126) )
  2357 		if ( (temp < 32) || (temp > 126) )
  2345 			{
  2358 			{
       
  2359 			OstTrace1( TRACE_DUMP, _TTFTABLETAGFROMBUFFERL, "invalid ASCII character (0x%x) in ttf table tag, Leave(KErrCorrupt)", temp);
  2346 			User::Leave(KErrCorrupt);
  2360 			User::Leave(KErrCorrupt);
  2347 #ifdef _DEBUG
       
  2348 			RDebug::Print(_L("invalid ASCII character (0x%x) in ttf table tag\n"), temp);
       
  2349 #endif
       
  2350 			}
  2361 			}
  2351 		value = (value << 8) | temp;
  2362 		value = (value << 8) | temp;
  2352 		}
  2363 		}
  2353 	return value;
  2364 	return value;
  2354 	}
  2365 	}
  2355 
  2366 
  2356 /* Sanity check for TrueType Font, checks that the font tables are sensible.
  2367 /* Sanity check for TrueType Font, checks that the font tables are sensible.
  2357 */
  2368 */
  2358 void CFontStore::SanityCheckForTtfL(RFile& aFontFile, TUint aFontFileSize, TBool aStrictChecking)
  2369 void CFontStore::SanityCheckForTtfL(RFile& aFontFile, TUint aFontFileSize, TBool aStrictChecking)
  2359 	{
  2370 	{
  2360 #if defined(_DEBUG)
  2371 	OstTraceExt2( TRACE_DUMP, CFONTSTORE_SANITYCHECKFORTTFL, "TTF File Size is %u (0x%x) bytes", aFontFileSize, aFontFileSize );
  2361 	RDebug::Print(_L("TTF File Size is %u (0x%x) bytes\n"), aFontFileSize, aFontFileSize);
       
  2362 #endif
       
  2363 
       
  2364 	// check the Offset Table at the start of the file
  2372 	// check the Offset Table at the start of the file
  2365 	TBuf8<16>	fileBuffer;
  2373 	TBuf8<16>	fileBuffer;
  2366 
  2374 
  2367 	ReadFromFileL(aFontFile, fileBuffer, 12);
  2375 	ReadFromFileL(aFontFile, fileBuffer, 12);
  2368 	TUint numTables = (fileBuffer[4] << 8) | (fileBuffer[5]);
  2376 	TUint numTables = (fileBuffer[4] << 8) | (fileBuffer[5]);
  2372 
  2380 
  2373 	const TInt tableStart = 12 + (numTables << 4);	// lowest possible address for actual table data
  2381 	const TInt tableStart = 12 + (numTables << 4);	// lowest possible address for actual table data
  2374 
  2382 
  2375 	if ( (numTables == 0) || (numTables & 0xF0000000) || (tableStart > aFontFileSize) )
  2383 	if ( (numTables == 0) || (numTables & 0xF0000000) || (tableStart > aFontFileSize) )
  2376 		{
  2384 		{
  2377 #ifdef _DEBUG
  2385 		OstTrace1( TRACE_DUMP, DUP1_CFONTSTORE_SANITYCHECKFORTTFL, "# of tables (%d) in ttf is invalid, Leave(KErrCorrupt)", numTables );
  2378 		RDebug::Print(_L("# of tables (%i) in ttf is invalid\n"), numTables);
       
  2379 #endif
       
  2380 		User::Leave(KErrCorrupt);
  2386 		User::Leave(KErrCorrupt);
  2381 		}
  2387 		}
  2382 
  2388 
  2383 #if defined(_DEBUG) && defined(VERBOSE_DEBUG)
  2389 #if defined(_DEBUG) && defined(VERBOSE_DEBUG)
  2384 	// scalar type is 0x00010000 for Windows fonts, other possible values include 0x74727565 and 0x74797031: not checked
  2390 	// scalar type is 0x00010000 for Windows fonts, other possible values include 0x74727565 and 0x74797031: not checked
  2391 	// check searchRange, entrySelector & rangeShift values
  2397 	// check searchRange, entrySelector & rangeShift values
  2392 	// (some not quite TTF files fail the rangeShift check)
  2398 	// (some not quite TTF files fail the rangeShift check)
  2393 	if ( (searchRange < 16) || (entrySelector > 24)
  2399 	if ( (searchRange < 16) || (entrySelector > 24)
  2394 		|| (aStrictChecking && (rangeShift != ( (numTables << 4) - searchRange )) ) )
  2400 		|| (aStrictChecking && (rangeShift != ( (numTables << 4) - searchRange )) ) )
  2395 		{
  2401 		{
  2396 #ifdef _DEBUG
  2402 		OstTraceExt4( TRACE_DUMP, DUP2_CFONTSTORE_SANITYCHECKFORTTFL, "searchRange (0x%x), entrySelector (0x%x) or rangeShift (0x%x) invalid for numTables (%d), Leave(KErrCorrupt)", 
  2397 		RDebug::Print(_L("searchRange (0x%x), entrySelector (0x%x) or rangeShift (0x%x) invalid for numTables (%i)\n"), 
  2403 		        searchRange, entrySelector, rangeShift, numTables );
  2398 			searchRange, entrySelector, rangeShift, numTables);
       
  2399 #endif
       
  2400 		User::Leave(KErrCorrupt);
  2404 		User::Leave(KErrCorrupt);
  2401 		}
  2405 		}
  2402 
  2406 
  2403 	// entrySelector is defined as Log2(Maximum power of 2 <= nmumTables)
  2407 	// entrySelector is defined as Log2(Maximum power of 2 <= nmumTables)
  2404 	TUint exp = 1 << entrySelector;		// log to exponent
  2408 	TUint exp = 1 << entrySelector;		// log to exponent
  2405 	if ( (numTables < exp) || (numTables > (exp << 1)) )
  2409 	if ( (numTables < exp) || (numTables > (exp << 1)) )
  2406 		{
  2410 		{
  2407 #ifdef _DEBUG
  2411 		OstTraceExt2( TRACE_DUMP, DUP3_CFONTSTORE_SANITYCHECKFORTTFL, "entrySelector (0x%x) wrong for numTables(%d), Leave(KErrCorrupt)", 
  2408 		RDebug::Print(_L("entrySelector (0x%x) wrong for numTables(%i)\n"), entrySelector, numTables);
  2412 		        entrySelector, numTables );
  2409 #endif
       
  2410 		User::Leave(KErrCorrupt);
  2413 		User::Leave(KErrCorrupt);
  2411 		}
  2414 		}
  2412 
  2415 
  2413 	// easy checks on the table directory
  2416 	// easy checks on the table directory
  2414 	TInt totalFontSize = tableStart;				// accumulated total directories plus table sizes
  2417 	TInt totalFontSize = tableStart;				// accumulated total directories plus table sizes
  2431 		length = (length + 3) & ~3;	// round up, all tables must be a multiple of 4 bytes for checksumming
  2434 		length = (length + 3) & ~3;	// round up, all tables must be a multiple of 4 bytes for checksumming
  2432 
  2435 
  2433 		// table Tags must be unique & in order
  2436 		// table Tags must be unique & in order
  2434 		if (tableTag <= lastTableTag)
  2437 		if (tableTag <= lastTableTag)
  2435 			{
  2438 			{
  2436 #ifdef _DEBUG
  2439 			OstTraceExt4( TRACE_DUMP, DUP4_CFONTSTORE_SANITYCHECKFORTTFL, "ttf table tag ('%c%c%c%c') is out of order, Leave(KErrCorrupt)",
  2437 			RDebug::Print(_L("ttf table tag ('%c%c%c%c') is out of order\n"), 
  2440 			        tableTag >> 24, (tableTag >> 16) & 0x7F, (tableTag >> 8) & 0x7F, tableTag & 0x7F);
  2438 				tableTag >> 24, (tableTag >> 16) & 0x7F, (tableTag >> 8) & 0x7F, tableTag & 0x7F);
       
  2439 #endif
       
  2440 			User::Leave(KErrCorrupt);
  2441 			User::Leave(KErrCorrupt);
  2441 			}
  2442 			}
  2442 
  2443 
  2443 
  2444 
  2444 		// the offset must be 4-byte aligned, and after the table directory
  2445 		// the offset must be 4-byte aligned, and after the table directory
  2445 		// offset + length must be bigger than the start offset (!)
  2446 		// offset + length must be bigger than the start offset (!)
  2446 		TInt end = length + offset;
  2447 		TInt end = length + offset;
  2447 		if ( (offset & 3) || (offset < tableStart) || (length == 0) || (end < offset) || (end > aFontFileSize))
  2448 		if ( (offset & 3) || (offset < tableStart) || (length == 0) || (end < offset) || (end > aFontFileSize))
  2448 			{
  2449 			{
  2449 #ifdef _DEBUG
  2450 			OstTraceExt2( TRACE_DUMP, DUP5_CFONTSTORE_SANITYCHECKFORTTFL, "offset (0x%x) or length (0x%x) are bad, Leave(KErrCorrupt)",
  2450 			RDebug::Print(_L("offset (0x%x) or length (0x%x) are bad\n"), offset, length);
  2451 			        offset, length );
  2451 #endif		
       
  2452 			User::Leave(KErrCorrupt);
  2452 			User::Leave(KErrCorrupt);
  2453 			}
  2453 			}
  2454 
  2454 
  2455 		lastTableTag = tableTag;
  2455 		lastTableTag = tableTag;
  2456 		totalFontSize += length;
  2456 		totalFontSize += length;
  2467 #endif
  2467 #endif
  2468 
  2468 
  2469 	// for single font files highestTableEnd & totalFontSize should be the same
  2469 	// for single font files highestTableEnd & totalFontSize should be the same
  2470 	if (highestTableEnd != totalFontSize)
  2470 	if (highestTableEnd != totalFontSize)
  2471 		{
  2471 		{
  2472 #ifdef _DEBUG
  2472 		OstTraceExt2( TRACE_DUMP, DUP6_CFONTSTORE_SANITYCHECKFORTTFL, "Total Font Size (0x%x) is different from end of the last table (0x%x), Leave(KErrCorrupt)",
  2473 		RDebug::Print(_L("Total Font Size (0x%x) is different from end of the last table (0x%x)\n"), 
  2473 		        highestTableEnd, totalFontSize);
  2474 				highestTableEnd, totalFontSize);
       
  2475 #endif
       
  2476 		User::Leave(KErrCorrupt);
  2474 		User::Leave(KErrCorrupt);
  2477 		}
  2475 		}
  2478 	}
  2476 	}
  2479 
  2477 
  2480 /* Sanity checks on font files, currently only knows about TrueType Font files: .ttf and .otf
  2478 /* Sanity checks on font files, currently only knows about TrueType Font files: .ttf and .otf
  3622 			aFont = openFont;
  3620 			aFont = openFont;
  3623 			return KErrNone;
  3621 			return KErrNone;
  3624 			}
  3622 			}
  3625 		else
  3623 		else
  3626 			{
  3624 			{
  3627 			__ASSERT_DEBUG(EFalse, Panic(EFntNoFontFound));
  3625 			OstTraceExt2( TRACE_FATAL, CFONTSTORE_GETNEARESTFONTINPIXELS, "GetNearestOpenFontInPixelsL() return %d, openFont is 0x%x, Panic(EFntNoFontFound)",
       
  3626 			        error, (unsigned int)openFont);
       
  3627 			__ASSERT_DEBUG(0, Panic(EFntNoFontFound));
  3628 			return KErrGeneral;
  3628 			return KErrGeneral;
  3629 			}
  3629 			}
  3630 		}
  3630 		}
  3631 	else if (NULL == openFont)
  3631 	else if (NULL == openFont)
  3632 		{
  3632 		{
  3772 		{
  3772 		{
  3773 		// copy Open Font typeface details
  3773 		// copy Open Font typeface details
  3774 		aTypefaceSupport = *iOpenFontTypefaceSupportList[aTypefaceIndex - iTypefaceList.Count()]->TypefaceSupport();
  3774 		aTypefaceSupport = *iOpenFontTypefaceSupportList[aTypefaceIndex - iTypefaceList.Count()]->TypefaceSupport();
  3775 		return;
  3775 		return;
  3776 		}
  3776 		}
  3777 
  3777 	
  3778 	__ASSERT_DEBUG((aTypefaceIndex >= 0) && (aTypefaceIndex < iTypefaceList.Count()),Panic(EFntTypefaceIndexOutOfRange));
  3778 	if (!((aTypefaceIndex >= 0) && (aTypefaceIndex < iTypefaceList.Count())))
       
  3779 	    {
       
  3780 	    OstTraceExt2( TRACE_FATAL, CFONTSTORE_TYPEFACESUPPORT, "aTypefaceIndex=%d, iTypefaceList.Count()=%d Panic(EFntTypefaceIndexOutOfRange)",
       
  3781 	            aTypefaceIndex, iTypefaceList.Count());
       
  3782 	    __ASSERT_DEBUG(0,Panic(EFntTypefaceIndexOutOfRange));
       
  3783 	    }
  3779 	TTypeface* typeface = iTypefaceList[aTypefaceIndex];
  3784 	TTypeface* typeface = iTypefaceList[aTypefaceIndex];
  3780 	aTypefaceSupport.iTypeface = *typeface;
  3785 	aTypefaceSupport.iTypeface = *typeface;
  3781 	TInt count = iTypefaceFontBitmapList.Count();
  3786 	TInt count = iTypefaceFontBitmapList.Count();
  3782 	TInt i;
  3787 	TInt i;
  3783 	for(i = 0; i < count && iTypefaceFontBitmapList[i].iTypeface != typeface; i++)
  3788 	for(i = 0; i < count && iTypefaceFontBitmapList[i].iTypeface != typeface; i++)
  3931 		for (TInt j=0; j<num; j++)
  3936 		for (TInt j=0; j<num; j++)
  3932 			{
  3937 			{
  3933 			TUid uid;
  3938 			TUid uid;
  3934 			stream >> uid;
  3939 			stream >> uid;
  3935  			CFontBitmap* fontbitmap = GetFontBitmapById(uid);
  3940  			CFontBitmap* fontbitmap = GetFontBitmapById(uid);
  3936 			__ASSERT_DEBUG(fontbitmap,Panic(EFntFontBitmapNotLoaded));
  3941  			if (!fontbitmap)
       
  3942  			    {
       
  3943  			    OstTrace0( TRACE_FATAL, CFONTSTORE_INTERNALIZEFONTSTOREFILEL, "Panic(EFntFontBitmapNotLoaded)" );
       
  3944  			   __ASSERT_DEBUG(0,Panic(EFntFontBitmapNotLoaded));
       
  3945  			    }
  3937 #ifndef _DEBUG
  3946 #ifndef _DEBUG
  3938 			User::LeaveIfNull(fontbitmap);
  3947 			User::LeaveIfNull(fontbitmap);
  3939 #endif			
  3948 #endif			
  3940 			TTypefaceFontBitmap typefacefontbitmap(iTypefaceList[index],fontbitmap);
  3949 			TTypefaceFontBitmap typefacefontbitmap(iTypefaceList[index],fontbitmap);
  3941 			typefacefontbitmap.iWidthFactor=stream.ReadInt8L();
  3950 			typefacefontbitmap.iWidthFactor=stream.ReadInt8L();
  3990 	}
  3999 	}
  3991 
  4000 
  3992 TTypeface* CFontStore::GetNearestTypeface(const TTypeface& aTypeface) const
  4001 TTypeface* CFontStore::GetNearestTypeface(const TTypeface& aTypeface) const
  3993 	{
  4002 	{
  3994 	TInt index,count = iTypefaceList.Count();
  4003 	TInt index,count = iTypefaceList.Count();
  3995 	__ASSERT_DEBUG(count>0,Panic(EFntNoTypefaces));
  4004 	if (count <= 0)
       
  4005 	    {
       
  4006 	    OstTrace1( TRACE_FATAL, CFONTSTORE_GETNEARESTTYPEFACE, "count=%d, Panic(EFntNoTypefaces)", count );
       
  4007 	    __ASSERT_DEBUG(0,Panic(EFntNoTypefaces));
       
  4008 	    }
  3996 	for (index=0; (index<count) && aTypeface.iName.CompareF(iTypefaceList[index]->iName); index++)	  
  4009 	for (index=0; (index<count) && aTypeface.iName.CompareF(iTypefaceList[index]->iName); index++)	  
  3997 		{ // tries matching	typeface name
  4010 		{ // tries matching	typeface name
  3998 		}
  4011 		}
  3999 	if (index==count)
  4012 	if (index==count)
  4000 		{
  4013 		{
  4030 
  4043 
  4031 TTypefaceFontBitmap CFontStore::GetNearestTypefaceFontBitmap(const TFontSpec& aFontSpecInPixels, TInt aMaxHeight)
  4044 TTypefaceFontBitmap CFontStore::GetNearestTypefaceFontBitmap(const TFontSpec& aFontSpecInPixels, TInt aMaxHeight)
  4032 	{
  4045 	{
  4033 	TTypefaceFontBitmap typefacefontbitmap;
  4046 	TTypefaceFontBitmap typefacefontbitmap;
  4034 	TInt count = iTypefaceFontBitmapList.Count();
  4047 	TInt count = iTypefaceFontBitmapList.Count();
  4035 	__ASSERT_DEBUG(count > 0, Panic(EFntNoTypefaceFontBitmaps));
  4048 	if (count <= 0)
       
  4049 	    {
       
  4050 	    OstTrace1( TRACE_FATAL, CFONTSTORE_GETNEARESTTYPEFACEFONTBITMAP, "count=%d, Panic(EFntNoTypefaceFontBitmaps)", count );
       
  4051 	    __ASSERT_DEBUG(0, Panic(EFntNoTypefaceFontBitmaps));
       
  4052 	    }
  4036 	TInt i;
  4053 	TInt i;
  4037 	TInt j;
  4054 	TInt j;
  4038 	// Assumes there is at least one fontbitmap per typeface
  4055 	// Assumes there is at least one fontbitmap per typeface
  4039 	for (i = 0; (i < count) && !(aFontSpecInPixels.iTypeface == *iTypefaceFontBitmapList[i].iTypeface); i++)
  4056 	for (i = 0; (i < count) && !(aFontSpecInPixels.iTypeface == *iTypefaceFontBitmapList[i].iTypeface); i++)
  4040 		{  // Finds first fontbitmap with correct typeface
  4057 		{  // Finds first fontbitmap with correct typeface
  4041 		}
  4058 		}
  4042 	__ASSERT_DEBUG(i < count, Panic(EFntTypefaceHasNoFontBitmaps));
  4059 	if (i >= count)
       
  4060 	    {
       
  4061 	    OstTraceExt2( TRACE_FATAL, DUP1_CFONTSTORE_GETNEARESTTYPEFACEFONTBITMAP, "i=%d, count=%d, Panic(EFntTypefaceHasNoFontBitmaps)", i, count );
       
  4062 	    __ASSERT_DEBUG(i < count, Panic(EFntTypefaceHasNoFontBitmaps));
       
  4063 	    }
  4043 	TTypeface* typeface = iTypefaceFontBitmapList[i].iTypeface;
  4064 	TTypeface* typeface = iTypefaceFontBitmapList[i].iTypeface;
  4044 	TInt height = 0;
  4065 	TInt height = 0;
  4045 	if (aMaxHeight > 0)
  4066 	if (aMaxHeight > 0)
  4046 		{ // need to check against max height
  4067 		{ // need to check against max height
  4047 		for (j = i; (j < count) && (iTypefaceFontBitmapList[ j ].iTypeface == typeface) 
  4068 		for (j = i; (j < count) && (iTypefaceFontBitmapList[ j ].iTypeface == typeface) 
  4189 // The cutoff is effectively at two-thirds of a twip
  4210 // The cutoff is effectively at two-thirds of a twip
  4190 // This is to support the legacy system of rounding down
  4211 // This is to support the legacy system of rounding down
  4191 // but with a sanity-check cutoff to round up past two-thirds
  4212 // but with a sanity-check cutoff to round up past two-thirds
  4192 TInt CFontStore::VerticalTwipsToPixels(TInt aTwipsHeight) const
  4213 TInt CFontStore::VerticalTwipsToPixels(TInt aTwipsHeight) const
  4193 	{
  4214 	{
  4194 	__ASSERT_DEBUG(iKPixelHeightInTwips,Panic(EFntKPixelHeightInTwipsZero));
  4215 	if (!iKPixelHeightInTwips)
       
  4216 	    {
       
  4217 	    OstTrace0( TRACE_FATAL, CFONTSTORE_VERTICALTWIPSTOPIXELS, "Panic(EFntKPixelHeightInTwipsZero)" );
       
  4218 	    __ASSERT_DEBUG(0, Panic(EFntKPixelHeightInTwipsZero));
       
  4219 	    }
  4195 	return ((aTwipsHeight * 1000) + (iKPixelHeightInTwips / 3)) / iKPixelHeightInTwips;  // Rounds down below two-thirds of a twip
  4220 	return ((aTwipsHeight * 1000) + (iKPixelHeightInTwips / 3)) / iKPixelHeightInTwips;  // Rounds down below two-thirds of a twip
  4196 	}
  4221 	}
  4197 
  4222 
  4198 /** Installs and takes ownership of an Open Font rasterizer.
  4223 /** Installs and takes ownership of an Open Font rasterizer.
  4199 
  4224