Nikolay Sivov : dwrite: Implement ConvertFontFaceToLOGFONT().
Alexandre Julliard
julliard at winehq.org
Mon Jan 6 14:47:12 CST 2014
Module: wine
Branch: master
Commit: 5e4d5ebde73db6340986abdf3d13b6f7844e76d2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5e4d5ebde73db6340986abdf3d13b6f7844e76d2
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Jan 6 01:24:17 2014 +0400
dwrite: Implement ConvertFontFaceToLOGFONT().
---
dlls/dwrite/dwrite_private.h | 1 +
dlls/dwrite/font.c | 11 ++++++++
dlls/dwrite/gdiinterop.c | 6 ++--
dlls/dwrite/tests/font.c | 53 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 0c2698e..5450732 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -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;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index ec18312..2564d67 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -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);
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index 496f099..bb24305 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -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,
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 8404c22..a4a7854 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -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);
}
More information about the wine-cvs
mailing list