Module: wine Branch: stable Commit: 8be91ed5710faf4b6bb2612d82b1e058d7cd60d5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=8be91ed5710faf4b6bb2612d8...
Author: Michael Müller michael@fds-team.de Date: Mon Jul 16 08:30:57 2018 +0100
gdi32: Treat lpResults as optional in GetCharacterPlacement.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 96721e4291378f0c2dfe6948df95691752250b95) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/gdi32/font.c | 13 ++++++++++++- dlls/gdi32/tests/font.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index d059f97..1a72026 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -3201,10 +3201,18 @@ GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount, TRACE("%s, %d, %d, 0x%08x\n", debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
+ lpStringW = FONT_mbtowc(hdc, lpString, uCount, &uCountW, &font_cp); + + if (!lpResults) + { + ret = GetCharacterPlacementW(hdc, lpStringW, uCountW, nMaxExtent, NULL, dwFlags); + HeapFree(GetProcessHeap(), 0, lpStringW); + return ret; + } + /* both structs are equal in size */ memcpy(&resultsW, lpResults, sizeof(resultsW));
- lpStringW = FONT_mbtowc(hdc, lpString, uCount, &uCountW, &font_cp); if(lpResults->lpOutString) resultsW.lpOutString = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*uCountW);
@@ -3259,6 +3267,9 @@ GetCharacterPlacementW( TRACE("%s, %d, %d, 0x%08x\n", debugstr_wn(lpString, uCount), uCount, nMaxExtent, dwFlags);
+ if (!lpResults) + return GetTextExtentPoint32W(hdc, lpString, uCount, &size) ? MAKELONG(size.cx, size.cy) : 0; + TRACE("lStructSize=%d, lpOutString=%p, lpOrder=%p, lpDx=%p, lpCaretPos=%p\n" "lpClass=%p, lpGlyphs=%p, nGlyphs=%u, nMaxFit=%d\n", lpResults->lStructSize, lpResults->lpOutString, lpResults->lpOrder, diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index ec4b29e..45686f3 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4904,6 +4904,39 @@ static void test_GetTextMetrics2(const char *fontname, int font_height) ok(ratio >= 90 && ratio <= 110, "expected width/height ratio 90-110, got %d\n", ratio); }
+static void test_GetCharacterPlacement(void) +{ + GCP_RESULTSA result; + DWORD size, size2; + WCHAR glyphs[20]; + HDC hdc; + + hdc = CreateCompatibleDC(0); + ok(!!hdc, "CreateCompatibleDC failed\n"); + + memset(&result, 0, sizeof(result)); + result.lStructSize = sizeof(result); + result.lpGlyphs = glyphs; + result.nGlyphs = 20; + + size = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, &result, 0); + ok(size, "GetCharacterPlacementA failed!\n"); + + size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, NULL, 0); + ok(size2, "GetCharacterPlacementA failed!\n"); + ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + + size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, NULL, GCP_REORDER); + ok(size2, "GetCharacterPlacementA failed!\n"); + ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + + size = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, &result, GCP_REORDER); + ok(size, "GetCharacterPlacementA failed!\n"); + ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + + DeleteDC(hdc); +} + static void test_CreateFontIndirect(void) { LOGFONTA lf, getobj_lf; @@ -6831,6 +6864,7 @@ START_TEST(font) test_GetTextMetrics2("Arial", -11); test_GetTextMetrics2("Arial", -55); test_GetTextMetrics2("Arial", -110); + test_GetCharacterPlacement(); test_CreateFontIndirect(); test_CreateFontIndirectEx(); test_oemcharset();