Commit 57826074 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

usp10: Add a stub implementation and a test for ScriptLayout.

parent 6fa9343b
......@@ -727,6 +727,52 @@ void test_ScriptGetGlyphABCWidth(HDC hdc)
ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
}
void test_ScriptLayout(void)
{
HRESULT hr;
static const BYTE levels[][5] =
{
{ 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1 },
{ 2, 2, 2, 2, 2 },
{ 3, 3, 3, 3, 3 },
};
static const int expect[][5] =
{
{ 0, 1, 2, 3, 4 },
{ 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4 },
{ 4, 3, 2, 1, 0 }
};
int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
{
hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
for (j = 0; j < sizeof(levels[i]); j++)
{
ok(expect[i][j] == vistolog[j],
"failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
i, j, levels[i][j], j, vistolog[j] );
}
for (j = 0; j < sizeof(levels[i]); j++)
{
ok(expect[i][j] == logtovis[j],
"failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
i, j, levels[i][j], j, logtovis[j] );
}
}
}
static const struct
{
LGRPID group;
......@@ -1010,6 +1056,7 @@ START_TEST(usp10)
test_ScriptTextOut();
test_ScriptXtoX();
test_ScriptString();
test_ScriptLayout();
test_digit_substitution();
}
......@@ -1124,3 +1124,50 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB
return S_OK;
}
/***********************************************************************
* ScriptLayout (USP10.@)
*
* Map embedding levels to visual and/or logical order.
*
* PARAMS
* runs [I] Size of level array.
* level [I] Array of embedding levels.
* vistolog [O] Map of embedding levels from visual to logical order.
* logtovis [O] Map of embedding levels from logical to visual order.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*
* BUGS
* This stub works correctly for any sequence of a single
* embedding level but not for sequences of different
* embedding levels, i.e. mixtures of RTL and LTR scripts.
*/
HRESULT WINAPI ScriptLayout(int runs, const BYTE *level, int *vistolog, int *logtovis)
{
int i, j = runs - 1, k = 0;
FIXME("(%d, %p, %p, %p): stub\n", runs, level, vistolog, logtovis);
if (!level || (!vistolog && !logtovis))
return E_INVALIDARG;
for (i = 0; i < runs; i++)
{
if (level[i] % 2)
{
if (vistolog) *vistolog++ = j;
if (logtovis) *logtovis++ = j;
j--;
}
else
{
if (vistolog) *vistolog++ = k;
if (logtovis) *logtovis++ = k;
k++;
}
}
return S_OK;
}
......@@ -13,7 +13,7 @@
@ stdcall ScriptIsComplex(wstr long long)
@ stdcall ScriptItemize(wstr long long ptr ptr ptr ptr)
@ stub ScriptJustify
@ stub ScriptLayout
@ stdcall ScriptLayout(long ptr ptr ptr)
@ stdcall ScriptPlace(ptr ptr ptr long ptr ptr ptr ptr ptr)
@ stdcall ScriptRecordDigitSubstitution(ptr ptr)
@ stdcall ScriptShape(ptr ptr ptr long long ptr ptr ptr ptr ptr)
......
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