fonts really fixed now?

This commit is contained in:
Titus Tscharntke 2011-07-01 00:03:30 +00:00
parent 7b95fac8cc
commit 97e19785a9
4 changed files with 14 additions and 27 deletions

View File

@ -1444,26 +1444,12 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
if(lineWidth < w) {
pos.x += ((w / 2.f) - (lineWidth / 2.f));
}
const Metrics &metrics= Metrics::getInstance();
float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue);
lineHeight= lineHeight / (2.f + 0.2f * FontMetrics::DEFAULT_Y_OFFSET_FACTOR);
lineHeight=metrics.toVirtualY(lineHeight);
//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;
// }
return pos;
}

View File

@ -38,7 +38,7 @@ bool Font::fontIsMultibyte = false;
bool Font::forceLegacyFonts = false;
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 2.0f;
bool Font::fontIsRightToLeft = false;
float Font::scaleFontValue = 0.75;
float Font::scaleFontValue = 1.0;
int Font::baseSize = 0;
//int Font::scaleFontYOffset = 0;
//

View File

@ -225,13 +225,17 @@ float TextFTGL::LineHeight(const char* str, const int len) {
//FTBBox box = ftFont->BBox(str);
//printf("String [%s] lineheight = %f upper_y = %f lower_y = %f\n",str,ftFont->LineHeight(),box.Upper().Y(),box.Lower().Y());
//return ftFont->Ascender() + ftFont->Descender();
return ftFont->LineHeight();
//FTBBox box = ftFont->BBox(str);
//float result = box.Upper().Y()- box.Lower().Y();
//printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
//return result;
//printf("ftFont->Ascender():%f ftFont->Descender()*-1 = %f ftFont->LineHeight() = %f\n",ftFont->Ascender(),ftFont->Descender()*-1 , ftFont->LineHeight());
//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);
return result;
// printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
// return result;
//float urx = box.Upper().X();
//float llx = box.Lower().X();

View File

@ -592,9 +592,6 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
{
line++;
//assertGl();
//printf("NEWLINE before [%s]\n",parts[i].c_str());
parts[i] = parts[i].erase(0);
//printf("NEWLINE after [%s]\n",parts[i].c_str());
float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
//assertGl();
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);