From 2aa72928e541bfebb458dc0c26bac1b31eee74e0 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 22 Mar 2014 14:24:32 -0500 Subject: [PATCH] Fixed fonts not being centered. --- src/resources/Font.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/resources/Font.cpp b/src/resources/Font.cpp index 7d53c47fc..14a197d5c 100644 --- a/src/resources/Font.cpp +++ b/src/resources/Font.cpp @@ -250,7 +250,7 @@ Eigen::Vector2f Font::sizeText(std::string text) const float lineWidth = 0.0f; float highestWidth = 0.0f; - float y = (float)getHeight(); + float y = getHeight(); for(unsigned int i = 0; i < text.length(); i++) { @@ -433,7 +433,10 @@ TextCache* Font::buildTextCache(const std::string& text, float offsetX, float of float th = (float)textureHeight; float x = offsetX; - float y = offsetY + mMaxGlyphHeight * 1.1f * fontScale; //padding (another 0.5% is added to the bottom through the sizeText function) + + float yTop = (charData['S'].bearingY); + float yBot = getHeight(); + float y = offsetY + (yBot + yTop)/2.0f; int charNum = 0; for(int i = 0; i < vertCount; i += 6, charNum++)