Merge pull request #417 from awaysoft/add_simplified_chinese_support

Add font support for chinese, japanese, korean.
This commit is contained in:
heinrich5991 2016-03-03 16:48:28 +01:00
commit e8be975f5b
5 changed files with 35 additions and 2 deletions

Binary file not shown.

View file

@ -52,6 +52,14 @@ italian
== Italiano
== 380
japanese
== 日本語
== 392
korean
== 한국어
== 410
kyrgyz
== Кыргызча
== 417
@ -80,6 +88,10 @@ serbian
== Srpski
== 688
simplified_chinese
== 简体中文
== 156
slovak
== Slovensky
== 703

View file

@ -1187,6 +1187,23 @@ void CMenus::RenderLanguageSelection(CUIRect MainView)
{
str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile));
g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName, Storage(), Console());
// Load Font
static CFont *pDefaultFont = 0;
char aFilename[512];
const char *pFontFile = "fonts/DejaVuSansCJKName.ttf";
if (str_find(g_Config.m_ClLanguagefile, "chinese") != NULL || str_find(g_Config.m_ClLanguagefile, "japanese") != NULL ||
str_find(g_Config.m_ClLanguagefile, "korean") != NULL)
pFontFile = "fonts/DejavuWenQuanYiMicroHei.ttf";
IOHANDLE File = Storage()->OpenFile(pFontFile, IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));
if(File)
{
io_close(File);
pDefaultFont = TextRender()->LoadFont(aFilename);
TextRender()->SetDefaultFont(pDefaultFont);
}
if(!pDefaultFont)
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load font. filename='%s'", pFontFile);
}
}

View file

@ -294,7 +294,11 @@ void CGameClient::OnInit()
// load default font
static CFont *pDefaultFont = 0;
char aFilename[512];
IOHANDLE File = Storage()->OpenFile("fonts/DejaVuSans.ttf", IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));
const char *pFontFile = "fonts/DejaVuSansCJKName.ttf";
if (str_find(g_Config.m_ClLanguagefile, "chinese") != NULL || str_find(g_Config.m_ClLanguagefile, "japanese") != NULL ||
str_find(g_Config.m_ClLanguagefile, "korean") != NULL)
pFontFile = "fonts/DejavuWenQuanYiMicroHei.ttf";
IOHANDLE File = Storage()->OpenFile(pFontFile, IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));
if(File)
{
io_close(File);
@ -302,7 +306,7 @@ void CGameClient::OnInit()
TextRender()->SetDefaultFont(pDefaultFont);
}
if(!pDefaultFont)
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load font. filename='fonts/DejaVuSans.ttf'");
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load font. filename='%s'", pFontFile);
// init all components
for(int i = m_All.m_Num-1; i >= 0; --i)