Commit cd7c31fe authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Implement CreateFontFaceFromHdc().

parent a088f7d3
......@@ -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,
......
TESTDLL = dwrite.dll
IMPORTS = dwrite gdi32
IMPORTS = dwrite gdi32 user32
C_SRCS = \
analyzer.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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment