[Scummvm-git-logs] scummvm master -> a21afb29b112660670a9fd1e9780f2f0474e8cc6
sev-
noreply at scummvm.org
Fri Aug 5 18:17:27 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ff1f5712e3 PINK: Fix reversed hebrew text
a21afb29b1 GRAPHICS: MACGUI: Reduce duplicated code in MacTect::render
Commit: ff1f5712e3b2b95196323cee39c2934db604cb80
https://github.com/scummvm/scummvm/commit/ff1f5712e3b2b95196323cee39c2934db604cb80
Author: Avijeet (am388488 at gmail.com)
Date: 2022-08-05T20:17:23+02:00
Commit Message:
PINK: Fix reversed hebrew text
Changed paths:
engines/pink/objects/actions/action_text.cpp
graphics/macgui/mactext.cpp
diff --git a/engines/pink/objects/actions/action_text.cpp b/engines/pink/objects/actions/action_text.cpp
index 162d181ae87..3a42ffacd26 100644
--- a/engines/pink/objects/actions/action_text.cpp
+++ b/engines/pink/objects/actions/action_text.cpp
@@ -21,6 +21,7 @@
#include "common/debug.h"
#include "common/substream.h"
+#include "common/unicode-bidi.h"
#include "graphics/transparent_surface.h"
@@ -95,7 +96,9 @@ void ActionText::start() {
stream->read(str, stream->size());
delete stream;
- switch(_actor->getPage()->getGame()->getLanguage()) {
+ Common::Language language = _actor->getPage()->getGame()->getLanguage();
+ screen->getWndManager()._language = language;
+ switch(language) {
case Common::DA_DNK:
case Common::ES_ESP:
case Common::FR_FRA:
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 2d4572d74aa..5dea4d6f102 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -917,38 +917,76 @@ void MacText::render(int from, int to, int shadow) {
int w = MIN(_maxWidth, _textMaxWidth);
ManagedSurface *surface = shadow ? _shadowSurface : _surface;
- for (int i = from; i <= to; i++) {
- int xOffset = getAlignOffset(i);
- xOffset++;
+ if (_wm->_language == Common::HE_ISR) {
+ for (int i = to; i >= from; i--) {
+ int xOffset = getAlignOffset(i);
+ xOffset++;
+
+ int maxAscentForRow = 0;
+ for (int j = _textLines[i].chunks.size() - 1; j >= 0; j--) {
+ if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
+ maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
+ }
- int maxAscentForRow = 0;
- for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
- if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
- maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
- }
+ // TODO: _textMaxWidth, when -1, was not rendering ANY text.
+ for (int j = _textLines[i].chunks.size() - 1; j >= 0; j--) {
+ debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
+ i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
+ _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
+ (const void *)_textLines[i].chunks[j].getFont());
- // 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] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
- i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
- _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
- (const void *)_textLines[i].chunks[j].getFont());
+ if (_textLines[i].chunks[j].text.empty())
+ continue;
- if (_textLines[i].chunks[j].text.empty())
- continue;
+ int yOffset = 0;
+ if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
+ yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
+ }
- int yOffset = 0;
- if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
- yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
+ if (_textLines[i].chunks[j].plainByteMode()) {
+ Common::String str = _textLines[i].chunks[j].getEncodedText();
+ _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
+ } else {
+ _textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text, Common::BIDI_PAR_RTL), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
+ }
+ }
+ }
+ } else {
+ for (int i = from; i <= to; i++) {
+ int xOffset = getAlignOffset(i);
+ xOffset++;
+
+ int maxAscentForRow = 0;
+ for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
+ if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
+ maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
}
- if (_textLines[i].chunks[j].plainByteMode()) {
- Common::String str = _textLines[i].chunks[j].getEncodedText();
- _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
- } else {
- _textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
+ // 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] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
+ i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
+ _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
+ (const void *)_textLines[i].chunks[j].getFont());
+
+ if (_textLines[i].chunks[j].text.empty())
+ continue;
+
+ int yOffset = 0;
+ if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
+ yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
+ }
+
+ if (_textLines[i].chunks[j].plainByteMode()) {
+ Common::String str = _textLines[i].chunks[j].getEncodedText();
+ _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
+ } else {
+ _textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
+ }
}
}
}
Commit: a21afb29b112660670a9fd1e9780f2f0474e8cc6
https://github.com/scummvm/scummvm/commit/a21afb29b112660670a9fd1e9780f2f0474e8cc6
Author: Avijeet (am388488 at gmail.com)
Date: 2022-08-05T20:17:23+02:00
Commit Message:
GRAPHICS: MACGUI: Reduce duplicated code in MacTect::render
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 5dea4d6f102..f6bad621b2a 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -917,76 +917,55 @@ void MacText::render(int from, int to, int shadow) {
int w = MIN(_maxWidth, _textMaxWidth);
ManagedSurface *surface = shadow ? _shadowSurface : _surface;
- if (_wm->_language == Common::HE_ISR) {
- for (int i = to; i >= from; i--) {
- int xOffset = getAlignOffset(i);
- xOffset++;
-
- int maxAscentForRow = 0;
- for (int j = _textLines[i].chunks.size() - 1; j >= 0; j--) {
- if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
- maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
- }
+ int myFrom = from, myTo = to + 1, delta = 1;
- // TODO: _textMaxWidth, when -1, was not rendering ANY text.
- for (int j = _textLines[i].chunks.size() - 1; j >= 0; j--) {
- debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
- i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
- _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
- (const void *)_textLines[i].chunks[j].getFont());
+ if (_wm->_language == Common::HE_ISR) {
+ myFrom = to;
+ myTo = from - 1;
+ delta = -1;
+ }
- if (_textLines[i].chunks[j].text.empty())
- continue;
+ for (int i = myFrom; i != myTo; i += delta) {
+ int xOffset = getAlignOffset(i);
+ xOffset++;
- int yOffset = 0;
- if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
- yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
- }
+ int start = 0, end = _textLines[i].chunks.size();
+ if (_wm->_language == Common::HE_ISR) {
+ start = _textLines[i].chunks.size() - 1;
+ end = -1;
+ }
- if (_textLines[i].chunks[j].plainByteMode()) {
- Common::String str = _textLines[i].chunks[j].getEncodedText();
- _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
- } else {
- _textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text, Common::BIDI_PAR_RTL), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
- }
- }
+ int maxAscentForRow = 0;
+ for (int j = start; j != end; j += delta) {
+ if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
+ maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
}
- } else {
- for (int i = from; i <= to; i++) {
- int xOffset = getAlignOffset(i);
- xOffset++;
-
- int maxAscentForRow = 0;
- for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
- if (_textLines[i].chunks[j].font->getFontAscent() > maxAscentForRow)
- maxAscentForRow = _textLines[i].chunks[j].font->getFontAscent();
- }
- // 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] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
- i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
- _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
- (const void *)_textLines[i].chunks[j].getFont());
+ // TODO: _textMaxWidth, when -1, was not rendering ANY text.
+ for (int j = start; j != end; j += delta) {
+ debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
+ i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
+ _textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
+ (const void *)_textLines[i].chunks[j].getFont());
- if (_textLines[i].chunks[j].text.empty())
- continue;
+ if (_textLines[i].chunks[j].text.empty())
+ continue;
- int yOffset = 0;
- if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
- yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
- }
+ int yOffset = 0;
+ if (_textLines[i].chunks[j].font->getFontAscent() < maxAscentForRow) {
+ yOffset = maxAscentForRow - _textLines[i].chunks[j].font->getFontAscent();
+ }
- if (_textLines[i].chunks[j].plainByteMode()) {
- Common::String str = _textLines[i].chunks[j].getEncodedText();
- _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
- } else {
+ if (_textLines[i].chunks[j].plainByteMode()) {
+ Common::String str = _textLines[i].chunks[j].getEncodedText();
+ _textLines[i].chunks[j].getFont()->drawString(surface, str, xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(str);
+ } else {
+ if (_wm->_language == Common::HE_ISR)
+ _textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text, Common::BIDI_PAR_RTL), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
+ else
_textLines[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_textLines[i].chunks[j].text), xOffset, _textLines[i].y + yOffset, w, shadow ? _wm->_colorBlack : _textLines[i].chunks[j].fgcolor, Graphics::kTextAlignLeft, 0, true);
- xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
- }
+ xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
}
}
}
More information about the Scummvm-git-logs
mailing list