From: Michael Müller michael@fds-team.de
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- Patch from Wine Staging. --- dlls/gdi32/font.c | 13 ++++++++++++- dlls/gdi32/tests/font.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 41ec07d1e2..c4b7cfb141 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -3204,10 +3204,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);
@@ -3262,6 +3270,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 8f5454b918..8a3f7a1efe 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4939,6 +4939,37 @@ 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); +} + static void test_CreateFontIndirect(void) { LOGFONTA lf, getobj_lf; @@ -6875,6 +6906,7 @@ START_TEST(font) test_GetTextMetrics2("Arial", -11); test_GetTextMetrics2("Arial", -55); test_GetTextMetrics2("Arial", -110); + test_GetCharacterPlacement(); test_CreateFontIndirect(); test_CreateFontIndirectEx(); test_oemcharset();