[2/2] mlang: Implement IMLangFontLink2_GetFontUnicodeRanges.
Hans Leidekker
hans at codeweavers.com
Fri Jun 26 07:20:31 CDT 2009
diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c
index 6590ea5..180e1ad 100644
--- a/dlls/mlang/mlang.c
+++ b/dlls/mlang/mlang.c
@@ -3357,8 +3357,30 @@ static HRESULT WINAPI fnIMLangFontLink2_MapFont(IMLangFontLink2* This,
static HRESULT WINAPI fnIMLangFontLink2_GetFontUnicodeRanges(IMLangFontLink2* This,
HDC hDC, UINT *puiRanges, UNICODERANGE *pUranges)
{
- FIXME("(%p)->%p %p %p\n",This, hDC, puiRanges, pUranges);
- return E_NOTIMPL;
+ DWORD size;
+ GLYPHSET *gs;
+
+ TRACE("(%p)->%p %p %p\n", This, hDC, puiRanges, pUranges);
+
+ if (!puiRanges) return E_INVALIDARG;
+ if (!(size = GetFontUnicodeRanges(hDC, NULL))) return E_FAIL;
+ if (!(gs = HeapAlloc(GetProcessHeap(), 0, size))) return E_OUTOFMEMORY;
+
+ GetFontUnicodeRanges(hDC, gs);
+ *puiRanges = gs->cRanges;
+ if (pUranges)
+ {
+ UINT i;
+ for (i = 0; i < gs->cRanges; i++)
+ {
+ if (i >= *puiRanges) break;
+ pUranges[i].wcFrom = gs->ranges[i].wcLow;
+ pUranges[i].wcTo = gs->ranges[i].wcLow + gs->ranges[i].cGlyphs;
+ }
+ *puiRanges = i;
+ }
+ HeapFree(GetProcessHeap(), 0, gs);
+ return S_OK;
}
static HRESULT WINAPI fnIMLangFontLink2_GetScriptFontInfo(IMLangFontLink2* This,
diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c
index eceb3ab..bd4fd6c 100644
--- a/dlls/mlang/tests/mlang.c
+++ b/dlls/mlang/tests/mlang.c
@@ -1914,6 +1914,49 @@ static void test_CodePageToScriptID(IMLangFontLink2 *font_link)
}
}
+static void test_GetFontUnicodeRanges(IMLangFontLink2 *font_link)
+{
+ HRESULT hr;
+ UINT count;
+ HFONT hfont, old_hfont;
+ LOGFONTA lf;
+ HDC hdc;
+ UNICODERANGE *ur;
+
+ hdc = CreateCompatibleDC(0);
+ memset(&lf, 0, sizeof(lf));
+ lstrcpyA(lf.lfFaceName, "Arial");
+ hfont = CreateFontIndirectA(&lf);
+ old_hfont = SelectObject(hdc, hfont);
+
+ count = 0;
+ hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, NULL, &count, NULL);
+ ok(hr == E_FAIL, "expected E_FAIL, got 0x%08x\n", hr);
+
+ hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, NULL, NULL);
+ ok(hr == E_INVALIDARG, "expected E_FAIL, got 0x%08x\n", hr);
+
+ count = 0;
+ hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, NULL);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+ ok(count, "expected count > 0\n");
+
+ ur = HeapAlloc(GetProcessHeap(), 0, sizeof(*ur) * count);
+
+ hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, ur);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+
+ count--;
+ hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, ur);
+ ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+
+ HeapFree(GetProcessHeap(), 0, ur);
+
+ SelectObject(hdc, old_hfont);
+ DeleteObject(hfont);
+ DeleteDC(hdc);
+}
+
START_TEST(mlang)
{
IMultiLanguage *iML = NULL;
@@ -1991,6 +2034,7 @@ START_TEST(mlang)
if (ret != S_OK || !iMLFL2) return;
test_GetScriptFontInfo(iMLFL2);
+ test_GetFontUnicodeRanges(iMLFL2);
test_CodePageToScriptID(iMLFL2);
IMLangFontLink2_Release(iMLFL2);
More information about the wine-patches
mailing list