From bcc97704b6639d5ffa8c2f070a81a4b048f39a16 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 2 Nov 2011 00:17:57 +0000 Subject: [PATCH] got ftgl raster fonts working when ini setting is: Enable3DFontRendering=false and NOT running legacy font mode --- source/glest_game/graphics/renderer.cpp | 2 ++ source/shared_lib/sources/graphics/font.cpp | 1 + source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 1e0acb4f..79843486 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1789,6 +1789,8 @@ Vec2i computeCenteredPos(const string &text, Font2D *font, int x, int y) { x-metrics.toVirtualX(virtualX), y-metrics.toVirtualY(virtualY)); + //printf("text [%s] x = %d y = %d virtualX = %d virtualY = %d fontMetrics->getHeight() = %f\n",text.c_str(),x,y,virtualX,virtualY,fontMetrics->getHeight()); + return textPos; } diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 86d90737..06447cf4 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -132,6 +132,7 @@ float FontMetrics::getTextWidth(const string &str) { float FontMetrics::getHeight() const { if(textHandler != NULL) { + //printf("(textHandler->LineHeight(" ") = %f Font::scaleFontValue = %f\n",textHandler->LineHeight(" "),Font::scaleFontValue); return (textHandler->LineHeight(" ") * Font::scaleFontValue); } else { diff --git a/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp index a1e47416..08945bbe 100644 --- a/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/text_renderer_gl.cpp @@ -74,10 +74,13 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere if(centered) { rasterPos.x= x - font->getTextHandler()->Advance(renderText.c_str()) / 2.f; rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str()) / 2; + //printf("text [%s] x = %f, y = %f rasterPos [%s]\n",text.c_str(),x,y,rasterPos.getString().c_str()); } else { rasterPos= Vec2f(static_cast(x), static_cast(y)); - rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str()); + //rasterPos.y= y + font->getTextHandler()->LineHeight(renderText.c_str()); + rasterPos.y= y; + //printf("text [%s] x = %f, y = %f rasterPos [%s]\n",text.c_str(),x,y,rasterPos.getString().c_str()); } } else {