Use exe path to search for fonts
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "resource.h"
|
||||
#include "AsuroTool.h"
|
||||
|
||||
const size_t MAX_FONT_PATH_LENGTH = 2048;
|
||||
const UINT TRAY_ID = 420;
|
||||
const UINT WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
||||
|
||||
@@ -46,20 +47,30 @@ int main()
|
||||
|
||||
void init(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
std::wstring appPath;
|
||||
getAppDir(appPath);
|
||||
char appPathStr[MAX_FONT_PATH_LENGTH];
|
||||
HRESULT convResult = WideCharToMultiByte(CP_UTF8, NULL, &appPath[0], -1, appPathStr, MAX_FONT_PATH_LENGTH, NULL, nullptr);
|
||||
isError(convResult, "Failed to convert path: ");
|
||||
|
||||
// sad :(
|
||||
gDrawData = &drawData;
|
||||
gAppData = &appData;
|
||||
|
||||
// Load text font
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->AddFontFromFileTTF("Montserrat-Regular.ttf", 18.0f);
|
||||
std::string fontPath = std::string(appPathStr);
|
||||
fontPath.append("\\Montserrat-Regular.ttf");
|
||||
io.Fonts->AddFontFromFileTTF(fontPath.c_str(), 18.0f);
|
||||
|
||||
// Load icon font
|
||||
static const ImWchar icons_ranges[] = { 0xEA01, 0xF2DF, 0 };
|
||||
ImFontConfig icons_config;
|
||||
icons_config.MergeMode = true;
|
||||
icons_config.PixelSnapH = true;
|
||||
io.Fonts->AddFontFromFileTTF("remixicon.ttf", 14.0f, &icons_config, icons_ranges);
|
||||
std::string iconFontPath = std::string(appPathStr);
|
||||
iconFontPath.append("\\remixicon.ttf");
|
||||
io.Fonts->AddFontFromFileTTF(iconFontPath.c_str(), 14.0f, &icons_config, icons_ranges);
|
||||
|
||||
// Set window icon
|
||||
HINSTANCE instance = GetModuleHandle(NULL);
|
||||
|
||||
Reference in New Issue
Block a user