From 4a33c03a4919face0f952fae7f83175a8145cda9 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 17 Nov 2013 17:31:51 +0000 Subject: [PATCH] (svn r26032) [1.3] -Backport from trunk: - Fix: The internal index of a character in the layout line depends on the used layouter (r26029) - Fix: Make the installer warning about Windows XP SP3 not trigger on the 64 bit Windows XP which is not really Windows XP to start with [FS#5773] (r26028) --- os/windows/installer/install.nsi | 9 ++++++++- src/gfx_layout.cpp | 26 +++++++++++--------------- src/gfx_layout.h | 1 + src/script/api/ai_changelog.hpp | 4 ++++ src/script/api/game_changelog.hpp | 4 ++++ 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/os/windows/installer/install.nsi b/os/windows/installer/install.nsi index ddac0e7e84..a88b1f35a1 100644 --- a/os/windows/installer/install.nsi +++ b/os/windows/installer/install.nsi @@ -545,15 +545,22 @@ FunctionEnd ;------------------------------------------------------------------------------- ; Determine windows version, returns "win9x" if Win9x/Me/2000/XP SP2- or "winnt" for the rest on the stack Function GetWindowsVersion + GetVersion::WindowsPlatformArchitecture + Pop $R0 + IntCmp $R0 64 WinNT 0 ClearErrors StrCpy $R0 "win9x" ${If} ${IsNT} ${If} ${IsWinXP} ${AndIf} ${AtLeastServicePack} 3 ${OrIf} ${AtLeastWin2003} - StrCpy $R0 "winnt" + GoTo WinNT ${EndIf} ${EndIf} + GoTo Done +WinNT: + StrCpy $R0 "winnt" +Done: Push $R0 FunctionEnd diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index cf2fe6da28..6f91fe832e 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -163,6 +163,12 @@ public: int GetWidth() const { return l->getWidth(); } int CountRuns() const { return l->countRuns(); } const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); } + + int GetInternalCharLength(WChar c) const + { + /* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */ + return Utf8CharLen(c) < 4 ? 1 : 2; + } }; ICUParagraphLayout(ParagraphLayout *p) : p(p) { } @@ -259,6 +265,8 @@ public: int GetWidth() const; int CountRuns() const; const ParagraphLayouter::VisualRun *GetVisualRun(int run) const; + + int GetInternalCharLength(WChar c) const { return 1; } }; const WChar *buffer_begin; ///< Begin of the buffer. @@ -699,12 +707,7 @@ Point Layouter::GetCharPosition(const char *ch) const size_t len = Utf8Decode(&c, str); if (c == '\0' || c == '\n') break; str += len; -#ifdef WITH_ICU - /* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */ - index += len < 4 ? 1 : 2; -#else - index++; -#endif + index += (*this->Begin())->GetInternalCharLength(c); } if (str == ch) { @@ -762,15 +765,8 @@ const char *Layouter::GetCharAtPosition(int x) const for (const char *str = this->string; *str != '\0'; ) { if (cur_idx == index) return str; - WChar c; - size_t len = Utf8Decode(&c, str); -#ifdef WITH_ICU - /* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */ - cur_idx += len < 4 ? 1 : 2; -#else - cur_idx++; -#endif - str += len; + WChar c = Utf8Consume(&str); + cur_idx += line->GetInternalCharLength(c); } } } diff --git a/src/gfx_layout.h b/src/gfx_layout.h index 4d85cb5a22..7cd70ce280 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -124,6 +124,7 @@ public: virtual int GetWidth() const = 0; virtual int CountRuns() const = 0; virtual const VisualRun *GetVisualRun(int run) const = 0; + virtual int GetInternalCharLength(WChar c) const = 0; }; virtual void Reflow() = 0; diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index 4338c29a3e..9ee9dce247 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -15,6 +15,10 @@ * functions may still be available if you return an older API version * in GetAPIVersion() in info.nut. * + * \b 1.3.3 + * + * No changes + * * \b 1.3.2 * * No changes diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 97b581b751..7dd0cf486c 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -15,6 +15,10 @@ * functions may still be available if you return an older API version * in GetAPIVersion() in info.nut. * + * \b 1.3.3 + * + * No changes + * * \b 1.3.2 * * No changes