diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index c2b2ee3f..89cae1d0 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -344,6 +344,9 @@ int CoreData::computeFontSize(int size) { } //FontSizeAdjustment rs += config.getInt("FontSizeAdjustment"); + if(Font::forceLegacyFonts == false) { + rs += Font::baseSize; //basesize only for new font system + } if(Font::forceLegacyFonts == true) { if(rs < 10) { rs= 10; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 16ee4561..8e625f21 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1445,20 +1445,25 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i pos.x += ((w / 2.f) - (lineWidth / 2.f)); } - //h /= 2.f; float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue); - if(lineHeight < h) { - //pos.y += ((float)h / 2.f); - //pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f)); - pos.y += (lineHeight / 2.f) + FontMetrics::DEFAULT_Y_OFFSET_FACTOR; - //pos.y -= h; - //printf("Center text [%s] h = %d, lineHeight = %f, pos.y = %f\n",text.c_str(),h,lineHeight,pos.y); + lineHeight= lineHeight / (2.f + 0.2f * FontMetrics::DEFAULT_Y_OFFSET_FACTOR); + pos.y += (h / 2.f) - (lineHeight / 2.f); + +// //h /= 2.f; +// float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue); +// if(lineHeight < h) { +// //pos.y += ((float)h / 2.f); +// //pos.y -= ((float(h) / 2.f) - (lineHeight / 2.f)); +// pos.y += (lineHeight / 2.f) + FontMetrics::DEFAULT_Y_OFFSET_FACTOR; +// //pos.y -= h; +// //printf("Center text [%s] h = %d, lineHeight = %f, pos.y = %f\n",text.c_str(),h,lineHeight,pos.y); +// +// //printf("Center text [%s] h = %d, lineHeight = %f, pos.y = %f\n",text.c_str(),h,lineHeight,pos.y); +// } +// else { +// pos.y += ((float)h / 2.f) - FontMetrics::DEFAULT_Y_OFFSET_FACTOR; +// } - //printf("Center text [%s] h = %d, lineHeight = %f, pos.y = %f\n",text.c_str(),h,lineHeight,pos.y); - } - else { - pos.y += ((float)h / 2.f) - FontMetrics::DEFAULT_Y_OFFSET_FACTOR; - } return pos; } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index f9e98a44..e8635095 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2559,6 +2559,7 @@ int glestMain(int argc, char** argv) { Font::fontTypeName = config.getString("FONT_TYPENAME",Font::fontTypeName.c_str()); Font::fontIsMultibyte = config.getBool("FONT_MULTIBYTE",intToStr(Font::fontIsMultibyte).c_str()); Font::fontIsRightToLeft = config.getBool("FONT_RIGHTTOLEFT",intToStr(Font::fontIsRightToLeft).c_str()); + Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Font::baseSize).c_str()); // Example values: // DEFAULT_CHARSET (English) = 1 @@ -2648,7 +2649,11 @@ int glestMain(int argc, char** argv) { } lang.loadStrings(language); - + if( lang.hasString("FONT_BASE_SIZE")) { + // 256 for English + // 30000 for Chinese + Font::baseSize = strToInt(lang.get("FONT_BASE_SIZE")); + } if( lang.hasString("FONT_CHARCOUNT")) { // 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 c0f7b208..4fcb7c07 100644 --- a/source/shared_lib/include/graphics/font.h +++ b/source/shared_lib/include/graphics/font.h @@ -66,6 +66,7 @@ public: static bool forceLegacyFonts; static bool fontIsRightToLeft; static float scaleFontValue; + static int baseSize; //static int scaleFontYOffset; public: diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 424db07f..7799c1bc 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -39,6 +39,7 @@ bool Font::forceLegacyFonts = false; float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 2.0f; bool Font::fontIsRightToLeft = false; float Font::scaleFontValue = 0.75; +int Font::baseSize = 0; //int Font::scaleFontYOffset = 0; //