- fixed debug output font position --> just for you james!

This commit is contained in:
Mark Vejvoda
2011-11-28 05:54:31 +00:00
parent 03a7a72ef5
commit 1658306b59
6 changed files with 28 additions and 13 deletions

View File

@@ -141,10 +141,11 @@ float FontMetrics::getTextWidth(const string &str) {
}
}
float FontMetrics::getHeight() const {
float FontMetrics::getHeight(const string &str) const {
if(textHandler != NULL) {
//printf("(textHandler->LineHeight(" ") = %f Font::scaleFontValue = %f\n",textHandler->LineHeight(" "),Font::scaleFontValue);
return (textHandler->LineHeight(" ") * Font::scaleFontValue);
//return (textHandler->LineHeight(str.c_str()) * Font::scaleFontValue);
return (textHandler->LineHeight(str.c_str()));
}
else {
return height;

View File

@@ -88,7 +88,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
metrics= font->getMetrics();
if(centered) {
rasterPos.x= x-metrics->getTextWidth(renderText)/2.f;
rasterPos.y= y+metrics->getHeight()/2.f;
rasterPos.y= y + metrics->getHeight(renderText)/2.f;
}
else {
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
@@ -328,7 +328,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
break;
case '\n':
line++;
rasterPos= Vec2f(static_cast<float>(x), y-(metrics->getHeight()*2.f)*line);
rasterPos= Vec2f(static_cast<float>(x), y-(metrics->getHeight("W")*2.f)*line);
glRasterPos2f(rasterPos.x, rasterPos.y);
break;
default:
@@ -511,7 +511,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
if(centered) {
//glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0);
translatePos.x = x-scale*metrics->getTextWidth(renderText)/2.f;
translatePos.y = y-scale*metrics->getHeight()/2.f;
translatePos.y = y-scale*metrics->getHeight(renderText)/2.f;
translatePos.z = 0;
}
else {