aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-02-03 18:32:44 +0100
committerEugene Sandulenko2017-02-03 18:32:44 +0100
commit74696f6c9267282bf14147dd54a98f63697bd9f0 (patch)
tree1d644784e90237662d07c30406ce6af1b8344f3e
parentc8328658753bacfb7c23497ee49e4059d59f7a8b (diff)
downloadscummvm-rg350-74696f6c9267282bf14147dd54a98f63697bd9f0.tar.gz
scummvm-rg350-74696f6c9267282bf14147dd54a98f63697bd9f0.tar.bz2
scummvm-rg350-74696f6c9267282bf14147dd54a98f63697bd9f0.zip
GRAPHICS: Fix MacText rendering when 3 fonts meet on one line
-rw-r--r--graphics/macgui/mactext.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index bdcb9acb42..7c22c815c2 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -77,6 +77,7 @@ void MacText::splitString(Common::String &str) {
int curLine = _textLines.size() - 1;
int curChunk = _textLines[curLine].chunks.size() - 1;
bool nextChunk = false;
+ MacFontRun previousFormatting;
while (*s) {
for (uint i = 0; i < _textLines.size(); i++) {
@@ -107,8 +108,12 @@ void MacText::splitString(Common::String &str) {
debug(8, "******** splitString: fontId: %d, textSlant: %d, unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x",
fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);
+ previousFormatting = _currentFormatting;
_currentFormatting.setValues(_wm, fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);
+ if (curLine == 0 && curChunk == 0 && tmp.empty())
+ previousFormatting = _currentFormatting;
+
nextChunk = true;
}
} else if (*s == '\n' && prevCR) { // trean \r\n as one
@@ -123,37 +128,34 @@ void MacText::splitString(Common::String &str) {
if (*s == '\r' || *s == '\n' || nextChunk) {
Common::Array<Common::String> text;
+ if (!nextChunk)
+ previousFormatting = _currentFormatting;
+
int w = getLineWidth(curLine, true);
- _font->wordWrapText(tmp, _maxWidth, text, w);
+ previousFormatting.getFont()->wordWrapText(tmp, _maxWidth, text, w);
tmp.clear();
if (text.size()) {
- if (nextChunk) {
- _textLines[curLine].chunks[curChunk].text += text[0];
- curChunk++;
-
- _textLines[curLine].chunks.push_back(_currentFormatting);
-
- if (_text.size() == curLine)
- _text.push_back(text[0]);
- else
- _text[curLine] += text[0];
-
- nextChunk = false;
-
- continue;
- }
-
for (uint i = 0; i < text.size(); i++) {
_text.push_back(text[i]);
_textLines[curLine].chunks[curChunk].text = text[i];
- curLine++;
- _textLines.resize(curLine + 1);
+ if ((text.size() > 1 || !nextChunk) && !(i == text.size() - 1 && nextChunk)) {
+ curLine++;
+ _textLines.resize(curLine + 1);
+ _textLines[curLine].chunks.push_back(previousFormatting);
+ curChunk = 0;
+ }
+ }
+
+ if (nextChunk) {
+ curChunk++;
+
_textLines[curLine].chunks.push_back(_currentFormatting);
- curChunk = 0;
+ } else {
+ _textLines[curLine].chunks[0] = _currentFormatting;
}
} else {
if (nextChunk) { // No text, replacing formatting
@@ -176,7 +178,7 @@ void MacText::splitString(Common::String &str) {
Common::Array<Common::String> text;
int w = getLineWidth(curLine, true);
- _font->wordWrapText(tmp, _maxWidth, text, w);
+ _currentFormatting.getFont()->wordWrapText(tmp, _maxWidth, text, w);
_textLines[curLine].chunks[curChunk].text = text[0];