dwrite: Added IDWriteLocalizedStrings stub.

This commit is contained in:
Nikolay Sivov 2012-10-07 13:11:04 -04:00 committed by Alexandre Julliard
parent 89561b9247
commit 45a9560e83
4 changed files with 171 additions and 1 deletions

View file

@ -46,3 +46,4 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;

View file

@ -256,8 +256,9 @@ static HRESULT WINAPI dwritefontfamily_GetFont(IDWriteFontFamily *iface, UINT32
static HRESULT WINAPI dwritefontfamily_GetFamilyNames(IDWriteFontFamily *iface, IDWriteLocalizedStrings **names)
{
struct dwrite_fontfamily *This = impl_from_IDWriteFontFamily(iface);
FIXME("(%p)->(%p): stub\n", This, names);
return E_NOTIMPL;
return create_localizedstrings(names);
}
static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily *iface, DWRITE_FONT_WEIGHT weight,

View file

@ -172,6 +172,127 @@ static HRESULT create_renderingparams(FLOAT gamma, FLOAT enhancedContrast, FLOAT
return S_OK;
}
struct localizedstrings {
IDWriteLocalizedStrings IDWriteLocalizedStrings_iface;
LONG ref;
};
static inline struct localizedstrings *impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings *iface)
{
return CONTAINING_RECORD(iface, struct localizedstrings, IDWriteLocalizedStrings_iface);
}
static HRESULT WINAPI localizedstrings_QueryInterface(IDWriteLocalizedStrings *iface, REFIID riid, void **obj)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteLocalizedStrings))
{
*obj = iface;
IDWriteLocalizedStrings_AddRef(iface);
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI localizedstrings_AddRef(IDWriteLocalizedStrings *iface)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
if (!ref)
heap_free(This);
return S_OK;
}
static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p): stub\n", This);
return 0;
}
static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
WCHAR const *locale_name, UINT32 *index, BOOL *exists)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%s %p %p): stub\n", This, debugstr_w(locale_name), index, exists);
return E_NOTIMPL;
}
static HRESULT WINAPI localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p): stub\n", This, index, length);
return E_NOTIMPL;
}
static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *locale_name, UINT32 size)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p %u): stub\n", This, index, locale_name, size);
return E_NOTIMPL;
}
static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p): stub\n", This, index, length);
return E_NOTIMPL;
}
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p %u): stub\n", This, index, buffer, size);
return E_NOTIMPL;
}
static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = {
localizedstrings_QueryInterface,
localizedstrings_AddRef,
localizedstrings_Release,
localizedstrings_GetCount,
localizedstrings_FindLocaleName,
localizedstrings_GetLocaleNameLength,
localizedstrings_GetLocaleName,
localizedstrings_GetStringLength,
localizedstrings_GetString
};
HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings)
{
struct localizedstrings *This;
*strings = NULL;
This = heap_alloc(sizeof(struct localizedstrings));
if (!This) return E_OUTOFMEMORY;
This->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
This->ref = 1;
*strings = &This->IDWriteLocalizedStrings_iface;
return S_OK;
}
static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj)
{
TRACE("(%s %p)\n", debugstr_guid(riid), obj);

View file

@ -312,6 +312,52 @@ if (0) /* crashes on native */
IDWriteGdiInterop_Release(interop);
}
static void test_GetFamilyNames(void)
{
static const WCHAR arialW[] = {'A','r','i','a','l',0};
IDWriteFontFamily *family;
IDWriteLocalizedStrings *names, *names2;
IDWriteGdiInterop *interop;
IDWriteFont *font;
LOGFONTW logfont;
HRESULT hr;
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
EXPECT_HR(hr, S_OK);
memset(&logfont, 0, sizeof(logfont));
logfont.lfHeight = 12;
logfont.lfWidth = 12;
logfont.lfWeight = FW_NORMAL;
logfont.lfItalic = 1;
lstrcpyW(logfont.lfFaceName, arialW);
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
EXPECT_HR(hr, S_OK);
hr = IDWriteFont_GetFontFamily(font, &family);
EXPECT_HR(hr, S_OK);
if (0) /* crashes on native */
hr = IDWriteFontFamily_GetFamilyNames(family, NULL);
hr = IDWriteFontFamily_GetFamilyNames(family, &names);
ok(hr == S_OK, "got 0x%08x\n", hr);
EXPECT_REF(names, 1);
hr = IDWriteFontFamily_GetFamilyNames(family, &names2);
ok(hr == S_OK, "got 0x%08x\n", hr);
EXPECT_REF(names2, 1);
ok(names != names2, "got %p, was %p\n", names2, names);
IDWriteLocalizedStrings_Release(names);
IDWriteLocalizedStrings_Release(names2);
IDWriteFontFamily_Release(family);
IDWriteFont_Release(font);
IDWriteGdiInterop_Release(interop);
}
START_TEST(font)
{
HRESULT hr;
@ -327,6 +373,7 @@ START_TEST(font)
test_CreateFontFromLOGFONT();
test_CreateBitmapRenderTarget();
test_GetFontFamily();
test_GetFamilyNames();
IDWriteFactory_Release(factory);
}