Commit 5e4d5ebd authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Implement ConvertFontFaceToLOGFONT().

parent 07ded6bb
......@@ -72,6 +72,7 @@ static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len)
}
extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC_HIDDEN;
extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC_HIDDEN;
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
......
......@@ -396,6 +396,8 @@ static HRESULT create_fontface(struct dwrite_font *font, IDWriteFontFace **face)
memset(&This->logfont, 0, sizeof(This->logfont));
This->logfont.lfItalic = font->style == DWRITE_FONT_STYLE_ITALIC;
/* weight values from DWRITE_FONT_WEIGHT match values used for LOGFONT */
This->logfont.lfWeight = font->weight;
strcpyW(This->logfont.lfFaceName, font->facename);
*face = &This->IDWriteFontFace_iface;
......@@ -403,6 +405,15 @@ static HRESULT create_fontface(struct dwrite_font *font, IDWriteFontFace **face)
return S_OK;
}
HRESULT convert_fontface_to_logfont(IDWriteFontFace *face, LOGFONTW *logfont)
{
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace(face);
*logfont = fontface->logfont;
return S_OK;
}
static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont *iface, REFIID riid, void **obj)
{
struct dwrite_font *This = impl_from_IDWriteFont(iface);
......
......@@ -242,10 +242,10 @@ static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop *iface,
}
static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop *iface,
IDWriteFontFace *font, LOGFONTW *logfont)
IDWriteFontFace *fontface, LOGFONTW *logfont)
{
FIXME("(%p %p): stub\n", font, logfont);
return E_NOTIMPL;
TRACE("(%p %p)\n", fontface, logfont);
return convert_fontface_to_logfont(fontface, logfont);
}
static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop *iface,
......
......@@ -561,6 +561,58 @@ static void test_system_fontcollection(void)
IDWriteFontCollection_Release(collection);
}
static void test_ConvertFontFaceToLOGFONT(void)
{
IDWriteGdiInterop *interop;
IDWriteFontFace *fontface;
IDWriteFont *font;
LOGFONTW logfont;
HRESULT hr;
hr = IDWriteFactory_GetGdiInterop(factory, &interop);
ok(hr == S_OK, "got 0x%08x\n", hr);
memset(&logfont, 0, sizeof(logfont));
logfont.lfHeight = 12;
logfont.lfWidth = 12;
logfont.lfEscapement = 100;
logfont.lfWeight = FW_NORMAL;
logfont.lfItalic = 1;
logfont.lfUnderline = 1;
logfont.lfStrikeOut = 1;
lstrcpyW(logfont.lfFaceName, tahomaW);
hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFont_CreateFontFace(font, &fontface);
ok(hr == S_OK, "got 0x%08x\n", hr);
if (0) /* crashes on native */
{
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, NULL, NULL);
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, NULL);
}
memset(&logfont, 0xa, sizeof(logfont));
logfont.lfFaceName[0] = 0;
hr = IDWriteGdiInterop_ConvertFontFaceToLOGFONT(interop, fontface, &logfont);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(logfont.lfHeight == 0, "got %d\n", logfont.lfHeight);
ok(logfont.lfWidth == 0, "got %d\n", logfont.lfWidth);
ok(logfont.lfWeight == FW_NORMAL, "got %d\n", logfont.lfWeight);
ok(logfont.lfEscapement == 0, "got %d\n", logfont.lfEscapement);
ok(logfont.lfItalic == 1, "got %d\n", logfont.lfItalic);
ok(logfont.lfUnderline == 0, "got %d\n", logfont.lfUnderline);
ok(logfont.lfStrikeOut == 0, "got %d\n", logfont.lfStrikeOut);
ok(!lstrcmpW(logfont.lfFaceName, tahomaW), "got %s\n", wine_dbgstr_w(logfont.lfFaceName));
IDWriteGdiInterop_Release(interop);
IDWriteFontFace_Release(fontface);
}
START_TEST(font)
{
HRESULT hr;
......@@ -580,6 +632,7 @@ START_TEST(font)
test_CreateFontFace();
test_GetMetrics();
test_system_fontcollection();
test_ConvertFontFaceToLOGFONT();
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