diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 3aa6bb41..a94296ae 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -33,6 +33,7 @@ #include "checksum.h" #include #include "sound_renderer.h" +#include "font_gl.h" #include "leak_dumper.h" #ifndef WIN32 @@ -44,6 +45,7 @@ using namespace std; using namespace Shared::Platform; using namespace Shared::Util; using namespace Shared::Graphics; +using namespace Shared::Graphics::Gl; namespace Glest{ namespace Game{ @@ -574,6 +576,7 @@ int glestMain(int argc, char** argv){ try{ std::auto_ptr preCacheThread; Config &config = Config::getInstance(); + FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str())); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/shared_lib/include/graphics/gl/font_gl.h b/source/shared_lib/include/graphics/gl/font_gl.h index 85aa47ac..72eaf8ac 100644 --- a/source/shared_lib/include/graphics/gl/font_gl.h +++ b/source/shared_lib/include/graphics/gl/font_gl.h @@ -14,20 +14,27 @@ #include "font.h" #include "opengl.h" +#include #include "leak_dumper.h" -namespace Shared{ namespace Graphics{ namespace Gl{ +using namespace std; + +namespace Shared { namespace Graphics { namespace Gl { // ===================================================== // class FontGl // ===================================================== -class FontGl{ +class FontGl { protected: GLuint handle; + static string default_fonttype; public: GLuint getHandle() const {return handle;} + + static string getDefault_fontType() { return default_fonttype; } + static void setDefault_fontType(string value) { default_fonttype = value; } }; // ===================================================== diff --git a/source/shared_lib/sources/graphics/gl/font_gl.cpp b/source/shared_lib/sources/graphics/gl/font_gl.cpp index e243f55c..e54bc58e 100644 --- a/source/shared_lib/sources/graphics/gl/font_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/font_gl.cpp @@ -23,6 +23,8 @@ using namespace Platform; // class Font2DGl // ===================================================== +string FontGl::default_fonttype = "fixed"; + void Font2DGl::init(){ assertGl(); diff --git a/source/shared_lib/sources/platform/unix/gl_wrap.cpp b/source/shared_lib/sources/platform/unix/gl_wrap.cpp index 11eab476..383b5dea 100644 --- a/source/shared_lib/sources/platform/unix/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/unix/gl_wrap.cpp @@ -12,7 +12,6 @@ #include #include - #include #include "opengl.h" @@ -21,15 +20,13 @@ #include "util.h" #include "window.h" #include -//#include +#include "font_gl.h" #include "leak_dumper.h" using namespace Shared::Graphics::Gl; using namespace Shared::Util; -namespace Shared{ namespace Platform{ - - +namespace Shared { namespace Platform { // ====================================== // Global Fcs @@ -42,8 +39,16 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, throw std::runtime_error("Couldn't create font: display is 0"); } XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str()); - if(!fontInfo) { - throw std::runtime_error("Font not found."); + if(fontInfo == NULL) { + string default_font = FontGl::getDefault_fontType(); + + //throw std::runtime_error("Font not found: [" + type + "]"); + SystemFlags::OutputDebug(SystemFlags::debugError,"Font not found [%s] trying to fallback to [%s]\n",type.c_str(),default_font.c_str()); + + fontInfo = XLoadQueryFont(display, default_font.c_str()); + if(fontInfo == NULL) { + throw std::runtime_error("Font not found: [" + type + "]"); + } } // we need the height of 'a' which sould ~ be half ascent+descent @@ -53,7 +58,8 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, if(i < fontInfo->min_char_or_byte2 || i > fontInfo->max_char_or_byte2) { metrics.setWidth(i, static_cast(6)); - } else { + } + else { int p = i - fontInfo->min_char_or_byte2; metrics.setWidth(i, static_cast ( fontInfo->per_char[p].width));