diff --git a/modules/rostests/apitests/gdi32/GetTextFace.c b/modules/rostests/apitests/gdi32/GetTextFace.c index e304986d13..e728573af8 100644 --- a/modules/rostests/apitests/gdi32/GetTextFace.c +++ b/modules/rostests/apitests/gdi32/GetTextFace.c @@ -3,16 +3,101 @@ * LICENSE: GPL - See COPYING in the top level directory * PURPOSE: Test for GetTextFace * PROGRAMMERS: Timo Kreuzer + * Katayama Hirofumi MZ + * Doug Lyons */ #include "precomp.h" +// GetTextFaceAliasW +typedef INT (WINAPI *GETTEXTFACEALIASW)(HDC, INT, LPWSTR); + void Test_GetTextFace() { HDC hDC; INT ret; INT ret2; WCHAR Buffer[20]; + HDC hdc; + INT i; + HFONT hFont; + HGDIOBJ hFontOld; + char buf1[LF_FACESIZE]; + char buf2[LF_FACESIZE]; + WCHAR szWide[LF_FACESIZE]; + + static const LPCSTR s_names[] = + { + "Arial", "Tahoma", "Tahoma Bold", "Helv", "invalid" + }; + + HMODULE hGdi32 = GetModuleHandleA("gdi32"); + GETTEXTFACEALIASW pGetTextFaceAliasW; + pGetTextFaceAliasW = (GETTEXTFACEALIASW)GetProcAddress(hGdi32, "GetTextFaceAliasW"); + if (!pGetTextFaceAliasW) + { + ok(FALSE, "GetTextFaceAliasW not found\n"); + return; + } + + hdc = CreateCompatibleDC(NULL); + if (hdc) + { + for (i = 0; i < (INT)ARRAYSIZE(s_names); ++i) + { + LOGFONTA lf = { 0 }; + lstrcpynA(lf.lfFaceName, s_names[i], ARRAYSIZE(lf.lfFaceName)); + + hFont = CreateFontIndirectA(&lf); + if (hFont) + { + hFontOld = SelectObject(hdc, hFont); + + GetTextFaceA(hdc, ARRAYSIZE(buf1), buf1); + + (*pGetTextFaceAliasW)(hdc, ARRAYSIZE(szWide), szWide); + + WideCharToMultiByte(CP_ACP, 0, szWide, -1, buf2, LF_FACESIZE, NULL, NULL); + + if (i == 0) + { + ok(strcmp(buf1, "Arial") == 0, "Arial GetTextFaceA failed, got '%s'.\n", buf1); + ok(strcmp(buf2, "Arial") == 0, "Arial GetTextFaceAliasW failed, got '%s'.\n", buf2); + } + + if (i == 1) + { + ok(strcmp(buf1, "Tahoma") == 0, "Tahoma GetTextFaceA failed, got '%s'.\n", buf1); + ok(strcmp(buf2, "Tahoma") == 0, "Tahoma GetTextFaceAliasW failed, got '%s'.\n", buf2); + } + + + if (i == 2) + { + ok(strcmp(buf1, "Tahoma Bold") == 0, "Tahoma Bold GetTextFaceA failed, got '%s'.\n", buf1); + ok(strcmp(buf2, "Tahoma Bold") == 0, "Tahoma Bold GetTextFaceAliasW failed, got '%s'.\n", buf2); + } + + + if (i == 3) + { + ok(strcmp(buf1, "Helv") == 0, "Helv GetTextFaceA failed, got '%s'.\n", buf1); + ok(strcmp(buf2, "Helv") == 0, "Helv GetTextFaceAliasW failed, got '%s'.\n", buf2); + } + + + if (i == 4) + { + ok(strcmp(buf1, "invalid") != 0, "Invalid Font Name GetTextFaceA failed, got '%s'.\n", buf1); + ok(strcmp(buf2, "invalid") != 0, "Invalid Font Name GetTextFaceAliasW failed, got '%s'.\n", buf2); + } + + SelectObject(hdc, hFontOld); + DeleteObject(hFont); + } + } + DeleteDC(hdc); + } hDC = CreateCompatibleDC(NULL); ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");