フォントをバイナリに入れ込む
守矢諏訪子 <suwako@076.moe>、2026-06-26 06:39
コミット 6957179842d8ab6c6b66dc025d9f58502c8845f8
・親 ee9e101
・ファイルを見る
1個のファイル、+11 -2
| @@ -34,6 +34,8 @@ | ||
| 34 | 34 | */ |
| 35 | 35 | #include <gui/guiengine.hh> |
| 36 | 36 | #include <util/glfwpp.hh> |
| 37 | +#include "../../ass/NotoSansCJKjp-Regular.h" | |
| 38 | +#include "../../ass/NotoMono-Regular.h" | |
| 37 | 39 | |
| 38 | 40 | namespace gui { |
| 39 | 41 | GuiEngine::GuiEngine(glfwpp::Window *window) { |
| @@ -42,8 +44,15 @@ | ||
| 42 | 44 | ImGui::CreateContext(); |
| 43 | 45 | ImGuiIO &io = ImGui::GetIO(); |
| 44 | 46 | (void)io; |
| 45 | - m_CjkFont = io.Fonts->AddFontFromFileTTF("NotoSansCJKjp-Regular.otf", 16.f, nullptr, io.Fonts->GetGlyphRangesJapanese()); | |
| 46 | - m_MonoFont = io.Fonts->AddFontFromFileTTF("NotoMono-Regular.ttf", 16.f, nullptr, io.Fonts->GetGlyphRangesJapanese()); | |
| 47 | + | |
| 48 | + ImFontConfig cfg; | |
| 49 | + cfg.FontDataOwnedByAtlas = false; | |
| 50 | + | |
| 51 | + m_CjkFont = io.Fonts->AddFontFromMemoryTTF(__NotoSansCJKjp_Regular_otf, __NotoSansCJKjp_Regular_otf_len, 16.f, &cfg, io.Fonts->GetGlyphRangesJapanese()); | |
| 52 | + m_MonoFont = io.Fonts->AddFontFromMemoryTTF(__NotoMono_Regular_ttf, __NotoMono_Regular_ttf_len, 16.f, &cfg, io.Fonts->GetGlyphRangesJapanese()); | |
| 53 | + //m_CjkFont = io.Fonts->AddFontFromFileTTF("NotoSansCJKjp-Regular.otf", 16.f, nullptr, io.Fonts->GetGlyphRangesJapanese()); | |
| 54 | + //m_MonoFont = io.Fonts->AddFontFromFileTTF("NotoMono-Regular.ttf", 16.f, nullptr, io.Fonts->GetGlyphRangesJapanese()); | |
| 55 | + | |
| 47 | 56 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; |
| 48 | 57 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; |
| 49 | 58 | io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; |