mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-12-02 08:35:12 -05:00
Fix #615 Be smarter when looking for font resources
This commit is contained in:
parent
490f72ceeb
commit
c1e60f31f5
@ -15,7 +15,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RES_FOLDER
|
#ifndef RES_FOLDER
|
||||||
#define RES_FOLDER ""
|
#define RES_FOLDER L""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GC_DRAW_COUNT_PERIOD 50
|
#define GC_DRAW_COUNT_PERIOD 50
|
||||||
@ -217,20 +217,29 @@ void GLFont::loadFontOnce() {
|
|||||||
wxString resourceFolder = RES_FOLDER;
|
wxString resourceFolder = RES_FOLDER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//full font file path
|
|
||||||
wxFileName fontDefFileName = wxFileName(resourceFolder + L"/" + fontDefFileSource);
|
|
||||||
|
|
||||||
if (!fontDefFileName.Exists()) {
|
|
||||||
wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath());
|
wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath());
|
||||||
|
|
||||||
//Full Path where the fonts are, including file name
|
//1) First try : RES_FOLDER/fonts/*
|
||||||
fontDefFileName = wxFileName(exePath.GetPath() + L"/"+ fontDefFileSource);
|
wxFileName fontDefFileName = wxFileName(resourceFolder + L"/" + fontDefFileSource);
|
||||||
|
|
||||||
if (!fontDefFileName.FileExists()) {
|
bool fontFilePathFound = fontDefFileName.Exists();
|
||||||
std::cout << "Font file " << fontDefFileName.GetFullPath() << " does not exist?" << std::endl;
|
|
||||||
return;
|
// 2) Second try: [Cubic exe path]/RES_FOLDER/fonts/*
|
||||||
|
if (!fontFilePathFound) {
|
||||||
|
|
||||||
|
fontDefFileName = wxFileName(exePath.GetPath() + L"/" + RES_FOLDER + L"/" + fontDefFileSource);
|
||||||
|
fontFilePathFound = fontDefFileName.Exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3) Third try: [Cubic exe path]/fonts/*
|
||||||
|
if (!fontFilePathFound) {
|
||||||
|
|
||||||
|
fontDefFileName = wxFileName(exePath.GetPath() + L"/" + fontDefFileSource);
|
||||||
|
fontFilePathFound = fontDefFileName.Exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fontFilePathFound) {
|
||||||
|
|
||||||
if (!fontDefFileName.IsFileReadable()) {
|
if (!fontDefFileName.IsFileReadable()) {
|
||||||
std::cout << "Font file " << fontDefFileName.GetFullPath() << " is not readable?" << std::endl;
|
std::cout << "Font file " << fontDefFileName.GetFullPath() << " is not readable?" << std::endl;
|
||||||
return;
|
return;
|
||||||
@ -238,8 +247,8 @@ void GLFont::loadFontOnce() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (!fontDefFileName.IsFileReadable()) {
|
if (!fontDefFileName.FileExists()) {
|
||||||
std::cout << "Font file " << fontDefFileName.GetFullPath() << " is not readable?" << std::endl;
|
std::cout << "Font file " << fontDefFileName.GetFullPath() << " does not exist?" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user