Nikolay Sivov : dwrite: Implement CreateFontFaceFromHdc().

Alexandre Julliard julliard at wine.codeweavers.com
Mon Oct 20 08:37:25 CDT 2014


Module: wine
Branch: master
Commit: cd7c31fe089523ded67bbad2057b450fa54f21b4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cd7c31fe089523ded67bbad2057b450fa54f21b4

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Oct 20 08:55:39 2014 +0400

dwrite: Implement CreateFontFaceFromHdc().

---

 dlls/dwrite/gdiinterop.c      | 24 ++++++++++++++++++++++--
 dlls/dwrite/tests/Makefile.in |  2 +-
 dlls/dwrite/tests/font.c      | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index 43ab60f..0e2f902 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -334,8 +334,28 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop *iface,
     HDC hdc, IDWriteFontFace **fontface)
 {
     struct gdiinterop *This = impl_from_IDWriteGdiInterop(iface);
-    FIXME("(%p)->(%p %p): stub\n", This, hdc, fontface);
-    return E_NOTIMPL;
+    IDWriteFont *font;
+    LOGFONTW logfont;
+    HFONT hfont;
+    HRESULT hr;
+
+    TRACE("(%p)->(%p %p)\n", This, hdc, fontface);
+
+    *fontface = NULL;
+
+    hfont = GetCurrentObject(hdc, OBJ_FONT);
+    if (!hfont)
+        return E_INVALIDARG;
+    GetObjectW(hfont, sizeof(logfont), &logfont);
+
+    hr = IDWriteGdiInterop_CreateFontFromLOGFONT(iface, &logfont, &font);
+    if (FAILED(hr))
+        return hr;
+
+    hr = IDWriteFont_CreateFontFace(font, fontface);
+    IDWriteFont_Release(font);
+
+    return hr;
 }
 
 static HRESULT WINAPI gdiinterop_CreateBitmapRenderTarget(IDWriteGdiInterop *iface,
diff --git a/dlls/dwrite/tests/Makefile.in b/dlls/dwrite/tests/Makefile.in
index f1287cd..7fbf9e3 100644
--- a/dlls/dwrite/tests/Makefile.in
+++ b/dlls/dwrite/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL = dwrite.dll
-IMPORTS = dwrite gdi32
+IMPORTS = dwrite gdi32 user32
 
 C_SRCS = \
 	analyzer.c \
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 1e46b52..1bb7754 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -1407,6 +1407,43 @@ static void test_GetGdiInterop(void)
     IDWriteGdiInterop_Release(interop);
 }
 
+static void test_CreateFontFaceFromHdc(void)
+{
+    IDWriteGdiInterop *interop;
+    IDWriteFontFace *fontface;
+    HFONT hfont, oldhfont;
+    LOGFONTW logfont;
+    HRESULT hr;
+    HDC hdc;
+
+    interop = NULL;
+    hr = IDWriteFactory_GetGdiInterop(factory, &interop);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, NULL, &fontface);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    memset(&logfont, 0, sizeof(logfont));
+    logfont.lfHeight = 12;
+    logfont.lfWidth  = 12;
+    logfont.lfWeight = FW_NORMAL;
+    logfont.lfItalic = 1;
+    lstrcpyW(logfont.lfFaceName, tahomaW);
+
+    hfont = CreateFontIndirectW(&logfont);
+    hdc = CreateCompatibleDC(0);
+    oldhfont = SelectObject(hdc, hfont);
+
+    fontface = NULL;
+    hr = IDWriteGdiInterop_CreateFontFaceFromHdc(interop, hdc, &fontface);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    IDWriteFontFace_Release(fontface);
+    DeleteObject(SelectObject(hdc, oldhfont));
+    DeleteDC(hdc);
+
+    IDWriteGdiInterop_Release(interop);
+}
+
 START_TEST(font)
 {
     HRESULT hr;
@@ -1436,6 +1473,7 @@ START_TEST(font)
     test_GetFirstMatchingFont();
     test_GetInformationalStrings();
     test_GetGdiInterop();
+    test_CreateFontFaceFromHdc();
 
     IDWriteFactory_Release(factory);
 }




More information about the wine-cvs mailing list