From 0b3b58adb8b71158a399b54952c32c8a58d62a6e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 19 May 2017 19:14:58 -0300 Subject: [PATCH] Hopefully fixed Font baseline calculation. --HG-- branch : minor --- src/modules/graphics/Font.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/Font.cpp b/src/modules/graphics/Font.cpp index 2b0bf2a39..f38024e6a 100644 --- a/src/modules/graphics/Font.cpp +++ b/src/modules/graphics/Font.cpp @@ -914,9 +914,11 @@ int Font::getDescent() const float Font::getBaseline() const { - // 1.25 is magic line height for true type fonts - if (rasterizers[0]->getDataType() == font::Rasterizer::DATA_TRUETYPE) - return floorf(getHeight() / 1.25f + 0.5f); + float ascent = getAscent(); + if (ascent != 0.0f) + return ascent; + else if (rasterizers[0]->getDataType() == font::Rasterizer::DATA_TRUETYPE) + return floorf(getHeight() / 1.25f + 0.5f); // 1.25 is magic line height for true type fonts else return 0.0f; }