[Scummvm-git-logs] scummvm master -> 8b09704245fb0f853e9f3d809c099181b3ad3468
bluegr
noreply at scummvm.org
Tue Aug 16 09:57:07 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8b09704245 SWORD2: Add Hebrew support
Commit: 8b09704245fb0f853e9f3d809c099181b3ad3468
https://github.com/scummvm/scummvm/commit/8b09704245fb0f853e9f3d809c099181b3ad3468
Author: Shahar Ariel (sariel at ravtech.co.il)
Date: 2022-08-16T12:57:02+03:00
Commit Message:
SWORD2: Add Hebrew support
Changed paths:
engines/sword2/maketext.cpp
engines/sword2/sword2.cpp
engines/sword2/sword2.h
diff --git a/engines/sword2/maketext.cpp b/engines/sword2/maketext.cpp
index 173e8fbad36..f19fc153bcf 100644
--- a/engines/sword2/maketext.cpp
+++ b/engines/sword2/maketext.cpp
@@ -41,6 +41,7 @@
#include "common/system.h"
+#include "common/unicode-bidi.h"
#include "common/textconsole.h"
#include "sword2/sword2.h"
@@ -265,18 +266,23 @@ byte *FontRenderer::buildTextSprite(const byte *sentence, uint32 fontRes, uint8
// Build the sprite, one line at a time
- uint16 pos = 0;
-
for (i = 0; i < noOfLines; i++) {
// Center each line
byte *spritePtr = linePtr + (spriteWidth - line[i].width) / 2;
+ const byte *currTxtLine = sentence;
+ Common::String reversedString;
+ if (_vm->_isRTL) {
+ const Common::String textLogical((const char *)currTxtLine, line[i].length);
+ reversedString = Common::convertBiDiString(textLogical, Common::kWindows1255);
+ currTxtLine = reinterpret_cast<const byte *>(reversedString.c_str());
+ }
// copy the sprite for each character in this line to the
// text sprite and inc the sprite ptr by the character's
// width minus the 'overlap'
for (uint j = 0; j < line[i].length; j++) {
- byte *charPtr = findChar(sentence[pos++], charSet);
+ byte *charPtr = findChar(*currTxtLine++, charSet);
frame_head.read(charPtr);
@@ -293,7 +299,7 @@ byte *FontRenderer::buildTextSprite(const byte *sentence, uint32 fontRes, uint8
}
// Skip space at end of last word in this line
- pos++;
+ sentence += line[i].length + 1;
if (Sword2Engine::isPsx())
linePtr += (char_height / 2 + _lineSpacing) * spriteWidth;
@@ -677,7 +683,7 @@ void Sword2Engine::initializeFontResourceFlags() {
else
textLine = (char *)fetchTextLine(textFile, 54) + 2;
- _system->setWindowCaption(Common::U32String(textLine));
+ _system->setWindowCaption(Common::U32String(textLine, _isRTL ? Common::kWindows1255 : Common::kUtf8));
_resman->closeResource(TEXT_RES);
}
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 3e0fde05f5b..305504adbc6 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -80,6 +80,7 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst), _rnd("sword2") {
_mouse = NULL;
_logic = NULL;
_fontRenderer = NULL;
+ _isRTL = Common::parseLanguage(ConfMan.get("language")) == Common::HE_ISR;
_debugger = NULL;
_keyboardEvent.pending = false;
diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h
index 261e70e56d8..f30bf34f08e 100644
--- a/engines/sword2/sword2.h
+++ b/engines/sword2/sword2.h
@@ -176,6 +176,8 @@ public:
Logic *_logic;
FontRenderer *_fontRenderer;
+ bool _isRTL;
+
Debugger *_debugger;
Common::RandomSource _rnd;
More information about the Scummvm-git-logs
mailing list