From 01d4b803389c7438aa3748b728007c061c190288 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 13 Aug 2020 13:46:50 +0200 Subject: [PATCH] Reimplement the method getHeight in FreeTypeGX --- source/gui/FreeTypeGX.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/gui/FreeTypeGX.cpp b/source/gui/FreeTypeGX.cpp index 47003b8..10d5774 100644 --- a/source/gui/FreeTypeGX.cpp +++ b/source/gui/FreeTypeGX.cpp @@ -442,8 +442,24 @@ uint16_t FreeTypeGX::getCharWidth(const wchar_t wChar, int16_t pixelSize, const * @return The height of the text string in pixels. */ uint16_t FreeTypeGX::getHeight(const wchar_t *text, int16_t pixelSize) { - getOffset(text, pixelSize); - return fontData[pixelSize].ftgxAlign.max - fontData[pixelSize].ftgxAlign.min; + if (text == NULL) { + return 0; + } + + int16_t strMax = 0, strMin = 0; + int32_t i = 0; + while (text[i]) { + ftgxCharData *glyphData = cacheGlyphData(text[i], pixelSize); + + if (glyphData != NULL) { + strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax; + strMin = glyphData->renderOffsetMin > strMin ? glyphData->renderOffsetMin : strMin; + } + + ++i; + } + + return strMax + strMin; } /**