diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index f758366e..e6a3f895 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2562,6 +2562,7 @@ int glestMain(int argc, char** argv) { Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Font::baseSize).c_str()); Font::scaleFontValue = config.getFloat("FONT_SCALE_SIZE",floatToStr(Font::scaleFontValue).c_str()); Font::scaleFontValueCenterHFactor = config.getFloat("FONT_SCALE_CENTERH_FACTOR",floatToStr(Font::scaleFontValueCenterHFactor).c_str()); + Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str()); // Example values: // DEFAULT_CHARSET (English) = 1 @@ -2664,6 +2665,10 @@ int glestMain(int argc, char** argv) { Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR")); } + if( lang.hasString("FONT_HEIGHT_TEXT")) { + Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str()); + } + if( lang.hasString("FONT_CHARCOUNT")) { // 256 for English // 30000 for Chinese @@ -2716,6 +2721,10 @@ int glestMain(int argc, char** argv) { Font::scaleFontValueCenterHFactor = strToFloat(lang.get("FONT_SCALE_CENTERH_FACTOR_WINDOWS")); } + if( lang.hasString("FONT_HEIGHT_TEXT_WINDOWS")) { + Font::langHeightText = config.getString("FONT_HEIGHT_TEXT_WINDOWS",Font::langHeightText.c_str()); + } + if( lang.hasString("FONT_CHARCOUNT_WINDOWS")) { // 256 for English // 30000 for Chinese diff --git a/source/shared_lib/include/graphics/font.h b/source/shared_lib/include/graphics/font.h index 2606054d..adc4bd1a 100644 --- a/source/shared_lib/include/graphics/font.h +++ b/source/shared_lib/include/graphics/font.h @@ -69,6 +69,7 @@ public: static float scaleFontValueCenterHFactor; static int baseSize; static int faceResolution; + static string langHeightText; public: enum Width { diff --git a/source/shared_lib/include/graphics/gl/font_textFTGL.h b/source/shared_lib/include/graphics/gl/font_textFTGL.h index ed2b293d..a1705ba5 100644 --- a/source/shared_lib/include/graphics/gl/font_textFTGL.h +++ b/source/shared_lib/include/graphics/gl/font_textFTGL.h @@ -28,6 +28,7 @@ class TextFTGL : public Text { public: + static string langHeightText; static int faceResolution; TextFTGL(FontTextHandlerType type); diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index bd615805..0f73ee11 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -47,7 +47,18 @@ float Font::scaleFontValueCenterHFactor = 3.0; //float Font::scaleFontValueCenterHFactor = 4.0; int Font::baseSize = 0; + +#ifdef USE_FTGL + +int Font::faceResolution = TextFTGL::faceResolution; +string Font::langHeightText = TextFTGL::langHeightText; + +#else + int Font::faceResolution = 72; +string Font::langHeightText = "yW"; + +#endif // // ===================================================== @@ -126,7 +137,9 @@ Font::Font(FontTextHandlerType type) { try { textHandler = NULL; textHandler = new TextFTGL(type); - TextFTGL::faceResolution = faceResolution; + TextFTGL::faceResolution = Font::faceResolution; + TextFTGL::langHeightText = Font::langHeightText; + metrics.setTextHandler(this->textHandler); } catch(exception &ex) { diff --git a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp index 01625a2e..dce4a17f 100644 --- a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp +++ b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp @@ -32,7 +32,8 @@ using namespace Shared::PlatformCommon; namespace Shared { namespace Graphics { namespace Gl { -int TextFTGL::faceResolution = 72; +string TextFTGL::langHeightText = "yW"; +int TextFTGL::faceResolution = 72; //==================================================================== TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) { @@ -232,9 +233,12 @@ float TextFTGL::LineHeight(const char* str, const int len) { //return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight(); //return ftFont->LineHeight(); - FTBBox box = ftFont->BBox("yW"); - float result = box.Upper().Y()- box.Lower().Y(); - //printf("ftFont->BBox(''yW'')%f\n",result); + static float result = -1000; + if(result == -1000) { + FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str()); + result = box.Upper().Y()- box.Lower().Y(); + //printf("ftFont->BBox(''yW'')%f\n",result); + } return result; // printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result); // return result;