class ChaChaFontInfo  expands FontInfo;
	  
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT10 FONTNAME="Unreal Tournament" HEIGHT=10 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT12 FONTNAME="Unreal Tournament" HEIGHT=12 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT14 FONTNAME="Unreal Tournament" HEIGHT=14 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT16 FONTNAME="Unreal Tournament" HEIGHT=16 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT18 FONTNAME="Unreal Tournament" HEIGHT=18 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT20 FONTNAME="Unreal Tournament" HEIGHT=20 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT22 FONTNAME="Unreal Tournament" HEIGHT=22 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT24 FONTNAME="Unreal Tournament" HEIGHT=24 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT30 FONTNAME="Unreal Tournament" HEIGHT=30 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT36 FONTNAME="Unreal Tournament" HEIGHT=36 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT42 FONTNAME="Unreal Tournament" HEIGHT=42 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT48 FONTNAME="Unreal Tournament" HEIGHT=48 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT54 FONTNAME="Unreal Tournament" HEIGHT=54 ANTIAlIAS=TRUE
#exec NEW TRUETYPEFONTFACTORY NAME=UnrealT60 FONTNAME="Unreal Tournament" HEIGHT=60 ANTIAlIAS=TRUE

var Font FontClass[14];

function Font GetFontIndex(int i, float Width)
{
	if ( CurrentInGameScalingFactor != InGameScalingFactor )
		SetScalingState(True);

	if ( (SavedFont[i] != None) && (Width == SavedWidth[i]) )
		return SavedFont[i];
	
	SavedWidth[i] = Width;

	//In lower resolutions fonts need to be a bit bigger
	SavedFont[i] = GetFontBySize( (Width + (6-i)*32) / FontDiv[i] );

	return SavedFont[i];
}


/*---------------- (469) Dynamically create fonts and cache them -----------------*/

//Precache fonts if font scaling is enabled at game start
event PostBeginPlay()
{
	SetScalingState(True);
}

function SetScalingState(bool bEnableScaling)
{
	local int i;
	
	if ( !bCacheSetup )
	{
		bCacheSetup = true;
		AddNewFontCache( Font'SmallFont', 0, 7);
		AddNewFontCache(FontClass[0], 7, 10);
		AddNewFontCache(FontClass[1], 10, 12);
		AddNewFontCache(FontClass[2], 12, 14);
		AddNewFontCache(FontClass[3], 14, 16);
		AddNewFontCache(FontClass[4], 16, 20);
		AddNewFontCache(FontClass[5], 20, 22);
		AddNewFontCache(FontClass[6], 22, 24);
		AddNewFontCache(FontClass[7], 24, 30);
		AddNewFontCache(FontClass[8], 30, 36);
		AddNewFontCache(FontClass[9], 36, 42);
		AddNewFontCache(FontClass[10], 42, 48);
		AddNewFontCache(FontClass[11], 48, 54);
		AddNewFontCache(FontClass[12], 54, 60);
		AddNewFontCache(FontClass[13], 60, 85);
	}
	

	// Reset resolution caches to make bEnableInGameScaling changes effective immediately
	for ( i=0 ; i<7 ; ++i )
	{
		SavedFont[i]  = none;
		SavedWidth[i] = 0;
	}

	bEnableInGameScaling = True;
	bCurrentInGameScaling = True;
	CurrentInGameScalingFactor = InGameScalingFactor;
}

defaultproperties
{
      FontClass(0)=Font'UnrealT10'
      FontClass(1)=Font'UnrealT12'
      FontClass(2)=Font'UnrealT14'
      FontClass(3)=Font'UnrealT16'
      FontClass(4)=Font'UnrealT18'
      FontClass(5)=Font'UnrealT20'
      FontClass(6)=Font'UnrealT22'
      FontClass(7)=Font'UnrealT24'
      FontClass(8)=Font'UnrealT30'
      FontClass(9)=Font'UnrealT36'
      FontClass(10)=Font'UnrealT42'
      FontClass(11)=Font'UnrealT48'
      FontClass(12)=Font'UnrealT54'
      FontClass(13)=Font'UnrealT60'
      bEnableInGameScaling=True
      bCurrentInGameScaling=True
}
