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

dwrite: Implement CreateTextFormat() for IDWriteFactory6.

parent 46a2f3e4
...@@ -286,8 +286,9 @@ struct dwrite_fontface ...@@ -286,8 +286,9 @@ struct dwrite_fontface
}; };
extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN; extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN;
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH, extern HRESULT create_text_format(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight,
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN; DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const WCHAR *locale, REFIID riid,
void **out) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(const struct textlayout_desc*,IDWriteTextLayout**) DECLSPEC_HIDDEN; extern HRESULT create_textlayout(const struct textlayout_desc*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format, extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format,
IDWriteInlineObject **sign) DECLSPEC_HIDDEN; IDWriteInlineObject **sign) DECLSPEC_HIDDEN;
......
...@@ -711,12 +711,14 @@ struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat * ...@@ -711,12 +711,14 @@ struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat *
CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat3_iface) : NULL; CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat3_iface) : NULL;
} }
HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, HRESULT create_text_format(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight,
DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const WCHAR *locale, IDWriteTextFormat **format) DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const WCHAR *locale,
REFIID riid, void **out)
{ {
struct dwrite_textformat *object; struct dwrite_textformat *object;
HRESULT hr;
*format = NULL; *out = NULL;
if (size <= 0.0f) if (size <= 0.0f)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -746,9 +748,10 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle ...@@ -746,9 +748,10 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
object->format.collection = collection; object->format.collection = collection;
IDWriteFontCollection_AddRef(object->format.collection); IDWriteFontCollection_AddRef(object->format.collection);
*format = (IDWriteTextFormat *)&object->IDWriteTextFormat3_iface; hr = IDWriteTextFormat3_QueryInterface(&object->IDWriteTextFormat3_iface, riid, out);
IDWriteTextFormat3_Release(&object->IDWriteTextFormat3_iface);
return S_OK; return hr;
} }
static HRESULT WINAPI dwritetrimmingsign_QueryInterface(IDWriteInlineObject *iface, REFIID riid, void **obj) static HRESULT WINAPI dwritetrimmingsign_QueryInterface(IDWriteInlineObject *iface, REFIID riid, void **obj)
......
...@@ -1199,7 +1199,8 @@ static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory7 *iface, WCH ...@@ -1199,7 +1199,8 @@ static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory7 *iface, WCH
return hr; return hr;
} }
hr = create_textformat(family_name, collection, weight, style, stretch, size, locale, format); hr = create_text_format(family_name, collection, weight, style, stretch, size, locale,
&IID_IDWriteTextFormat, (void **)format);
IDWriteFontCollection_Release(collection); IDWriteFontCollection_Release(collection);
return hr; return hr;
} }
...@@ -1895,14 +1896,35 @@ static HRESULT WINAPI dwritefactory6_CreateFontSetBuilder(IDWriteFactory7 *iface ...@@ -1895,14 +1896,35 @@ static HRESULT WINAPI dwritefactory6_CreateFontSetBuilder(IDWriteFactory7 *iface
return create_fontset_builder(iface, builder); return create_fontset_builder(iface, builder);
} }
static HRESULT WINAPI dwritefactory6_CreateTextFormat(IDWriteFactory7 *iface, const WCHAR *familyname, static HRESULT WINAPI dwritefactory6_CreateTextFormat(IDWriteFactory7 *iface, const WCHAR *family_name,
IDWriteFontCollection *collection, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_axis, IDWriteFontCollection *collection, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_axis,
FLOAT fontsize, const WCHAR *localename, IDWriteTextFormat3 **format) float size, const WCHAR *locale, IDWriteTextFormat3 **format)
{ {
FIXME("%p, %s, %p, %p, %u, %.8e, %s, %p.\n", iface, debugstr_w(familyname), collection, axis_values, num_axis, struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
fontsize, debugstr_w(localename), format); HRESULT hr;
return E_NOTIMPL; TRACE("%p, %s, %p, %p, %u, %.8e, %s, %p.\n", iface, debugstr_w(family_name), collection, axis_values, num_axis,
size, debugstr_w(locale), format);
*format = NULL;
if (axis_values)
FIXME("Axis values are ignored.\n");
if (collection)
{
IDWriteFontCollection_AddRef(collection);
}
else if (FAILED(hr = factory_get_system_collection(factory, DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC,
&IID_IDWriteFontCollection, (void **)&collection)))
{
return hr;
}
hr = create_text_format(family_name, collection, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, size, locale, &IID_IDWriteTextFormat3, (void **)format);
IDWriteFontCollection_Release(collection);
return hr;
} }
static HRESULT WINAPI dwritefactory7_GetSystemFontSet(IDWriteFactory7 *iface, BOOL include_downloadable, static HRESULT WINAPI dwritefactory7_GetSystemFontSet(IDWriteFactory7 *iface, BOOL include_downloadable,
......
...@@ -5986,11 +5986,8 @@ static void test_text_format_axes(void) ...@@ -5986,11 +5986,8 @@ static void test_text_format_axes(void)
} }
hr = IDWriteFactory6_CreateTextFormat(factory, L"test_family", NULL, NULL, 0, 10.0f, L"en-us", &format3); hr = IDWriteFactory6_CreateTextFormat(factory, L"test_family", NULL, NULL, 0, 10.0f, L"en-us", &format3);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
hr = IDWriteTextFormat3_GetFontCollection(format3, &collection); hr = IDWriteTextFormat3_GetFontCollection(format3, &collection);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
...@@ -6025,7 +6022,7 @@ if (SUCCEEDED(hr)) ...@@ -6025,7 +6022,7 @@ if (SUCCEEDED(hr))
ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "Unexpected font weight %d.\n", weight); ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "Unexpected font weight %d.\n", weight);
IDWriteTextFormat3_Release(format3); IDWriteTextFormat3_Release(format3);
}
hr = IDWriteFactory_CreateTextFormat((IDWriteFactory *)factory, L"test_family", NULL, hr = IDWriteFactory_CreateTextFormat((IDWriteFactory *)factory, L"test_family", NULL,
DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_EXPANDED, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_EXPANDED,
10.0f, L"en-us", &format); 10.0f, L"en-us", &format);
......
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