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

dwrite: Compare axis values when testing for face reference equality.

parent ae67aa8b
...@@ -236,6 +236,8 @@ struct dwrite_fontfacereference ...@@ -236,6 +236,8 @@ struct dwrite_fontfacereference
IDWriteFactory7 *factory; IDWriteFactory7 *factory;
}; };
static const IDWriteFontFaceReference1Vtbl fontfacereferencevtbl;
struct dwrite_fontresource struct dwrite_fontresource
{ {
IDWriteFontResource IDWriteFontResource_iface; IDWriteFontResource IDWriteFontResource_iface;
...@@ -1896,6 +1898,16 @@ struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface) ...@@ -1896,6 +1898,16 @@ struct dwrite_fontface *unsafe_impl_from_IDWriteFontFace(IDWriteFontFace *iface)
return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFace5_iface); return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFace5_iface);
} }
static struct dwrite_fontfacereference *unsafe_impl_from_IDWriteFontFaceReference(IDWriteFontFaceReference *iface)
{
if (!iface)
return NULL;
if (iface->lpVtbl != (IDWriteFontFaceReferenceVtbl *)&fontfacereferencevtbl)
return NULL;
return CONTAINING_RECORD((IDWriteFontFaceReference1 *)iface, struct dwrite_fontfacereference,
IDWriteFontFaceReference1_iface);
}
void get_logfont_from_font(IDWriteFont *iface, LOGFONTW *lf) void get_logfont_from_font(IDWriteFont *iface, LOGFONTW *lf)
{ {
struct dwrite_font *font = unsafe_impl_from_IDWriteFont(iface); struct dwrite_font *font = unsafe_impl_from_IDWriteFont(iface);
...@@ -6132,18 +6144,18 @@ static HRESULT WINAPI fontfacereference_CreateFontFaceWithSimulations(IDWriteFon ...@@ -6132,18 +6144,18 @@ static HRESULT WINAPI fontfacereference_CreateFontFaceWithSimulations(IDWriteFon
static BOOL WINAPI fontfacereference_Equals(IDWriteFontFaceReference1 *iface, IDWriteFontFaceReference *ref) static BOOL WINAPI fontfacereference_Equals(IDWriteFontFaceReference1 *iface, IDWriteFontFaceReference *ref)
{ {
struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface); struct dwrite_fontfacereference *reference = impl_from_IDWriteFontFaceReference1(iface);
IDWriteFontFile *file; struct dwrite_fontfacereference *other = unsafe_impl_from_IDWriteFontFaceReference(ref);
BOOL ret; BOOL ret;
TRACE("%p, %p.\n", iface, ref); TRACE("%p, %p.\n", iface, ref);
if (FAILED(IDWriteFontFaceReference_GetFontFile(ref, &file))) ret = is_same_fontfile(reference->file, other->file) && reference->index == other->index &&
return FALSE; reference->simulations == other->simulations;
if (reference->axis_values_count)
ret = is_same_fontfile(reference->file, file) && {
reference->index == IDWriteFontFaceReference_GetFontFaceIndex(ref) && ret &= reference->axis_values_count == other->axis_values_count &&
reference->simulations == IDWriteFontFaceReference_GetSimulations(ref); !memcmp(reference->axis_values, other->axis_values, reference->axis_values_count * sizeof(*reference->axis_values));
IDWriteFontFile_Release(file); }
return ret; return ret;
} }
......
...@@ -9279,13 +9279,14 @@ static void test_font_resource(void) ...@@ -9279,13 +9279,14 @@ static void test_font_resource(void)
IDWriteFontFaceReference1 *reference, *reference2; IDWriteFontFaceReference1 *reference, *reference2;
IDWriteFontResource *resource, *resource2; IDWriteFontResource *resource, *resource2;
IDWriteFontFile *fontfile, *fontfile2; IDWriteFontFile *fontfile, *fontfile2;
DWRITE_FONT_AXIS_VALUE axis_value; DWRITE_FONT_AXIS_VALUE axis_values[2];
IDWriteFontFace5 *fontface5; IDWriteFontFace5 *fontface5;
IDWriteFontFace *fontface; IDWriteFontFace *fontface;
IDWriteFactory6 *factory; IDWriteFactory6 *factory;
UINT32 count, index; UINT32 count, index;
HRESULT hr; HRESULT hr;
ULONG ref; ULONG ref;
BOOL ret;
if (!(factory = create_factory_iid(&IID_IDWriteFactory6))) if (!(factory = create_factory_iid(&IID_IDWriteFactory6)))
{ {
...@@ -9316,9 +9317,9 @@ static void test_font_resource(void) ...@@ -9316,9 +9317,9 @@ static void test_font_resource(void)
ok(!index, "Unexpected index %u.\n", index); ok(!index, "Unexpected index %u.\n", index);
/* Specify axis value, font has no variations. */ /* Specify axis value, font has no variations. */
axis_value.axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT; axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
axis_value.value = 400.0f; axis_values[0].value = 400.0f;
hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, &axis_value, 1, &reference); hr = IDWriteFontResource_CreateFontFaceReference(resource, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 1, &reference);
ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr); ok(hr == S_OK, "Failed to create reference object, hr %#x.\n", hr);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference); count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
...@@ -9326,7 +9327,7 @@ static void test_font_resource(void) ...@@ -9326,7 +9327,7 @@ static void test_font_resource(void)
IDWriteFontFaceReference1_Release(reference); IDWriteFontFaceReference1_Release(reference);
hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, &axis_value, 1, hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 1,
&reference); &reference);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference); count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
ok(count == 1, "Unexpected axis value count.\n"); ok(count == 1, "Unexpected axis value count.\n");
...@@ -9360,6 +9361,55 @@ static void test_font_resource(void) ...@@ -9360,6 +9361,55 @@ static void test_font_resource(void)
IDWriteFontFace5_Release(fontface5); IDWriteFontFace5_Release(fontface5);
/* Reference equality regarding set axis values. */
axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
axis_values[0].value = 400.0f;
axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
axis_values[1].value = 1.0f;
hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
&reference);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference);
ok(count == 2, "Unexpected axis value count.\n");
hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, NULL, 0,
&reference2);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
ok(!count, "Unexpected axis value count.\n");
ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
ok(!ret, "Unexpected result.\n");
IDWriteFontFaceReference1_Release(reference2);
/* Different values order. */
axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
axis_values[0].value = 1.0f;
axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
axis_values[1].value = 400.0f;
hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
&reference2);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
ok(count == 2, "Unexpected axis value count.\n");
ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
ok(!ret, "Unexpected result.\n");
IDWriteFontFaceReference1_Release(reference2);
/* Different axis values. */
axis_values[0].axisTag = DWRITE_FONT_AXIS_TAG_ITALIC;
axis_values[0].value = 1.0f;
axis_values[1].axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
axis_values[1].value = 401.0f;
hr = IDWriteFactory6_CreateFontFaceReference(factory, fontfile, 0, DWRITE_FONT_SIMULATIONS_NONE, axis_values, 2,
&reference2);
count = IDWriteFontFaceReference1_GetFontAxisValueCount(reference2);
ok(count == 2, "Unexpected axis value count.\n");
ret = IDWriteFontFaceReference1_Equals(reference, (IDWriteFontFaceReference *)reference2);
ok(!ret, "Unexpected result.\n");
IDWriteFontFaceReference1_Release(reference2);
IDWriteFontFaceReference1_Release(reference);
IDWriteFontFile_Release(fontfile); IDWriteFontFile_Release(fontfile);
IDWriteFontFace_Release(fontface); IDWriteFontFace_Release(fontface);
......
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