Commit 3acbf500 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Added IDWriteFontFallbackBuilder stub.

parent ec42839c
......@@ -215,6 +215,12 @@ struct dwrite_fontfallback {
UINT32 count;
};
struct dwrite_fontfallback_builder {
IDWriteFontFallbackBuilder IDWriteFontFallbackBuilder_iface;
LONG ref;
IDWriteFactory5 *factory;
};
struct dwrite_numbersubstitution {
IDWriteNumberSubstitution IDWriteNumberSubstitution_iface;
LONG ref;
......@@ -236,6 +242,11 @@ static inline struct dwrite_fontfallback *impl_from_IDWriteFontFallback(IDWriteF
return CONTAINING_RECORD(iface, struct dwrite_fontfallback, IDWriteFontFallback_iface);
}
static inline struct dwrite_fontfallback_builder *impl_from_IDWriteFontFallbackBuilder(IDWriteFontFallbackBuilder *iface)
{
return CONTAINING_RECORD(iface, struct dwrite_fontfallback_builder, IDWriteFontFallbackBuilder_iface);
}
static inline UINT32 decode_surrogate_pair(const WCHAR *str, UINT32 index, UINT32 end)
{
if (index < end-1 && IS_SURROGATE_PAIR(str[index], str[index+1])) {
......@@ -2166,3 +2177,102 @@ void release_system_fontfallback(IDWriteFontFallback *iface)
IDWriteFontCollection1_Release(fallback->systemcollection);
heap_free(fallback);
}
static HRESULT WINAPI fontfallbackbuilder_QueryInterface(IDWriteFontFallbackBuilder *iface, REFIID riid, void **obj)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
TRACE("(%p)->(%s %p)\n", fallbackbuilder, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteFontFallbackBuilder) || IsEqualIID(riid, &IID_IUnknown)) {
*obj = iface;
IDWriteFontFallbackBuilder_AddRef(iface);
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI fontfallbackbuilder_AddRef(IDWriteFontFallbackBuilder *iface)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
ULONG ref = InterlockedIncrement(&fallbackbuilder->ref);
TRACE("(%p)->(%d)\n", fallbackbuilder, ref);
return ref;
}
static ULONG WINAPI fontfallbackbuilder_Release(IDWriteFontFallbackBuilder *iface)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
ULONG ref = InterlockedDecrement(&fallbackbuilder->ref);
TRACE("(%p)->(%d)\n", fallbackbuilder, ref);
if (!ref) {
IDWriteFactory5_Release(fallbackbuilder->factory);
heap_free(fallbackbuilder);
}
return ref;
}
static HRESULT WINAPI fontfallbackbuilder_AddMapping(IDWriteFontFallbackBuilder *iface,
const DWRITE_UNICODE_RANGE *ranges, UINT32 ranges_count, WCHAR const **target_families, UINT32 families_count,
IDWriteFontCollection *collection, WCHAR const *locale, WCHAR const *base_family, FLOAT scale)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
FIXME("(%p)->(%p, %u, %p, %u, %p, %s, %s, %f): stub\n", fallbackbuilder, ranges, ranges_count, target_families,
families_count, collection, debugstr_w(locale), debugstr_w(base_family), scale);
return E_NOTIMPL;
}
static HRESULT WINAPI fontfallbackbuilder_AddMappings(IDWriteFontFallbackBuilder *iface, IDWriteFontFallback *fallback)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
FIXME("(%p)->(%p): stub\n", fallbackbuilder, fallback);
return E_NOTIMPL;
}
static HRESULT WINAPI fontfallbackbuilder_CreateFontFallback(IDWriteFontFallbackBuilder *iface,
IDWriteFontFallback **fallback)
{
struct dwrite_fontfallback_builder *fallbackbuilder = impl_from_IDWriteFontFallbackBuilder(iface);
FIXME("(%p)->(%p): stub\n", fallbackbuilder, fallback);
return E_NOTIMPL;
}
static const IDWriteFontFallbackBuilderVtbl fontfallbackbuildervtbl =
{
fontfallbackbuilder_QueryInterface,
fontfallbackbuilder_AddRef,
fontfallbackbuilder_Release,
fontfallbackbuilder_AddMapping,
fontfallbackbuilder_AddMappings,
fontfallbackbuilder_CreateFontFallback,
};
HRESULT create_fontfallback_builder(IDWriteFactory5 *factory, IDWriteFontFallbackBuilder **ret)
{
struct dwrite_fontfallback_builder *builder;
*ret = NULL;
builder = heap_alloc(sizeof(*builder));
if (!builder)
return E_OUTOFMEMORY;
builder->IDWriteFontFallbackBuilder_iface.lpVtbl = &fontfallbackbuildervtbl;
builder->ref = 1;
builder->factory = factory;
IDWriteFactory5_AddRef(builder->factory);
*ret = &builder->IDWriteFontFallbackBuilder_iface;
return S_OK;
}
......@@ -191,6 +191,7 @@ extern HRESULT create_colorglyphenum(FLOAT,FLOAT,const DWRITE_GLYPH_RUN*,const D
extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN;
extern HRESULT create_system_fontfallback(IDWriteFactory5*,IDWriteFontFallback**) DECLSPEC_HIDDEN;
extern void release_system_fontfallback(IDWriteFontFallback*) DECLSPEC_HIDDEN;
extern HRESULT create_fontfallback_builder(IDWriteFactory5*,IDWriteFontFallbackBuilder**) DECLSPEC_HIDDEN;
extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
IDWriteFont**) DECLSPEC_HIDDEN;
extern HRESULT create_fontfacereference(IDWriteFactory5*,IDWriteFontFile*,UINT32,DWRITE_FONT_SIMULATIONS,
......
......@@ -1329,8 +1329,10 @@ static HRESULT WINAPI dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory5 *
IDWriteFontFallbackBuilder **fallbackbuilder)
{
struct dwritefactory *This = impl_from_IDWriteFactory5(iface);
FIXME("(%p)->(%p): stub\n", This, fallbackbuilder);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, fallbackbuilder);
return create_fontfallback_builder(iface, fallbackbuilder);
}
static HRESULT WINAPI dwritefactory2_TranslateColorGlyphRun(IDWriteFactory5 *iface, FLOAT originX, FLOAT originY,
......
......@@ -4665,21 +4665,27 @@ static void test_FontFallbackBuilder(void)
IDWriteFont *font;
FLOAT scale;
HRESULT hr;
ULONG ref;
factory = create_factory();
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void**)&factory2);
IDWriteFactory_Release(factory);
if (factory2)
if (factory2) {
EXPECT_REF(factory2, 1);
hr = IDWriteFactory2_CreateFontFallbackBuilder(factory2, &builder);
EXPECT_REF(factory2, 2);
}
if (hr != S_OK) {
skip("IDWriteFontFallbackBuilder is not supported\n");
return;
}
fallback = NULL;
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, &fallback);
todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFontFallbackBuilder_AddMapping(builder, NULL, 0, NULL, 0, NULL, NULL, NULL, 0.0f);
......@@ -4717,13 +4723,18 @@ static void test_FontFallbackBuilder(void)
range.last = 'A';
hr = IDWriteFontFallbackBuilder_AddMapping(builder, &range, 1, &familyW, 1, NULL, NULL, NULL, 4.0f);
ok(hr == S_OK, "got 0x%08x\n", hr);
}
if (fallback)
IDWriteFontFallback_Release(fallback);
if (0) /* crashes on native */
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, NULL);
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, &fallback);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
/* fallback font missing from system collection */
g_source = strW;
mappedlength = 0;
......@@ -4737,15 +4748,18 @@ static void test_FontFallbackBuilder(void)
ok(font == NULL, "got %p\n", font);
IDWriteFontFallback_Release(fallback);
}
/* remap with custom collection */
range.first = range.last = 'A';
hr = IDWriteFontFallbackBuilder_AddMapping(builder, &range, 1, &familyW, 1, &fallbackcollection, NULL, NULL, 5.0f);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, &fallback);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
g_source = strW;
mappedlength = 0;
scale = 0.0f;
......@@ -4759,15 +4773,18 @@ static void test_FontFallbackBuilder(void)
IDWriteFont_Release(font);
IDWriteFontFallback_Release(fallback);
}
range.first = 'B';
range.last = 'A';
hr = IDWriteFontFallbackBuilder_AddMapping(builder, &range, 1, &familyW, 1, &fallbackcollection, NULL, NULL, 6.0f);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, &fallback);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
g_source = strW;
mappedlength = 0;
scale = 0.0f;
......@@ -4781,16 +4798,19 @@ static void test_FontFallbackBuilder(void)
IDWriteFont_Release(font);
IDWriteFontFallback_Release(fallback);
}
/* explicit locale */
range.first = 'A';
range.last = 'B';
hr = IDWriteFontFallbackBuilder_AddMapping(builder, &range, 1, &familyW, 1, &fallbackcollection, localeW, NULL, 6.0f);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFontFallbackBuilder_CreateFontFallback(builder, &fallback);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
g_source = strW;
mappedlength = 0;
scale = 0.0f;
......@@ -4803,8 +4823,12 @@ static void test_FontFallbackBuilder(void)
ok(font != NULL, "got %p\n", font);
IDWriteFont_Release(font);
IDWriteFontFallback_Release(fallback);
}
IDWriteFontFallbackBuilder_Release(builder);
IDWriteFactory2_Release(factory2);
ref = IDWriteFactory2_Release(factory2);
ok(ref == 0, "Factory is not released, ref %u.\n", ref);
}
static void test_SetTypography(void)
......
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