usp10: Improve support for Syriac in ScriptItemize.

This commit is contained in:
Aric Stewart 2010-04-19 07:31:28 -05:00 committed by Alexandre Julliard
parent 4459c5b619
commit af3dfc198a
2 changed files with 82 additions and 2 deletions

View file

@ -55,6 +55,10 @@ static void test_ScriptItemize( void )
static const WCHAR test7[] = {'p','a','r','t',' ','o','n','e',' ',0x05d7, 0x05dc, 0x05e7, ' ', 0x05e9, 0x05ea, 0x05d9, 0x05d9, 0x05dd, ' ','p','a','r','t',' ','t','h','r','e','e', 0};
static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
/* Syriac (Like Arabic )*/
static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
SCRIPT_ITEM items[15];
SCRIPT_CONTROL Control;
SCRIPT_STATE State;
@ -407,6 +411,70 @@ static void test_ScriptItemize( void )
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
hr = ScriptItemize(test9, 5, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 2, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 4, "Wrong CharPos \n");
ok(items[1].a.fRTL == 0, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test9, 5, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 2, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 4, "Wrong CharPos \n");
ok(items[1].a.fRTL == 0, "Wrong fRTL\n");
ok(items[1].a.fLayoutRTL == 0, "Wrong fLayoutRTL\n");
ok(items[1].a.s.uBidiLevel == 0, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test9, 5, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 2, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
ok(items[1].iCharPos == 4, "Wrong CharPos \n");
todo_wine ok(items[1].a.fRTL == 1, "Wrong fRTL\n");
todo_wine ok(items[1].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
todo_wine ok(items[1].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
hr = ScriptItemize(test10, 4, 10, NULL, NULL, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
State.uBidiLevel = 0;
hr = ScriptItemize(test10, 4, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
State.uBidiLevel = 1;
hr = ScriptItemize(test10, 4, 10, &Control, &State, items, &nItems);
ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
ok(nItems == 1, "Wrong number of items\n");
ok(items[0].iCharPos == 0, "Wrong CharPos \n");
ok(items[0].a.fRTL == 1, "Wrong fRTL\n");
ok(items[0].a.fLayoutRTL == 1, "Wrong fLayoutRTL\n");
ok(items[0].a.s.uBidiLevel == 1, "Wrong BidiLevel\n");
}

View file

@ -519,8 +519,11 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
#define Arabic_stop 0x06ff
#define Hebrew_start 0x0590
#define Hebrew_stop 0x05ff
#define Syriac_start 0x0700
#define Syriac_stop 0x074f
#define Latin_start 0x0001
#define Latin_stop 0x024f
#define Script_Syriac 8
#define Script_Hebrew 7
#define Script_Arabic 6
#define Script_Latin 1
@ -574,6 +577,9 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
if (pwcInChars[cnt] >= Hebrew_start && pwcInChars[cnt] <= Hebrew_stop)
pItems[index].a.eScript = Script_Hebrew;
else
if (pwcInChars[cnt] >= Syriac_start && pwcInChars[cnt] <= Syriac_stop)
pItems[index].a.eScript = Script_Syriac;
else
if (pwcInChars[cnt] >= Latin_start && pwcInChars[cnt] <= Latin_stop)
pItems[index].a.eScript = Script_Latin;
@ -584,7 +590,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
pItems[index].a.s.uBidiLevel = levels[cnt];
}
else if ((pItems[index].a.eScript == Script_Arabic) ||
(pItems[index].a.eScript == Script_Hebrew))
(pItems[index].a.eScript == Script_Hebrew) ||
(pItems[index].a.eScript == Script_Syriac))
{
pItems[index].a.s.uBidiLevel = 1;
pItems[index].a.fRTL = 1;
@ -619,6 +626,10 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
|| (New_Script == Script_Hebrew && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Hebrew;
else
if ((pwcInChars[cnt] >= Syriac_start && pwcInChars[cnt] <= Syriac_stop)
|| (New_Script == Script_Syriac && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Syriac;
else
if ((pwcInChars[cnt] >= Latin_start && pwcInChars[cnt] <= Latin_stop)
|| (New_Script == Script_Latin && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Latin;
@ -642,7 +653,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
pItems[index].a.s.uBidiLevel = levels[cnt];
}
else if ((New_Script == Script_Arabic) ||
(New_Script == Script_Hebrew))
(New_Script == Script_Hebrew) ||
(New_Script == Script_Syriac))
{
pItems[index].a.s.uBidiLevel = 1;
pItems[index].a.fRTL = 1;