fix(Renderer): Cyrillic on Proton (#589)

This commit is contained in:
Yimura 2022-11-12 20:22:02 +01:00 committed by GitHub
parent e6ce363963
commit f68d68a92b

View File

@ -42,24 +42,15 @@ namespace big
std::filesystem::path(std::getenv("SYSTEMROOT")) / "Fonts"
);
file chinese_font_file = windows_fonts.get_file("./msyh.ttc");
if (!chinese_font_file.exists())
chinese_font_file = windows_fonts.get_file("./msyh.ttf");
auto font_file = std::ifstream(chinese_font_file.get_path(), std::ios::binary | std::ios::ate);
const auto chinese_font_data_size = static_cast<int>(font_file.tellg());
const auto chinese_font_data = std::make_unique<std::uint8_t[]>(chinese_font_data_size);
file font_file_path = windows_fonts.get_file("./msyh.ttc");
if (!font_file_path.exists())
font_file_path = windows_fonts.get_file("./msyh.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());
const auto font_data = std::make_unique<std::uint8_t[]>(font_data_size);
font_file.seekg(0);
font_file.read(reinterpret_cast<char*>(chinese_font_data.get()), chinese_font_data_size);
font_file.close();
file cyrillic_font_file = windows_fonts.get_file("./Segoeui.ttf");
font_file.open(cyrillic_font_file.get_path(), std::ios::binary | std::ios::ate);
const auto cyrillic_font_data_size = static_cast<int>(font_file.tellg());
const auto cyrillic_font_data = std::make_unique<std::uint8_t[]>(cyrillic_font_data_size);
font_file.seekg(0);
font_file.read(reinterpret_cast<char*>(cyrillic_font_data.get()), cyrillic_font_data_size);
font_file.read(reinterpret_cast<char*>(font_data.get()), font_data_size);
font_file.close();
auto& io = ImGui::GetIO();
@ -71,8 +62,8 @@ namespace big
io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 20.f, &fnt_cfg, io.Fonts->GetGlyphRangesDefault());
fnt_cfg.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF(chinese_font_data.get(), chinese_font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(cyrillic_font_data.get(), cyrillic_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->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
io.Fonts->Build();
}
@ -83,8 +74,8 @@ namespace big
g->window.font_title = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 28.f, &fnt_cfg);
fnt_cfg.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF(chinese_font_data.get(), chinese_font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(cyrillic_font_data.get(), cyrillic_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->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
io.Fonts->Build();
}
@ -95,8 +86,8 @@ namespace big
g->window.font_sub_title = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 24.f, &fnt_cfg);
fnt_cfg.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF(chinese_font_data.get(), chinese_font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(cyrillic_font_data.get(), cyrillic_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->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
io.Fonts->Build();
}
@ -107,8 +98,8 @@ namespace big
g->window.font_small = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 18.f, &fnt_cfg);
fnt_cfg.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF(chinese_font_data.get(), chinese_font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(cyrillic_font_data.get(), cyrillic_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->GetGlyphRangesChineseSimplifiedCommon());
io.Fonts->AddFontFromMemoryTTF(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesCyrillic());
io.Fonts->Build();
}