[PATCH 6/7] d3dx9: Implement ID3DXFont_PreloadText().

Nikolay Sivov nsivov at codeweavers.com
Sun Jan 5 04:03:36 CST 2020


On 1/4/20 2:59 PM, Sven Baars wrote:
>   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;
> +    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;
> +
> +    if (count < 0)
> +        count = MultiByteToWideChar(CP_ACP, 0, string, -1, NULL, 0);
> +
> +    wstr = heap_alloc_zero(count * sizeof(WCHAR));
> +    if (!wstr)
> +        return E_OUTOFMEMORY;
> +
> +    MultiByteToWideChar(CP_ACP, 0, string, -1, wstr, count);
> +
> +    hr = ID3DXFont_PreloadTextW(iface, wstr, count);
> +
> +    heap_free(wstr);
> +
> +    return hr;
There is some confusion with conversion here. Method argument indicates 
length on input A string, and if negative means it's terminated. So to 
convert to W:

- countW = mbtowc(string, count < 0 ? -1 : count, NULL, 0)
- wstr = heap_alloc(countW)
- mbtowc(string, count < 0 ? -1 : count, wstr, countW)



More information about the wine-devel mailing list