MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / loadFont

Function loadFont

apps/tools/Studio/main.cpp:85–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85static void loadFont()
86{
87 ImGuiIO& io = ImGui::GetIO();
88 io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader());
89 ImFontConfig cfg;
90 cfg.FontLoaderFlags = ImGuiFreeTypeLoaderFlags_ForceAutoHint;
91
92#ifdef _WIN32
93 const char* fontPath = "C:\\Windows\\Fonts\\segoeui.ttf";
94 const char* monoPath = "C:\\Windows\\Fonts\\consola.ttf";
95#else
96 const char* sansPaths[] = {"/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf",
97 "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", "/usr/share/fonts/TTF/DejaVuSans.ttf",
98 nullptr};
99 const char* monoPaths[] = {"/usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf",
100 "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
101 "/usr/share/fonts/TTF/DejaVuSansMono.ttf", nullptr};
102 const char* fontPath = findFont(sansPaths);
103 const char* monoPath = findFont(monoPaths);
104#endif
105
106 if (!fontPath || !io.Fonts->AddFontFromFileTTF(fontPath, 16.0f, &cfg))
107 {
108 fprintf(stderr, "Sans font not found, using default\n");
109 io.Fonts->AddFontDefault(&cfg);
110 }
111
112 if (monoPath)
113 monoFont = io.Fonts->AddFontFromFileTTF(monoPath, 14.0f, &cfg);
114 if (!monoFont)
115 monoFont = io.Fonts->AddFontDefault(&cfg);
116}
117
118static std::string iniFilePath;
119

Callers 1

mainFunction · 0.85

Calls 1

findFontFunction · 0.85

Tested by

no test coverage detected