From 4512845d58d048598a7824a000cef526cb8ef757 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 26 Dec 2019 18:45:30 +0100 Subject: GRAPHICS: MACGUI: Fix incorrect text dimension calculations --- graphics/macgui/mactext.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'graphics') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index cb520652b6..0df403ac8c 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -349,7 +349,9 @@ void MacText::render(int from, int to) { // TODO: _textMaxWidth, when -1, was not rendering ANY text. for (uint j = 0; j < _textLines[i].chunks.size(); j++) { - debug(9, "MacText::render: line %d[%d]/%d at %d,%d (%s)", i, j, xOffset, _textLines[i].chunks[j].fontId, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str()); + debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d", + i, j, xOffset, _textLines[i].y, _textLines[i].height, _textLines[i].chunks[j].text.encode().c_str(), + _textLines[i].chunks[j].fontId, _surface->w, _surface->h); if (_textLines[i].chunks[j].text.empty()) continue; @@ -426,8 +428,10 @@ void MacText::recalcDims() { for (uint i = 0; i < _textLines.size(); i++) { _textLines[i].y = y; - y += getLineHeight(i) + _interLinear; + // We must calculate width first, because it enforces + // the computation. Calling Height() will return cached value! _textMaxWidth = MAX(_textMaxWidth, getLineWidth(i, true)); + y += getLineHeight(i) + _interLinear; } _textMaxHeight = y - _interLinear; -- cgit v1.2.3