Index: reactos/win32ss/gdi/gdi32/objects/font.c =================================================================== --- reactos/win32ss/gdi/gdi32/objects/font.c (revision 75509) +++ reactos/win32ss/gdi/gdi32/objects/font.c (working copy) @@ -121,7 +121,7 @@ * caller should free the returned LPWSTR from the process heap * itself. */ -static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) +LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) { UINT cp = GdiGetCodePage( hdc ); INT lenW; @@ -131,9 +131,13 @@ lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0); strW = HeapAlloc(GetProcessHeap(), 0, lenW*sizeof(WCHAR)); if (!strW) + { + if(plenW) *plenW = count; return NULL; + } if(!MultiByteToWideChar(cp, 0, str, count, strW, lenW)) { + if(plenW) *plenW = count; HeapFree(GetProcessHeap(), 0, strW); return NULL; } Index: reactos/win32ss/gdi/gdi32/objects/text.c =================================================================== --- reactos/win32ss/gdi/gdi32/objects/text.c (revision 75509) +++ reactos/win32ss/gdi/gdi32/objects/text.c (working copy) @@ -3,6 +3,8 @@ #define NDEBUG #include +LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP); + /* * @implemented */ @@ -15,23 +17,16 @@ _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString) { - ANSI_STRING StringA; - UNICODE_STRING StringU; + WCHAR *lpStringW; + INT countW; BOOL bResult; - if (lpString != NULL) - { - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); - } - else - { - StringU.Buffer = NULL; - } + lpStringW = FONT_mbtowc(hdc, lpString, cchString, &countW, NULL); - bResult = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cchString); + bResult = TextOutW(hdc, nXStart, nYStart, lpStringW, cchString); - RtlFreeUnicodeString(&StringU); + HeapFree(GetProcessHeap(), 0, lpStringW); + return bResult; } @@ -223,16 +218,15 @@ _In_ INT cchString, _Out_ LPSIZE lpsz) { - ANSI_STRING StringA; - UNICODE_STRING StringU; + WCHAR *lpStringW; + INT countW; BOOL ret; - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + lpStringW = FONT_mbtowc(hdc, lpString, cchString, &countW, NULL); - ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpsz); + ret = GetTextExtentPointW(hdc, lpStringW, cchString, lpsz); - RtlFreeUnicodeString(&StringU); + HeapFree(GetProcessHeap(), 0, lpStringW); return ret; } @@ -303,7 +297,7 @@ WINAPI GetTextExtentExPointA( _In_ HDC hdc, - _In_reads_(cchString) LPCSTR lpszStr, + _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString, _In_ INT nMaxExtent, _Out_opt_ LPINT lpnFit, @@ -310,8 +304,8 @@ _Out_writes_to_opt_ (cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize) { - NTSTATUS Status; - LPWSTR lpszStrW; + WCHAR *lpStringW; + INT countW; BOOL bResult = FALSE; if (nMaxExtent < -1) @@ -320,15 +314,10 @@ return FALSE; } - Status = HEAP_strdupA2W(&lpszStrW, lpszStr); - if (!NT_SUCCESS (Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } + lpStringW = FONT_mbtowc(hdc, lpString, cchString, &countW, NULL); bResult = NtGdiGetTextExtentExW(hdc, - lpszStrW, + lpStringW, cchString, nMaxExtent, (PULONG)lpnFit, @@ -336,7 +325,7 @@ lpSize, 0); - HEAP_free(lpszStrW); + HeapFree(GetProcessHeap(), 0, lpStringW); return bResult; } @@ -353,17 +342,15 @@ _In_ INT cchString, _Out_ LPSIZE lpSize) { - ANSI_STRING StringA; - UNICODE_STRING StringU; + WCHAR *lpStringW; + INT countW; BOOL ret; - StringA.Buffer = (LPSTR)lpString; - StringA.Length = cchString; - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + lpStringW = FONT_mbtowc(hdc, lpString, cchString, &countW, NULL); - ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize); + ret = GetTextExtentPoint32W(hdc, lpStringW, cchString, lpSize); - RtlFreeUnicodeString(&StringU); + HeapFree(GetProcessHeap(), 0, lpStringW); return ret; } @@ -433,19 +420,18 @@ _In_ UINT fuOptions, _In_opt_ const RECT *lprc, _In_reads_opt_(cch) LPCSTR lpString, - _In_ UINT cch, + _In_ UINT cchString, _In_reads_opt_(cch) const INT *lpDx) { - ANSI_STRING StringA; - UNICODE_STRING StringU; + WCHAR *lpStringW; + INT countW; BOOL ret; - RtlInitAnsiString(&StringA, (LPSTR)lpString); - RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE); + lpStringW = FONT_mbtowc(hdc, lpString, cchString, &countW, NULL); - ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, StringU.Buffer, cch, lpDx); + ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpStringW, cchString, lpDx); - RtlFreeUnicodeString(&StringU); + HeapFree(GetProcessHeap(), 0, lpStringW); return ret; }