フォントをバイナリに入れ込む

守矢諏訪子 <suwako@076.moe>、2026-06-26 06:39
コミット 6957179842d8ab6c6b66dc025d9f58502c8845f8 ・親 ee9e101 ・ファイルを見る

1個のファイル、+11 -2

@@ -34,6 +34,8 @@
3434 */
3535 #include <gui/guiengine.hh>
3636 #include <util/glfwpp.hh>
37+#include "../../ass/NotoSansCJKjp-Regular.h"
38+#include "../../ass/NotoMono-Regular.h"
3739
3840 namespace gui {
3941 GuiEngine::GuiEngine(glfwpp::Window *window) {
@@ -42,8 +44,15 @@
4244 ImGui::CreateContext();
4345 ImGuiIO &io = ImGui::GetIO();
4446 (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+
4756 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
4857 io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
4958 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;