Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 2 + dlls/dwrite/font.c | 217 +++++++++++++++++++++++++++++++++++ dlls/dwrite/main.c | 4 +- dlls/dwrite/tests/font.c | 22 ++-- 4 files changed, 233 insertions(+), 12 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 7898403dd9..a5d946c385 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -279,6 +279,8 @@ extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface) DECLSPEC_HIDD extern void factory_lock(IDWriteFactory5*) DECLSPEC_HIDDEN; extern void factory_unlock(IDWriteFactory5*) DECLSPEC_HIDDEN; extern HRESULT create_inmemory_fileloader(IDWriteFontFileLoader**) DECLSPEC_HIDDEN; +extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, + IDWriteFontResource **resource) DECLSPEC_HIDDEN;
struct dwrite_fontface;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 1bf88d6b17..8788181303 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -234,6 +234,16 @@ struct dwrite_fontfacereference IDWriteFactory5 *factory; };
+struct dwrite_fontresource +{ + IDWriteFontResource IDWriteFontResource_iface; + LONG refcount; + + IDWriteFontFile *file; + UINT32 face_index; + 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; @@ -325,6 +335,11 @@ static inline struct dwrite_fontfacereference *impl_from_IDWriteFontFaceReferenc return CONTAINING_RECORD(iface, struct dwrite_fontfacereference, IDWriteFontFaceReference1_iface); }
+static struct dwrite_fontresource *impl_from_IDWriteFontResource(IDWriteFontResource *iface) +{ + return CONTAINING_RECORD(iface, struct dwrite_fontresource, IDWriteFontResource_iface); +} + static HRESULT get_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics) { static const DWRITE_GLYPH_METRICS nil; @@ -6555,3 +6570,205 @@ HRESULT create_inmemory_fileloader(IDWriteFontFileLoader **ret)
return S_OK; } + +static HRESULT WINAPI dwritefontresource_QueryInterface(IDWriteFontResource *iface, REFIID riid, void **obj) +{ + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj); + + if (IsEqualIID(riid, &IID_IDWriteFontResource) || + IsEqualIID(riid, &IID_IUnknown)) + { + *obj = iface; + IDWriteFontResource_AddRef(iface); + return S_OK; + } + + WARN("Unsupported interface %s.\n", debugstr_guid(riid)); + + return E_NOINTERFACE; +} + +static ULONG WINAPI dwritefontresource_AddRef(IDWriteFontResource *iface) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + ULONG refcount = InterlockedIncrement(&resource->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI dwritefontresource_Release(IDWriteFontResource *iface) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + ULONG refcount = InterlockedDecrement(&resource->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + if (!refcount) + { + IDWriteFactory7_Release(resource->factory); + IDWriteFontFile_Release(resource->file); + heap_free(resource); + } + + return refcount; +} + +static HRESULT WINAPI dwritefontresource_GetFontFile(IDWriteFontResource *iface, IDWriteFontFile **fontfile) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + + TRACE("%p, %p.\n", iface, fontfile); + + *fontfile = resource->file; + IDWriteFontFile_AddRef(*fontfile); + + return S_OK; +} + +static UINT32 WINAPI dwritefontresource_GetFontFaceIndex(IDWriteFontResource *iface) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + + TRACE("%p.\n", iface); + + return resource->face_index; +} + +static UINT32 WINAPI dwritefontresource_GetFontAxisCount(IDWriteFontResource *iface) +{ + FIXME("%p.\n", iface); + + return 0; +} + +static HRESULT WINAPI dwritefontresource_GetDefaultFontAxisValues(IDWriteFontResource *iface, + DWRITE_FONT_AXIS_VALUE const *values, UINT32 num_values) +{ + FIXME("%p, %p, %u.\n", iface, values, num_values); + + return E_NOTIMPL; +} + +static HRESULT WINAPI dwritefontresource_GetFontAxisRanges(IDWriteFontResource *iface, + DWRITE_FONT_AXIS_RANGE const *ranges, UINT32 num_ranges) +{ + FIXME("%p, %p, %u.\n", iface, ranges, num_ranges); + + return E_NOTIMPL; +} + +static DWRITE_FONT_AXIS_ATTRIBUTES WINAPI dwritefontresource_GetFontAxisAttributes(IDWriteFontResource *iface, + UINT32 axis) +{ + FIXME("%p, %u.\n", iface, axis); + + return DWRITE_FONT_AXIS_ATTRIBUTES_NONE; +} + +static HRESULT WINAPI dwritefontresource_GetAxisNames(IDWriteFontResource *iface, UINT32 axis, + IDWriteLocalizedStrings **names) +{ + FIXME("%p, %u, %p.\n", iface, axis, names); + + return E_NOTIMPL; +} + +static UINT32 WINAPI dwritefontresource_GetAxisValueNameCount(IDWriteFontResource *iface, UINT32 axis) +{ + FIXME("%p, %u.\n", iface, axis); + + return 0; +} + +static HRESULT WINAPI dwritefontresource_GetAxisValueNames(IDWriteFontResource *iface, UINT32 axis, + UINT32 axis_value, DWRITE_FONT_AXIS_RANGE *axis_range, IDWriteLocalizedStrings **names) +{ + FIXME("%p, %u, %u, %p, %p.\n", iface, axis, axis_value, axis_range, names); + + return E_NOTIMPL; +} + +static BOOL WINAPI dwritefontresource_HasVariations(IDWriteFontResource *iface) +{ + FIXME("%p.\n", iface); + + return FALSE; +} + +static HRESULT WINAPI dwritefontresource_CreateFontFace(IDWriteFontResource *iface, + DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values, + IDWriteFontFace5 **fontface) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + IDWriteFontFaceReference1 *reference; + HRESULT hr; + + TRACE("%p, %#x, %p, %u, %p.\n", iface, simulations, axis_values, num_values, fontface); + + hr = IDWriteFactory7_CreateFontFaceReference(resource->factory, resource->file, resource->face_index, + simulations, axis_values, num_values, &reference); + if (SUCCEEDED(hr)) + { + hr = IDWriteFontFaceReference1_CreateFontFace(reference, fontface); + IDWriteFontFaceReference1_Release(reference); + } + + return hr; +} + +static HRESULT WINAPI dwritefontresource_CreateFontFaceReference(IDWriteFontResource *iface, + DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_values, + IDWriteFontFaceReference1 **reference) +{ + struct dwrite_fontresource *resource = impl_from_IDWriteFontResource(iface); + + TRACE("%p, %#x, %p, %u, %p.\n", iface, simulations, axis_values, num_values, reference); + + return IDWriteFactory7_CreateFontFaceReference(resource->factory, resource->file, resource->face_index, + simulations, axis_values, num_values, reference); +} + +static const IDWriteFontResourceVtbl fontresourcevtbl = +{ + dwritefontresource_QueryInterface, + dwritefontresource_AddRef, + dwritefontresource_Release, + dwritefontresource_GetFontFile, + dwritefontresource_GetFontFaceIndex, + dwritefontresource_GetFontAxisCount, + dwritefontresource_GetDefaultFontAxisValues, + dwritefontresource_GetFontAxisRanges, + dwritefontresource_GetFontAxisAttributes, + dwritefontresource_GetAxisNames, + dwritefontresource_GetAxisValueNameCount, + dwritefontresource_GetAxisValueNames, + dwritefontresource_HasVariations, + dwritefontresource_CreateFontFace, + dwritefontresource_CreateFontFaceReference, +}; + +HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, + IDWriteFontResource **ret) +{ + struct dwrite_fontresource *resource; + + *ret = NULL; + + resource = heap_alloc_zero(sizeof(*resource)); + if (!resource) + return E_OUTOFMEMORY; + + resource->IDWriteFontResource_iface.lpVtbl = &fontresourcevtbl; + resource->refcount = 1; + resource->face_index = face_index; + resource->file = file; + IDWriteFontFile_AddRef(resource->file); + resource->factory = factory; + IDWriteFactory7_AddRef(resource->factory); + + *ret = &resource->IDWriteFontResource_iface; + + return S_OK; +} diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 033a664dcf..1c1fabdb7d 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1666,9 +1666,9 @@ static HRESULT WINAPI dwritefactory6_CreateFontFaceReference(IDWriteFactory7 *if static HRESULT WINAPI dwritefactory6_CreateFontResource(IDWriteFactory7 *iface, IDWriteFontFile *file, UINT32 face_index, IDWriteFontResource **resource) { - FIXME("%p, %p, %u, %p.\n", iface, file, face_index, resource); + TRACE("%p, %p, %u, %p.\n", iface, file, face_index, resource);
- return E_NOTIMPL; + return create_font_resource(iface, file, face_index, resource); }
static HRESULT WINAPI dwritefactory6_GetSystemFontSet(IDWriteFactory7 *iface, BOOL include_downloadable, diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 58f2af6e7a..f0266cb751 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -9259,17 +9259,8 @@ static void test_font_resource(void) ok(hr == S_OK, "Failed to get file object, hr %#x.\n", hr);
hr = IDWriteFactory6_CreateFontResource(factory, fontfile, 0, &resource); -todo_wine ok(hr == S_OK, "Failed to create font resource, hr %#x.\n", hr);
- if (FAILED(hr)) - { - IDWriteFactory6_Release(factory); - IDWriteFontFile_Release(fontfile); - IDWriteFontFace_Release(fontface); - return; - } - hr = IDWriteFactory6_CreateFontResource(factory, fontfile, 0, &resource2); ok(hr == S_OK, "Failed to create font resource, hr %#x.\n", hr); ok(resource != resource2, "Unexpected instance.\n"); @@ -9283,18 +9274,29 @@ todo_wine index = IDWriteFontResource_GetFontFaceIndex(resource); ok(!index, "Unexpected index %u.\n", index);
+ EXPECT_REF(resource, 1); hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference); +todo_wine ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); + EXPECT_REF(resource, 1);
hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference2); +todo_wine ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); + +if (SUCCEEDED(hr)) +{ ok(reference != reference2, "Unexpected reference instance.\n"); IDWriteFontFaceReference1_Release(reference2); IDWriteFontFaceReference1_Release(reference); - +} hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5); +todo_wine ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
+ if (FAILED(hr)) + return; + hr = IDWriteFontFace5_GetFontResource(fontface5, &resource2); ok(hr == S_OK, "Failed to get font resource, hr %#x.\n", hr); ok(resource != resource2, "Unexpected resource instance.\n");
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 7 ++++--- dlls/dwrite/tests/font.c | 17 ++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 8788181303..bfe32d5fd9 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -474,7 +474,8 @@ static HRESULT WINAPI dwritefontface_QueryInterface(IDWriteFontFace5 *iface, REF
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
- if (IsEqualIID(riid, &IID_IDWriteFontFace4) || + if (IsEqualIID(riid, &IID_IDWriteFontFace5) || + IsEqualIID(riid, &IID_IDWriteFontFace4) || IsEqualIID(riid, &IID_IDWriteFontFace3) || IsEqualIID(riid, &IID_IDWriteFontFace2) || IsEqualIID(riid, &IID_IDWriteFontFace1) || @@ -1425,7 +1426,7 @@ static HRESULT WINAPI dwritefontface5_GetFontAxisValues(IDWriteFontFace5 *iface, return E_NOTIMPL; }
-static BOOL WINAPI dwritefontface5_HasVariantions(IDWriteFontFace5 *iface) +static BOOL WINAPI dwritefontface5_HasVariations(IDWriteFontFace5 *iface) { FIXME("%p: stub\n", iface);
@@ -1496,7 +1497,7 @@ static const IDWriteFontFace5Vtbl dwritefontfacevtbl = dwritefontface4_ReleaseGlyphImageData, dwritefontface5_GetFontAxisValueCount, dwritefontface5_GetFontAxisValues, - dwritefontface5_HasVariantions, + dwritefontface5_HasVariations, dwritefontface5_GetFontResource, };
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index f0266cb751..d06b2f555a 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -9291,25 +9291,28 @@ if (SUCCEEDED(hr)) IDWriteFontFaceReference1_Release(reference); } hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5); -todo_wine ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
- if (FAILED(hr)) - return; - hr = IDWriteFontFace5_GetFontResource(fontface5, &resource2); +todo_wine ok(hr == S_OK, "Failed to get font resource, hr %#x.\n", hr); + +if (SUCCEEDED(hr)) +{ ok(resource != resource2, "Unexpected resource instance.\n"); IDWriteFontResource_Release(resource); - +} hr = IDWriteFontFace5_GetFontResource(fontface5, &resource); +todo_wine ok(hr == S_OK, "Failed to get font resource, hr %#x.\n", hr); + +if (SUCCEEDED(hr)) +{ ok(resource != resource2, "Unexpected resource instance.\n"); EXPECT_REF(resource, 1); - IDWriteFontResource_Release(resource); IDWriteFontResource_Release(resource2); - +} IDWriteFontFace5_Release(fontface5);
IDWriteFontResource_Release(resource);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 10 +++++----- dlls/dwrite/font.c | 11 ++++++----- dlls/dwrite/main.c | 14 +++++++------- 3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index a5d946c385..1598bb6aee 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -154,7 +154,7 @@ struct glyphrunanalysis_desc
struct fontface_desc { - IDWriteFactory5 *factory; + IDWriteFactory7 *factory; DWRITE_FONT_FACE_TYPE face_type; IDWriteFontFile * const *files; IDWriteFontFileStream *stream; @@ -193,7 +193,7 @@ struct dwrite_fontface UINT32 file_count; UINT32 index;
- IDWriteFactory5 *factory; + IDWriteFactory7 *factory; struct fontfacecached *cached;
USHORT simulations; @@ -268,7 +268,7 @@ extern HRESULT factory_get_cached_fontface(IDWriteFactory5*,IDWriteFontFile*cons struct list**,REFIID,void**) DECLSPEC_HIDDEN; extern void factory_detach_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; extern void factory_detach_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1*) DECLSPEC_HIDDEN; -extern struct fontfacecached *factory_cache_fontface(IDWriteFactory5 *factory, struct list *fontfaces, +extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces, IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*) DECLSPEC_HIDDEN; extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*) DECLSPEC_HIDDEN; @@ -276,8 +276,8 @@ extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*) DECLSPEC_HIDDE extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*) DECLSPEC_HIDDEN; extern HRESULT create_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1**) DECLSPEC_HIDDEN; extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; -extern void factory_lock(IDWriteFactory5*) DECLSPEC_HIDDEN; -extern void factory_unlock(IDWriteFactory5*) DECLSPEC_HIDDEN; +extern void factory_lock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN; +extern void factory_unlock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN; extern HRESULT create_inmemory_fileloader(IDWriteFontFileLoader**) DECLSPEC_HIDDEN; extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, IDWriteFontResource **resource) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index bfe32d5fd9..8c58d7561a 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -551,7 +551,7 @@ static ULONG WINAPI dwritefontface_Release(IDWriteFontFace5 *iface)
freetype_notify_cacheremove(iface);
- IDWriteFactory5_Release(fontface->factory); + IDWriteFactory7_Release(fontface->factory); heap_free(fontface); }
@@ -1518,7 +1518,7 @@ static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace5 if (FAILED(hr = get_filestream_from_file(data->file, &desc.stream))) return hr;
- desc.factory = font->family->collection->factory; + desc.factory = (IDWriteFactory7 *)font->family->collection->factory; desc.face_type = data->face_type; desc.files = &data->file; desc.files_number = 1; @@ -4051,7 +4051,7 @@ HRESULT create_font_collection(IDWriteFactory5 *factory, IDWriteFontFileEnumerat WCHAR familyW[255]; UINT32 index;
- desc.factory = factory; + desc.factory = (IDWriteFactory7 *)factory; desc.face_type = face_type; desc.files = &file; desc.stream = stream; @@ -4394,7 +4394,7 @@ static HRESULT eudc_collection_add_family(IDWriteFactory5 *factory, struct dwrit struct fontface_desc desc;
/* alloc and init new font data structure */ - desc.factory = factory; + desc.factory = (IDWriteFactory7 *)factory; desc.face_type = face_type; desc.index = i; desc.files = &file; @@ -4660,7 +4660,8 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li fontface->colr.exists = TRUE; fontface->index = desc->index; fontface->simulations = desc->simulations; - IDWriteFactory5_AddRef(fontface->factory = desc->factory); + fontface->factory = desc->factory; + IDWriteFactory7_AddRef(fontface->factory);
for (i = 0; i < fontface->file_count; i++) { fontface->files[i] = desc->files[i]; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 1c1fabdb7d..e4b76823ff 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -847,15 +847,15 @@ static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory return create_font_file(loader, reference_key, key_size, font_file); }
-void factory_lock(IDWriteFactory5 *iface) +void factory_lock(IDWriteFactory7 *iface) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); EnterCriticalSection(&factory->cs); }
-void factory_unlock(IDWriteFactory5 *iface) +void factory_unlock(IDWriteFactory7 *iface) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); LeaveCriticalSection(&factory->cs); }
@@ -935,10 +935,10 @@ HRESULT factory_get_cached_fontface(IDWriteFactory5 *iface, IDWriteFontFile * co return *obj ? S_OK : S_FALSE; }
-struct fontfacecached *factory_cache_fontface(IDWriteFactory5 *iface, struct list *fontfaces, +struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *iface, struct list *fontfaces, IDWriteFontFace5 *fontface) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); struct fontfacecached *cached;
/* new cache entry */ @@ -1006,7 +1006,7 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory7 *iface, DWRIT if (hr != S_FALSE) goto failed;
- desc.factory = (IDWriteFactory5 *)iface; + desc.factory = iface; desc.face_type = req_facetype; desc.files = font_files; desc.stream = stream;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 6 ++++-- dlls/dwrite/tests/font.c | 13 ++----------- 2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 8c58d7561a..8045bce870 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -1435,9 +1435,11 @@ static BOOL WINAPI dwritefontface5_HasVariations(IDWriteFontFace5 *iface)
static HRESULT WINAPI dwritefontface5_GetFontResource(IDWriteFontFace5 *iface, IDWriteFontResource **resource) { - FIXME("%p, %p: stub\n", iface, resource); + struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, resource); + + return IDWriteFactory7_CreateFontResource(fontface->factory, fontface->files[0], fontface->index, resource); }
static const IDWriteFontFace5Vtbl dwritefontfacevtbl = diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index d06b2f555a..83d6be4449 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -9294,28 +9294,19 @@ if (SUCCEEDED(hr)) ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
hr = IDWriteFontFace5_GetFontResource(fontface5, &resource2); -todo_wine ok(hr == S_OK, "Failed to get font resource, hr %#x.\n", hr); - -if (SUCCEEDED(hr)) -{ ok(resource != resource2, "Unexpected resource instance.\n"); IDWriteFontResource_Release(resource); -} + hr = IDWriteFontFace5_GetFontResource(fontface5, &resource); -todo_wine ok(hr == S_OK, "Failed to get font resource, hr %#x.\n", hr); - -if (SUCCEEDED(hr)) -{ ok(resource != resource2, "Unexpected resource instance.\n"); EXPECT_REF(resource, 1); IDWriteFontResource_Release(resource); IDWriteFontResource_Release(resource2); -} + IDWriteFontFace5_Release(fontface5);
- IDWriteFontResource_Release(resource); IDWriteFontFile_Release(fontfile);
IDWriteFontFace_Release(fontface);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 5 +++-- dlls/dwrite/font.c | 26 +++++++++++++++++++++----- dlls/dwrite/main.c | 19 ++++++++++++------- dlls/dwrite/tests/font.c | 25 +++++++++++++++++++------ 4 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 1598bb6aee..9447c59663 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -262,8 +262,9 @@ extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC 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, - IDWriteFontFaceReference**) DECLSPEC_HIDDEN; +extern HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file, UINT32 face_index, + DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, + IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN; extern HRESULT factory_get_cached_fontface(IDWriteFactory5*,IDWriteFontFile*const*,UINT32,DWRITE_FONT_SIMULATIONS, struct list**,REFIID,void**) DECLSPEC_HIDDEN; extern void factory_detach_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 8045bce870..c9f1e885d5 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -231,6 +231,8 @@ struct dwrite_fontfacereference IDWriteFontFile *file; UINT32 index; USHORT simulations; + DWRITE_FONT_AXIS_VALUE *axis_values; + UINT32 axis_values_count; IDWriteFactory5 *factory; };
@@ -6081,6 +6083,7 @@ static ULONG WINAPI fontfacereference_Release(IDWriteFontFaceReference1 *iface) { IDWriteFontFile_Release(reference->file); IDWriteFactory5_Release(reference->factory); + heap_free(reference->axis_values); heap_free(reference); }
@@ -6253,9 +6256,11 @@ static HRESULT WINAPI fontfacereference1_CreateFontFace(IDWriteFontFaceReference
static UINT32 WINAPI fontfacereference1_GetFontAxisValueCount(IDWriteFontFaceReference1 *iface) { - FIXME("%p.\n", iface); + struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
- return 0; + TRACE("%p.\n", iface); + + return reference->axis_values_count; }
static HRESULT WINAPI fontfacereference1_GetFontAxisValues(IDWriteFontFaceReference1 *iface, @@ -6291,7 +6296,8 @@ static const IDWriteFontFaceReference1Vtbl fontfacereferencevtbl = };
HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file, UINT32 index, - DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **ret) + DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, + IDWriteFontFaceReference1 **ret) { struct dwrite_fontfacereference *object;
@@ -6300,7 +6306,7 @@ HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file if (!is_simulation_valid(simulations)) return E_INVALIDARG;
- object = heap_alloc(sizeof(*object)); + object = heap_alloc_zero(sizeof(*object)); if (!object) return E_OUTOFMEMORY;
@@ -6313,8 +6319,18 @@ HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file IDWriteFontFile_AddRef(object->file); object->index = index; object->simulations = simulations; + if (axis_values_count) + { + if (!(object->axis_values = heap_alloc(axis_values_count * sizeof(*axis_values)))) + { + IDWriteFontFaceReference1_Release(&object->IDWriteFontFaceReference1_iface); + return E_OUTOFMEMORY; + } + memcpy(object->axis_values, axis_values, axis_values_count * sizeof(*axis_values)); + object->axis_values_count = axis_values_count; + }
- *ret = (IDWriteFontFaceReference *)&object->IDWriteFontFaceReference1_iface; + *ret = &object->IDWriteFontFaceReference1_iface;
return S_OK; } diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index e4b76823ff..5f30b8e4f4 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1443,7 +1443,8 @@ static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory7 *i { TRACE("%p, %p, %u, %x, %p.\n", iface, file, index, simulations, reference);
- return create_fontfacereference((IDWriteFactory5 *)iface, file, index, simulations, reference); + return create_fontfacereference((IDWriteFactory5 *)iface, file, index, simulations, NULL, 0, + (IDWriteFontFaceReference1 **)reference); }
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory7 *iface, WCHAR const *path, @@ -1455,13 +1456,15 @@ static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory7 *if
TRACE("%p, %s, %p, %u, %#x, %p.\n", iface, debugstr_w(path), writetime, index, simulations, reference);
- hr = IDWriteFactory5_CreateFontFileReference((IDWriteFactory5 *)iface, path, writetime, &file); - if (FAILED(hr)) { + hr = IDWriteFactory7_CreateFontFileReference(iface, path, writetime, &file); + if (FAILED(hr)) + { *reference = NULL; return hr; }
- hr = IDWriteFactory5_CreateFontFaceReference_((IDWriteFactory5 *)iface, file, index, simulations, reference); + hr = create_fontfacereference((IDWriteFactory5 *)iface, file, index, simulations, NULL, 0, + (IDWriteFontFaceReference1 **)reference); IDWriteFontFile_Release(file); return hr; } @@ -1656,11 +1659,13 @@ static HRESULT WINAPI dwritefactory5_UnpackFontFile(IDWriteFactory7 *iface, DWRI
static HRESULT WINAPI dwritefactory6_CreateFontFaceReference(IDWriteFactory7 *iface, IDWriteFontFile *file, UINT32 face_index, DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, - UINT32 num_axis, IDWriteFontFaceReference1 **ref) + UINT32 axis_values_count, IDWriteFontFaceReference1 **reference) { - FIXME("%p, %p, %u, %#x, %p, %u, %p.\n", iface, file, face_index, simulations, axis_values, num_axis, ref); + TRACE("%p, %p, %u, %#x, %p, %u, %p.\n", iface, file, face_index, simulations, axis_values, axis_values_count, + reference);
- return E_NOTIMPL; + return create_fontfacereference((IDWriteFactory5 *)iface, file, face_index, simulations, axis_values, + axis_values_count, reference); }
static HRESULT WINAPI dwritefactory6_CreateFontResource(IDWriteFactory7 *iface, IDWriteFontFile *file, diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 83d6be4449..5ab01465b7 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -9239,6 +9239,7 @@ static void test_font_resource(void) IDWriteFontFaceReference1 *reference, *reference2; IDWriteFontResource *resource, *resource2; IDWriteFontFile *fontfile, *fontfile2; + DWRITE_FONT_AXIS_VALUE axis_value; IDWriteFontFace5 *fontface5; IDWriteFontFace *fontface; IDWriteFactory6 *factory; @@ -9274,22 +9275,34 @@ static void test_font_resource(void) index = IDWriteFontResource_GetFontFaceIndex(resource); ok(!index, "Unexpected index %u.\n", index);
+ /* Specify axis value, font has no variations. */ + axis_value.axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT; + axis_value.value = 400.0f; + hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, &axis_value, 1, &reference); + ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); + + count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference); + ok(count == 1, "Unexpected axis value count.\n"); + + IDWriteFontFaceReference1_Release(reference); + + hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, &axis_value, 1, + &reference); + count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference); + ok(count == 1, "Unexpected axis value count.\n"); + IDWriteFontFaceReference1_Release(reference); + EXPECT_REF(resource, 1); hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference); -todo_wine ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); EXPECT_REF(resource, 1);
hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0, &reference2); -todo_wine ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); - -if (SUCCEEDED(hr)) -{ ok(reference != reference2, "Unexpected reference instance.\n"); IDWriteFontFaceReference1_Release(reference2); IDWriteFontFaceReference1_Release(reference); -} + hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace5, (void **)&fontface5); ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 2 +- dlls/dwrite/font.c | 12 ++++++------ dlls/dwrite/main.c | 9 +++------ 3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 9447c59663..ae9576d010 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -262,7 +262,7 @@ extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC 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 *factory, IDWriteFontFile *file, UINT32 face_index, +extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN; extern HRESULT factory_get_cached_fontface(IDWriteFactory5*,IDWriteFontFile*const*,UINT32,DWRITE_FONT_SIMULATIONS, diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index c9f1e885d5..baf915bd17 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -233,7 +233,7 @@ struct dwrite_fontfacereference USHORT simulations; DWRITE_FONT_AXIS_VALUE *axis_values; UINT32 axis_values_count; - IDWriteFactory5 *factory; + IDWriteFactory7 *factory; };
struct dwrite_fontresource @@ -6082,7 +6082,7 @@ static ULONG WINAPI fontfacereference_Release(IDWriteFontFaceReference1 *iface) if (!refcount) { IDWriteFontFile_Release(reference->file); - IDWriteFactory5_Release(reference->factory); + IDWriteFactory7_Release(reference->factory); heap_free(reference->axis_values); heap_free(reference); } @@ -6116,7 +6116,7 @@ static HRESULT WINAPI fontfacereference_CreateFontFaceWithSimulations(IDWriteFon if (FAILED(hr)) return hr;
- hr = IDWriteFactory5_CreateFontFace(reference->factory, face_type, 1, &reference->file, reference->index, + hr = IDWriteFactory7_CreateFontFace(reference->factory, face_type, 1, &reference->file, reference->index, simulations, &fontface); if (SUCCEEDED(hr)) { @@ -6182,7 +6182,7 @@ static HRESULT WINAPI fontfacereference_GetFontFile(IDWriteFontFaceReference1 *i if (FAILED(hr)) return hr;
- hr = IDWriteFactory5_CreateCustomFontFileReference(reference->factory, key, key_size, loader, file); + hr = IDWriteFactory7_CreateCustomFontFileReference(reference->factory, key, key_size, loader, file); IDWriteFontFileLoader_Release(loader);
return hr; @@ -6295,7 +6295,7 @@ static const IDWriteFontFaceReference1Vtbl fontfacereferencevtbl = fontfacereference1_GetFontAxisValues, };
-HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file, UINT32 index, +HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 index, DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, IDWriteFontFaceReference1 **ret) { @@ -6314,7 +6314,7 @@ HRESULT create_fontfacereference(IDWriteFactory5 *factory, IDWriteFontFile *file object->refcount = 1;
object->factory = factory; - IDWriteFactory5_AddRef(object->factory); + IDWriteFactory7_AddRef(object->factory); object->file = file; IDWriteFontFile_AddRef(object->file); object->index = index; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 5f30b8e4f4..a63af6c488 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1443,8 +1443,7 @@ static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory7 *i { TRACE("%p, %p, %u, %x, %p.\n", iface, file, index, simulations, reference);
- return create_fontfacereference((IDWriteFactory5 *)iface, file, index, simulations, NULL, 0, - (IDWriteFontFaceReference1 **)reference); + return create_fontfacereference(iface, file, index, simulations, NULL, 0, (IDWriteFontFaceReference1 **)reference); }
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory7 *iface, WCHAR const *path, @@ -1463,8 +1462,7 @@ static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory7 *if return hr; }
- hr = create_fontfacereference((IDWriteFactory5 *)iface, file, index, simulations, NULL, 0, - (IDWriteFontFaceReference1 **)reference); + hr = create_fontfacereference(iface, file, index, simulations, NULL, 0, (IDWriteFontFaceReference1 **)reference); IDWriteFontFile_Release(file); return hr; } @@ -1664,8 +1662,7 @@ static HRESULT WINAPI dwritefactory6_CreateFontFaceReference(IDWriteFactory7 *if TRACE("%p, %p, %u, %#x, %p, %u, %p.\n", iface, file, face_index, simulations, axis_values, axis_values_count, reference);
- return create_fontfacereference((IDWriteFactory5 *)iface, file, face_index, simulations, axis_values, - axis_values_count, reference); + return create_fontfacereference(iface, file, face_index, simulations, axis_values, axis_values_count, reference); }
static HRESULT WINAPI dwritefactory6_CreateFontResource(IDWriteFactory7 *iface, IDWriteFontFile *file,
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 12 +++++----- dlls/dwrite/font.c | 44 +++++++++++++++++++----------------- dlls/dwrite/main.c | 18 +++++++-------- 3 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index ae9576d010..ce693239cf 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -238,15 +238,15 @@ extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const W extern HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN; extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN; extern void sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN; -extern HRESULT get_system_fontcollection(IDWriteFactory5*,IDWriteFontCollection1**) DECLSPEC_HIDDEN; -extern HRESULT get_eudc_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN; +extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection) DECLSPEC_HIDDEN; +extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN; extern IDWriteTextAnalyzer *get_text_analyzer(void) DECLSPEC_HIDDEN; extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size, IDWriteFontFile **font_file) DECLSPEC_HIDDEN; extern void init_local_fontfile_loader(void) DECLSPEC_HIDDEN; extern IDWriteFontFileLoader *get_local_fontfile_loader(void) DECLSPEC_HIDDEN; extern HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_list, IDWriteFontFace5 **fontface) DECLSPEC_HIDDEN; -extern HRESULT create_font_collection(IDWriteFactory5 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system, +extern HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN; extern HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc*,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN; extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN; @@ -265,9 +265,9 @@ extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_F extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count, IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN; -extern HRESULT factory_get_cached_fontface(IDWriteFactory5*,IDWriteFontFile*const*,UINT32,DWRITE_FONT_SIMULATIONS, - struct list**,REFIID,void**) DECLSPEC_HIDDEN; -extern void factory_detach_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; +extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files, + DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN; +extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; extern void factory_detach_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1*) DECLSPEC_HIDDEN; extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces, IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index baf915bd17..ef09f8e2bf 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -119,7 +119,7 @@ struct dwrite_fontcollection IDWriteFontCollection3 IDWriteFontCollection3_iface; LONG refcount;
- IDWriteFactory5 *factory; + IDWriteFactory7 *factory; struct dwrite_fontfamily_data **family_data; size_t size; size_t count; @@ -1828,12 +1828,12 @@ static BOOL WINAPI dwritefont3_Equals(IDWriteFont3 *iface, IDWriteFont *font)
static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWriteFontFaceReference **reference) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); + struct dwrite_font *font = impl_from_IDWriteFont3(iface);
- TRACE("(%p)->(%p)\n", This, reference); + TRACE("%p, %p.\n", iface, reference);
- return IDWriteFactory5_CreateFontFaceReference_(This->family->collection->factory, This->data->file, - This->data->face_index, This->data->simulations, reference); + return IDWriteFactory5_CreateFontFaceReference_((IDWriteFactory5 *)font->family->collection->factory, + font->data->file, font->data->face_index, font->data->simulations, reference); }
static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch) @@ -3970,7 +3970,7 @@ static void fontcollection_add_replacements(struct dwrite_fontcollection *collec RegCloseKey(hkey); }
-HRESULT create_font_collection(IDWriteFactory5 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system, +HRESULT create_font_collection(IDWriteFactory7 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system, IDWriteFontCollection3 **ret) { struct fontfile_enum { @@ -4126,7 +4126,7 @@ HRESULT create_font_collection(IDWriteFactory5 *factory, IDWriteFontFileEnumerat fontcollection_add_replacements(collection);
collection->factory = factory; - IDWriteFactory5_AddRef(factory); + IDWriteFactory7_AddRef(factory);
return hr; } @@ -4136,7 +4136,7 @@ struct system_fontfile_enumerator IDWriteFontFileEnumerator IDWriteFontFileEnumerator_iface; LONG ref;
- IDWriteFactory5 *factory; + IDWriteFactory7 *factory; HKEY hkey; int index;
@@ -4175,8 +4175,9 @@ static ULONG WINAPI systemfontfileenumerator_Release(IDWriteFontFileEnumerator * struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface); ULONG ref = InterlockedDecrement(&enumerator->ref);
- if (!ref) { - IDWriteFactory5_Release(enumerator->factory); + if (!ref) + { + IDWriteFactory7_Release(enumerator->factory); RegCloseKey(enumerator->hkey); heap_free(enumerator->filename); heap_free(enumerator); @@ -4185,7 +4186,7 @@ static ULONG WINAPI systemfontfileenumerator_Release(IDWriteFontFileEnumerator * return ref; }
-static HRESULT create_local_file_reference(IDWriteFactory5 *factory, const WCHAR *filename, IDWriteFontFile **file) +static HRESULT create_local_file_reference(IDWriteFactory7 *factory, const WCHAR *filename, IDWriteFontFile **file) { HRESULT hr;
@@ -4198,10 +4199,10 @@ static HRESULT create_local_file_reference(IDWriteFactory5 *factory, const WCHAR strcatW(fullpathW, fontsW); strcatW(fullpathW, filename);
- hr = IDWriteFactory5_CreateFontFileReference(factory, fullpathW, NULL, file); + hr = IDWriteFactory7_CreateFontFileReference(factory, fullpathW, NULL, file); } else - hr = IDWriteFactory5_CreateFontFileReference(factory, filename, NULL, file); + hr = IDWriteFactory7_CreateFontFileReference(factory, filename, NULL, file);
return hr; } @@ -4283,7 +4284,7 @@ static const struct IDWriteFontFileEnumeratorVtbl systemfontfileenumeratorvtbl = systemfontfileenumerator_GetCurrentFontFile };
-static HRESULT create_system_fontfile_enumerator(IDWriteFactory5 *factory, IDWriteFontFileEnumerator **ret) +static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWriteFontFileEnumerator **ret) { struct system_fontfile_enumerator *enumerator; static const WCHAR fontslistW[] = { @@ -4309,11 +4310,12 @@ static HRESULT create_system_fontfile_enumerator(IDWriteFactory5 *factory, IDWri return E_OUTOFMEMORY; }
- IDWriteFactory5_AddRef(factory); + IDWriteFactory7_AddRef(factory);
- if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, fontslistW, 0, GENERIC_READ, &enumerator->hkey)) { + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, fontslistW, 0, GENERIC_READ, &enumerator->hkey)) + { ERR("failed to open fonts list key\n"); - IDWriteFactory5_Release(factory); + IDWriteFactory7_Release(factory); heap_free(enumerator->filename); heap_free(enumerator); return E_FAIL; @@ -4324,7 +4326,7 @@ static HRESULT create_system_fontfile_enumerator(IDWriteFactory5 *factory, IDWri return S_OK; }
-HRESULT get_system_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection1 **collection) +HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection) { IDWriteFontFileEnumerator *enumerator; HRESULT hr; @@ -4341,7 +4343,7 @@ HRESULT get_system_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollectio return hr; }
-static HRESULT eudc_collection_add_family(IDWriteFactory5 *factory, struct dwrite_fontcollection *collection, +static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrite_fontcollection *collection, const WCHAR *keynameW, const WCHAR *pathW) { static const WCHAR defaultfontW[] = {'S','y','s','t','e','m','D','e','f','a','u','l','t','E','U','D','C','F','o','n','t',0}; @@ -4429,7 +4431,7 @@ static HRESULT eudc_collection_add_family(IDWriteFactory5 *factory, struct dwrit return hr; }
-HRESULT get_eudc_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3 **ret) +HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **ret) { static const WCHAR eudckeyfmtW[] = {'E','U','D','C','\','%','u',0}; struct dwrite_fontcollection *collection; @@ -4457,7 +4459,7 @@ HRESULT get_eudc_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection3
*ret = &collection->IDWriteFontCollection3_iface; collection->factory = factory; - IDWriteFactory5_AddRef(factory); + IDWriteFactory7_AddRef(factory);
/* return empty collection if EUDC fonts are not configured */ sprintfW(eudckeypathW, eudckeyfmtW, GetACP()); diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index a63af6c488..448e94058b 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -667,7 +667,7 @@ static IDWriteFontCollection1 *factory_get_system_collection(struct dwritefactor return factory->system_collection; }
- if (FAILED(hr = get_system_fontcollection((IDWriteFactory5 *)&factory->IDWriteFactory7_iface, &collection))) + if (FAILED(hr = get_system_fontcollection(&factory->IDWriteFactory7_iface, &collection))) { WARN("Failed to create system font collection, hr %#x.\n", hr); return NULL; @@ -757,7 +757,7 @@ static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory7 * if (FAILED(hr)) return hr;
- hr = create_font_collection((IDWriteFactory5 *)iface, enumerator, FALSE, (IDWriteFontCollection3 **)collection); + hr = create_font_collection(iface, enumerator, FALSE, (IDWriteFontCollection3 **)collection); IDWriteFontFileEnumerator_Release(enumerator); return hr; } @@ -859,10 +859,10 @@ void factory_unlock(IDWriteFactory7 *iface) LeaveCriticalSection(&factory->cs); }
-HRESULT factory_get_cached_fontface(IDWriteFactory5 *iface, IDWriteFontFile * const *font_files, UINT32 index, +HRESULT factory_get_cached_fontface(IDWriteFactory7 *iface, IDWriteFontFile * const *font_files, UINT32 index, DWRITE_FONT_SIMULATIONS simulations, struct list **cached_list, REFIID riid, void **obj) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); struct fontfacecached *cached; IDWriteFontFileLoader *loader; struct list *fontfaces; @@ -1001,7 +1001,7 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory7 *iface, DWRIT goto failed; }
- hr = factory_get_cached_fontface((IDWriteFactory5 *)iface, font_files, index, simulations, &fontfaces, + hr = factory_get_cached_fontface(iface, font_files, index, simulations, &fontfaces, &IID_IDWriteFontFace, (void **)fontface); if (hr != S_FALSE) goto failed; @@ -1290,7 +1290,7 @@ static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory7 *ifac else { IDWriteFontCollection3 *eudc_collection;
- if (FAILED(hr = get_eudc_fontcollection((IDWriteFactory5 *)iface, &eudc_collection))) + if (FAILED(hr = get_eudc_fontcollection(iface, &eudc_collection))) { *collection = NULL; WARN("Failed to get EUDC collection, hr %#x.\n", hr); @@ -1885,12 +1885,12 @@ static void init_dwritefactory(struct dwritefactory *factory, DWRITE_FACTORY_TYP factory->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": dwritefactory.lock"); }
-void factory_detach_fontcollection(IDWriteFactory5 *iface, IDWriteFontCollection3 *collection) +void factory_detach_fontcollection(IDWriteFactory7 *iface, IDWriteFontCollection3 *collection) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); InterlockedCompareExchangePointer((void **)&factory->system_collection, NULL, collection); InterlockedCompareExchangePointer((void **)&factory->eudc_collection, NULL, collection); - IDWriteFactory5_Release(iface); + IDWriteFactory7_Release(iface); }
void factory_detach_gdiinterop(IDWriteFactory5 *iface, IDWriteGdiInterop1 *interop)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 5 +++-- dlls/dwrite/layout.c | 14 +++++++------- dlls/dwrite/main.c | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index ce693239cf..871f93b60b 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -128,7 +128,7 @@ static inline BOOL is_simulation_valid(DWRITE_FONT_SIMULATIONS simulations)
struct textlayout_desc { - IDWriteFactory5 *factory; + IDWriteFactory7 *factory; const WCHAR *string; UINT32 length; IDWriteTextFormat *format; @@ -231,7 +231,8 @@ extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const 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 struct textlayout_desc*,IDWriteTextLayout**) DECLSPEC_HIDDEN; -extern HRESULT create_trimmingsign(IDWriteFactory5*,IDWriteTextFormat*,IDWriteInlineObject**) DECLSPEC_HIDDEN; +extern HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format, + IDWriteInlineObject **sign) DECLSPEC_HIDDEN; extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN; extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 6f166b03f7..b9321157a9 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -251,7 +251,7 @@ struct dwrite_textlayout IDWriteTextAnalysisSource1 IDWriteTextAnalysisSource1_iface; LONG refcount;
- IDWriteFactory5 *factory; + IDWriteFactory7 *factory;
WCHAR *str; UINT32 len; @@ -806,7 +806,7 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout) struct layout_run *r; HRESULT hr;
- if (FAILED(hr = IDWriteFactory5_GetSystemFontCollection(layout->factory, FALSE, + if (FAILED(hr = IDWriteFactory5_GetSystemFontCollection((IDWriteFactory5 *)layout->factory, FALSE, (IDWriteFontCollection1 **)&sys_collection, FALSE))) { WARN("Failed to get system collection, hr %#x.\n", hr); return hr; @@ -817,7 +817,7 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout) IDWriteFontFallback_AddRef(fallback); } else { - if (FAILED(hr = IDWriteFactory5_GetSystemFontFallback(layout->factory, &fallback))) { + if (FAILED(hr = IDWriteFactory7_GetSystemFontFallback(layout->factory, &fallback))) { WARN("Failed to get system fallback, hr %#x.\n", hr); goto fatal; } @@ -2843,7 +2843,7 @@ static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout4 *iface)
if (!refcount) { - IDWriteFactory5_Release(layout->factory); + IDWriteFactory7_Release(layout->factory); free_layout_ranges_list(layout); free_layout_eruns(layout); free_layout_runs(layout); @@ -5204,7 +5204,7 @@ static HRESULT init_textlayout(const struct textlayout_desc *desc, struct dwrite layout->transform = desc->transform ? *desc->transform : identity;
layout->factory = desc->factory; - IDWriteFactory5_AddRef(layout->factory); + IDWriteFactory7_AddRef(layout->factory); list_add_head(&layout->ranges, &range->entry); list_add_head(&layout->strike_ranges, &strike->entry); list_add_head(&layout->underline_ranges, &underline->entry); @@ -5366,7 +5366,7 @@ static inline BOOL is_flow_direction_vert(DWRITE_FLOW_DIRECTION direction) (direction == DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP); }
-HRESULT create_trimmingsign(IDWriteFactory5 *factory, IDWriteTextFormat *format, IDWriteInlineObject **sign) +HRESULT create_trimmingsign(IDWriteFactory7 *factory, IDWriteTextFormat *format, IDWriteInlineObject **sign) { static const WCHAR ellipsisW = 0x2026; struct dwrite_trimmingsign *This; @@ -5392,7 +5392,7 @@ HRESULT create_trimmingsign(IDWriteFactory5 *factory, IDWriteTextFormat *format, This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl; This->ref = 1;
- hr = IDWriteFactory5_CreateTextLayout(factory, &ellipsisW, 1, format, 0.0f, 0.0f, &This->layout); + hr = IDWriteFactory7_CreateTextLayout(factory, &ellipsisW, 1, format, 0.0f, 0.0f, &This->layout); if (FAILED(hr)) { heap_free(This); return hr; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 448e94058b..73dafffd67 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1171,7 +1171,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory7 *iface, WCH
TRACE("%p, %s:%u, %p, %.8e, %.8e, %p.\n", iface, debugstr_wn(string, length), length, format, max_width, max_height, layout);
- desc.factory = (IDWriteFactory5 *)iface; + desc.factory = iface; desc.string = string; desc.length = length; desc.format = format; @@ -1193,7 +1193,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory TRACE("%p, %s:%u, %p, %.8e, %.8e, %.8e, %p, %d, %p.\n", iface, debugstr_wn(string, length), length, format, max_width, max_height, pixels_per_dip, transform, use_gdi_natural, layout);
- desc.factory = (IDWriteFactory5 *)iface; + desc.factory = iface; desc.string = string; desc.length = length; desc.format = format; @@ -1211,7 +1211,7 @@ static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory7 * { TRACE("%p, %p, %p.\n", iface, format, trimming_sign);
- return create_trimmingsign((IDWriteFactory5 *)iface, format, trimming_sign); + return create_trimmingsign(iface, format, trimming_sign); }
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory7 *iface, IDWriteTextAnalyzer **analyzer)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 4 +- dlls/dwrite/gdiinterop.c | 162 +++++++++++++++++++---------------- dlls/dwrite/main.c | 8 +- 3 files changed, 93 insertions(+), 81 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 871f93b60b..c2aef6b77c 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -269,14 +269,14 @@ extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFil extern HRESULT factory_get_cached_fontface(IDWriteFactory7 *factory, IDWriteFontFile * const *files, UINT32 num_files, DWRITE_FONT_SIMULATIONS simulations, struct list **cache, REFIID riid, void **obj) DECLSPEC_HIDDEN; extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 *collection) DECLSPEC_HIDDEN; -extern void factory_detach_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1*) DECLSPEC_HIDDEN; +extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop) DECLSPEC_HIDDEN; extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces, IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*) DECLSPEC_HIDDEN; extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*) DECLSPEC_HIDDEN; extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*) DECLSPEC_HIDDEN; extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*) DECLSPEC_HIDDEN; -extern HRESULT create_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1**) DECLSPEC_HIDDEN; +extern HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **interop) DECLSPEC_HIDDEN; extern void fontface_detach_from_cache(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern void factory_lock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN; extern void factory_unlock(IDWriteFactory7 *factory) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 2e4a949286..7e88f7490c 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -38,12 +38,13 @@ struct dib_data { int width; };
-struct rendertarget { +struct rendertarget +{ IDWriteBitmapRenderTarget1 IDWriteBitmapRenderTarget1_iface; ID2D1SimplifiedGeometrySink ID2D1SimplifiedGeometrySink_iface; - LONG ref; + LONG refcount;
- IDWriteFactory5 *factory; + IDWriteFactory7 *factory; DWRITE_TEXT_ANTIALIAS_MODE antialiasmode; FLOAT ppdip; DWRITE_MATRIX m; @@ -52,11 +53,12 @@ struct rendertarget { struct dib_data dib; };
-struct gdiinterop { +struct gdiinterop +{ IDWriteGdiInterop1 IDWriteGdiInterop1_iface; IDWriteFontFileLoader IDWriteFontFileLoader_iface; - LONG ref; - IDWriteFactory5 *factory; + LONG refcount; + IDWriteFactory7 *factory; };
struct memresource_stream { @@ -249,27 +251,29 @@ static HRESULT WINAPI rendertarget_QueryInterface(IDWriteBitmapRenderTarget1 *if
static ULONG WINAPI rendertarget_AddRef(IDWriteBitmapRenderTarget1 *iface) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); + ULONG refcount = InterlockedIncrement(&target->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI rendertarget_Release(IDWriteBitmapRenderTarget1 *iface) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); + ULONG refcount = InterlockedDecrement(&target->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %u.\n", iface, refcount);
- if (!ref) + if (!refcount) { - IDWriteFactory5_Release(This->factory); - DeleteDC(This->hdc); - heap_free(This); + IDWriteFactory7_Release(target->factory); + DeleteDC(target->hdc); + heap_free(target); }
- return ref; + return refcount; }
static inline DWORD *get_pixel_ptr_32(struct dib_data *dib, int x, int y) @@ -341,22 +345,22 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac DWRITE_GLYPH_RUN const *run, IDWriteRenderingParams *params, COLORREF color, RECT *bbox_ret) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); IDWriteGlyphRunAnalysis *analysis; DWRITE_RENDERING_MODE1 rendermode; DWRITE_GRID_FIT_MODE gridfitmode; DWRITE_TEXTURE_TYPE texturetype; DWRITE_GLYPH_RUN scaled_run; IDWriteFontFace3 *fontface; - RECT target, bounds; + RECT target_rect, bounds; HRESULT hr;
- TRACE("(%p)->(%.2f %.2f %d %p %p 0x%08x %p)\n", This, originX, originY, + TRACE("%p, %.8e, %.8e, %d, %p, %p, 0x%08x, %p.\n", iface, originX, originY, measuring_mode, run, params, color, bbox_ret);
SetRectEmpty(bbox_ret);
- if (!This->dib.ptr) + if (!target->dib.ptr) return S_OK;
if (!params) @@ -367,18 +371,19 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac return hr; }
- hr = IDWriteFontFace3_GetRecommendedRenderingMode(fontface, run->fontEmSize, This->ppdip * 96.0f, - This->ppdip * 96.0f, NULL /* FIXME */, run->isSideways, DWRITE_OUTLINE_THRESHOLD_ALIASED, measuring_mode, + hr = IDWriteFontFace3_GetRecommendedRenderingMode(fontface, run->fontEmSize, target->ppdip * 96.0f, + target->ppdip * 96.0f, NULL /* FIXME */, run->isSideways, DWRITE_OUTLINE_THRESHOLD_ALIASED, measuring_mode, params, &rendermode, &gridfitmode); IDWriteFontFace3_Release(fontface); if (FAILED(hr)) return hr;
- SetRect(&target, 0, 0, This->size.cx, This->size.cy); + SetRect(&target_rect, 0, 0, target->size.cx, target->size.cy);
- if (rendermode == DWRITE_RENDERING_MODE1_OUTLINE) { + if (rendermode == DWRITE_RENDERING_MODE1_OUTLINE) + { static const XFORM identity = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; - const DWRITE_MATRIX *m = &This->m; + const DWRITE_MATRIX *m = &target->m; XFORM xform;
/* target allows any transform to be set, filter it here */ @@ -397,40 +402,42 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac xform.eDx = m->m11 * originX + m->m21 * originY + m->dx; xform.eDy = m->m12 * originX + m->m22 * originY + m->dy; } - SetWorldTransform(This->hdc, &xform); + SetWorldTransform(target->hdc, &xform);
- BeginPath(This->hdc); + BeginPath(target->hdc);
- hr = IDWriteFontFace_GetGlyphRunOutline(run->fontFace, run->fontEmSize * This->ppdip, + hr = IDWriteFontFace_GetGlyphRunOutline(run->fontFace, run->fontEmSize * target->ppdip, run->glyphIndices, run->glyphAdvances, run->glyphOffsets, run->glyphCount, - run->isSideways, run->bidiLevel & 1, &This->ID2D1SimplifiedGeometrySink_iface); + run->isSideways, run->bidiLevel & 1, &target->ID2D1SimplifiedGeometrySink_iface);
- EndPath(This->hdc); + EndPath(target->hdc);
- if (hr == S_OK) { + if (hr == S_OK) + { HBRUSH brush = CreateSolidBrush(color);
- SelectObject(This->hdc, brush); + SelectObject(target->hdc, brush);
- FillPath(This->hdc); + FillPath(target->hdc);
/* FIXME: one way to get affected rectangle bounds is to use region fill */ if (bbox_ret) - *bbox_ret = target; + *bbox_ret = target_rect;
DeleteObject(brush); }
- SetWorldTransform(This->hdc, &identity); + SetWorldTransform(target->hdc, &identity);
return hr; }
scaled_run = *run; - scaled_run.fontEmSize *= This->ppdip; - hr = IDWriteFactory5_CreateGlyphRunAnalysis(This->factory, &scaled_run, &This->m, rendermode, measuring_mode, - gridfitmode, This->antialiasmode, originX, originY, &analysis); - if (FAILED(hr)) { + scaled_run.fontEmSize *= target->ppdip; + hr = IDWriteFactory7_CreateGlyphRunAnalysis(target->factory, &scaled_run, &target->m, rendermode, measuring_mode, + gridfitmode, target->antialiasmode, originX, originY, &analysis); + if (FAILED(hr)) + { WARN("failed to create analysis instance, 0x%08x\n", hr); return hr; } @@ -448,8 +455,9 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac texturetype = DWRITE_TEXTURE_CLEARTYPE_3x1; }
- if (IntersectRect(&target, &target, &bounds)) { - UINT32 size = (target.right - target.left) * (target.bottom - target.top); + if (IntersectRect(&target_rect, &target_rect, &bounds)) + { + UINT32 size = (target_rect.right - target_rect.left) * (target_rect.bottom - target_rect.top); BYTE *bitmap;
color = colorref_to_pixel_888(color); @@ -461,15 +469,15 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac return E_OUTOFMEMORY; }
- hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, texturetype, &target, bitmap, size); + hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, texturetype, &target_rect, bitmap, size); if (hr == S_OK) { /* blit to target dib */ if (texturetype == DWRITE_TEXTURE_ALIASED_1x1) - blit_8(&This->dib, bitmap, &target, color); + blit_8(&target->dib, bitmap, &target_rect, color); else - blit_subpixel_888(&This->dib, This->size.cx, bitmap, &target, color); + blit_subpixel_888(&target->dib, target->size.cx, bitmap, &target_rect, color);
- if (bbox_ret) *bbox_ret = target; + if (bbox_ret) *bbox_ret = target_rect; }
heap_free(bitmap); @@ -584,7 +592,7 @@ static const IDWriteBitmapRenderTarget1Vtbl rendertargetvtbl = { rendertarget_SetTextAntialiasMode };
-static HRESULT create_rendertarget(IDWriteFactory5 *factory, HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget **ret) +static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget **ret) { struct rendertarget *target; HRESULT hr; @@ -596,7 +604,7 @@ static HRESULT create_rendertarget(IDWriteFactory5 *factory, HDC hdc, UINT32 wid
target->IDWriteBitmapRenderTarget1_iface.lpVtbl = &rendertargetvtbl; target->ID2D1SimplifiedGeometrySink_iface.lpVtbl = &rendertargetsinkvtbl; - target->ref = 1; + target->refcount = 1;
target->hdc = CreateCompatibleDC(hdc); SetGraphicsMode(target->hdc, GM_ADVANCED); @@ -610,7 +618,7 @@ static HRESULT create_rendertarget(IDWriteFactory5 *factory, HDC hdc, UINT32 wid target->ppdip = GetDeviceCaps(target->hdc, LOGPIXELSX) / 96.0f; target->antialiasmode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE; target->factory = factory; - IDWriteFactory5_AddRef(factory); + IDWriteFactory7_AddRef(factory);
*ret = (IDWriteBitmapRenderTarget*)&target->IDWriteBitmapRenderTarget1_iface;
@@ -640,26 +648,29 @@ static HRESULT WINAPI gdiinterop_QueryInterface(IDWriteGdiInterop1 *iface, REFII
static ULONG WINAPI gdiinterop_AddRef(IDWriteGdiInterop1 *iface) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - LONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct gdiinterop *interop = impl_from_IDWriteGdiInterop1(iface); + LONG refcount = InterlockedIncrement(&interop->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI gdiinterop_Release(IDWriteGdiInterop1 *iface) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - LONG ref = InterlockedDecrement(&This->ref); + struct gdiinterop *interop = impl_from_IDWriteGdiInterop1(iface); + LONG refcount = InterlockedDecrement(&interop->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %u.\n", iface, refcount);
- if (!ref) { - IDWriteFactory5_UnregisterFontFileLoader(This->factory, &This->IDWriteFontFileLoader_iface); - factory_detach_gdiinterop(This->factory, iface); - heap_free(This); + if (!refcount) + { + IDWriteFactory7_UnregisterFontFileLoader(interop->factory, &interop->IDWriteFontFileLoader_iface); + factory_detach_gdiinterop(interop->factory, iface); + heap_free(interop); }
- return ref; + return refcount; }
static HRESULT WINAPI gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface, @@ -751,7 +762,7 @@ extern BOOL WINAPI GetFontFileData(DWORD instance_id, DWORD unknown, UINT64 offs static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface, HDC hdc, IDWriteFontFace **fontface) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); + struct gdiinterop *interop = impl_from_IDWriteGdiInterop1(iface); struct font_realization_info info; struct font_fileinfo *fileinfo; DWRITE_FONT_FILE_TYPE filetype; @@ -762,7 +773,7 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface SIZE_T needed; HRESULT hr;
- TRACE("(%p)->(%p %p)\n", This, hdc, fontface); + TRACE("%p, %p, %p.\n", iface, hdc, fontface);
*fontface = NULL;
@@ -793,10 +804,10 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface }
if (*fileinfo->path) - hr = IDWriteFactory5_CreateFontFileReference(This->factory, fileinfo->path, &fileinfo->writetime, &file); + hr = IDWriteFactory7_CreateFontFileReference(interop->factory, fileinfo->path, &fileinfo->writetime, &file); else - hr = IDWriteFactory5_CreateCustomFontFileReference(This->factory, &info.instance_id, sizeof(info.instance_id), - &This->IDWriteFontFileLoader_iface, &file); + hr = IDWriteFactory7_CreateCustomFontFileReference(interop->factory, &info.instance_id, + sizeof(info.instance_id), &interop->IDWriteFontFileLoader_iface, &file);
heap_free(fileinfo); if (FAILED(hr)) @@ -807,7 +818,7 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface if (SUCCEEDED(hr)) { if (is_supported) /* Simulations flags values match DWRITE_FONT_SIMULATIONS */ - hr = IDWriteFactory5_CreateFontFace(This->factory, facetype, 1, &file, info.face_index, + hr = IDWriteFactory7_CreateFontFace(interop->factory, facetype, 1, &file, info.face_index, info.simulations, fontface); else hr = DWRITE_E_FILEFORMAT; @@ -828,14 +839,14 @@ static HRESULT WINAPI gdiinterop_CreateBitmapRenderTarget(IDWriteGdiInterop1 *if static HRESULT WINAPI gdiinterop1_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont, IDWriteFontCollection *collection, IDWriteFont **font) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); + struct gdiinterop *interop = impl_from_IDWriteGdiInterop1(iface); IDWriteFontFamily *family; DWRITE_FONT_STYLE style; BOOL exists = FALSE; UINT32 index; HRESULT hr;
- TRACE("(%p)->(%p %p %p)\n", This, logfont, collection, font); + TRACE("%p, %p, %p, %p.\n", iface, logfont, collection, font);
*font = NULL;
@@ -844,7 +855,7 @@ static HRESULT WINAPI gdiinterop1_CreateFontFromLOGFONT(IDWriteGdiInterop1 *ifac if (collection) IDWriteFontCollection_AddRef(collection); else { - hr = IDWriteFactory5_GetSystemFontCollection(This->factory, FALSE, (IDWriteFontCollection1**)&collection, FALSE); + hr = IDWriteFactory5_GetSystemFontCollection((IDWriteFactory5 *)interop->factory, FALSE, (IDWriteFontCollection1 **)&collection, FALSE); if (FAILED(hr)) { ERR("failed to get system font collection: 0x%08x.\n", hr); return hr; @@ -1089,7 +1100,7 @@ static const struct IDWriteFontFileLoaderVtbl memresourceloadervtbl = { memresourceloader_CreateStreamFromKey, };
-HRESULT create_gdiinterop(IDWriteFactory5 *factory, IDWriteGdiInterop1 **ret) +HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **ret) { struct gdiinterop *interop;
@@ -1100,9 +1111,10 @@ HRESULT create_gdiinterop(IDWriteFactory5 *factory, IDWriteGdiInterop1 **ret)
interop->IDWriteGdiInterop1_iface.lpVtbl = &gdiinteropvtbl; interop->IDWriteFontFileLoader_iface.lpVtbl = &memresourceloadervtbl; - interop->ref = 1; - IDWriteFactory5_AddRef(interop->factory = factory); - IDWriteFactory5_RegisterFontFileLoader(factory, &interop->IDWriteFontFileLoader_iface); + interop->refcount = 1; + interop->factory = factory; + IDWriteFactory7_AddRef(interop->factory); + IDWriteFactory7_RegisterFontFileLoader(factory, &interop->IDWriteFontFileLoader_iface);
*ret = &interop->IDWriteGdiInterop1_iface; return S_OK; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 73dafffd67..9c88ab6871 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1157,7 +1157,7 @@ static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory7 *iface, IDWrit if (factory->gdiinterop) IDWriteGdiInterop1_AddRef(factory->gdiinterop); else - hr = create_gdiinterop((IDWriteFactory5 *)iface, &factory->gdiinterop); + hr = create_gdiinterop(iface, &factory->gdiinterop);
*gdi_interop = (IDWriteGdiInterop *)factory->gdiinterop;
@@ -1893,11 +1893,11 @@ void factory_detach_fontcollection(IDWriteFactory7 *iface, IDWriteFontCollection IDWriteFactory7_Release(iface); }
-void factory_detach_gdiinterop(IDWriteFactory5 *iface, IDWriteGdiInterop1 *interop) +void factory_detach_gdiinterop(IDWriteFactory7 *iface, IDWriteGdiInterop1 *interop) { - struct dwritefactory *factory = impl_from_IDWriteFactory7((IDWriteFactory7 *)iface); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface); factory->gdiinterop = NULL; - IDWriteFactory5_Release(iface); + IDWriteFactory7_Release(iface); }
HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret)