[5/6] dwrite: Implement GetStringLength method
Nikolay Sivov
nsivov at codeweavers.com
Mon Oct 8 01:02:23 CDT 2012
Implement GetStringLength method
-------------- next part --------------
>From c0197cb9270bf0f587b9ee33cb683d4a81e23224 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun, 7 Oct 2012 17:25:23 -0400
Subject: [PATCH 5/6] Implement GetStringLength method
---
dlls/dwrite/main.c | 12 ++++++++++--
dlls/dwrite/tests/font.c | 18 +++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index b056cb1..4ddc74b 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -271,8 +271,16 @@ static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *if
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;
+
+ TRACE("(%p)->(%u %p)\n", This, index, length);
+
+ if (index >= This->count) {
+ *length = (UINT32)-1;
+ return E_FAIL;
+ }
+
+ *length = strlenW(This->data[index].string);
+ return S_OK;
}
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 3bba1ca..b22453c 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -321,6 +321,7 @@ static void test_GetFamilyNames(void)
IDWriteFont *font;
LOGFONTW logfont;
HRESULT hr;
+ UINT32 len;
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
EXPECT_HR(hr, S_OK);
@@ -350,9 +351,24 @@ if (0) /* crashes on native */
EXPECT_REF(names2, 1);
ok(names != names2, "got %p, was %p\n", names2, names);
- IDWriteLocalizedStrings_Release(names);
IDWriteLocalizedStrings_Release(names2);
+ /* GetStringLength */
+if (0) /* crashes on native */
+ hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL);
+
+ len = 0;
+ hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(len > 0, "got %u\n", len);
+
+ len = 100;
+ hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
+ ok(hr == E_FAIL, "got 0x%08x\n", hr);
+ ok(len == (UINT32)-1, "got %u\n", len);
+
+ IDWriteLocalizedStrings_Release(names);
+
IDWriteFontFamily_Release(family);
IDWriteFont_Release(font);
IDWriteGdiInterop_Release(interop);
--
1.7.10.4
More information about the wine-patches
mailing list