From 022045a1455784aab9f37c7d540b2d136d4aa9af Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 13 Aug 2020 14:11:18 +0200 Subject: [PATCH] Add `getLineHeight` to GuIText --- include/gui/GuiText.h | 4 ++++ source/gui/GuiText.cpp | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/gui/GuiText.h b/include/gui/GuiText.h index 6ac7879..1f8720f 100644 --- a/include/gui/GuiText.h +++ b/include/gui/GuiText.h @@ -104,6 +104,10 @@ public: return maxWidth; } + float getLineHeight() { + return (float) currentSize; + } + float getTextHeight(); void setSSAA(int32_t ssaa) { diff --git a/source/gui/GuiText.cpp b/source/gui/GuiText.cpp index 0dcc7fb..a51bb3e 100644 --- a/source/gui/GuiText.cpp +++ b/source/gui/GuiText.cpp @@ -590,10 +590,6 @@ void GuiText::draw(CVideo *pVideo) { textMutex.unlock(); return; } else if (wrapMode == WRAP) { - int32_t lineheight = internalRenderingSize + 6; - int32_t yoffset = 0; - int32_t voffset = 0; - if (textDyn.size() == 0) { wrapText(); } @@ -606,13 +602,14 @@ void GuiText::draw(CVideo *pVideo) { } } + float voffset = 0.0f; if (alignment & ALIGN_MIDDLE) { - voffset = (lineheight * (textDyn.size() - 1)) >> 1; + voffset = (float) (((int32_t) getLineHeight() * (textDyn.size() - 1)) >> 1) * internalRenderingScale; } - + float y_offset = 0.0f; for (uint32_t i = 0; i < textDyn.size(); i++) { font->drawText(pVideo, x_pos, y_pos + y_offset + voffset, getDepth(), textDyn[i], internalRenderingSize, color, alignment, textDynWidth[i], defaultBlur, blurGlowIntensity, blurGlowColor, internalRenderingScale); - yoffset -= lineheight; + y_offset -= getLineHeight() * getScale() * internalRenderingScale; } textMutex.unlock(); return;