[PATCH 4/5] d3dx9: Implement ID3DXFont_PreloadText.
Sven Baars
sbaars at codeweavers.com
Wed Feb 26 05:09:00 CST 2020
Based on a patch by Tony Wasserka.
Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
dlls/d3dx9_36/font.c | 48 ++++++++++++++++++++++++++++++++++----
dlls/d3dx9_36/tests/core.c | 2 --
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index 00ba068f8e..44bd08a9fb 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -409,14 +409,54 @@ 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 == 0) 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(WCHAR));
+ 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;
+ UINT i;
+
+ TRACE("iface %p, string %s, count %d\n", iface, debugstr_w(string), count);
+
+ if (!string && count == 0) return D3D_OK;
+ if (!string) return D3DERR_INVALIDCALL;
+ if (count < 0) count = lstrlenW(string);
+
+ indices = heap_alloc(count * sizeof(WORD));
+ 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);
--
2.24.0
More information about the wine-devel
mailing list