--------------------------------------------------------------------------------
--  CLEARFONT狂鼠修改版(英文原版作者KIRKBURN)
--  Beta 2     07.04.06
--------------------------------------------------------------------------------
--  Home page:  http://bbs.ngacn.com/read.php?tid=538596
--  在此页面下载并查看详细说明！
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- FUNCTION TO DETECT ADDONS FOR OVERRIDES
-- by Iriel
--------------------------------------------------------------------------------

local function CanSetFont(object) 
   return (type(object)=="table" 
	   and object.SetFont and object.IsObjectType 
	      and not object:IsObjectType("SimpleHTML")); 
end



--------------------------------------------------------------------------------
-- FUCTION TO RELOAD EVERY BLOODY TIME AN ADDON LOADS
-- Since they like to mess up my addon :( ... Also by Iriel
--------------------------------------------------------------------------------

ClearFont = CreateFrame("Frame", "ClearFont");

-- Set up an OnEvent handler to re-apply font settings whenever Fonts.xml is overridden
ClearFont:SetScript("OnEvent",
		    function() 
		       if (event == "ADDON_LOADED") then
			  ClearFont:ApplySystemFonts()
			     end
		    end);
ClearFont:RegisterEvent("ADDON_LOADED");

-- Set up font locals for brevity later
local CLEAR_FONT_BASE = "Fonts\\";
local CLEAR_FONT = CLEAR_FONT_BASE .. "FZLBJW.TTF";
local CLEAR_FONT_NUMBER = CLEAR_FONT_BASE .. "ARIALN.TTF";
local CLEAR_FONT_ZONE = CLEAR_FONT_BASE .. "FZL2JW.TTF";
local CLEAR_FONT_DAMAGE = CLEAR_FONT_BASE .. "FZJZJW.TTF";
local CLEAR_FONT_QUESTTITLE = CLEAR_FONT_BASE .. "LBJW.TTF";
local CLEAR_FONT_QUEST = CLEAR_FONT_BASE .. "FZBWJW.TTF";

--------------------------------------------------------------------------------
-- STANDARD WOW UI SECTION
-- This is the bit you want to edit ...
--------------------------------------------------------------------------------

function ClearFont:ApplySystemFonts()


-- 角色头上的名字 , 系统伤害字体 (thanks Dark Imakuni)
--------------------------------------------------------------------------------

   STANDARD_TEXT_FONT = CLEAR_FONT;
   UNIT_NAME_FONT = CLEAR_FONT;
   DAMAGE_TEXT_FONT = CLEAR_FONT_DAMAGE;
   NAMEPLATE_FONT = CLEAR_FONT;
		CHAT_FONT_HEIGHTS = {
			[1] = 12,
			[2] = 14,
			[3] = 16,
			[4] = 18
		};



-- Stuff that's not in the fonts.xml, wonderfully and annoyingly
--------------------------------------------------------------------------------

    UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 12;


-- Master Fonts
--------------------------------------------------------------------------------

   MasterFont:SetShadowColor(0, 0, 0);
   MasterFont:SetShadowOffset(1, -1);


-- 系统字体
--------------------------------------------------------------------------------

   SystemFont:SetFont(CLEAR_FONT, 14);


-- 主体字体
--------------------------------------------------------------------------------

   GameFontNormal:SetFont(CLEAR_FONT, 14);
   GameFontNormal:SetShadowColor(0, 0, 0);
   GameFontNormal:SetShadowOffset(1, -1);

   GameFontHighlight:SetFont(CLEAR_FONT, 14);

   GameFontDisable:SetFont(CLEAR_FONT, 14);
   GameFontDisable:SetTextColor(0.6, 0.6, 0.6);

   GameFontGreen:SetFont(CLEAR_FONT, 14);

   GameFontRed:SetFont(CLEAR_FONT, 14);

   GameFontWhite:SetFont(CLEAR_FONT, 12);

   GameFontBlack:SetFont(CLEAR_FONT, 12);


-- 小字体
--------------------------------------------------------------------------------

   GameFontNormalSmall:SetFont(CLEAR_FONT, 12);
   GameFontNormalSmall:SetShadowColor(0, 0, 0);
   GameFontNormalSmall:SetShadowOffset(1, -1);

   GameFontDisableSmall:SetFont(CLEAR_FONT, 12);
   GameFontDisableSmall:SetTextColor(0.6, 0.6, 0.6);

   GameFontDarkGraySmall:SetFont(CLEAR_FONT, 12);
   GameFontDarkGraySmall:SetTextColor(0.4, 0.4, 0.4);

   GameFontGreenSmall:SetFont(CLEAR_FONT, 12);

   GameFontRedSmall:SetFont(CLEAR_FONT, 12);

   GameFontHighlightSmall:SetFont(CLEAR_FONT, 12);

   GameFontHighlightSmallOutline:SetFont(CLEAR_FONT, 12, "OUTLINE");


-- 大字体
--------------------------------------------------------------------------------

   GameFontNormalLarge:SetFont(CLEAR_FONT, 14);
   GameFontNormalLarge:SetShadowColor(0, 0, 0);
   GameFontNormalLarge:SetShadowOffset(1, -1);

   GameFontHighlightLarge:SetFont(CLEAR_FONT, 14);

   GameFontDisableLarge:SetFont(CLEAR_FONT, 14);
   GameFontDisableLarge:SetTextColor(0.6, 0.6, 0.6);

   GameFontGreenLarge:SetFont(CLEAR_FONT, 14);

   GameFontRedLarge:SetFont(CLEAR_FONT, 14);


-- 数字字体：拍卖行价位、钱数、按键数、物品数目
--------------------------------------------------------------------------------

   NumberFontNormal:SetFont(CLEAR_FONT_NUMBER, 13, "OUTLINE");

   NumberFontNormalYellow:SetFont(CLEAR_FONT_NUMBER, 13, "OUTLINE");

   NumberFontNormalSmall:SetFont(CLEAR_FONT_NUMBER, 11, "OUTLINE");

   NumberFontNormalSmallGray:SetFont(CLEAR_FONT_NUMBER, 11, "OUTLINE");

   NumberFontNormalLarge:SetFont(CLEAR_FONT_NUMBER, 15, "OUTLINE");

   NumberFontNormalHuge:SetFont(CLEAR_FONT_DAMAGE, 24, "THICKOUTLINE");


-- 聊天栏字体
--------------------------------------------------------------------------------

   ChatFontNormal:SetFont(CLEAR_FONT, 14);


-- 任务面板字体
--------------------------------------------------------------------------------

   QuestTitleFont:SetFont(CLEAR_FONT_QUESTTITLE, 18);
   QuestTitleFont:SetShadowColor(0.54, 0.4, 0.1);
   QuestTitleFont:SetShadowOffset(1, -1);

   QuestFont:SetFont(CLEAR_FONT_QUEST, 14);
   QuestFont:SetTextColor(0.15, 0.09, 0.04);

   QuestFontNormalSmall:SetFont(CLEAR_FONT, 12);
   QuestFontNormalSmall:SetShadowColor(0.54, 0.4, 0.1);
   QuestFontNormalSmall:SetShadowOffset(1, -1);

   QuestFontHighlight:SetFont(CLEAR_FONT_QUEST, 13);


-- 物品说明用字体
--------------------------------------------------------------------------------

   ItemTextFontNormal:SetFont(CLEAR_FONT_QUEST, 15);


-- 技能书用字体
--------------------------------------------------------------------------------

   SubSpellFont:SetFont(CLEAR_FONT_QUEST, 12);


-- 对话框按钮
--------------------------------------------------------------------------------

   DialogButtonNormalText:SetFont(CLEAR_FONT, 13);

   DialogButtonHighlightText:SetFont(CLEAR_FONT, 13);


-- 区域切换时提示用字体: On-screen Notifications
--------------------------------------------------------------------------------

   ZoneTextFont:SetFont(CLEAR_FONT_ZONE, 112, "THICKOUTLINE");
   ZoneTextFont:SetShadowColor(0, 0, 0);
   ZoneTextFont:SetShadowOffset(1, -1);

   SubZoneTextFont:SetFont(CLEAR_FONT_ZONE, 26, "THICKOUTLINE");


-- 系统错误信息用字体
--------------------------------------------------------------------------------

   ErrorFont:SetFont(CLEAR_FONT, 14);


-- 状态栏字体
--------------------------------------------------------------------------------

   TextStatusBarText:SetFont(CLEAR_FONT_NUMBER, 13, "OUTLINE");

   TextStatusBarTextSmall:SetFont(CLEAR_FONT, 14);


-- 战斗错误提示用字体: 比如"另外一个动作正在进行中", "不能在昏迷状态下做这个动作"等.
--------------------------------------------------------------------------------

   CombatLogFont:SetFont(CLEAR_FONT, 14);


-- 提示面板字体
--------------------------------------------------------------------------------

   GameTooltipText:SetFont(CLEAR_FONT, 12);

   GameTooltipTextSmall:SetFont(CLEAR_FONT, 12);

   GameTooltipHeaderText:SetFont(CLEAR_FONT, 14);


-- 世界地图字体
--------------------------------------------------------------------------------
   WorldMapTextFont:SetFont(CLEAR_FONT_ZONE, 102, "THICKOUTLINE");
   WorldMapTextFont:SetShadowColor(0, 0, 0);
   WorldMapTextFont:SetShadowOffset(1, -1);

-- 邮件字体
--------------------------------------------------------------------------------
   MailTextFontNormal:SetFont(CLEAR_FONT_QUEST, 15);
   MailTextFontNormal:SetTextColor(0.15, 0.09, 0.04);
   MailTextFontNormal:SetShadowColor(0.54, 0.4, 0.1);
   MailTextFontNormal:SetShadowOffset(1, -1);


-- 拍卖行发货单字体
--------------------------------------------------------------------------------
   InvoiceTextFontNormal:SetFont(CLEAR_FONT_QUEST, 13);
   InvoiceTextFontNormal:SetTextColor(0.15, 0.09, 0.04);

   InvoiceTextFontSmall:SetFont(CLEAR_FONT_QUEST, 11);
   InvoiceTextFontSmall:SetTextColor(0.15, 0.09, 0.04);

end




--------------------------------------------------------------------------------
-- Apply all the first time explicitly, for sanity
--------------------------------------------------------------------------------

ClearFont:ApplySystemFonts()
