Nikolay Sivov : dwrite: Added IDWriteLocalizedStrings stub.
Alexandre Julliard
julliard at winehq.org
Mon Oct 8 13:39:56 CDT 2012
Module: wine
Branch: master
Commit: 45a9560e83bf172f95e404730f451fef544dc650
URL: http://source.winehq.org/git/wine.git/?a=commit;h=45a9560e83bf172f95e404730f451fef544dc650
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Oct 7 13:11:04 2012 -0400
dwrite: Added IDWriteLocalizedStrings stub.
---
dlls/dwrite/dwrite_private.h | 1 +
dlls/dwrite/font.c | 3 +-
dlls/dwrite/main.c | 121 ++++++++++++++++++++++++++++++++++++++++++
dlls/dwrite/tests/font.c | 47 ++++++++++++++++
4 files changed, 171 insertions(+), 1 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index d3af015..cba8130 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -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;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 15e9d14..7a3ec6b 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -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,
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index c126ec1..679416b 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -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);
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 229e2f7..34d123c 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -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);
}
More information about the wine-cvs
mailing list