Revert "Add: [Win32] Uniscribe configure options for MinGW targets."

Revert "Change: [Win32] Use Uniscribe instead of ICU for text caret handling."
Revert "Change: [Win32/MSVC] Make the Uniscribe text layouter the windows default and remove usage of the deprecated ICU layout libs."
Revert "Add: [Win32] Text layout using the native Windows Uniscribe library."
Revert "Codechange: Move ParagraphLayouter-specific functions into factory classes instead of relying on overloads."
Revert "Add: [Win32] Native natural sort implementation."

This reverts commit cd966f3810.
This reverts commit eec3f40931.
This reverts commit 33829dc6ab.
This reverts commit 768a31bfe3.
This reverts commit a4278c302b.
This reverts commit f4394debdc.

This is to fix various problems and crashes with text rendering
and font handling on Windows.

See #58.
This commit is contained in:
Jonathan G Rennison
2018-06-13 01:45:07 +01:00
parent 21040dc00b
commit ca4a4869a2
24 changed files with 159 additions and 1065 deletions

View File

@@ -28,7 +28,6 @@
#include "../../crashlog.h"
#include <errno.h>
#include <sys/stat.h>
#include "../../language.h"
/* Due to TCHAR, strncat and strncpy have to remain (for a while). */
#include "../../safeguards.h"
@@ -743,70 +742,6 @@ uint GetCPUCoreCount()
return info.dwNumberOfProcessors;
}
static WCHAR _cur_iso_locale[16] = L"";
void Win32SetCurrentLocaleName(const char *iso_code)
{
/* Convert the iso code into the format that windows expects. */
char iso[16];
if (strcmp(iso_code, "zh_TW") == 0) {
strecpy(iso, "zh-Hant", lastof(iso));
} else if (strcmp(iso_code, "zh_CN") == 0) {
strecpy(iso, "zh-Hans", lastof(iso));
} else {
/* Windows expects a '-' between language and country code, but we use a '_'. */
strecpy(iso, iso_code, lastof(iso));
for (char *c = iso; *c != '\0'; c++) {
if (*c == '_') *c = '-';
}
}
MultiByteToWideChar(CP_UTF8, 0, iso, -1, _cur_iso_locale, lengthof(_cur_iso_locale));
}
int OTTDStringCompare(const char *s1, const char *s2)
{
typedef int (WINAPI *PFNCOMPARESTRINGEX)(LPCWSTR, DWORD, LPCWCH, int, LPCWCH, int, LPVOID, LPVOID, LPARAM);
static PFNCOMPARESTRINGEX _CompareStringEx = NULL;
static bool first_time = true;
#ifndef SORT_DIGITSASNUMBERS
# define SORT_DIGITSASNUMBERS 0x00000008 // use digits as numbers sort method
#endif
#ifndef LINGUISTIC_IGNORECASE
# define LINGUISTIC_IGNORECASE 0x00000010 // linguistically appropriate 'ignore case'
#endif
if (first_time) {
_CompareStringEx = (PFNCOMPARESTRINGEX)GetProcAddress(GetModuleHandle(_T("Kernel32")), "CompareStringEx");
first_time = false;
}
if (_CompareStringEx != NULL) {
/* CompareStringEx takes UTF-16 strings, even in ANSI-builds. */
int len_s1 = MultiByteToWideChar(CP_UTF8, 0, s1, -1, NULL, 0);
int len_s2 = MultiByteToWideChar(CP_UTF8, 0, s2, -1, NULL, 0);
if (len_s1 != 0 && len_s2 != 0) {
LPWSTR str_s1 = AllocaM(WCHAR, len_s1);
LPWSTR str_s2 = AllocaM(WCHAR, len_s2);
MultiByteToWideChar(CP_UTF8, 0, s1, -1, str_s1, len_s1);
MultiByteToWideChar(CP_UTF8, 0, s2, -1, str_s2, len_s2);
int result = _CompareStringEx(_cur_iso_locale, LINGUISTIC_IGNORECASE | SORT_DIGITSASNUMBERS, str_s1, -1, str_s2, -1, NULL, NULL, 0);
if (result != 0) return result;
}
}
TCHAR s1_buf[512], s2_buf[512];
convert_to_fs(s1, s1_buf, lengthof(s1_buf));
convert_to_fs(s2, s2_buf, lengthof(s2_buf));
return CompareString(MAKELCID(_current_language->winlangid, SORT_DEFAULT), NORM_IGNORECASE, s1_buf, -1, s2_buf, -1);
}
#ifdef _MSC_VER
/* Code from MSDN: https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx */
const DWORD MS_VC_EXCEPTION = 0x406D1388;