Nikolay Sivov : dwrite: Store simulations flags at font instance level.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Oct 29 07:36:58 CDT 2014
Module: wine
Branch: master
Commit: 901a65ae42d56f4b791534f6b22b46ff6356ac14
URL: http://source.winehq.org/git/wine.git/?a=commit;h=901a65ae42d56f4b791534f6b22b46ff6356ac14
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Oct 27 17:37:49 2014 +0300
dwrite: Store simulations flags at font instance level.
---
dlls/dwrite/font.c | 24 +++++++++++--------
dlls/dwrite/tests/font.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 10 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 5112d24..dd46ee7 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -37,7 +37,6 @@ struct dwrite_font_data {
DWRITE_FONT_STYLE style;
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_WEIGHT weight;
- DWRITE_FONT_SIMULATIONS simulations;
DWRITE_FONT_METRICS metrics;
IDWriteLocalizedStrings *info_strings[DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME+1];
@@ -91,6 +90,7 @@ struct dwrite_font {
BOOL is_system;
IDWriteFontFamily *family;
+ DWRITE_FONT_SIMULATIONS simulations;
struct dwrite_font_data *data;
};
@@ -138,7 +138,7 @@ struct dwrite_fontfile {
static HRESULT create_fontfamily(IDWriteLocalizedStrings *familyname, IDWriteFontFamily **family);
static HRESULT create_fontfamily_from_data(struct dwrite_fontfamily_data *data, IDWriteFontCollection *collection, IDWriteFontFamily **family);
static HRESULT create_font_base(IDWriteFont **font);
-static HRESULT create_font_from_data(struct dwrite_font_data*,IDWriteFontFamily*,IDWriteFont**);
+static HRESULT create_font_from_data(struct dwrite_font_data*,IDWriteFontFamily*,DWRITE_FONT_SIMULATIONS,IDWriteFont**);
static inline struct dwrite_fontface *impl_from_IDWriteFontFace2(IDWriteFontFace2 *iface)
{
@@ -744,7 +744,7 @@ static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace2
hr = font->is_system ? create_system_fontface(font, &face) :
IDWriteFactory_CreateFontFace(data->factory, data->face_type, 1, &data->file,
- data->face_index, DWRITE_FONT_SIMULATIONS_NONE, &face);
+ data->face_index, font->simulations, &face);
if (FAILED(hr))
return hr;
@@ -765,7 +765,7 @@ static HRESULT create_font_base(IDWriteFont **font)
data = heap_alloc_zero(sizeof(*data));
if (!data) return E_OUTOFMEMORY;
- ret = create_font_from_data( data, NULL, font );
+ ret = create_font_from_data( data, NULL, DWRITE_FONT_SIMULATIONS_NONE, font );
if (FAILED(ret)) heap_free( data );
return ret;
}
@@ -870,7 +870,7 @@ static HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **f
This->is_system = TRUE;
This->family = family;
- This->data->simulations = DWRITE_FONT_SIMULATIONS_NONE;
+ This->simulations = DWRITE_FONT_SIMULATIONS_NONE;
This->data->facename = heap_strdupW(logfont->lfFaceName);
return S_OK;
@@ -1016,7 +1016,7 @@ static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont2 *if
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
TRACE("(%p)\n", This);
- return This->data->simulations;
+ return This->simulations;
}
static void WINAPI dwritefont_GetMetrics(IDWriteFont2 *iface, DWRITE_FONT_METRICS *metrics)
@@ -1201,7 +1201,7 @@ static HRESULT WINAPI dwritefontfamily_GetFont(IDWriteFontFamily *iface, UINT32
{
if (index >= This->data->font_count)
return E_INVALIDARG;
- return create_font_from_data(This->data->fonts[index], iface, font);
+ return create_font_from_data(This->data->fonts[index], iface, DWRITE_FONT_SIMULATIONS_NONE, font);
}
else
return E_NOTIMPL;
@@ -1247,7 +1247,7 @@ static HRESULT WINAPI dwritefontfamily_GetFirstMatchingFont(IDWriteFontFamily *i
}
}
- return found != -1 ? create_font_from_data(This->data->fonts[found], iface, font) : DWRITE_E_NOFONT;
+ return found != -1 ? create_font_from_data(This->data->fonts[found], iface, DWRITE_FONT_SIMULATIONS_NONE, font) : DWRITE_E_NOFONT;
}
}
@@ -1414,6 +1414,7 @@ static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollec
struct dwrite_fontcollection *This = impl_from_IDWriteFontCollection(iface);
struct dwrite_fontfamily_data *found_family = NULL;
struct dwrite_font_data *found_font = NULL;
+ DWRITE_FONT_SIMULATIONS simulations;
IDWriteFontFamily *family;
UINT32 i, j;
HRESULT hr;
@@ -1443,7 +1444,8 @@ static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollec
if (FAILED(hr))
return hr;
- hr = create_font_from_data(found_font, family, font);
+ simulations = IDWriteFontFace_GetSimulations(face);
+ hr = create_font_from_data(found_font, family, simulations, font);
IDWriteFontFamily_Release(family);
return hr;
}
@@ -1819,7 +1821,8 @@ static HRESULT create_fontfamily(IDWriteLocalizedStrings *familyname, IDWriteFon
return ret;
}
-static HRESULT create_font_from_data(struct dwrite_font_data *data, IDWriteFontFamily *family, IDWriteFont **font)
+static HRESULT create_font_from_data(struct dwrite_font_data *data, IDWriteFontFamily *family, DWRITE_FONT_SIMULATIONS simulations,
+ IDWriteFont **font)
{
struct dwrite_font *This;
*font = NULL;
@@ -1833,6 +1836,7 @@ static HRESULT create_font_from_data(struct dwrite_font_data *data, IDWriteFontF
if (family)
IDWriteFontFamily_AddRef(family);
This->is_system = FALSE;
+ This->simulations = simulations;
This->data = data;
InterlockedIncrement(&This->data->ref);
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index d9e927f..9cad650 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -1651,6 +1651,65 @@ static void test_CreateFontFaceFromHdc(void)
IDWriteFactory_Release(factory);
}
+static void test_GetSimulations(void)
+{
+ DWRITE_FONT_SIMULATIONS simulations;
+ IDWriteGdiInterop *interop;
+ IDWriteFontFace *fontface;
+ IDWriteFactory *factory;
+ IDWriteFont *font;
+ LOGFONTW logfont;
+ HRESULT hr;
+
+ factory = create_factory();
+
+ 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.lfWeight = FW_NORMAL;
+ logfont.lfItalic = 1;
+ lstrcpyW(logfont.lfFaceName, tahomaW);
+
+ hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ simulations = IDWriteFont_GetSimulations(font);
+todo_wine
+ ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
+ hr = IDWriteFont_CreateFontFace(font, &fontface);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ simulations = IDWriteFontFace_GetSimulations(fontface);
+todo_wine
+ ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "got %d\n", simulations);
+ IDWriteFontFace_Release(fontface);
+ IDWriteFont_Release(font);
+
+ memset(&logfont, 0, sizeof(logfont));
+ logfont.lfHeight = 12;
+ logfont.lfWidth = 12;
+ logfont.lfWeight = FW_NORMAL;
+ logfont.lfItalic = 0;
+ lstrcpyW(logfont.lfFaceName, tahomaW);
+
+ hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ simulations = IDWriteFont_GetSimulations(font);
+ ok(simulations == 0, "got %d\n", simulations);
+ hr = IDWriteFont_CreateFontFace(font, &fontface);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ simulations = IDWriteFontFace_GetSimulations(fontface);
+ ok(simulations == 0, "got %d\n", simulations);
+ IDWriteFontFace_Release(fontface);
+ IDWriteFont_Release(font);
+
+ IDWriteGdiInterop_Release(interop);
+ IDWriteFactory_Release(factory);
+}
+
START_TEST(font)
{
IDWriteFactory *factory;
@@ -1678,6 +1737,7 @@ START_TEST(font)
test_GetInformationalStrings();
test_GetGdiInterop();
test_CreateFontFaceFromHdc();
+ test_GetSimulations();
IDWriteFactory_Release(factory);
}
More information about the wine-cvs
mailing list