From: Piotr Caban Subject: gdiplus: Added support for UTF16 encoded strings in load_ttf_name_id Message-Id: <51D3D82E.6040507@codeweavers.com> Date: Wed, 03 Jul 2013 09:52:14 +0200 This patch fixes bug 33880. It's reported as regression but I think that it stopped working because of game update. --- dlls/gdiplus/font.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 51c7aec..d0cb393 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -1163,6 +1163,8 @@ typedef struct _tagTT_NAME_TABLE_HEADER { * from start of the table */ } TT_NAME_TABLE_HEADER; +#define PLATFORM_ID_UNICODE 0 + #define NAME_ID_FULL_FONT_NAME 4 #define NAME_ID_VERSION 5 @@ -1238,8 +1240,23 @@ static WCHAR *load_ttf_name_id( const char *mem, DWORD_PTR size, DWORD id, WCHAR if (ofs + ttRecord.uStringOffset + ttNTHeader.uStorageOffset + ttRecord.uStringLength > size) return NULL; buf = mem + ofs + ttRecord.uStringOffset + ttNTHeader.uStorageOffset; - len = MultiByteToWideChar(CP_ACP, 0, buf, ttRecord.uStringLength, ret, len-1); - ret[len] = 0; + + if (ttRecord.uPlatformID == PLATFORM_ID_UNICODE) + { + int j; + + if (ttRecord.uStringLength >= len*sizeof(WCHAR)) + return NULL; + + for(j=0; j