[USP10_WINETEST]
[reactos.git] / rostests / winetests / usp10 / usp10.c
1 /*
2 * Tests for usp10 dll
3 *
4 * Copyright 2006 Jeff Latimer
5 * Copyright 2006 Hans Leidekker
6 * Copyright 2010 CodeWeavers, Aric Stewart
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 *
22 * Notes:
23 * Uniscribe allows for processing of complex scripts such as joining
24 * and filtering characters and bi-directional text with custom line breaks.
25 */
26
27 #include <assert.h>
28 #include <stdio.h>
29
30 #include <wine/test.h>
31 #include <winnls.h>
32 #include <wingdi.h>
33 #include <winuser.h>
34 //#include <windows.h>
35 #include <usp10.h>
36
37 typedef struct _itemTest {
38 char todo_flag[5];
39 int iCharPos;
40 int fRTL;
41 int fLayoutRTL;
42 int uBidiLevel;
43 ULONG scriptTag;
44 BOOL isBroken;
45 int broken_value[5];
46 } itemTest;
47
48 typedef struct _shapeTest_char {
49 WORD wLogClust;
50 SCRIPT_CHARPROP CharProp;
51 } shapeTest_char;
52
53 typedef struct _shapeTest_glyph {
54 int Glyph;
55 SCRIPT_GLYPHPROP GlyphProp;
56 } shapeTest_glyph;
57
58 /* Uniscribe 1.6 calls */
59 static HRESULT (WINAPI *pScriptItemizeOpenType)( const WCHAR *pwcInChars, int cInChars, int cMaxItems, const SCRIPT_CONTROL *psControl, const SCRIPT_STATE *psState, SCRIPT_ITEM *pItems, ULONG *pScriptTags, int *pcItems);
60
61 static HRESULT (WINAPI *pScriptShapeOpenType)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int *rcRangeChars, TEXTRANGE_PROPERTIES **rpRangeProperties, int cRanges, const WCHAR *pwcChars, int cChars, int cMaxGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProps, WORD *pwOutGlyphs, SCRIPT_GLYPHPROP *pOutGlyphProps, int *pcGlyphs);
62
63 static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
64
65 static HRESULT (WINAPI *pScriptGetFontScriptTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags);
66 static HRESULT (WINAPI *pScriptGetFontLanguageTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags);
67 static HRESULT (WINAPI *pScriptGetFontFeatureTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags);
68
69 static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
70 SCRIPT_CONTROL *Control, SCRIPT_STATE *State,
71 DWORD nItems, const itemTest* items, BOOL nItemsToDo,
72 const INT nItemsBroken[2])
73 {
74 HRESULT hr;
75 int x, outnItems;
76 SCRIPT_ITEM outpItems[15];
77 ULONG tags[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
78
79 if (pScriptItemizeOpenType)
80 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
81 else
82 hr = ScriptItemize(string, cchString, 15, Control, State, outpItems, &outnItems);
83
84 winetest_ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
85 if (nItemsBroken && (broken(nItemsBroken[0] == outnItems) || broken(nItemsBroken[1] == outnItems)))
86 {
87 winetest_win_skip("This test broken on this platform\n");
88 return;
89 }
90 if (nItemsToDo)
91 todo_wine winetest_ok(outnItems == nItems, "Wrong number of items\n");
92 else
93 winetest_ok(outnItems == nItems, "Wrong number of items\n");
94 for (x = 0; x <= outnItems; x++)
95 {
96 if (items[x].isBroken && broken(outpItems[x].iCharPos == items[x].broken_value[0]))
97 winetest_win_skip("This test broken on this platform\n");
98 else if (items[x].todo_flag[0])
99 todo_wine winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos\n",x);
100 else
101 winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos (%i)\n",x,outpItems[x].iCharPos);
102
103 if (items[x].isBroken && broken(outpItems[x].a.fRTL== items[x].broken_value[1]))
104 winetest_win_skip("This test broken on this platform\n");
105 else if (items[x].todo_flag[1])
106 todo_wine winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL\n",x);
107 else
108 winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL(%i)\n",x,outpItems[x].a.fRTL);
109
110 if (items[x].isBroken && broken(outpItems[x].a.fLayoutRTL == items[x].broken_value[2]))
111 winetest_win_skip("This test broken on this platform\n");
112 else if (items[x].todo_flag[2])
113 todo_wine winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL\n",x);
114 else
115 winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL(%i)\n",x,outpItems[x].a.fLayoutRTL);
116
117 if (items[x].isBroken && broken(outpItems[x].a.s.uBidiLevel == items[x].broken_value[3]))
118 winetest_win_skip("This test broken on this platform\n");
119 else if (items[x].todo_flag[3])
120 todo_wine winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel\n",x);
121 else
122 winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel(%i)\n",x,outpItems[x].a.s.uBidiLevel);
123 if (x != outnItems)
124 winetest_ok(outpItems[x].a.eScript != SCRIPT_UNDEFINED, "%i: Undefined script\n",x);
125 if (pScriptItemizeOpenType)
126 {
127 if (items[x].isBroken && broken(tags[x] == items[x].broken_value[4]))
128 winetest_win_skip("This test broken on this platform\n");
129 else if (items[x].todo_flag[4])
130 todo_wine winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
131 else
132 winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
133 }
134 }
135 }
136
137 #define test_items_ok(a,b,c,d,e,f,g,h) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_items_ok(a,b,c,d,e,f,g,h)
138
139 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
140 ( ( (ULONG)_x4 << 24 ) | \
141 ( (ULONG)_x3 << 16 ) | \
142 ( (ULONG)_x2 << 8 ) | \
143 (ULONG)_x1 )
144
145 #define latn_tag MS_MAKE_TAG('l','a','t','n')
146 #define arab_tag MS_MAKE_TAG('a','r','a','b')
147 #define thai_tag MS_MAKE_TAG('t','h','a','i')
148 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
149 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
150 #define deva_tag MS_MAKE_TAG('d','e','v','a')
151 #define beng_tag MS_MAKE_TAG('b','e','n','g')
152 #define guru_tag MS_MAKE_TAG('g','u','r','u')
153 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
154 #define orya_tag MS_MAKE_TAG('o','r','y','a')
155 #define taml_tag MS_MAKE_TAG('t','a','m','l')
156 #define telu_tag MS_MAKE_TAG('t','e','l','u')
157 #define knda_tag MS_MAKE_TAG('k','n','d','a')
158 #define mlym_tag MS_MAKE_TAG('m','l','y','m')
159 #define mymr_tag MS_MAKE_TAG('m','y','m','r')
160 #define tale_tag MS_MAKE_TAG('t','a','l','e')
161 #define talu_tag MS_MAKE_TAG('t','a','l','u')
162 #define khmr_tag MS_MAKE_TAG('k','h','m','r')
163 #define hani_tag MS_MAKE_TAG('h','a','n','i')
164 #define bopo_tag MS_MAKE_TAG('b','o','p','o')
165 #define kana_tag MS_MAKE_TAG('k','a','n','a')
166 #define hang_tag MS_MAKE_TAG('h','a','n','g')
167 #define yi_tag MS_MAKE_TAG('y','i',' ',' ')
168 #define ethi_tag MS_MAKE_TAG('e','t','h','i')
169 #define mong_tag MS_MAKE_TAG('m','o','n','g')
170 #define tfng_tag MS_MAKE_TAG('t','f','n','g')
171 #define nko_tag MS_MAKE_TAG('n','k','o',' ')
172 #define vai_tag MS_MAKE_TAG('v','a','i',' ')
173 #define cher_tag MS_MAKE_TAG('c','h','e','r')
174 #define cans_tag MS_MAKE_TAG('c','a','n','s')
175 #define ogam_tag MS_MAKE_TAG('o','g','a','m')
176 #define runr_tag MS_MAKE_TAG('r','u','n','r')
177 #define brai_tag MS_MAKE_TAG('b','r','a','i')
178 #define dsrt_tag MS_MAKE_TAG('d','s','r','t')
179 #define osma_tag MS_MAKE_TAG('o','s','m','a')
180 #define math_tag MS_MAKE_TAG('m','a','t','h')
181
182 static void test_ScriptItemize( void )
183 {
184 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
185 static const itemTest t11[2] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1}};
186 static const itemTest t12[2] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
187
188 static const WCHAR test1b[] = {' ', ' ', ' ', ' ',0};
189 static const itemTest t1b1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
190 static const itemTest t1b2[2] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
191
192 static const WCHAR test1c[] = {' ', ' ', ' ', '1', '2', ' ',0};
193 static const itemTest t1c1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
194 static const itemTest t1c2[4] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},5,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
195
196 /* Arabic, English*/
197 static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
198 static const itemTest t21[7] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,0,0,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
199 static const itemTest t22[5] = {{{0,0,0,0,0},0,0,0,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
200 static const itemTest t23[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,1,1,1,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
201
202 static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
203 static const itemTest t2b1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
204 static const itemTest t2b2[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
205 static const itemTest t2b3[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
206 static const int b2[2] = {4,4};
207
208 /* leading space */
209 static const WCHAR test2c[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
210 static const itemTest t2c1[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
211 static const itemTest t2c2[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},1,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
212 static const itemTest t2c3[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,2,0,FALSE},{{0,0,0,0,0},8,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
213 static const itemTest t2c4[3] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
214
215 /* trailing space */
216 static const WCHAR test2d[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
217 static const itemTest t2d1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
218 static const itemTest t2d2[6] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
219 static const itemTest t2d3[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
220 static const itemTest t2d4[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
221
222 /* Thai */
223 static const WCHAR test3[] =
224 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
225 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
226 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
227 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
228
229 static const itemTest t31[2] = {{{0,0,0,0,0},0,0,0,0,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
230 static const itemTest t32[2] = {{{0,0,0,0,0},0,0,0,2,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
231
232 static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
233
234 static const itemTest t41[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
235 static const itemTest t42[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,2,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
236 static const itemTest t43[4] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
237 static const int b43[2] = {4,4};
238
239 /* Arabic */
240 static const WCHAR test5[] =
241 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
242 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
243 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
244 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
245 static const itemTest t51[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},38,0,0,0,-1,FALSE}};
246
247 /* Hebrew */
248 static const WCHAR test6[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
249 static const itemTest t61[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
250 static const itemTest t62[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
251 static const itemTest t63[2] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
252 static const int b63[2] = {2,2};
253 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};
254 static const itemTest t71[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0},19,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
255 static const itemTest t72[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},18,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
256 static const itemTest t73[4] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},19,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
257 static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
258 static const itemTest t81[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
259
260 /* Syriac (Like Arabic )*/
261 static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
262 static const itemTest t91[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
263 static const itemTest t92[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
264 static const itemTest t93[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
265 static const int b93[2] = {2,2};
266
267 static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
268 static const itemTest t101[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
269
270 /* Devanagari */
271 static const WCHAR test11[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
272 static const itemTest t111[2] = {{{0,0,0,0,0},0,0,0,0,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
273 static const itemTest t112[2] = {{{0,0,0,0,0},0,0,0,2,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
274
275 /* Bengali */
276 static const WCHAR test12[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
277 static const itemTest t121[2] = {{{0,0,0,0,0},0,0,0,0,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
278 static const itemTest t122[2] = {{{0,0,0,0,0},0,0,0,2,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
279
280 /* Gurmukhi */
281 static const WCHAR test13[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
282 static const itemTest t131[2] = {{{0,0,0,0,0},0,0,0,0,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
283 static const itemTest t132[2] = {{{0,0,0,0,0},0,0,0,2,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
284
285 /* Gujarati */
286 static const WCHAR test14[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
287 static const itemTest t141[2] = {{{0,0,0,0,0},0,0,0,0,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
288 static const itemTest t142[2] = {{{0,0,0,0,0},0,0,0,2,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
289
290 /* Oriya */
291 static const WCHAR test15[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
292 static const itemTest t151[2] = {{{0,0,0,0,0},0,0,0,0,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
293 static const itemTest t152[2] = {{{0,0,0,0,0},0,0,0,2,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
294
295 /* Tamil */
296 static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
297 static const itemTest t161[2] = {{{0,0,0,0,0},0,0,0,0,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
298 static const itemTest t162[2] = {{{0,0,0,0,0},0,0,0,2,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
299
300 /* Telugu */
301 static const WCHAR test17[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
302 static const itemTest t171[2] = {{{0,0,0,0,0},0,0,0,0,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
303 static const itemTest t172[2] = {{{0,0,0,0,0},0,0,0,2,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
304
305 /* Kannada */
306 static const WCHAR test18[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
307 static const itemTest t181[2] = {{{0,0,0,0,0},0,0,0,0,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
308 static const itemTest t182[2] = {{{0,0,0,0,0},0,0,0,2,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
309
310 /* Malayalam */
311 static const WCHAR test19[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
312 static const itemTest t191[2] = {{{0,0,0,0,0},0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
313 static const itemTest t192[2] = {{{0,0,0,0,0},0,0,0,2,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
314
315 /* Diacritical */
316 static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
317 static const itemTest t201[3] = {{{0,0,0,0,0},0,0,0,0,0x0,FALSE},{{0,0,0,0,0},1,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
318 static const itemTest t202[3] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},1,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
319
320 static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
321 static const itemTest t211[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
322
323 /* Latin Punctuation */
324 static const WCHAR test22[] = {'#','$',',','!','\"','*',0};
325 static const itemTest t221[3] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
326 static const itemTest t222[3] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},3,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
327 static const itemTest t223[2] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
328 static const int b222[2] = {1,1};
329 static const int b223[2] = {2,2};
330
331 /* Number 2*/
332 static const WCHAR test23[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
333 static const itemTest t231[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
334 static const itemTest t232[3] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
335
336 /* Myanmar */
337 static const WCHAR test24[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
338 static const itemTest t241[2] = {{{0,0,0,0,0},0,0,0,0,mymr_tag,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
339 static const itemTest t242[2] = {{{0,0,0,0,0},0,0,0,2,mymr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
340
341 /* Tai Le */
342 static const WCHAR test25[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
343 static const itemTest t251[2] = {{{0,0,0,0,0},0,0,0,0,tale_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
344 static const itemTest t252[2] = {{{0,0,0,0,0},0,0,0,2,tale_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
345
346 /* New Tai Lue */
347 static const WCHAR test26[] = {0x1992,0x19c4};
348 static const itemTest t261[2] = {{{0,0,0,0,0},0,0,0,0,talu_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
349 static const itemTest t262[2] = {{{0,0,0,0,0},0,0,0,2,talu_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
350
351 /* Khmer */
352 static const WCHAR test27[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
353 static const itemTest t271[2] = {{{0,0,0,0,0},0,0,0,0,khmr_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
354 static const itemTest t272[2] = {{{0,0,0,0,0},0,0,0,2,khmr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
355
356 /* CJK Han */
357 static const WCHAR test28[] = {0x8bed,0x7d20,0x6587,0x5b57};
358 static const itemTest t281[2] = {{{0,0,0,0,0},0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
359 static const itemTest t282[2] = {{{0,0,0,0,0},0,0,0,2,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
360
361 /* Ideographic */
362 static const WCHAR test29[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
363 static const itemTest t291[3] = {{{0,0,0,0,0},0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
364 static const itemTest t292[3] = {{{0,0,0,0,0},0,1,1,1,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,2,hani_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
365
366 /* Bopomofo */
367 static const WCHAR test30[] = {0x3113,0x3128,0x3127,0x3123,0x3108,0x3128,0x310f,0x3120};
368 static const itemTest t301[2] = {{{0,0,0,0,0},0,0,0,0,bopo_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
369 static const itemTest t302[2] = {{{0,0,0,0,0},0,0,0,2,bopo_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
370
371 /* Kana */
372 static const WCHAR test31[] = {0x3072,0x3089,0x304b,0x306a,0x30ab,0x30bf,0x30ab,0x30ca};
373 static const itemTest t311[2] = {{{0,0,0,0,0},0,0,0,0,kana_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
374 static const itemTest t312[2] = {{{0,0,0,0,0},0,0,0,2,kana_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
375 static const int b311[2] = {2,2};
376 static const int b312[2] = {2,2};
377
378 /* Hangul */
379 static const WCHAR test32[] = {0xd55c,0xad6d,0xc5b4};
380 static const itemTest t321[2] = {{{0,0,0,0,0},0,0,0,0,hang_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
381 static const itemTest t322[2] = {{{0,0,0,0,0},0,0,0,2,hang_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
382
383 /* Yi */
384 static const WCHAR test33[] = {0xa188,0xa320,0xa071,0xa0b7};
385 static const itemTest t331[2] = {{{0,0,0,0,0},0,0,0,0,yi_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
386 static const itemTest t332[2] = {{{0,0,0,0,0},0,0,0,2,yi_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
387
388 /* Ethiopic */
389 static const WCHAR test34[] = {0x130d,0x12d5,0x12dd};
390 static const itemTest t341[2] = {{{0,0,0,0,0},0,0,0,0,ethi_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
391 static const itemTest t342[2] = {{{0,0,0,0,0},0,0,0,2,ethi_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
392 static const int b342[2] = {2,2};
393
394 /* Mongolian */
395 static const WCHAR test35[] = {0x182e,0x1823,0x1829,0x182d,0x1823,0x182f,0x0020,0x182a,0x1822,0x1834,0x1822,0x182d,0x180c};
396 static const itemTest t351[2] = {{{0,0,0,0,0},0,0,0,0,mong_tag,FALSE},{{0,0,0,0,0},13,0,0,0,-1,FALSE}};
397 static const itemTest t352[2] = {{{0,0,0,0,0},0,0,0,2,mong_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},13,0,0,0,-1,FALSE}};
398 static const int b351[2] = {2,2};
399 static const int b352[2] = {2,3};
400
401 /* Tifinagh */
402 static const WCHAR test36[] = {0x2d5c,0x2d49,0x2d3c,0x2d49,0x2d4f,0x2d30,0x2d56};
403 static const itemTest t361[2] = {{{0,0,0,0,0},0,0,0,0,tfng_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
404 static const itemTest t362[2] = {{{0,0,0,0,0},0,0,0,2,tfng_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
405
406 /* N'Ko */
407 static const WCHAR test37[] = {0x07d2,0x07de,0x07cf};
408 static const itemTest t371[2] = {{{0,0,0,0,0},0,1,1,1,nko_tag,TRUE,{-1,0,0,0,arab_tag}},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
409 static const itemTest t372[2] = {{{0,0,0,0,0},0,1,1,1,nko_tag,TRUE,{-1,0,0,2,arab_tag}},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
410
411 /* Vai */
412 static const WCHAR test38[] = {0xa559,0xa524};
413 static const itemTest t381[2] = {{{0,0,0,0,0},0,0,0,0,vai_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
414 static const itemTest t382[2] = {{{0,0,0,0,0},0,0,0,2,vai_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
415
416 /* Cherokee */
417 static const WCHAR test39[] = {0x13e3,0x13b3,0x13a9,0x0020,0x13a6,0x13ec,0x13c2,0x13af,0x13cd,0x13d7};
418 static const itemTest t391[2] = {{{0,0,0,0,0},0,0,0,0,cher_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
419 static const itemTest t392[2] = {{{0,0,0,0,0},0,0,0,2,cher_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
420
421 /* Canadian Aboriginal Syllabics */
422 static const WCHAR test40[] = {0x1403,0x14c4,0x1483,0x144e,0x1450,0x1466};
423 static const itemTest t401[2] = {{{0,0,0,0,0},0,0,0,0,cans_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
424 static const itemTest t402[2] = {{{0,0,0,0,0},0,0,0,2,cans_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
425
426 /* Ogham */
427 static const WCHAR test41[] = {0x169b,0x1691,0x168c,0x1690,0x168b,0x169c};
428 static const itemTest t411[2] = {{{0,0,0,0,0},0,0,0,0,ogam_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
429 static const itemTest t412[4] = {{{0,0,0,0,0},0,1,1,1,ogam_tag,FALSE},{{0,0,0,0,0},1,0,0,2,ogam_tag,FALSE},{{0,0,0,0,0},5,1,1,1,ogam_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
430 static const int b412[2] = {1,1};
431
432 /* Runic */
433 static const WCHAR test42[] = {0x16a0,0x16a1,0x16a2,0x16a3,0x16a4,0x16a5};
434 static const itemTest t421[2] = {{{0,0,0,0,0},0,0,0,0,runr_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
435 static const itemTest t422[4] = {{{0,0,0,0,0},0,0,0,2,runr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
436
437 /* Braille */
438 static const WCHAR test43[] = {0x280f,0x2817,0x2811,0x280d,0x280a,0x2811,0x2817};
439 static const itemTest t431[2] = {{{0,0,0,0,0},0,0,0,0,brai_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
440 static const itemTest t432[4] = {{{0,0,0,0,0},0,0,0,2,brai_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
441
442 /* Private and Surrogates Area */
443 static const WCHAR test44[] = {0xe000, 0xe001, 0xd800, 0xd801};
444 static const itemTest t441[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},2,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
445 static const itemTest t442[4] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},2,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
446
447 /* Deseret */
448 static const WCHAR test45[] = {0xd801,0xdc19,0xd801,0xdc32,0xd801,0xdc4c,0xd801,0xdc3c,0xd801,0xdc32,0xd801,0xdc4b,0xd801,0xdc2f,0xd801,0xdc4c,0xd801,0xdc3b,0xd801,0xdc32,0xd801,0xdc4a,0xd801,0xdc28};
449 static const itemTest t451[2] = {{{0,0,0,0,0},0,0,0,0,dsrt_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},24,0,0,0,-1,FALSE}};
450 static const itemTest t452[2] = {{{0,0,0,0,0},0,0,0,2,dsrt_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},24,0,0,0,-1,FALSE}};
451
452 /* Osmanya */
453 static const WCHAR test46[] = {0xd801,0xdc8b,0xd801,0xdc98,0xd801,0xdc88,0xd801,0xdc91,0xd801,0xdc9b,0xd801,0xdc92,0xd801,0xdc95,0xd801,0xdc80};
454 static const itemTest t461[2] = {{{0,0,0,0,0},0,0,0,0,osma_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
455 static const itemTest t462[2] = {{{0,0,0,0,0},0,0,0,2,osma_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
456
457 /* Mathematical Alphanumeric Symbols */
458 static const WCHAR test47[] = {0xd835,0xdc00,0xd835,0xdc35,0xd835,0xdc6a,0xd835,0xdc9f,0xd835,0xdcd4,0xd835,0xdd09,0xd835,0xdd3e,0xd835,0xdd73,0xd835,0xdda8,0xd835,0xdddd,0xd835,0xde12,0xd835,0xde47,0xd835,0xde7c};
459 static const itemTest t471[2] = {{{0,0,0,0,0},0,0,0,0,math_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},26,0,0,0,-1,FALSE}};
460 static const itemTest t472[2] = {{{0,0,0,0,0},0,0,0,2,math_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},26,0,0,0,-1,FALSE}};
461
462 SCRIPT_ITEM items[15];
463 SCRIPT_CONTROL Control;
464 SCRIPT_STATE State;
465 HRESULT hr;
466 HMODULE usp10;
467 int nItems;
468
469 usp10 = LoadLibraryA("usp10.dll");
470 ok (usp10 != 0,"Unable to LoadLibrary on usp10.dll\n");
471 pScriptItemizeOpenType = (void*)GetProcAddress(usp10, "ScriptItemizeOpenType");
472 pScriptShapeOpenType = (void*)GetProcAddress(usp10, "ScriptShapeOpenType");
473 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
474
475 memset(&Control, 0, sizeof(Control));
476 memset(&State, 0, sizeof(State));
477
478 hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
479 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
480
481 hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
482 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
483
484 hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
485 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
486
487 hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
488 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
489
490 test_items_ok(test1,4,NULL,NULL,1,t11,FALSE,0);
491 test_items_ok(test1b,4,NULL,NULL,1,t1b1,FALSE,0);
492 test_items_ok(test1c,6,NULL,NULL,1,t1c1,FALSE,0);
493 test_items_ok(test2,16,NULL,NULL,6,t21,FALSE,0);
494 test_items_ok(test2b,11,NULL,NULL,4,t2b1,FALSE,0);
495 test_items_ok(test2c,11,NULL,NULL,4,t2c1,FALSE,0);
496 test_items_ok(test2d,11,NULL,NULL,4,t2d1,FALSE,0);
497 test_items_ok(test3,41,NULL,NULL,1,t31,FALSE,0);
498 test_items_ok(test4,12,NULL,NULL,5,t41,FALSE,0);
499 test_items_ok(test5,38,NULL,NULL,1,t51,FALSE,0);
500 test_items_ok(test6,5,NULL,NULL,2,t61,FALSE,0);
501 test_items_ok(test7,29,NULL,NULL,3,t71,FALSE,0);
502 test_items_ok(test8,4,NULL,NULL,1,t81,FALSE,0);
503 test_items_ok(test9,5,NULL,NULL,2,t91,FALSE,0);
504 test_items_ok(test10,4,NULL,NULL,1,t101,FALSE,0);
505 test_items_ok(test11,8,NULL,NULL,1,t111,FALSE,0);
506 test_items_ok(test12,5,NULL,NULL,1,t121,FALSE,0);
507 test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
508 test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
509 test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
510 test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
511 test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
512 test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
513 test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
514 test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
515 test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
516 test_items_ok(test22,6,NULL,NULL,2,t221,FALSE,0);
517 test_items_ok(test23,6,NULL,NULL,2,t231,FALSE,0);
518 test_items_ok(test24,12,NULL,NULL,1,t241,FALSE,0);
519 test_items_ok(test25,10,NULL,NULL,1,t251,FALSE,0);
520 test_items_ok(test26,2,NULL,NULL,1,t261,FALSE,0);
521 test_items_ok(test27,8,NULL,NULL,1,t271,FALSE,0);
522 test_items_ok(test28,4,NULL,NULL,1,t281,FALSE,0);
523 test_items_ok(test29,10,NULL,NULL,2,t291,FALSE,0);
524 test_items_ok(test30,8,NULL,NULL,1,t301,FALSE,0);
525 test_items_ok(test31,8,NULL,NULL,1,t311,FALSE,b311);
526 test_items_ok(test32,3,NULL,NULL,1,t321,FALSE,0);
527 test_items_ok(test33,4,NULL,NULL,1,t331,FALSE,0);
528 test_items_ok(test34,3,NULL,NULL,1,t341,FALSE,0);
529 test_items_ok(test35,13,NULL,NULL,1,t351,FALSE,b351);
530 test_items_ok(test36,7,NULL,NULL,1,t361,FALSE,0);
531 test_items_ok(test37,3,NULL,NULL,1,t371,FALSE,0);
532 test_items_ok(test38,2,NULL,NULL,1,t381,FALSE,0);
533 test_items_ok(test39,10,NULL,NULL,1,t391,FALSE,0);
534 test_items_ok(test40,6,NULL,NULL,1,t401,FALSE,0);
535 test_items_ok(test41,6,NULL,NULL,1,t411,FALSE,0);
536 test_items_ok(test42,6,NULL,NULL,1,t421,FALSE,0);
537 test_items_ok(test43,7,NULL,NULL,1,t431,FALSE,0);
538 test_items_ok(test44,4,NULL,NULL,2,t441,FALSE,0);
539 test_items_ok(test45,24,NULL,NULL,1,t451,FALSE,0);
540 test_items_ok(test46,16,NULL,NULL,1,t461,FALSE,0);
541 test_items_ok(test47,26,NULL,NULL,1,t471,FALSE,0);
542
543 State.uBidiLevel = 0;
544 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
545 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
546 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
547 test_items_ok(test2,16,&Control,&State,4,t22,FALSE,0);
548 test_items_ok(test2b,11,&Control,&State,4,t2b1,FALSE,0);
549 test_items_ok(test2c,11,&Control,&State,5,t2c2,FALSE,0);
550 test_items_ok(test2d,11,&Control,&State,5,t2d2,FALSE,0);
551 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
552 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
553 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
554 test_items_ok(test6,5,&Control,&State,2,t61,FALSE,0);
555 test_items_ok(test7,29,&Control,&State,3,t72,FALSE,0);
556 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
557 test_items_ok(test9,5,&Control,&State,2,t91,FALSE,0);
558 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
559 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
560 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
561 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
562 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
563 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
564 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
565 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
566 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
567 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
568 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
569 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
570 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
571 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
572 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
573 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
574 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
575 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
576 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
577 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
578 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
579 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
580 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
581 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
582 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
583 test_items_ok(test35,13,&Control,&State,1,t351,FALSE,b351);
584 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
585 test_items_ok(test37,3,&Control,&State,1,t371,FALSE,0);
586 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
587 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
588 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
589 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
590 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
591 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
592 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
593 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
594 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
595 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
596
597 State.uBidiLevel = 1;
598 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
599 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
600 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
601 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
602 test_items_ok(test2b,11,&Control,&State,4,t2b2,FALSE,0);
603 test_items_ok(test2c,11,&Control,&State,4,t2c3,FALSE,0);
604 test_items_ok(test2d,11,&Control,&State,4,t2d3,FALSE,0);
605 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
606 test_items_ok(test4,12,&Control,&State,4,t42,FALSE,0);
607 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
608 test_items_ok(test6,5,&Control,&State,2,t62,FALSE,0);
609 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
610 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
611 test_items_ok(test9,5,&Control,&State,2,t92,FALSE,0);
612 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
613 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
614 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
615 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
616 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
617 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
618 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
619 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
620 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
621 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
622 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
623 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
624 test_items_ok(test22,6,&Control,&State,2,t222,FALSE,b222);
625 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
626 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
627 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
628 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
629 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
630 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
631 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
632 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
633 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
634 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
635 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
636 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
637 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
638 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
639 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
640 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
641 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
642 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
643 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
644 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
645 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
646 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
647 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
648 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
649 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
650
651 State.uBidiLevel = 1;
652 Control.fMergeNeutralItems = TRUE;
653 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
654 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
655 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
656 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
657 test_items_ok(test2b,11,&Control,&State,2,t2b3,FALSE,b2);
658 test_items_ok(test2c,11,&Control,&State,2,t2c4,FALSE,b2);
659 test_items_ok(test2d,11,&Control,&State,2,t2d4,FALSE,b2);
660 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
661 test_items_ok(test4,12,&Control,&State,3,t43,FALSE,b43);
662 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
663 test_items_ok(test6,5,&Control,&State,1,t63,FALSE,b63);
664 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
665 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
666 test_items_ok(test9,5,&Control,&State,1,t93,FALSE,b93);
667 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
668 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
669 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
670 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
671 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
672 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
673 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
674 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
675 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
676 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
677 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
678 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
679 test_items_ok(test22,6,&Control,&State,1,t223,FALSE,b223);
680 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
681 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
682 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
683 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
684 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
685 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
686 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
687 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
688 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
689 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
690 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
691 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
692 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
693 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
694 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
695 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
696 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
697 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
698 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
699 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
700 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
701 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
702 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
703 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
704 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
705 }
706
707 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
708 DWORD cchString, SCRIPT_CONTROL *Control,
709 SCRIPT_STATE *State, DWORD item, DWORD nGlyphs,
710 const shapeTest_char* charItems,
711 const shapeTest_glyph* glyphItems)
712 {
713 HRESULT hr;
714 int x, outnItems=0, outnGlyphs=0;
715 SCRIPT_ITEM outpItems[15];
716 SCRIPT_CACHE sc = NULL;
717 WORD *glyphs;
718 WORD *logclust;
719 int maxGlyphs = cchString * 1.5;
720 SCRIPT_GLYPHPROP *glyphProp;
721 SCRIPT_CHARPROP *charProp;
722 ULONG tags[15];
723
724 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
725 if (hr == USP_E_SCRIPT_NOT_IN_FONT)
726 {
727 if (valid > 0)
728 winetest_win_skip("Select font does not support script\n");
729 else
730 winetest_trace("Select font does not support script\n");
731 return;
732 }
733 if (valid > 0)
734 winetest_ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
735 else if (hr != S_OK)
736 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr);
737
738 if (outnItems <= item)
739 {
740 if (valid > 0)
741 winetest_win_skip("Did not get enough items\n");
742 else
743 winetest_trace("Did not get enough items\n");
744 return;
745 }
746
747 logclust = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * cchString);
748 memset(logclust,'a',sizeof(WORD) * cchString);
749 charProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP) * cchString);
750 memset(charProp,'a',sizeof(SCRIPT_CHARPROP) * cchString);
751 glyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * maxGlyphs);
752 memset(glyphs,'a',sizeof(WORD) * cchString);
753 glyphProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP) * maxGlyphs);
754 memset(glyphProp,'a',sizeof(SCRIPT_GLYPHPROP) * cchString);
755
756 hr = pScriptShapeOpenType(hdc, &sc, &outpItems[item].a, tags[item], 0x00000000, NULL, NULL, 0, string, cchString, maxGlyphs, logclust, charProp, glyphs, glyphProp, &outnGlyphs);
757 if (valid > 0)
758 winetest_ok(hr == S_OK, "ScriptShapeOpenType failed (%x)\n",hr);
759 else if (hr != S_OK)
760 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr);
761 if (FAILED(hr))
762 return;
763
764 for (x = 0; x < cchString; x++)
765 {
766 if (valid > 0)
767 winetest_ok(logclust[x] == charItems[x].wLogClust, "%i: invalid LogClust(%i)\n",x,logclust[x]);
768 else if (logclust[x] != charItems[x].wLogClust)
769 winetest_trace("%i: invalid LogClust(%i)\n",x,logclust[x]);
770 if (valid > 0)
771 winetest_ok(charProp[x].fCanGlyphAlone == charItems[x].CharProp.fCanGlyphAlone, "%i: invalid fCanGlyphAlone\n",x);
772 else if (charProp[x].fCanGlyphAlone != charItems[x].CharProp.fCanGlyphAlone)
773 winetest_trace("%i: invalid fCanGlyphAlone\n",x);
774 }
775
776 if (valid > 0)
777 winetest_ok(nGlyphs == outnGlyphs, "got incorrect number of glyphs (%i)\n",outnGlyphs);
778 else if (nGlyphs != outnGlyphs)
779 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs);
780 for (x = 0; x < outnGlyphs; x++)
781 {
782 if (glyphItems[x].Glyph)
783 {
784 if (valid > 0)
785 winetest_ok(glyphs[x]!=0, "%i: Glyph not present when it should be\n",x);
786 else if (glyphs[x]==0)
787 winetest_trace("%i: Glyph not present when it should be\n",x);
788 }
789 else
790 {
791 if (valid > 0)
792 winetest_ok(glyphs[x]==0, "%i: Glyph present when it should not be\n",x);
793 else if (glyphs[x]!=0)
794 winetest_trace("%i: Glyph present when it should not be\n",x);
795 }
796 if (valid > 0)
797 winetest_ok(glyphProp[x].sva.uJustification == glyphItems[x].GlyphProp.sva.uJustification, "%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
798 else if (glyphProp[x].sva.uJustification != glyphItems[x].GlyphProp.sva.uJustification)
799 winetest_trace("%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
800 if (valid > 0)
801 winetest_ok(glyphProp[x].sva.fClusterStart == glyphItems[x].GlyphProp.sva.fClusterStart, "%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
802 else if (glyphProp[x].sva.fClusterStart != glyphItems[x].GlyphProp.sva.fClusterStart)
803 winetest_trace("%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
804 if (valid > 0)
805 winetest_ok(glyphProp[x].sva.fDiacritic == glyphItems[x].GlyphProp.sva.fDiacritic, "%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
806 else if (glyphProp[x].sva.fDiacritic != glyphItems[x].GlyphProp.sva.fDiacritic)
807 winetest_trace("%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
808 if (valid > 0)
809 winetest_ok(glyphProp[x].sva.fZeroWidth == glyphItems[x].GlyphProp.sva.fZeroWidth, "%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
810 else if (glyphProp[x].sva.fZeroWidth != glyphItems[x].GlyphProp.sva.fZeroWidth)
811 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
812 }
813
814 HeapFree(GetProcessHeap(),0,logclust);
815 HeapFree(GetProcessHeap(),0,charProp);
816 HeapFree(GetProcessHeap(),0,glyphs);
817 HeapFree(GetProcessHeap(),0,glyphProp);
818 ScriptFreeCache(&sc);
819 }
820
821 #define test_shape_ok(a,b,c,d,e,f,g,h,i) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_shape_ok(1,a,b,c,d,e,f,g,h,i)
822
823 #define test_shape_ok_valid(v,a,b,c,d,e,f,g,h,i) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_shape_ok(v,a,b,c,d,e,f,g,h,i)
824
825 typedef struct tagRangeP {
826 BYTE range;
827 LOGFONTA lf;
828 } fontEnumParam;
829
830 static int CALLBACK enumFontProc( const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam )
831 {
832 NEWTEXTMETRICEXA *ntme = (NEWTEXTMETRICEXA*)lpntme;
833 fontEnumParam *rp = (fontEnumParam*) lParam;
834 int idx = 0;
835 DWORD i;
836 DWORD mask = 0;
837
838 if (FontType != TRUETYPE_FONTTYPE)
839 return 1;
840
841 i = rp->range;
842 while (i >= sizeof(DWORD)*8)
843 {
844 idx++;
845 i -= (sizeof(DWORD)*8);
846 }
847 if (idx > 3)
848 return 0;
849
850 mask = 1 << i;
851
852 if (ntme->ntmFontSig.fsUsb[idx] & mask)
853 {
854 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONTA));
855 return 0;
856 }
857 return 1;
858 }
859
860 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
861 {
862 int rc = 0;
863 fontEnumParam lParam;
864
865 lParam.range = range;
866 memset(&lParam.lf,0,sizeof(LOGFONTA));
867 *hfont = NULL;
868
869 if (recommended)
870 {
871 lstrcpyA(lParam.lf.lfFaceName, recommended);
872 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
873 {
874 *hfont = CreateFontIndirectA(&lParam.lf);
875 if (*hfont)
876 {
877 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
878 rc = 1;
879 }
880 }
881 }
882
883 if (!*hfont)
884 {
885 memset(&lParam.lf,0,sizeof(LOGFONTA));
886 lParam.lf.lfCharSet = DEFAULT_CHARSET;
887
888 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
889 {
890 *hfont = CreateFontIndirectA(&lParam.lf);
891 if (*hfont)
892 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
893 }
894 }
895
896 if (*hfont)
897 {
898 WORD glyph = 0;
899
900 *origFont = SelectObject(hdc,*hfont);
901 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
902 {
903 winetest_trace(" Font fails to contain required glyphs\n");
904 SelectObject(hdc,*origFont);
905 DeleteObject(*hfont);
906 *hfont=NULL;
907 rc = 0;
908 }
909 else if (!rc)
910 rc = -1;
911 }
912 else
913 winetest_trace("Failed to find usable font\n");
914
915 return rc;
916 }
917
918 #define find_font_for_range(a,b,c,d,e,f) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _find_font_for_range(a,b,c,d,e,f)
919
920 static void test_ScriptShapeOpenType(HDC hdc)
921 {
922 HRESULT hr;
923 SCRIPT_CACHE sc = NULL;
924 WORD glyphs[4], logclust[4];
925 SCRIPT_GLYPHPROP glyphProp[4];
926 SCRIPT_ITEM items[2];
927 ULONG tags[2];
928 SCRIPT_CONTROL Control;
929 SCRIPT_STATE State;
930 int nb, outnItems;
931 HFONT hfont, hfont_orig;
932 int test_valid;
933
934 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
935 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
936 static const shapeTest_glyph t1_g[] = {
937 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
938 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
939 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
940 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
941
942 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
943 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
944 static const shapeTest_glyph t2_g[] = {
945 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
946 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
947 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
948 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
949
950 /* Hebrew */
951 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
952 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
953 static const shapeTest_glyph hebrew_g[] = {
954 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
955 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
956 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
957 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
958
959 /* Arabic */
960 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
961 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
962 static const shapeTest_glyph arabic_g[] = {
963 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
964 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
965 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
966
967 /* Thai */
968 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
969 static const shapeTest_char thai_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{5,{0,0}},{5,{0,0}},{7,{0,0}},{8,{0,0}},{9,{0,0}}};
970 static const shapeTest_glyph thai_g[] = {
971 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
972 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
973 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
974 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
975 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
976 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
977 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
978 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
979 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
980 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
981
982 /* Syriac */
983 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
984 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
985 static const shapeTest_glyph syriac_g[] = {
986 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
987 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
988 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
989 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
990 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
991 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
992
993 /* Thaana */
994 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
995 static const shapeTest_char thaana_c[] = {{12,{0,0}},{12,{0,0}},{10,{0,0}},{10,{0,0}},{8,{1,0}},{7,{0,0}},{7,{0,0}},{5,{0,0}},{5,{0,0}},{3,{0,0}},{3,{0,0}},{1,{0,0}},{1,{0,0}}};
996 static const shapeTest_glyph thaana_g[] = {
997 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
998 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
999 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1000 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1001 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1002 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1003 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1004 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1005 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1006 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1007 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1008 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1009 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1010
1011 /* Phags-pa */
1012 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
1013 static const shapeTest_char phagspa_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{1,0}},{4,{0,0}},{5,{0,0}},{6,{0,0}},{7,{1,0}},{8,{0,0}},{9,{0,0}},{10,{0,0}}};
1014 static const shapeTest_glyph phagspa_g[] = {
1015 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1016 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1017 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1018 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1019 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1020 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1021 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1022 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1023 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1024 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1025 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1026
1027 /* Lao */
1028 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
1029 static const shapeTest_char lao_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{4,{0,0}},{5,{0,0}},{6,{0,0}},{7,{0,0}},{8,{0,0}}};
1030 static const shapeTest_glyph lao_g[] = {
1031 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1032 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1033 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1034 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1035 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1036 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1037 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1038 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1039 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1040
1041 /* Tibetan */
1042 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
1043 static const shapeTest_char tibetan_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{1,0}},{4,{0,0}},{4,{0,0}},{6,{0,0}},{7,{0,0}},{8,{0,0}},{9,{0,0}},{10,{0,0}},{11,{0,0}},{12,{0,0}},{13,{0,0}},{14,{0,0}},{14,{0,0}},{16,{0,0}}};
1044 static const shapeTest_glyph tibetan_g[] = {
1045 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1046 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1047 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1048 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
1049 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1050 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1051 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1052 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1053 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1054 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1055 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1056 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1057 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1058 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1059 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1060 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1061 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1062
1063 /* Devanagari */
1064 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
1065 static const shapeTest_char devanagari_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{6,{0,0}},{6,{0,0}}};
1066 static const shapeTest_glyph devanagari_g[] = {
1067 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1068 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1069 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1070 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1071 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1072 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1073 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1074 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1075
1076 /* Bengali */
1077 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
1078 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
1079 static const shapeTest_glyph bengali_g[] = {
1080 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1081 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1082 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1083 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1084 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1085
1086 /* Gurmukhi */
1087 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
1088 static const shapeTest_char gurmukhi_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{5,{0,0}}};
1089 static const shapeTest_glyph gurmukhi_g[] = {
1090 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1091 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1092 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1093 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1094 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1095 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1096 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1097
1098 /* Gujarati */
1099 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
1100 static const shapeTest_char gujarati_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{5,{0,0}}};
1101 static const shapeTest_glyph gujarati_g[] = {
1102 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1103 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1104 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1105 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1106 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1107 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1108 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1109
1110 /* Oriya */
1111 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
1112 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1113 static const shapeTest_glyph oriya_g[] = {
1114 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1115 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1116 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1117 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1118
1119 /* Tamil */
1120 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1121 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1122 static const shapeTest_glyph tamil_g[] = {
1123 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1124 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1125 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1126 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1127
1128 /* Telugu */
1129 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1130 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1131 static const shapeTest_glyph telugu_g[] = {
1132 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1133 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1134 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1135 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1136 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1137 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1138
1139 /* Malayalam */
1140 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1141 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1142 static const shapeTest_glyph malayalam_g[] = {
1143 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1144 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1145 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1146 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1147 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1148 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1149
1150 /* Kannada */
1151 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1152 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1153 static const shapeTest_glyph kannada_g[] = {
1154 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1155 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1156 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1157 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1158 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1159
1160 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
1161 {
1162 win_skip("ScriptShapeOpenType not available on this platform\n");
1163 return;
1164 }
1165
1166 memset(&Control, 0 , sizeof(Control));
1167 memset(&State, 0 , sizeof(State));
1168
1169 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
1170 ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
1171 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1172
1173 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
1174 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1175
1176 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
1177 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1178
1179 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1180 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
1181
1182 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1183 ok( hr == E_INVALIDARG,
1184 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1185 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
1186 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1187
1188 ScriptFreeCache(&sc);
1189
1190 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
1191 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, t2_g);
1192
1193 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
1194 if (hfont != NULL)
1195 {
1196 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
1197 SelectObject(hdc, hfont_orig);
1198 DeleteObject(hfont);
1199 }
1200
1201 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
1202 if (hfont != NULL)
1203 {
1204 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
1205 SelectObject(hdc, hfont_orig);
1206 DeleteObject(hfont);
1207 }
1208
1209 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
1210 if (hfont != NULL)
1211 {
1212 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
1213 SelectObject(hdc, hfont_orig);
1214 DeleteObject(hfont);
1215 }
1216
1217 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
1218 if (hfont != NULL)
1219 {
1220 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
1221 SelectObject(hdc, hfont_orig);
1222 DeleteObject(hfont);
1223 }
1224
1225 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
1226 if (hfont != NULL)
1227 {
1228 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
1229 SelectObject(hdc, hfont_orig);
1230 DeleteObject(hfont);
1231 }
1232
1233 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
1234 if (hfont != NULL)
1235 {
1236 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
1237 SelectObject(hdc, hfont_orig);
1238 DeleteObject(hfont);
1239 }
1240
1241 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
1242 if (hfont != NULL)
1243 {
1244 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
1245 SelectObject(hdc, hfont_orig);
1246 DeleteObject(hfont);
1247 }
1248
1249 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
1250 if (hfont != NULL)
1251 {
1252 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
1253 SelectObject(hdc, hfont_orig);
1254 DeleteObject(hfont);
1255 }
1256
1257 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1258 if (hfont != NULL)
1259 {
1260 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1261 SelectObject(hdc, hfont_orig);
1262 DeleteObject(hfont);
1263 }
1264
1265 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1266 if (hfont != NULL)
1267 {
1268 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1269 SelectObject(hdc, hfont_orig);
1270 DeleteObject(hfont);
1271 }
1272
1273 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1274 if (hfont != NULL)
1275 {
1276 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1277 SelectObject(hdc, hfont_orig);
1278 DeleteObject(hfont);
1279 }
1280
1281 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1282 if (hfont != NULL)
1283 {
1284 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1285 SelectObject(hdc, hfont_orig);
1286 DeleteObject(hfont);
1287 }
1288
1289 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1290 if (hfont != NULL)
1291 {
1292 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1293 SelectObject(hdc, hfont_orig);
1294 DeleteObject(hfont);
1295 }
1296
1297 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1298 if (hfont != NULL)
1299 {
1300 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1301 SelectObject(hdc, hfont_orig);
1302 DeleteObject(hfont);
1303 }
1304
1305 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1306 if (hfont != NULL)
1307 {
1308 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1309 SelectObject(hdc, hfont_orig);
1310 DeleteObject(hfont);
1311 }
1312
1313 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1314 if (hfont != NULL)
1315 {
1316 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1317 SelectObject(hdc, hfont_orig);
1318 DeleteObject(hfont);
1319 }
1320
1321 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1322 if (hfont != NULL)
1323 {
1324 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1325 SelectObject(hdc, hfont_orig);
1326 DeleteObject(hfont);
1327 }
1328 }
1329
1330 static void test_ScriptShape(HDC hdc)
1331 {
1332 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1333 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1334 HRESULT hr;
1335 SCRIPT_CACHE sc = NULL;
1336 WORD glyphs[4], glyphs2[4], logclust[4];
1337 SCRIPT_VISATTR attrs[4];
1338 SCRIPT_ITEM items[2];
1339 int nb;
1340
1341 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1342 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1343 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1344
1345 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1346 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1347
1348 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1349 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1350
1351 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1352 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1353
1354 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1355 ok(broken(hr == S_OK) ||
1356 hr == E_INVALIDARG || /* Vista, W2K8 */
1357 hr == E_FAIL, /* WIN7 */
1358 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1359 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1360
1361 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1362 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1363 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1364
1365
1366 memset(glyphs,-1,sizeof(glyphs));
1367 memset(logclust,-1,sizeof(logclust));
1368 memset(attrs,-1,sizeof(attrs));
1369 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1370 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1371 ok(nb == 4, "Wrong number of items\n");
1372 ok(logclust[0] == 0, "clusters out of order\n");
1373 ok(logclust[1] == 1, "clusters out of order\n");
1374 ok(logclust[2] == 2, "clusters out of order\n");
1375 ok(logclust[3] == 3, "clusters out of order\n");
1376 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1377 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1378 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1379 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1380 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1381 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1382 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1383 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1384 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1385 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1386 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1387 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1388 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1389 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1390 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1391 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1392
1393 ScriptFreeCache(&sc);
1394 sc = NULL;
1395
1396 memset(glyphs2,-1,sizeof(glyphs2));
1397 memset(logclust,-1,sizeof(logclust));
1398 memset(attrs,-1,sizeof(attrs));
1399 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1400 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1401 ok(nb == 4, "Wrong number of items\n");
1402 ok(glyphs2[0] == 0 || broken(glyphs2[0] == 0x80), "Incorrect glyph for 0x202B\n");
1403 ok(glyphs2[3] == 0 || broken(glyphs2[3] == 0x80), "Incorrect glyph for 0x202C\n");
1404 ok(logclust[0] == 0, "clusters out of order\n");
1405 ok(logclust[1] == 1, "clusters out of order\n");
1406 ok(logclust[2] == 2, "clusters out of order\n");
1407 ok(logclust[3] == 3, "clusters out of order\n");
1408 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1409 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1410 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1411 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1412 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1413 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1414 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1415 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1416 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1417 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1418 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1419 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1420 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1421 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1422 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1423 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1424
1425 /* modify LTR to RTL */
1426 items[0].a.fRTL = 1;
1427 memset(glyphs2,-1,sizeof(glyphs2));
1428 memset(logclust,-1,sizeof(logclust));
1429 memset(attrs,-1,sizeof(attrs));
1430 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1431 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1432 ok(nb == 4, "Wrong number of items\n");
1433 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1434 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1435 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1436 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1437 ok(logclust[0] == 3, "clusters out of order\n");
1438 ok(logclust[1] == 2, "clusters out of order\n");
1439 ok(logclust[2] == 1, "clusters out of order\n");
1440 ok(logclust[3] == 0, "clusters out of order\n");
1441 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1442 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1443 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1444 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1445 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1446 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1447 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1448 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1449 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1450 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1451 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1452 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1453 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1454 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1455 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1456 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1457
1458 ScriptFreeCache(&sc);
1459 }
1460
1461 static void test_ScriptPlace(HDC hdc)
1462 {
1463 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1464 BOOL ret;
1465 HRESULT hr;
1466 SCRIPT_CACHE sc = NULL;
1467 WORD glyphs[4], logclust[4];
1468 SCRIPT_VISATTR attrs[4];
1469 SCRIPT_ITEM items[2];
1470 int nb, widths[4];
1471 GOFFSET offset[4];
1472 ABC abc[4];
1473
1474 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1475 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1476 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1477
1478 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1479 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1480 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1481
1482 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1483 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1484
1485 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1486 ok(broken(hr == E_PENDING) ||
1487 hr == E_INVALIDARG || /* Vista, W2K8 */
1488 hr == E_FAIL, /* WIN7 */
1489 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1490
1491 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1492 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1493
1494 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1495 ok(broken(hr == E_PENDING) ||
1496 hr == E_INVALIDARG || /* Vista, W2K8 */
1497 hr == E_FAIL, /* WIN7 */
1498 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1499
1500 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1501 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1502 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1503
1504 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1505 ok(ret, "ExtTextOutW should return TRUE\n");
1506
1507 ScriptFreeCache(&sc);
1508 }
1509
1510 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1511 {
1512 HRESULT hr;
1513 int iMaxProps;
1514 const SCRIPT_PROPERTIES **ppSp;
1515
1516 int cInChars;
1517 int cMaxItems;
1518 SCRIPT_ITEM pItem[255];
1519 int pcItems;
1520 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1521 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1522 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1523 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1524 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1525 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1526
1527 SCRIPT_CACHE psc;
1528 int cChars;
1529 int cMaxGlyphs;
1530 unsigned short pwOutGlyphs1[256];
1531 unsigned short pwOutGlyphs2[256];
1532 unsigned short pwLogClust[256];
1533 SCRIPT_VISATTR psva[256];
1534 int pcGlyphs;
1535 int piAdvance[256];
1536 GOFFSET pGoffset[256];
1537 ABC pABC[256];
1538 int cnt;
1539
1540 /* Start testing usp10 functions */
1541 /* This test determines that the pointer returned by ScriptGetProperties is valid
1542 * by checking a known value in the table */
1543 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1544 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1545 trace("number of script properties %d\n", iMaxProps);
1546 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1547 if (iMaxProps > 0)
1548 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1549 /* ptrs work */
1550
1551 /* This is a valid test that will cause parsing to take place */
1552 cInChars = 5;
1553 cMaxItems = 255;
1554 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1555 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1556 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1557 * returned. */
1558 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1559 if (pcItems > 0)
1560 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1561 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1562 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1563
1564 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1565 * ie. ScriptItemize has succeeded and that pItem has been set */
1566 cInChars = 5;
1567 if (hr == S_OK) {
1568 psc = NULL; /* must be null on first call */
1569 cChars = cInChars;
1570 cMaxGlyphs = cInChars;
1571 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1572 cMaxGlyphs, &pItem[0].a,
1573 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1574 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1575 cMaxGlyphs = 4;
1576 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1577 cMaxGlyphs, &pItem[0].a,
1578 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1579 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1580 "(%d) but not E_OUTOFMEMORY\n",
1581 cChars, cMaxGlyphs);
1582 cMaxGlyphs = 256;
1583 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1584 cMaxGlyphs, &pItem[0].a,
1585 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1586 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1587 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1588 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1589 if (hr ==0) {
1590 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1591 pGoffset, pABC);
1592 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1593 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1594 pGoffset, pABC);
1595 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1596 for (cnt=0; cnt < pcGlyphs; cnt++)
1597 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1598 }
1599
1600 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1601 * takes place if fNoGlyphIndex is set. */
1602
1603 cInChars = 5;
1604 cMaxItems = 255;
1605 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1606 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1607 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1608 * returned. */
1609 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1610 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1611 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1612 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1613 if (hr == S_OK) {
1614 cChars = cInChars;
1615 cMaxGlyphs = 256;
1616 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1617 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1618 cMaxGlyphs, &pItem[0].a,
1619 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1620 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1621 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1622 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1623 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1624 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1625 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1626 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1627 if (hr == S_OK) {
1628 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1629 pGoffset, pABC);
1630 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1631 }
1632 }
1633 ScriptFreeCache( &psc);
1634 ok (!psc, "psc is not null after ScriptFreeCache\n");
1635
1636 }
1637
1638 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1639 cInChars = (sizeof(TestItem3)/2)-1;
1640 cMaxItems = 255;
1641 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1642 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1643 if (hr == S_OK)
1644 {
1645 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1646 if (pcItems > 2)
1647 {
1648 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1649 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1650 pItem[0].iCharPos, pItem[1].iCharPos);
1651 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1652 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1653 pItem[1].iCharPos, pItem[2].iCharPos);
1654 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1655 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1656 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1657 }
1658 }
1659
1660 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1661 cInChars = (sizeof(TestItem4)/2)-1;
1662 cMaxItems = 255;
1663 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1664 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1665 if (hr == S_OK)
1666 {
1667 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1668 if (pcItems > 4)
1669 {
1670 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1671 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1672 pItem[0].iCharPos, pItem[1].iCharPos);
1673 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1674 pItem[0].a.s.uBidiLevel);
1675 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1676 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1677 pItem[1].iCharPos, pItem[2].iCharPos);
1678 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1679 pItem[1].a.s.uBidiLevel);
1680 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1681 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1682 pItem[2].iCharPos, pItem[3].iCharPos);
1683 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1684 pItem[2].a.s.uBidiLevel);
1685 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1686 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1687 pItem[3].iCharPos, pItem[4].iCharPos);
1688 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1689 pItem[3].a.s.uBidiLevel);
1690 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1691 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1692 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1693 }
1694 }
1695
1696 /*
1697 * This test is for when the first unicode character requires bidi support
1698 */
1699 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1700 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1701 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1702 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1703 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1704 pItem[0].a.s.uBidiLevel);
1705
1706 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1707 * the pointer to the last char works. Note that windows often needs a greater number of *
1708 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1709 cInChars = (sizeof(TestItem6)/2)-1;
1710 cMaxItems = 4;
1711 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1712 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1713
1714 }
1715
1716 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1717 {
1718 HRESULT hr;
1719 SCRIPT_CACHE psc = NULL;
1720 int cInChars;
1721 int cChars;
1722 unsigned short pwOutGlyphs2[256];
1723 unsigned short pwOutGlyphs3[256];
1724 DWORD dwFlags;
1725 int cnt;
1726
1727 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1728 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1729 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1730 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1731
1732 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1733 dwFlags = 0;
1734 cInChars = cChars = 5;
1735 /* Some sanity checks for ScriptGetCMap */
1736
1737 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1738 ok( hr == E_INVALIDARG