From 3dfd31648441fae47258a681f4d9021e8aca3f9e Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 1 Nov 2011 23:51:28 +0000 Subject: [PATCH] fixed legacyfont --- source/glest_game/main/main.cpp | 3 ++- source/shared_lib/sources/graphics/font.cpp | 2 +- source/shared_lib/sources/graphics/gl/font_gl.cpp | 12 ++++++++---- source/shared_lib/sources/platform/unix/gl_wrap.cpp | 6 ++++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index b908df29..368f181b 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2571,7 +2571,8 @@ int glestMain(int argc, char** argv) { if(config.getBool("EnableLegacyFonts","false") == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_ENABLE_LEGACYFONTS]) == true) { Font::forceLegacyFonts = true; Renderer::renderText3DEnabled = false; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n"); + //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n"); + printf("**WARNING** Forcing Legacy Fonts Enabled\n"); } else { Renderer::renderText3DEnabled = config.getBool("Enable3DFontRendering",intToStr(Renderer::renderText3DEnabled).c_str()); diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index a0da3d21..86d90737 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -56,7 +56,7 @@ void Font::resetToDefaults() { Font::charCount = 256; Font::fontTypeName = "Times New Roman"; Font::fontIsMultibyte = false; - Font::forceLegacyFonts = false; + //Font::forceLegacyFonts = false; Font::fontIsRightToLeft = false; // This value is used to scale the font text rendering diff --git a/source/shared_lib/sources/graphics/gl/font_gl.cpp b/source/shared_lib/sources/graphics/gl/font_gl.cpp index eff8e995..190d0aa3 100644 --- a/source/shared_lib/sources/graphics/gl/font_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/font_gl.cpp @@ -26,12 +26,15 @@ using namespace Platform; string FontGl::default_fonttype = "fixed"; void Font2DGl::init() { + //printf("In [%s::%s] Line: %d inited = %d\n",__FILE__,__FUNCTION__,__LINE__,inited); if(inited == false) { - if(getTextHandler() == NULL) { + //printf("In [%s::%s] Line: %d inited = %d Font::forceLegacyFonts = %d\n",__FILE__,__FUNCTION__,__LINE__,inited,Font::forceLegacyFonts); + if(getTextHandler() == NULL || Font::forceLegacyFonts == true) { assertGl(); handle= glGenLists(charCount); assertGl(); + //printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); createGlFontBitmaps((Shared::Platform::uint32&)handle, type, size, width, charCount, metrics); assertGl(); } @@ -41,7 +44,7 @@ void Font2DGl::init() { void Font2DGl::end() { if(inited) { - if(getTextHandler() == NULL) { + if(getTextHandler() == NULL || Font::forceLegacyFonts == true) { assertGl(); //assert(glIsList(handle)); glDeleteLists(handle, 1); @@ -56,8 +59,9 @@ void Font2DGl::end() { // ===================================================== void Font3DGl::init() { + //printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); if(inited == false) { - if(getTextHandler() == NULL) { + if(getTextHandler() == NULL || Font::forceLegacyFonts == true) { assertGl(); handle= glGenLists(charCount); createGlFontOutlines((Shared::Platform::uint32&)handle, type, width, depth, charCount, metrics); @@ -69,7 +73,7 @@ void Font3DGl::init() { void Font3DGl::end() { if(inited) { - if(getTextHandler() == NULL) { + if(getTextHandler() == NULL || Font::forceLegacyFonts == true) { assertGl(); assert(glIsList(handle)); glDeleteLists(handle, 1); diff --git a/source/shared_lib/sources/platform/unix/gl_wrap.cpp b/source/shared_lib/sources/platform/unix/gl_wrap.cpp index a16ce701..20858b0a 100644 --- a/source/shared_lib/sources/platform/unix/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/unix/gl_wrap.cpp @@ -41,7 +41,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("About to try font [%s]\n",type.c_str()); - printf("About to try font [%s]\n",type.c_str()); + //printf("About to try font [%s]\n",type.c_str()); XFontStruct* fontInfo = XLoadQueryFont(display, type.c_str()); if(fontInfo == NULL) { @@ -49,7 +49,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, //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()); - printf("Font not found [%s] trying to fallback to [%s]\n",type.c_str(),default_font.c_str()); + //printf("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) { @@ -58,6 +58,8 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, } // we need the height of 'a' which sould ~ be half ascent+descent + //printf("Font height [%s] = %d\n",type.c_str(),(fontInfo->ascent + fontInfo->descent) / 2); + metrics.setHeight(static_cast (fontInfo->ascent + fontInfo->descent) / 2);