diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index 51704e2bbbe..1a95dbeca02 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -168,9 +168,50 @@ static HRESULT WINAPI d3dx_font_GetGlyphData(ID3DX10Font *iface, UINT glyph, static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first, UINT last) { - FIXME("iface %p, first %u, last %u stub!\n", iface, first, last); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + unsigned int i, count, start, end; + WORD *indices; + WCHAR *chars; - return E_NOTIMPL; + TRACE("iface %p, first %u, last %u.\n", iface, first, last); + + if (last < first) + return S_OK; + + count = last - first + 1; + indices = heap_alloc(count * sizeof(*indices)); + if (!indices) + return E_OUTOFMEMORY; + + chars = heap_alloc(count * sizeof(*chars)); + if (!chars) + { + heap_free(indices); + return E_OUTOFMEMORY; + } + + for (i = 0; i < count; ++i) + chars[i] = first + i; + + GetGlyphIndicesW(font->hdc, chars, count, indices, 0); + + start = end = indices[0]; + for (i = 1; i < count; ++i) + { + if (indices[i] == end + 1) + { + end = indices[i]; + continue; + } + ID3DX10Font_PreloadGlyphs(iface, start, end); + start = end = indices[i]; + } + ID3DX10Font_PreloadGlyphs(iface, start, end); + + heap_free(chars); + heap_free(indices); + + return S_OK; } static HRESULT WINAPI d3dx_font_PreloadGlyphs(ID3DX10Font *iface, UINT first, UINT last) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 65bccb71521..c7aa3eccd24 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2307,14 +2307,12 @@ todo_wine ID3D10ShaderResourceView_Release(srv); hr = ID3DX10Font_PreloadCharacters(font, 'b', 'a'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadGlyphs(font, 1, 0); todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadCharacters(font, 'a', 'a'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); for (c = 'b'; c <= 'z'; ++c) @@ -2376,7 +2374,6 @@ todo_wine } hr = ID3DX10Font_PreloadCharacters(font, 'a', 'z'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); /* Test multiple textures */