Commit 96721e42 authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

gdi32: Treat lpResults as optional in GetCharacterPlacement.

parent bddb067d
......@@ -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,
......
......@@ -4939,6 +4939,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;
......@@ -6875,6 +6908,7 @@ START_TEST(font)
test_GetTextMetrics2("Arial", -11);
test_GetTextMetrics2("Arial", -55);
test_GetTextMetrics2("Arial", -110);
test_GetCharacterPlacement();
test_CreateFontIndirect();
test_CreateFontIndirectEx();
test_oemcharset();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment