Added Korean font support. (#2718)
This commit is contained in:
parent
a822da4af3
commit
4e294162fb
@ -34,23 +34,34 @@ namespace big
|
|||||||
ImGui_ImplDX11_Init(m_d3d_device, m_d3d_device_context);
|
ImGui_ImplDX11_Init(m_d3d_device, m_d3d_device_context);
|
||||||
ImGui_ImplWin32_Init(g_pointers->m_hwnd);
|
ImGui_ImplWin32_Init(g_pointers->m_hwnd);
|
||||||
|
|
||||||
folder windows_fonts(std::filesystem::path(std::getenv("SYSTEMROOT")) / "Fonts");
|
const auto fonts_folder = std::filesystem::path(std::getenv("SYSTEMROOT")) / "Fonts";
|
||||||
|
|
||||||
file font_file_path = windows_fonts.get_file("./msyh.ttc");
|
file font_file(fonts_folder / "msyh.ttc");
|
||||||
if (!font_file_path.exists())
|
if (!font_file.exists())
|
||||||
font_file_path = windows_fonts.get_file("./msyh.ttf");
|
font_file = file(fonts_folder / "msyh.ttf");
|
||||||
if (!font_file_path.exists())
|
|
||||||
|
if (*g_pointers->m_gta.m_language == 8)
|
||||||
|
{
|
||||||
|
font_file = file(fonts_folder / "malgun.ttf");
|
||||||
|
if (!font_file.exists())
|
||||||
|
{
|
||||||
|
LOG(WARNING) << "Korean language detected, but failed to find Korean font, you may not be able to read the menu!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!font_file.exists())
|
||||||
{
|
{
|
||||||
LOG(WARNING) << "Failed to find msyh font, falling back to Arial!";
|
LOG(WARNING) << "Failed to find msyh font, falling back to Arial!";
|
||||||
font_file_path = windows_fonts.get_file("./arial.ttf");
|
font_file = file(fonts_folder / "arial.ttf");
|
||||||
}
|
}
|
||||||
auto font_file = std::ifstream(font_file_path.get_path(), std::ios::binary | std::ios::ate);
|
|
||||||
const auto font_data_size = static_cast<int>(font_file.tellg());
|
auto font_file_stream = std::ifstream(font_file.get_path(), std::ios::binary | std::ios::ate);
|
||||||
|
const auto font_data_size = static_cast<int>(font_file_stream.tellg());
|
||||||
const auto font_data = std::make_unique<uint8_t[]>(font_data_size);
|
const auto font_data = std::make_unique<uint8_t[]>(font_data_size);
|
||||||
|
|
||||||
font_file.seekg(0);
|
font_file_stream.seekg(0);
|
||||||
font_file.read(reinterpret_cast<char*>(font_data.get()), font_data_size);
|
font_file_stream.read(reinterpret_cast<char*>(font_data.get()), font_data_size);
|
||||||
font_file.close();
|
font_file_stream.close();
|
||||||
|
|
||||||
auto& io = ImGui::GetIO();
|
auto& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -65,7 +76,10 @@ namespace big
|
|||||||
&fnt_cfg,
|
&fnt_cfg,
|
||||||
io.Fonts->GetGlyphRangesDefault());
|
io.Fonts->GetGlyphRangesDefault());
|
||||||
fnt_cfg.MergeMode = true;
|
fnt_cfg.MergeMode = true;
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
if (*g_pointers->m_gta.m_language == 8)
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesKorean());
|
||||||
|
else
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
}
|
}
|
||||||
@ -77,7 +91,10 @@ namespace big
|
|||||||
|
|
||||||
g.window.font_title = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 28.f, &fnt_cfg);
|
g.window.font_title = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 28.f, &fnt_cfg);
|
||||||
fnt_cfg.MergeMode = true;
|
fnt_cfg.MergeMode = true;
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
if (*g_pointers->m_gta.m_language == 8)
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesKorean());
|
||||||
|
else
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
}
|
}
|
||||||
@ -89,7 +106,10 @@ namespace big
|
|||||||
|
|
||||||
g.window.font_sub_title = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 24.f, &fnt_cfg);
|
g.window.font_sub_title = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 24.f, &fnt_cfg);
|
||||||
fnt_cfg.MergeMode = true;
|
fnt_cfg.MergeMode = true;
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
if (*g_pointers->m_gta.m_language == 8)
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesKorean());
|
||||||
|
else
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
}
|
}
|
||||||
@ -101,7 +121,10 @@ namespace big
|
|||||||
|
|
||||||
g.window.font_small = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 18.f, &fnt_cfg);
|
g.window.font_small = io.Fonts->AddFontFromMemoryTTF(const_cast<uint8_t*>(font_storopia), sizeof(font_storopia), 18.f, &fnt_cfg);
|
||||||
fnt_cfg.MergeMode = true;
|
fnt_cfg.MergeMode = true;
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
if (*g_pointers->m_gta.m_language == 8)
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesKorean());
|
||||||
|
else
|
||||||
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||||
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user