diff --git a/include/gui/GuiText.h b/include/gui/GuiText.h index 83eb1e3..6ac7879 100644 --- a/include/gui/GuiText.h +++ b/include/gui/GuiText.h @@ -104,6 +104,7 @@ public: return maxWidth; } + float getTextHeight(); void setSSAA(int32_t ssaa) { this->internalSSAA = ssaa; diff --git a/source/gui/GuiText.cpp b/source/gui/GuiText.cpp index 46918bd..0dcc7fb 100644 --- a/source/gui/GuiText.cpp +++ b/source/gui/GuiText.cpp @@ -292,6 +292,18 @@ int32_t GuiText::getTextWidth() { res = res > maxWidth && maxWidth > 0 ? maxWidth : res; textMutex.unlock(); return res; +} + +float GuiText::getTextHeight() { + textMutex.lock(); + if (wrapMode == GuiText::WRAP && textDyn.empty()) { + if (maxWidth > 0 && font->getWidth(text, currentSize)) { + wrapText(); + } + } + + auto res = textDyn.empty() ? getLineHeight() : getLineHeight() * textDyn.size(); + textMutex.unlock(); return res; }