Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/d3dx10_43/font.c | 28 ++++++++++++++++++++++++++--
dlls/d3dx10_43/tests/d3dx10.c | 9 ---------
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c
index 2145b1c6f1e..51704e2bbbe 100644
--- a/dlls/d3dx10_43/font.c
+++ b/dlls/d3dx10_43/font.c
@@ -210,9 +210,33 @@ static HRESULT WINAPI d3dx_font_PreloadTextA(ID3DX10Font *iface, const char *str
static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *string, INT count)
{
- FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_wn(string, count), count);
+ struct d3dx_font *font = impl_from_ID3DX10Font(iface);
+ WORD *indices;
+ int i;
- return E_NOTIMPL;
+ TRACE("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count);
+
+ if (!string && !count)
+ return S_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)
+ ID3DX10Font_PreloadGlyphs(iface, indices[i], indices[i]);
+
+ heap_free(indices);
+
+ return S_OK;
}
static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite,
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c
index 8c55dd5810b..65bccb71521 100644
--- a/dlls/d3dx10_43/tests/d3dx10.c
+++ b/dlls/d3dx10_43/tests/d3dx10.c
@@ -2263,32 +2263,23 @@ static void test_font(void)
hr = ID3DX10Font_PreloadTextA(font, NULL, 1);
ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextA(font, "test", -1);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextA(font, "", 0);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextA(font, "", -1);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, NULL, -1);
-todo_wine
ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, NULL, 0);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, NULL, 1);
-todo_wine
ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, testW, -1);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, L"", 0);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, L"", -1);
-todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3DX10Font_Release(font);
--
2.33.0