Based on a patch by Tony Wasserka.
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 56 +++++++++++++++++++++++++++++++++++--- dlls/d3dx9_36/tests/core.c | 2 -- 2 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 9196295637..8d2d6c8c44 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -420,14 +420,62 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count) { - FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count); - return E_NOTIMPL; + WCHAR *wstr; + HRESULT hr; + int countW; + + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_a(string), count); + + if (!string && !count) + return D3D_OK; + + if (!string) + return D3DERR_INVALIDCALL; + + countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0); + + wstr = heap_alloc(countW * sizeof(*wstr)); + if (!wstr) + return E_OUTOFMEMORY; + + MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW); + + hr = ID3DXFont_PreloadTextW(iface, wstr, count); + + heap_free(wstr); + + return hr; }
static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *string, INT count) { - FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_w(string), count); - return E_NOTIMPL; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + WORD *indices; + int i; + + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_w(string), count); + + if (!string && !count) + return D3D_OK; + + if (!string) + return D3DERR_INVALIDCALL; + + if (count < 0) + count = lstrlenW(string); + + indices = heap_alloc(count * sizeof(*indices)); + if (!indices) + return E_OUTOFMEMORY; + + GetGlyphIndicesW(font->hdc, string, count, indices, 0); + + for (i = 0; i < count; ++i) + ID3DXFont_PreloadGlyphs(iface, indices[i], indices[i]); + + heap_free(indices); + + return D3D_OK; }
static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index b8e680d1c5..662483b687 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -504,7 +504,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- todo_wine { hr = ID3DXFont_PreloadTextA(font, NULL, -1); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadTextA(font, NULL, 0); @@ -530,7 +529,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadTextW(font, L"", -1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - }
check_release((IUnknown*)font, 0);
Based on a patch by Tony Wasserka.
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 127 +++++++++++++++++++++++++++++++++++-- dlls/d3dx9_36/tests/core.c | 59 ++++++++--------- 2 files changed, 148 insertions(+), 38 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 8d2d6c8c44..7a187f63de 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -481,17 +481,132 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", - iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + int ret, countW; + WCHAR *wstr; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", + iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); + + if (!string || !count) + return 0; + + countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0); + + if (!countW) + return 0; + + wstr = heap_alloc_zero(countW * sizeof(*wstr)); + if (!wstr) + return 0; + + MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW); + + ret = ID3DXFont_DrawTextW(iface, sprite, wstr, count, rect, format, color); + + heap_free(wstr); + + return ret; }
static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", - iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ID3DXSprite *target = sprite; + RECT textrect = {0}; + int lh, x, y; + int ret = 0; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", + iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); + + if (!string) + return 0; + + if (count < 0) + count = lstrlenW(string); + + if (!count) + return 0; + + if (!rect) + { + y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); + + if (format & DT_CALCRECT) + return y; + } + else + { + textrect = *rect; + } + + x = textrect.left; + y = textrect.top; + + lh = font->metrics.tmHeight; + + if (!(format & DT_CALCRECT) && !sprite) + { + D3DXCreateSprite(font->device, &target); + ID3DXSprite_Begin(target, 0); + } + + if (!(format & DT_CALCRECT)) + { + GCP_RESULTSW results; + D3DXVECTOR3 pos; + int i; + + memset(&results, 0, sizeof(results)); + results.nGlyphs = count; + + results.lpCaretPos = heap_alloc(count * sizeof(*results.lpCaretPos)); + if (!results.lpCaretPos) + goto cleanup; + + results.lpGlyphs = heap_alloc(count * sizeof(*results.lpGlyphs)); + if (!results.lpGlyphs) + { + heap_free(results.lpCaretPos); + goto cleanup; + } + + GetCharacterPlacementW(font->hdc, string, count, 0, &results, 0); + + for (i = 0; i < results.nGlyphs; ++i) + { + IDirect3DTexture9 *texture; + POINT cell_inc; + RECT black_box; + + ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc); + + if (!texture) + continue; + + pos.x = cell_inc.x + x + results.lpCaretPos[i]; + pos.y = cell_inc.y + y; + + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); + IDirect3DTexture9_Release(texture); + } + + heap_free(results.lpCaretPos); + heap_free(results.lpGlyphs); + } + y += lh; + + ret = y - textrect.top; + +cleanup: + if (target != sprite) + { + ID3DXSprite_End(target); + ID3DXSprite_Release(target); + } + + return ret; }
static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 662483b687..c1e0eac0c8 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -652,8 +652,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND); ok (hr == D3D_OK, "Test %d: got unexpected hr %#x.\n", i, hr);
- todo_wine - { height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff); ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff); @@ -662,12 +660,11 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, 0xffffffff); ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); - }
SetRectEmpty(&rect); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_CALCRECT, 0xffffffff); - todo_wine ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); ok(!rect.left, "Test %d: got unexpected rect left %d.\n", i, rect.left); ok(!rect.top, "Test %d: got unexpected rect top %d.\n", i, rect.top); todo_wine ok(rect.right, "Test %d: got unexpected rect right %d.\n", i, rect.right); @@ -687,7 +684,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- todo_wine { SetRect(&rect, 10, 10, 200, 200);
height = ID3DXFont_DrawTextA(font, NULL, "test", -2, &rect, 0, 0xFF00FF); @@ -723,10 +719,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) SetRect(&rect, 10, 10, 50, 50);
height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - ok(height == 96, "Got unexpected height %d.\n", height); + todo_wine ok(height == 96, "Got unexpected height %d.\n", height);
SetRect(&rect, 10, 10, 200, 200);
@@ -760,16 +756,16 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) SetRect(&rect, 10, 10, 50, 50);
height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - ok(height == 96, "Got unexpected height %d.\n", height); + todo_wine ok(height == 96, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\ra", -1, &rect, 0, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height); @@ -778,71 +774,70 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); - ok(height == 48, "Got unexpected height %d.\n", height); + todo_wine ok(height == 48, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); - ok(height == 72, "Got unexpected height %d.\n", height); + todo_wine ok(height == 72, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 0, "Got unexpected height %d.\n", height); + todo_wine ok(height == 0, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\ta", -1, &rect, DT_WORDBREAK, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 48, "Got unexpected height %d.\n", height); + todo_wine ok(height == 48, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\ta\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a a", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, 0xff00ff); - ok(height == 40, "Got unexpected height %d.\n", height); + todo_wine ok(height == 40, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER, 0xff00ff); - ok(height == 32, "Got unexpected height %d.\n", height); + todo_wine ok(height == 32, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); - } + todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
ID3DXFont_Release(font); }
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 109 ++++++++++++++++++++++++++----------- dlls/d3dx9_36/tests/core.c | 14 ++--- 2 files changed, 83 insertions(+), 40 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 7a187f63de..a4154c8264 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -508,14 +508,49 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, return ret; }
+#define LF 10 +#define CR 13 +static const WCHAR *TEXT_NextLineW(HDC hdc, const WCHAR *str, int *count, + WCHAR *dest, int *len, int width, SIZE *retsize) +{ + int max_len = *len; + int i = 0, j = 0; + + while (*count && str[i] != LF) + { + --(*count); + if (j < max_len && str[i] != CR) + dest[j++] = str[i]; + ++i; + } + + GetTextExtentExPointW(hdc, dest, j, width, NULL, NULL, retsize); + + if (*count && str[i] == LF) + { + --(*count); + ++i; + } + + *len = j; + if (*count) + return str + i; + else + return NULL; +} + +#define MAX_BUFFER 1024 static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { struct d3dx_font *font = impl_from_ID3DXFont(iface); ID3DXSprite *target = sprite; + const WCHAR *strPtr = string; + WCHAR line[MAX_BUFFER]; RECT textrect = {0}; - int lh, x, y; + int lh, x, y, width; int ret = 0; + SIZE size;
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); @@ -543,6 +578,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
x = textrect.left; y = textrect.top; + width = textrect.right - textrect.left;
lh = font->metrics.tmHeight;
@@ -552,50 +588,57 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, ID3DXSprite_Begin(target, 0); }
- if (!(format & DT_CALCRECT)) + while (strPtr) { - GCP_RESULTSW results; - D3DXVECTOR3 pos; - int i; - - memset(&results, 0, sizeof(results)); - results.nGlyphs = count; + int len = ARRAY_SIZE(line);
- results.lpCaretPos = heap_alloc(count * sizeof(*results.lpCaretPos)); - if (!results.lpCaretPos) - goto cleanup; + strPtr = TEXT_NextLineW(font->hdc, strPtr, &count, line, &len, width, &size);
- results.lpGlyphs = heap_alloc(count * sizeof(*results.lpGlyphs)); - if (!results.lpGlyphs) + if (!(format & DT_CALCRECT)) { - heap_free(results.lpCaretPos); - goto cleanup; - } + GCP_RESULTSW results; + D3DXVECTOR3 pos; + int i;
- GetCharacterPlacementW(font->hdc, string, count, 0, &results, 0); + memset(&results, 0, sizeof(results)); + results.nGlyphs = len;
- for (i = 0; i < results.nGlyphs; ++i) - { - IDirect3DTexture9 *texture; - POINT cell_inc; - RECT black_box; + results.lpCaretPos = heap_alloc(len * sizeof(*results.lpCaretPos)); + if (!results.lpCaretPos) + goto cleanup;
- ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc); + results.lpGlyphs = heap_alloc(len * sizeof(*results.lpGlyphs)); + if (!results.lpGlyphs) + { + heap_free(results.lpCaretPos); + goto cleanup; + }
- if (!texture) - continue; + GetCharacterPlacementW(font->hdc, line, len, 0, &results, 0);
- pos.x = cell_inc.x + x + results.lpCaretPos[i]; - pos.y = cell_inc.y + y; + for (i = 0; i < results.nGlyphs; ++i) + { + IDirect3DTexture9 *texture; + POINT cell_inc; + RECT black_box;
- ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); - IDirect3DTexture9_Release(texture); - } + ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc);
- heap_free(results.lpCaretPos); - heap_free(results.lpGlyphs); + if (!texture) + continue; + + pos.x = cell_inc.x + x + results.lpCaretPos[i]; + pos.y = cell_inc.y + y; + + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); + IDirect3DTexture9_Release(texture); + } + + heap_free(results.lpCaretPos); + heap_free(results.lpGlyphs); + } + y += lh; } - y += lh;
ret = y - textrect.top;
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index c1e0eac0c8..c6f5beff43 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -762,19 +762,19 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 96, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\ra", -1, &rect, 0, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, 0xff00ff); - ok(height == 12, "Got unexpected height %d.\n", height); + todo_wine ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 36, "Got unexpected height %d.\n", height); @@ -783,7 +783,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 48, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 72, "Got unexpected height %d.\n", height); + ok(height == 72, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 0, "Got unexpected height %d.\n", height); @@ -834,10 +834,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 32, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
ID3DXFont_Release(font); }
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 5 +++++ dlls/d3dx9_36/tests/core.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index a4154c8264..00d7bf29d2 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -564,6 +564,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, if (!count) return 0;
+ if (format & DT_CALCRECT) + format |= DT_NOCLIP; + if (!rect) { y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); @@ -638,6 +641,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, heap_free(results.lpGlyphs); } y += lh; + if (!(DT_NOCLIP & format) && (y > textrect.bottom)) + break; }
ret = y - textrect.top; diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index c6f5beff43..c79f5c1f72 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -780,7 +780,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 48, "Got unexpected height %d.\n", height); + ok(height == 48, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); ok(height == 72, "Got unexpected height %d.\n", height);
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_24/Makefile.in | 2 +- dlls/d3dx9_25/Makefile.in | 2 +- dlls/d3dx9_26/Makefile.in | 2 +- dlls/d3dx9_27/Makefile.in | 2 +- dlls/d3dx9_28/Makefile.in | 2 +- dlls/d3dx9_29/Makefile.in | 2 +- dlls/d3dx9_30/Makefile.in | 2 +- dlls/d3dx9_31/Makefile.in | 2 +- dlls/d3dx9_32/Makefile.in | 2 +- dlls/d3dx9_33/Makefile.in | 2 +- dlls/d3dx9_34/Makefile.in | 2 +- dlls/d3dx9_35/Makefile.in | 2 +- dlls/d3dx9_36/Makefile.in | 2 +- dlls/d3dx9_36/font.c | 73 +++++++++++++++++++++++++++++++++++--- dlls/d3dx9_36/tests/core.c | 22 ++++++------ dlls/d3dx9_37/Makefile.in | 2 +- dlls/d3dx9_38/Makefile.in | 2 +- dlls/d3dx9_39/Makefile.in | 2 +- dlls/d3dx9_40/Makefile.in | 2 +- dlls/d3dx9_41/Makefile.in | 2 +- dlls/d3dx9_42/Makefile.in | 2 +- dlls/d3dx9_43/Makefile.in | 2 +- 22 files changed, 100 insertions(+), 35 deletions(-)
diff --git a/dlls/d3dx9_24/Makefile.in b/dlls/d3dx9_24/Makefile.in index faad4c49ac..f80541a9aa 100644 --- a/dlls/d3dx9_24/Makefile.in +++ b/dlls/d3dx9_24/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=24 MODULE = d3dx9_24.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_25/Makefile.in b/dlls/d3dx9_25/Makefile.in index 292b33db2b..e3144f0d45 100644 --- a/dlls/d3dx9_25/Makefile.in +++ b/dlls/d3dx9_25/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=25 MODULE = d3dx9_25.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_26/Makefile.in b/dlls/d3dx9_26/Makefile.in index 22bb54a498..1b432afb21 100644 --- a/dlls/d3dx9_26/Makefile.in +++ b/dlls/d3dx9_26/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=26 MODULE = d3dx9_26.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_27/Makefile.in b/dlls/d3dx9_27/Makefile.in index 4ed104a170..65d8cad9d6 100644 --- a/dlls/d3dx9_27/Makefile.in +++ b/dlls/d3dx9_27/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=27 MODULE = d3dx9_27.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_28/Makefile.in b/dlls/d3dx9_28/Makefile.in index 94e059ae9d..ff7ba564c1 100644 --- a/dlls/d3dx9_28/Makefile.in +++ b/dlls/d3dx9_28/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=28 MODULE = d3dx9_28.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_29/Makefile.in b/dlls/d3dx9_29/Makefile.in index 94b39aee37..7e53415c43 100644 --- a/dlls/d3dx9_29/Makefile.in +++ b/dlls/d3dx9_29/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=29 MODULE = d3dx9_29.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_30/Makefile.in b/dlls/d3dx9_30/Makefile.in index 6beadbc47e..9bc955753f 100644 --- a/dlls/d3dx9_30/Makefile.in +++ b/dlls/d3dx9_30/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=30 MODULE = d3dx9_30.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_31/Makefile.in b/dlls/d3dx9_31/Makefile.in index b73f32872c..58b72c527c 100644 --- a/dlls/d3dx9_31/Makefile.in +++ b/dlls/d3dx9_31/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=31 MODULE = d3dx9_31.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_32/Makefile.in b/dlls/d3dx9_32/Makefile.in index 50bc9d0e26..88cc083bbe 100644 --- a/dlls/d3dx9_32/Makefile.in +++ b/dlls/d3dx9_32/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=32 MODULE = d3dx9_32.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_33/Makefile.in b/dlls/d3dx9_33/Makefile.in index 7be34e1d4b..f6de942ed8 100644 --- a/dlls/d3dx9_33/Makefile.in +++ b/dlls/d3dx9_33/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=33 MODULE = d3dx9_33.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_34/Makefile.in b/dlls/d3dx9_34/Makefile.in index 248735a531..5d0bc9b3a4 100644 --- a/dlls/d3dx9_34/Makefile.in +++ b/dlls/d3dx9_34/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=34 MODULE = d3dx9_34.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_35/Makefile.in b/dlls/d3dx9_35/Makefile.in index 01c809dab2..5eb00327c1 100644 --- a/dlls/d3dx9_35/Makefile.in +++ b/dlls/d3dx9_35/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=35 MODULE = d3dx9_35.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in index 825e5ddfbc..6a08c41159 100644 --- a/dlls/d3dx9_36/Makefile.in +++ b/dlls/d3dx9_36/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=36 MODULE = d3dx9_36.dll IMPORTLIB = d3dx9 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 00d7bf29d2..d613b2e92e 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -20,6 +20,10 @@
#include "d3dx9_private.h"
+#include <assert.h> + +#include "usp10.h" + WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
struct d3dx_glyph @@ -508,13 +512,61 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, return ret; }
+static void TEXT_WordBreak(HDC hdc, const WCHAR *str, unsigned int *len_str, + int format, unsigned int chars_fit, + unsigned int *chars_used, SIZE *size) +{ + SCRIPT_LOGATTR *sla; + SCRIPT_ANALYSIS sa; + int i; + + assert(format & DT_WORDBREAK); + assert(chars_fit < *len_str); + + *chars_used = 0; + + sla = heap_alloc(*len_str * sizeof(*sla)); + if (!sla) + return; + + memset(&sa, 0, sizeof(sa)); + sa.eScript = SCRIPT_UNDEFINED; + + ScriptBreak(str, *len_str, &sa, sla); + + /* Work back from the last character that did fit to a place where we can break */ + i = chars_fit; + while (i > 0 && !sla[i].fSoftBreak) /* chars_fit < *len_str so this is valid */ + --i; + + /* If the there is no word that fits put in all characters that do fit */ + if (!sla[i].fSoftBreak) + i = chars_fit; + + *chars_used = i; + if (sla[i].fWhiteSpace) + ++(*chars_used); + + /* Remove extra spaces */ + while (i > 0 && sla[i-1].fWhiteSpace) + --i; + *len_str = i; + + /* Remeasure the string */ + GetTextExtentExPointW(hdc, str, *len_str, 0, NULL, NULL, size); + heap_free(sla); +} + #define LF 10 #define CR 13 static const WCHAR *TEXT_NextLineW(HDC hdc, const WCHAR *str, int *count, - WCHAR *dest, int *len, int width, SIZE *retsize) + WCHAR *dest, int *len, int width, + DWORD format, SIZE *retsize) { + unsigned int i = 0, j = 0; + int orig_count = *count; int max_len = *len; - int i = 0, j = 0; + int num_fit;
while (*count && str[i] != LF) { @@ -524,7 +576,19 @@ static const WCHAR *TEXT_NextLineW(HDC hdc, const WCHAR *str, int *count, ++i; }
- GetTextExtentExPointW(hdc, dest, j, width, NULL, NULL, retsize); + num_fit = 0; + GetTextExtentExPointW(hdc, dest, j, width, &num_fit, NULL, retsize); + + if (num_fit < j && (format & DT_WORDBREAK)) + { + unsigned int chars_used; + + TEXT_WordBreak(hdc, dest, &j, format, + num_fit, &chars_used, retsize); + *count = orig_count - chars_used; + i = chars_used; + } +
if (*count && str[i] == LF) { @@ -595,7 +659,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, { int len = ARRAY_SIZE(line);
- strPtr = TEXT_NextLineW(font->hdc, strPtr, &count, line, &len, width, &size); + strPtr = TEXT_NextLineW(font->hdc, strPtr, &count, line, &len, + width, format, &size);
if (!(format & DT_CALCRECT)) { diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index c79f5c1f72..45cde62b3a 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -722,7 +722,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 60, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 96, "Got unexpected height %d.\n", height); + ok(height == 96, "Got unexpected height %d.\n", height);
SetRect(&rect, 10, 10, 200, 200);
@@ -759,7 +759,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 60, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 96, "Got unexpected height %d.\n", height); + ok(height == 96, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); ok(height == 24, "Got unexpected height %d.\n", height); @@ -777,7 +777,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); ok(height == 48, "Got unexpected height %d.\n", height); @@ -789,16 +789,16 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 0, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\ta", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 12, "Got unexpected height %d.\n", height); + todo_wine ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 48, "Got unexpected height %d.\n", height); @@ -813,19 +813,19 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 24, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a a", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, 0xff00ff); todo_wine ok(height == 40, "Got unexpected height %d.\n", height); diff --git a/dlls/d3dx9_37/Makefile.in b/dlls/d3dx9_37/Makefile.in index a0896df82e..b9dda315f2 100644 --- a/dlls/d3dx9_37/Makefile.in +++ b/dlls/d3dx9_37/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=37 MODULE = d3dx9_37.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_38/Makefile.in b/dlls/d3dx9_38/Makefile.in index 24bbc3f0cf..adeb4f245a 100644 --- a/dlls/d3dx9_38/Makefile.in +++ b/dlls/d3dx9_38/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=38 MODULE = d3dx9_38.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_39/Makefile.in b/dlls/d3dx9_39/Makefile.in index a3f7626f33..0e210488f6 100644 --- a/dlls/d3dx9_39/Makefile.in +++ b/dlls/d3dx9_39/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=39 MODULE = d3dx9_39.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_40/Makefile.in b/dlls/d3dx9_40/Makefile.in index fbbcb0c04e..05349e4b40 100644 --- a/dlls/d3dx9_40/Makefile.in +++ b/dlls/d3dx9_40/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=40 MODULE = d3dx9_40.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_41/Makefile.in b/dlls/d3dx9_41/Makefile.in index 9b44213117..587e94b7d1 100644 --- a/dlls/d3dx9_41/Makefile.in +++ b/dlls/d3dx9_41/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=41 MODULE = d3dx9_41.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_42/Makefile.in b/dlls/d3dx9_42/Makefile.in index f725e87471..bb837c4e39 100644 --- a/dlls/d3dx9_42/Makefile.in +++ b/dlls/d3dx9_42/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=42 MODULE = d3dx9_42.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3dx9_43/Makefile.in b/dlls/d3dx9_43/Makefile.in index dbebc51ad0..0701cde7b7 100644 --- a/dlls/d3dx9_43/Makefile.in +++ b/dlls/d3dx9_43/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=43 MODULE = d3dx9_43.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 ucrtbase PARENTSRC = ../d3dx9_36 -DELAYIMPORTS = windowscodecs +DELAYIMPORTS = windowscodecs usp10
EXTRADLLFLAGS = -mno-cygwin
Hi Sven,
On Mon, 2 Mar 2020 11:51:52 +0100, Sven Baars wrote:
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 9196295637..8d2d6c8c44 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -420,14 +420,62 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count) {
- FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count);
- return E_NOTIMPL;
- WCHAR *wstr;
- HRESULT hr;
- int countW;
- TRACE("iface %p, string %s, count %d.\n", iface, debugstr_a(string), count);
debugstr_an(string, count) is preferable.
- if (!string && !count)
return D3D_OK;
- if (!string)
return D3DERR_INVALIDCALL;
- countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
- wstr = heap_alloc(countW * sizeof(*wstr));
- if (!wstr)
return E_OUTOFMEMORY;
- MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
- hr = ID3DXFont_PreloadTextW(iface, wstr, count);
You want to use countW instead of count here.
There are similar issues with ID3DXFontImpl_DrawTextA in PATCH 2/5.
Regards, Akihiro Sagawa
On 02-03-2020 15:20, Akihiro Sagawa wrote:
- MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
- hr = ID3DXFont_PreloadTextW(iface, wstr, count);
You want to use countW instead of count here.
There are similar issues with ID3DXFontImpl_DrawTextA in PATCH 2/5.
Regards, Akihiro Sagawa
Hi Akihiro,
Thanks for the comments. I could not exactly use countW there, but I sent updated patches that address the issue.
Cheers, Sven
On Mon, Mar 2, 2020 at 8:06 PM Akihiro Sagawa sagawa.aki@gmail.com wrote:
Hi Sven,
On Mon, 2 Mar 2020 11:51:52 +0100, Sven Baars wrote:
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 9196295637..8d2d6c8c44 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -420,14 +420,62 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count) {
- FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count);
- return E_NOTIMPL;
- WCHAR *wstr;
- HRESULT hr;
- int countW;
- TRACE("iface %p, string %s, count %d.\n", iface, debugstr_a(string), count);
debugstr_an(string, count) is preferable.
- if (!string && !count)
return D3D_OK;
- if (!string)
return D3DERR_INVALIDCALL;
- countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
- wstr = heap_alloc(countW * sizeof(*wstr));
- if (!wstr)
return E_OUTOFMEMORY;
- MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
- hr = ID3DXFont_PreloadTextW(iface, wstr, count);
You want to use countW instead of count here.
There are similar issues with ID3DXFontImpl_DrawTextA in PATCH 2/5.
Regards, Akihiro Sagawa
Thank you for having a look, that's very helpful!