no fun with fonts

This commit is contained in:
Titus Tscharntke 2011-06-29 23:48:48 +00:00
parent 4e4825d752
commit baea45cae8
5 changed files with 28 additions and 13 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -66,6 +66,7 @@ public:
static bool forceLegacyFonts;
static bool fontIsRightToLeft;
static float scaleFontValue;
static int baseSize;
//static int scaleFontYOffset;
public:

View File

@ -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;
//