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

dwrite: Add font set builder stub.

parent 239530e8
......@@ -346,6 +346,7 @@ extern void factory_unlock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN;
extern HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **loader) DECLSPEC_HIDDEN;
extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
IDWriteFontResource **resource) DECLSPEC_HIDDEN;
extern HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret) DECLSPEC_HIDDEN;
struct dwrite_fontface;
......
......@@ -250,6 +250,13 @@ struct dwrite_fontresource
IDWriteFactory7 *factory;
};
struct dwrite_fontset_builder
{
IDWriteFontSetBuilder2 IDWriteFontSetBuilder2_iface;
LONG refcount;
IDWriteFactory7 *factory;
};
static void dwrite_grab_font_table(void *context, UINT32 table, const BYTE **data, UINT32 *size, void **data_context)
{
struct dwrite_fontface *fontface = context;
......@@ -373,6 +380,11 @@ static struct dwrite_fontresource *impl_from_IDWriteFontResource(IDWriteFontReso
return CONTAINING_RECORD(iface, struct dwrite_fontresource, IDWriteFontResource_iface);
}
static struct dwrite_fontset_builder *impl_from_IDWriteFontSetBuilder2(IDWriteFontSetBuilder2 *iface)
{
return CONTAINING_RECORD(iface, struct dwrite_fontset_builder, IDWriteFontSetBuilder2_iface);
}
static HRESULT get_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics)
{
static const DWRITE_GLYPH_METRICS nil;
......@@ -7105,3 +7117,137 @@ HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UI
return S_OK;
}
static HRESULT WINAPI dwritefontsetbuilder_QueryInterface(IDWriteFontSetBuilder2 *iface,
REFIID riid, void **obj)
{
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteFontSetBuilder2) ||
IsEqualIID(riid, &IID_IDWriteFontSetBuilder1) ||
IsEqualIID(riid, &IID_IDWriteFontSetBuilder) ||
IsEqualIID(riid, &IID_IUnknown))
{
*obj = iface;
IDWriteFontSetBuilder2_AddRef(iface);
return S_OK;
}
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI dwritefontsetbuilder_AddRef(IDWriteFontSetBuilder2 *iface)
{
struct dwrite_fontset_builder *builder = impl_from_IDWriteFontSetBuilder2(iface);
ULONG refcount = InterlockedIncrement(&builder->refcount);
TRACE("%p, refcount %u.\n", iface, refcount);
return refcount;
}
static ULONG WINAPI dwritefontsetbuilder_Release(IDWriteFontSetBuilder2 *iface)
{
struct dwrite_fontset_builder *builder = impl_from_IDWriteFontSetBuilder2(iface);
ULONG refcount = InterlockedDecrement(&builder->refcount);
TRACE("%p, refcount %u.\n", iface, refcount);
if (!refcount)
{
IDWriteFactory7_Release(builder->factory);
heap_free(builder);
}
return refcount;
}
static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference_(IDWriteFontSetBuilder2 *iface,
IDWriteFontFaceReference *ref, DWRITE_FONT_PROPERTY const *props, UINT32 prop_count)
{
FIXME("%p, %p, %p, %u.\n", iface, ref, props, prop_count);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference(IDWriteFontSetBuilder2 *iface,
IDWriteFontFaceReference *ref)
{
FIXME("%p, %p.\n", iface, ref);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder_AddFontSet(IDWriteFontSetBuilder2 *iface, IDWriteFontSet *fontset)
{
FIXME("%p, %p.\n", iface, fontset);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder_CreateFontSet(IDWriteFontSetBuilder2 *iface, IDWriteFontSet **fontset)
{
FIXME("%p, %p.\n", iface, fontset);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder1_AddFontFile(IDWriteFontSetBuilder2 *iface, IDWriteFontFile *file)
{
FIXME("%p, %p.\n", iface, file);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder2_AddFont(IDWriteFontSetBuilder2 *iface, IDWriteFontFile *file,
unsigned int face_index, DWRITE_FONT_SIMULATIONS simulations, const DWRITE_FONT_AXIS_VALUE *axis_values,
unsigned int num_values, const DWRITE_FONT_AXIS_RANGE *axis_ranges, unsigned int num_ranges,
const DWRITE_FONT_PROPERTY *props, unsigned int num_properties)
{
FIXME("%p, %p, %u, %#x, %p, %u, %p, %u, %p, %u.\n", iface, file, face_index, simulations, axis_values, num_values,
axis_ranges, num_ranges, props, num_properties);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritefontsetbuilder2_AddFontFile(IDWriteFontSetBuilder2 *iface, const WCHAR *filepath)
{
FIXME("%p, %s.\n", iface, debugstr_w(filepath));
return E_NOTIMPL;
}
static const IDWriteFontSetBuilder2Vtbl fontsetbuildervtbl =
{
dwritefontsetbuilder_QueryInterface,
dwritefontsetbuilder_AddRef,
dwritefontsetbuilder_Release,
dwritefontsetbuilder_AddFontFaceReference_,
dwritefontsetbuilder_AddFontFaceReference,
dwritefontsetbuilder_AddFontSet,
dwritefontsetbuilder_CreateFontSet,
dwritefontsetbuilder1_AddFontFile,
dwritefontsetbuilder2_AddFont,
dwritefontsetbuilder2_AddFontFile,
};
HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret)
{
struct dwrite_fontset_builder *builder;
*ret = NULL;
if (!(builder = heap_alloc_zero(sizeof(*builder))))
return E_OUTOFMEMORY;
builder->IDWriteFontSetBuilder2_iface.lpVtbl = &fontsetbuildervtbl;
builder->refcount = 1;
builder->factory = factory;
IDWriteFactory7_AddRef(builder->factory);
*ret = &builder->IDWriteFontSetBuilder2_iface;
return S_OK;
}
......@@ -1501,9 +1501,9 @@ static HRESULT WINAPI dwritefactory3_GetSystemFontSet(IDWriteFactory7 *iface, ID
static HRESULT WINAPI dwritefactory3_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder **builder)
{
FIXME("%p, %p: stub\n", iface, builder);
TRACE("%p, %p.\n", iface, builder);
return E_NOTIMPL;
return create_fontset_builder(iface, (IDWriteFontSetBuilder2 **)builder);
}
static HRESULT WINAPI dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory7 *iface, IDWriteFontSet *fontset,
......@@ -1644,9 +1644,9 @@ static HRESULT WINAPI dwritefactory4_ComputeGlyphOrigins(IDWriteFactory7 *iface,
static HRESULT WINAPI dwritefactory5_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder1 **builder)
{
FIXME("%p, %p: stub\n", iface, builder);
TRACE("%p, %p.\n", iface, builder);
return E_NOTIMPL;
return create_fontset_builder(iface, (IDWriteFontSetBuilder2 **)builder);
}
static HRESULT WINAPI dwritefactory5_CreateInMemoryFontFileLoader(IDWriteFactory7 *iface,
......@@ -1725,9 +1725,9 @@ static HRESULT WINAPI dwritefactory6_CreateFontCollectionFromFontSet(IDWriteFact
static HRESULT WINAPI dwritefactory6_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder2 **builder)
{
FIXME("%p, %p.\n", iface, builder);
TRACE("%p, %p.\n", iface, builder);
return E_NOTIMPL;
return create_fontset_builder(iface, builder);
}
static HRESULT WINAPI dwritefactory6_CreateTextFormat(IDWriteFactory7 *iface, const WCHAR *familyname,
......
......@@ -9371,21 +9371,15 @@ static void test_fontsetbuilder(void)
HRESULT hr;
factory = create_factory_iid(&IID_IDWriteFactory3);
if (!factory) {
skip("IDWriteFontSetBuilder is not supported.\n");
if (!factory)
{
win_skip("IDWriteFontSetBuilder is not supported.\n");
return;
}
EXPECT_REF(factory, 1);
hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
todo_wine
ok(hr == S_OK, "Failed to create font set builder, hr %#x.\n", hr);
if (FAILED(hr)) {
IDWriteFactory3_Release(factory);
return;
}
EXPECT_REF(factory, 2);
IDWriteFontSetBuilder_Release(builder);
......@@ -9419,12 +9413,16 @@ todo_wine
EXPECT_REF(ref, 1);
hr = IDWriteFontSetBuilder_AddFontFaceReference(builder, ref);
todo_wine
ok(hr == S_OK, "Failed to add fontface reference, hr %#x.\n", hr);
EXPECT_REF(ref, 1);
hr = IDWriteFontSetBuilder_CreateFontSet(builder, &fontset);
todo_wine
ok(hr == S_OK, "Failed to create a font set, hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
setcount = IDWriteFontSet_GetFontCount(fontset);
ok(setcount == 1, "Unexpected font count %u.\n", setcount);
......@@ -9490,6 +9488,7 @@ todo_wine
}
IDWriteFontSet_Release(fontset);
}
IDWriteFontFaceReference_Release(ref);
IDWriteFontSetBuilder_Release(builder);
......
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