mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-01-05 17:13:29 +08:00
feat(Renderer): Merge Chinese font into other menu fonts (#487)
This commit is contained in:
parent
485243f21a
commit
5b6ff174be
@ -314,7 +314,6 @@ namespace big
|
||||
|
||||
ImFont* font_title = nullptr;
|
||||
ImFont* font_sub_title = nullptr;
|
||||
ImFont* font_normal = nullptr;
|
||||
ImFont* font_small = nullptr;
|
||||
ImFont* font_icon = nullptr;
|
||||
|
||||
|
@ -38,20 +38,66 @@ namespace big
|
||||
ImGui_ImplDX11_Init(m_d3d_device.Get(), m_d3d_device_context.Get());
|
||||
ImGui_ImplWin32_Init(g_pointers->m_hwnd);
|
||||
|
||||
ImFontConfig font_storopia_cfg{};
|
||||
font_storopia_cfg.FontDataOwnedByAtlas = false;
|
||||
std::strcpy(font_storopia_cfg.Name, "Storopia");
|
||||
m_font = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 20.f, &font_storopia_cfg);
|
||||
auto font_file = std::ifstream(file("C:/Windows/Fonts/msyh.ttc").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*>(font_data.get()), font_data_size);
|
||||
font_file.close();
|
||||
|
||||
g->window.font_title = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 28.f, &font_storopia_cfg);
|
||||
g->window.font_sub_title = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 24.f, &font_storopia_cfg);
|
||||
g->window.font_normal = m_font;
|
||||
g->window.font_small = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_storopia), sizeof(font_storopia), 18.f, &font_storopia_cfg);
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
ImFontConfig font_icons_cfg{};
|
||||
font_icons_cfg.FontDataOwnedByAtlas = false;
|
||||
std::strcpy(font_icons_cfg.Name, "Icons");
|
||||
g->window.font_icon = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_icons), sizeof(font_icons), 24.f, &font_icons_cfg);
|
||||
{
|
||||
ImFontConfig fnt_cfg{};
|
||||
fnt_cfg.FontDataOwnedByAtlas = false;
|
||||
strcpy(fnt_cfg.Name, "Fnt20px");
|
||||
|
||||
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(font_data.get(), font_data_size, 20.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->Build();
|
||||
}
|
||||
|
||||
{
|
||||
ImFontConfig fnt_cfg{};
|
||||
fnt_cfg.FontDataOwnedByAtlas = false;
|
||||
strcpy(fnt_cfg.Name, "Fnt28px");
|
||||
|
||||
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(font_data.get(), font_data_size, 28.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->Build();
|
||||
}
|
||||
|
||||
{
|
||||
ImFontConfig fnt_cfg{};
|
||||
fnt_cfg.FontDataOwnedByAtlas = false;
|
||||
strcpy(fnt_cfg.Name, "Fnt24px");
|
||||
|
||||
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(font_data.get(), font_data_size, 24.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->Build();
|
||||
}
|
||||
|
||||
{
|
||||
ImFontConfig fnt_cfg{};
|
||||
fnt_cfg.FontDataOwnedByAtlas = false;
|
||||
strcpy(fnt_cfg.Name, "Fnt18px");
|
||||
|
||||
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(font_data.get(), font_data_size, 18.f, &fnt_cfg, ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->Build();
|
||||
}
|
||||
|
||||
{
|
||||
ImFontConfig font_icons_cfg{};
|
||||
font_icons_cfg.FontDataOwnedByAtlas = false;
|
||||
std::strcpy(font_icons_cfg.Name, "Icons");
|
||||
g->window.font_icon = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(font_icons), sizeof(font_icons), 24.f, &font_icons_cfg);
|
||||
}
|
||||
|
||||
g_gui.dx_init();
|
||||
g_renderer = this;
|
||||
|
@ -17,9 +17,6 @@ namespace big
|
||||
|
||||
void wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
public:
|
||||
ImFont* m_font;
|
||||
|
||||
private:
|
||||
comptr<IDXGISwapChain> m_dxgi_swapchain;
|
||||
comptr<ID3D11Device> m_d3d_device;
|
||||
|
@ -267,4 +267,4 @@ workspace "BigBaseV2"
|
||||
filter "configurations:Release"
|
||||
flags { "FatalWarnings", "NoManifest" }
|
||||
defines { "RELEASE" }
|
||||
optimize "speed"
|
||||
optimize "speed"
|
Loading…
x
Reference in New Issue
Block a user