diff --git a/src/util/GLFont.cpp b/src/util/GLFont.cpp index ad9a54d..9b1c0f9 100644 --- a/src/util/GLFont.cpp +++ b/src/util/GLFont.cpp @@ -153,9 +153,30 @@ std::string GLFont::getParamValue(std::string param_str) { } void GLFont::loadFont(std::string fontFile) { - fontFileSource = RES_FOLDER; - fontFileSource.append(fontFile); + + std::string resourceFolder = RES_FOLDER; + wxFileName fontFileName = wxFileName(resourceFolder, fontFile); + + if (!fontFileName.Exists()) { + wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath()); + fontFileName = wxFileName(exePath.GetPath(), fontFile); + resourceFolder = exePath.GetPath(); + } + + fontFileSource = fontFileName.GetFullPath(wxPATH_NATIVE).ToStdString(); + + if (!fontFileName.IsFileReadable()) { + std::cout << "Font file " << fontFileSource << " does not exist?" << std::endl; + return; + } + + if (!fontFileName.IsFileReadable()) { + std::cout << "Font file " << fontFileSource << " is not readable?" << std::endl; + return; + } + + std::ifstream input; input.open(fontFileSource.c_str(), std::ios::in); @@ -215,8 +236,8 @@ void GLFont::loadFont(std::string fontFile) { std::string paramValue = getParamValue(param); if (paramKey == "file") { - imageFile = RES_FOLDER; - imageFile.append(paramValue); + wxFileName imgFileName = wxFileName(resourceFolder, paramValue); + imageFile = imgFileName.GetFullPath(wxPATH_NATIVE).ToStdString(); } // std::cout << "[" << paramKey << "] = '" << paramValue << "'" << std::endl; } diff --git a/src/util/GLFont.h b/src/util/GLFont.h index 7936553..503dec1 100644 --- a/src/util/GLFont.h +++ b/src/util/GLFont.h @@ -5,6 +5,8 @@ #include #include "lodepng.h" #include "wx/glcanvas.h" +#include "wx/filename.h" +#include "wx/stdpaths.h" class GLFontChar { public: