fonts really fixed now?
This commit is contained in:
parent
7b95fac8cc
commit
97e19785a9
|
@ -1444,26 +1444,12 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
|
||||||
if(lineWidth < w) {
|
if(lineWidth < w) {
|
||||||
pos.x += ((w / 2.f) - (lineWidth / 2.f));
|
pos.x += ((w / 2.f) - (lineWidth / 2.f));
|
||||||
}
|
}
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue);
|
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);
|
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;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ bool Font::fontIsMultibyte = false;
|
||||||
bool Font::forceLegacyFonts = false;
|
bool Font::forceLegacyFonts = false;
|
||||||
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 2.0f;
|
float FontMetrics::DEFAULT_Y_OFFSET_FACTOR = 2.0f;
|
||||||
bool Font::fontIsRightToLeft = false;
|
bool Font::fontIsRightToLeft = false;
|
||||||
float Font::scaleFontValue = 0.75;
|
float Font::scaleFontValue = 1.0;
|
||||||
int Font::baseSize = 0;
|
int Font::baseSize = 0;
|
||||||
//int Font::scaleFontYOffset = 0;
|
//int Font::scaleFontYOffset = 0;
|
||||||
//
|
//
|
||||||
|
|
|
@ -225,13 +225,17 @@ float TextFTGL::LineHeight(const char* str, const int len) {
|
||||||
//FTBBox box = ftFont->BBox(str);
|
//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());
|
//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);
|
//printf("ftFont->Ascender():%f ftFont->Descender()*-1 = %f ftFont->LineHeight() = %f\n",ftFont->Ascender(),ftFont->Descender()*-1 , ftFont->LineHeight());
|
||||||
//float result = box.Upper().Y()- box.Lower().Y();
|
//return ftFont->Ascender() + ftFont->Descender()*-1 - ftFont->LineHeight();
|
||||||
//printf("For str [%s] LineHeight = %f, result = %f\n",str, ftFont->LineHeight(),result);
|
//return ftFont->LineHeight();
|
||||||
//return result;
|
|
||||||
|
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 urx = box.Upper().X();
|
||||||
//float llx = box.Lower().X();
|
//float llx = box.Lower().X();
|
||||||
|
|
|
@ -592,9 +592,6 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
||||||
{
|
{
|
||||||
line++;
|
line++;
|
||||||
//assertGl();
|
//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);
|
float yLineValue = (font->getTextHandler()->LineHeight(parts[i].c_str()) * Font::scaleFontValue);
|
||||||
//assertGl();
|
//assertGl();
|
||||||
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user