[Scummvm-git-logs] scummvm master -> 818d57c50f38b2785122ddc0082f35c9cb51f7f7

mduggan noreply at scummvm.org
Thu Apr 20 11:14:32 UTC 2023


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:
818d57c50f TETRAEDGE: Encode text before draw


Commit: 818d57c50f38b2785122ddc0082f35c9cb51f7f7
    https://github.com/scummvm/scummvm/commit/818d57c50f38b2785122ddc0082f35c9cb51f7f7
Author: BLooperZ (blooperz at users.noreply.github.com)
Date: 2023-04-20T20:14:27+09:00

Commit Message:
TETRAEDGE: Encode text before draw

Changed paths:
    engines/tetraedge/te/te_font3.cpp
    engines/tetraedge/te/te_font3.h


diff --git a/engines/tetraedge/te/te_font3.cpp b/engines/tetraedge/te/te_font3.cpp
index 0a390c0d81d..289a95ab41b 100644
--- a/engines/tetraedge/te/te_font3.cpp
+++ b/engines/tetraedge/te/te_font3.cpp
@@ -109,14 +109,29 @@ TeFont3::GlyphData TeFont3::glyph(uint pxSize, uint charcode) {
 	return retval;
 }
 
+Common::CodePage TeFont3::codePage() const {
+	Common::String lang = g_engine->getCore()->language();
+	if (lang == "he")
+		return Common::kWindows1255; 
+	if (lang == "ru")
+		return Common::kISO8859_5;
+	return Common::kLatin1;
+}
+
+
 int TeFont3::wordWrapText(const Common::String &str, int fontSize, int maxWidth, Common::Array<Common::String> &lines) {
 	Graphics::Font *font = getAtSize(fontSize);
-	return font->wordWrapText(str, maxWidth, lines);
+	Common::Array<Common::U32String> u32lines;
+	int retval = font->wordWrapText(str.decode(_codePage), maxWidth, u32lines);
+	for (auto &line: u32lines) {
+		lines.push_back(line.encode(_codePage));
+	}
+	return retval;
 }
 
 Common::Rect TeFont3::getBoundingBox(const Common::String &str, int fontSize) {
 	Graphics::Font *font = getAtSize(fontSize);
-	return font->getBoundingBox(str);
+	return font->getBoundingBox(str.decode(_codePage));
 }
 
 int TeFont3::getHeight(int fontSize) {
@@ -145,9 +160,9 @@ void TeFont3::draw(TeImage &destImage, const Common::String &str, int fontSize,
 
 	uint32 uintcol = ((uint32)col.a() << fmt.aShift) | ((uint32)(col.r()) << fmt.rShift)
 						| ((uint32)(col.g()) << fmt.gShift) | ((uint32)(col.b()) << fmt.bShift);
-	Common::String line(str);
+	Common::U32String line = str.decode(_codePage);
 	if (g_engine->getCore()->language() == "he")
-		line = Common::convertBiDiString(str, Common::kWindows1255);
+		line = Common::convertBiDiU32String(line).visual;
 	font->drawString(&destImage, line, 0, yoff, destImage.w, uintcol, talign);
 }
 
@@ -192,6 +207,7 @@ void TeFont3::unload() {
 }
 
 void TeFont3::init() {
+	_codePage = codePage();
 }
 
 float TeFont3::ascender(uint pxSize) {
diff --git a/engines/tetraedge/te/te_font3.h b/engines/tetraedge/te/te_font3.h
index a4fcd44f3d8..1bc7a69cffc 100644
--- a/engines/tetraedge/te/te_font3.h
+++ b/engines/tetraedge/te/te_font3.h
@@ -86,7 +86,9 @@ public:
 private:
 	void init();
 	Graphics::Font *getAtSize(uint size);
+	Common::CodePage codePage() const;
 
+	Common::CodePage _codePage;
 	Common::File _fontFile;
 	Common::HashMap<uint, Graphics::Font *> _fonts;
 	Common::String _loadedPath;




More information about the Scummvm-git-logs mailing list