Added patch to treat lpResults as optional in gdi32.GetCharacterPlacement.

This commit is contained in:
Sebastian Lackner 2017-03-20 17:40:32 +01:00
parent 3f05773e20
commit 3e2e449d4e
3 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,97 @@
From 1f4a7bc3ed8ede33a6e623bf49067550cee433d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 19 Mar 2017 15:52:42 +0100
Subject: gdi32: Treat lpResults as optional in GetCharacterPlacement.
---
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 ddd0051ab6..fcc24d8645 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 fb27f8e005..974b471462 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -4910,6 +4910,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;
@@ -6682,6 +6713,7 @@ START_TEST(font)
test_GetTextMetrics2("Arial", -11);
test_GetTextMetrics2("Arial", -55);
test_GetTextMetrics2("Arial", -110);
+ test_GetCharacterPlacement();
test_CreateFontIndirect();
test_CreateFontIndirectEx();
test_oemcharset();
--
2.11.0

View File

@ -0,0 +1 @@
Fixes: [42669] Treat lpResults as optional in gdi32.GetCharacterPlacement

View File

@ -156,6 +156,7 @@ patch_enable_all ()
enable_explorer_Video_Registry_Key="$1"
enable_fonts_Missing_Fonts="$1"
enable_fsutil_Stub_Program="$1"
enable_gdi32_GetCharacterPlacement="$1"
enable_gdi32_Lazy_Font_Initialization="$1"
enable_gdi32_MultiMonitor="$1"
enable_gdi32_Path_Metafile="$1"
@ -691,6 +692,9 @@ patch_enable ()
fsutil-Stub_Program)
enable_fsutil_Stub_Program="$2"
;;
gdi32-GetCharacterPlacement)
enable_gdi32_GetCharacterPlacement="$2"
;;
gdi32-Lazy_Font_Initialization)
enable_gdi32_Lazy_Font_Initialization="$2"
;;
@ -4077,6 +4081,21 @@ if test "$enable_fsutil_Stub_Program" -eq 1; then
) >> "$patchlist"
fi
# Patchset gdi32-GetCharacterPlacement
# |
# | This patchset fixes the following Wine bugs:
# | * [#42669] Treat lpResults as optional in gdi32.GetCharacterPlacement
# |
# | Modified files:
# | * dlls/gdi32/font.c, dlls/gdi32/tests/font.c
# |
if test "$enable_gdi32_GetCharacterPlacement" -eq 1; then
patch_apply gdi32-GetCharacterPlacement/0001-gdi32-Treat-lpResults-as-optional-in-GetCharacterPla.patch
(
printf '%s\n' '+ { "Michael Müller", "gdi32: Treat lpResults as optional in GetCharacterPlacement.", 1 },';
) >> "$patchlist"
fi
# Patchset gdi32-Lazy_Font_Initialization
# |
# | Modified files: