mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-10 06:18:57 -05:00
If font resource not found then try executable path.
This commit is contained in:
parent
8496287455
commit
44e73839a8
@ -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;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <sstream>
|
||||
#include "lodepng.h"
|
||||
#include "wx/glcanvas.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/stdpaths.h"
|
||||
|
||||
class GLFontChar {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user