dwrite: Implement CreateFontFaceFromHdc().

This commit is contained in:
Nikolay Sivov 2014-10-20 08:55:39 +04:00 committed by Alexandre Julliard
parent a088f7d381
commit cd7c31fe08
3 changed files with 61 additions and 3 deletions

View File

@ -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,

View File

@ -1,5 +1,5 @@
TESTDLL = dwrite.dll
IMPORTS = dwrite gdi32
IMPORTS = dwrite gdi32 user32
C_SRCS = \
analyzer.c \

View File

@ -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);
}