dwrite/tests: Add some tests for text format properties.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-01-21 16:36:51 +03:00 committed by Alexandre Julliard
parent 612652bb9c
commit 239530e8a8
1 changed files with 91 additions and 3 deletions

View File

@ -190,11 +190,17 @@ static IDWriteTextAnalysisSourceVtbl analysissourcevtbl = {
static IDWriteTextAnalysisSource analysissource = { &analysissourcevtbl };
static void *create_factory_iid(REFIID riid)
{
IUnknown *factory = NULL;
DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, riid, &factory);
return factory;
}
static IDWriteFactory *create_factory(void)
{
IDWriteFactory *factory;
HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteFactory *factory = create_factory_iid(&IID_IDWriteFactory);
ok(factory != NULL, "Failed to create factory.\n");
return factory;
}
@ -5860,6 +5866,87 @@ static void test_automatic_font_axes(void)
IDWriteFactory_Release(factory);
}
static void test_text_format_axes(void)
{
IDWriteFontCollection *collection;
IDWriteFontCollection2 *collection2;
DWRITE_FONT_AXIS_VALUE axis;
IDWriteTextFormat3 *format3;
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_WEIGHT weight;
IDWriteTextFormat *format;
IDWriteFactory6 *factory;
DWRITE_FONT_STYLE style;
DWRITE_FONT_FAMILY_MODEL model;
unsigned int count;
HRESULT hr;
factory = create_factory_iid(&IID_IDWriteFactory6);
if (!factory)
{
win_skip("Text format does not support variations.\n");
return;
}
hr = IDWriteFactory6_CreateTextFormat(factory, L"test_family", NULL, NULL, 0, 10.0f, L"en-us", &format3);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IDWriteTextFormat3_GetFontCollection(format3, &collection);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection2, (void **)&collection2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
model = IDWriteFontCollection2_GetFontFamilyModel(collection2);
ok(model == DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC, "Unexpected model %d.\n", model);
IDWriteFontCollection_Release(collection);
IDWriteFontCollection2_Release(collection2);
count = IDWriteTextFormat3_GetFontAxisValueCount(format3);
ok(!count, "Unexpected axis count %u.\n", count);
stretch = IDWriteTextFormat3_GetFontStretch(format3);
ok(stretch == DWRITE_FONT_STRETCH_NORMAL, "Unexpected font stretch %d.\n", stretch);
style = IDWriteTextFormat3_GetFontStyle(format3);
ok(style == DWRITE_FONT_STYLE_NORMAL, "Unexpected font style %d.\n", style);
weight = IDWriteTextFormat3_GetFontWeight(format3);
ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "Unexpected font weight %d.\n", weight);
/* Regular properties are not set from axis values. */
axis.axisTag = DWRITE_FONT_AXIS_TAG_WEIGHT;
axis.value = 200.0f;
hr = IDWriteTextFormat3_SetFontAxisValues(format3, &axis, 1);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
weight = IDWriteTextFormat3_GetFontWeight(format3);
ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "Unexpected font weight %d.\n", weight);
IDWriteTextFormat3_Release(format3);
}
hr = IDWriteFactory_CreateTextFormat((IDWriteFactory *)factory, L"test_family", NULL,
DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_EXPANDED,
10.0f, L"en-us", &format);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IDWriteTextFormat_QueryInterface(format, &IID_IDWriteTextFormat3, (void **)&format3);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
count = IDWriteTextFormat3_GetFontAxisValueCount(format3);
ok(!count, "Unexpected axis count %u.\n", count);
IDWriteTextFormat3_Release(format3);
IDWriteTextFormat_Release(format);
IDWriteFactory6_Release(factory);
}
START_TEST(layout)
{
IDWriteFactory *factory;
@ -5912,6 +5999,7 @@ START_TEST(layout)
test_GetOverhangMetrics();
test_tab_stops();
test_automatic_font_axes();
test_text_format_axes();
IDWriteFactory_Release(factory);
}