mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-16 17:11:46 -05:00
Merge pull request #85 from cjcliffe/resource_finder
Resource finder for fonts
This commit is contained in:
commit
e7297beaa3
@ -153,8 +153,29 @@ std::string GLFont::getParamValue(std::string param_str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GLFont::loadFont(std::string fontFile) {
|
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.FileExists()) {
|
||||||
|
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;
|
std::ifstream input;
|
||||||
input.open(fontFileSource.c_str(), std::ios::in);
|
input.open(fontFileSource.c_str(), std::ios::in);
|
||||||
@ -215,8 +236,8 @@ void GLFont::loadFont(std::string fontFile) {
|
|||||||
std::string paramValue = getParamValue(param);
|
std::string paramValue = getParamValue(param);
|
||||||
|
|
||||||
if (paramKey == "file") {
|
if (paramKey == "file") {
|
||||||
imageFile = RES_FOLDER;
|
wxFileName imgFileName = wxFileName(resourceFolder, paramValue);
|
||||||
imageFile.append(paramValue);
|
imageFile = imgFileName.GetFullPath(wxPATH_NATIVE).ToStdString();
|
||||||
}
|
}
|
||||||
// std::cout << "[" << paramKey << "] = '" << paramValue << "'" << std::endl;
|
// std::cout << "[" << paramKey << "] = '" << paramValue << "'" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
#include "wx/glcanvas.h"
|
#include "wx/glcanvas.h"
|
||||||
|
#include "wx/filename.h"
|
||||||
|
#include "wx/stdpaths.h"
|
||||||
|
|
||||||
class GLFontChar {
|
class GLFontChar {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user