From d39404c8e8144af504f8a4dfef69f2009c05582e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 1 Feb 2017 19:06:36 +0100 Subject: GRAPHICS: Fix rendering of MacText with font change in the middle of the string --- graphics/macgui/mactext.cpp | 11 +++++++---- graphics/macgui/mactext.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'graphics') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 11dd7d22fe..84db1c2b4a 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -129,7 +129,9 @@ void MacText::splitString(Common::String &str) { if (*s == '\r' || *s == '\n' || nextChunk) { Common::Array text; - _font->wordWrapText(tmp, _maxWidth, text); + int w = getLineWidth(curLine, true); + + _font->wordWrapText(tmp, _maxWidth, text, w); tmp.clear(); if (text.size()) { @@ -178,8 +180,9 @@ void MacText::splitString(Common::String &str) { if (tmp.size()) { Common::Array text; + int w = getLineWidth(curLine, true); - _font->wordWrapText(tmp, _maxWidth, text); + _font->wordWrapText(tmp, _maxWidth, text, w); _textLines[curLine].chunks[curChunk].text = text[0]; @@ -260,11 +263,11 @@ void MacText::render(int from, int to) { } } -int MacText::getLineWidth(int line) { +int MacText::getLineWidth(int line, bool enforce) { if ((uint)line >= _textLines.size()) return 0; - if (_textLines[line].width != -1) + if (_textLines[line].width != -1 && !enforce) return _textLines[line].width; int width = 0; diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 90f85e6b22..2ce0c3065b 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -105,7 +105,7 @@ private: void render(int from, int to); void recalcDims(); void reallocSurface(); - int getLineWidth(int line); + int getLineWidth(int line, bool enforce = false); int getLineHeight(int line); private: -- cgit v1.2.3