[USP10_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
[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 goto cleanup;
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 cleanup:
815 HeapFree(GetProcessHeap(),0,logclust);
816 HeapFree(GetProcessHeap(),0,charProp);
817 HeapFree(GetProcessHeap(),0,glyphs);
818 HeapFree(GetProcessHeap(),0,glyphProp);
819 ScriptFreeCache(&sc);
820 }
821
822 #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)
823
824 #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)
825
826 typedef struct tagRangeP {
827 BYTE range;
828 LOGFONTA lf;
829 } fontEnumParam;
830
831 static int CALLBACK enumFontProc( const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam )
832 {
833 NEWTEXTMETRICEXA *ntme = (NEWTEXTMETRICEXA*)lpntme;
834 fontEnumParam *rp = (fontEnumParam*) lParam;
835 int idx = 0;
836 DWORD i;
837 DWORD mask = 0;
838
839 if (FontType != TRUETYPE_FONTTYPE)
840 return 1;
841
842 i = rp->range;
843 while (i >= sizeof(DWORD)*8)
844 {
845 idx++;
846 i -= (sizeof(DWORD)*8);
847 }
848 if (idx > 3)
849 return 0;
850
851 mask = 1 << i;
852
853 if (ntme->ntmFontSig.fsUsb[idx] & mask)
854 {
855 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONTA));
856 return 0;
857 }
858 return 1;
859 }
860
861 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
862 {
863 int rc = 0;
864 fontEnumParam lParam;
865
866 lParam.range = range;
867 memset(&lParam.lf,0,sizeof(LOGFONTA));
868 *hfont = NULL;
869
870 if (recommended)
871 {
872 lstrcpyA(lParam.lf.lfFaceName, recommended);
873 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
874 {
875 *hfont = CreateFontIndirectA(&lParam.lf);
876 if (*hfont)
877 {
878 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
879 rc = 1;
880 }
881 }
882 }
883
884 if (!*hfont)
885 {
886 memset(&lParam.lf,0,sizeof(LOGFONTA));
887 lParam.lf.lfCharSet = DEFAULT_CHARSET;
888
889 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
890 {
891 *hfont = CreateFontIndirectA(&lParam.lf);
892 if (*hfont)
893 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
894 }
895 }
896
897 if (*hfont)
898 {
899 WORD glyph = 0;
900
901 *origFont = SelectObject(hdc,*hfont);
902 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
903 {
904 winetest_trace(" Font fails to contain required glyphs\n");
905 SelectObject(hdc,*origFont);
906 DeleteObject(*hfont);
907 *hfont=NULL;
908 rc = 0;
909 }
910 else if (!rc)
911 rc = -1;
912 }
913 else
914 winetest_trace("Failed to find usable font\n");
915
916 return rc;
917 }
918
919 #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)
920
921 static void test_ScriptShapeOpenType(HDC hdc)
922 {
923 HRESULT hr;
924 SCRIPT_CACHE sc = NULL;
925 WORD glyphs[4], logclust[4];
926 SCRIPT_GLYPHPROP glyphProp[4];
927 SCRIPT_ITEM items[2];
928 ULONG tags[2];
929 SCRIPT_CONTROL Control;
930 SCRIPT_STATE State;
931 int nb, outnItems;
932 HFONT hfont, hfont_orig;
933 int test_valid;
934 shapeTest_glyph glyph_test[4];
935
936 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
937 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
938 static const shapeTest_glyph t1_g[] = {
939 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
940 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
941 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
942 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
943
944 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
945 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
946 static const shapeTest_glyph t2_g[] = {
947 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
948 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
949 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
950 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
951
952 /* Hebrew */
953 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
954 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
955 static const shapeTest_glyph hebrew_g[] = {
956 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
957 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
958 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
959 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
960
961 /* Arabic */
962 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
963 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
964 static const shapeTest_glyph arabic_g[] = {
965 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
966 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
967 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
968
969 /* Thai */
970 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
971 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}}};
972 static const shapeTest_glyph thai_g[] = {
973 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
974 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
975 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
976 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
977 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
978 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
979 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
980 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
981 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
982 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
983
984 /* Syriac */
985 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
986 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
987 static const shapeTest_glyph syriac_g[] = {
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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
993 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
994
995 /* Thaana */
996 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
997 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}}};
998 static const shapeTest_glyph thaana_g[] = {
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_NONE,0,1,1,0,0},0}},
1006 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1007 {1,{{SCRIPT_JUSTIFY_CHARACTER,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 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1011 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1012
1013 /* Phags-pa */
1014 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
1015 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}}};
1016 static const shapeTest_glyph phagspa_g[] = {
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_CHARACTER,1,0,0,0,0},0}},
1026 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1027 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1028
1029 /* Lao */
1030 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
1031 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}}};
1032 static const shapeTest_glyph lao_g[] = {
1033 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1034 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,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_CHARACTER,1,0,0,0,0},0}},
1040 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1041 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1042
1043 /* Tibetan */
1044 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
1045 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}}};
1046 static const shapeTest_glyph tibetan_g[] = {
1047 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1048 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1049 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1050 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
1051 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1052 {1,{{SCRIPT_JUSTIFY_NONE,0,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,1,0,0,0,0},0}},
1061 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1062 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1063 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1064
1065 /* Devanagari */
1066 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
1067 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}}};
1068 static const shapeTest_glyph devanagari_g[] = {
1069 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1070 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1071 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1072 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1073 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1074 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1075 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1076 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1077
1078 /* Bengali */
1079 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
1080 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
1081 static const shapeTest_glyph bengali_g[] = {
1082 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1083 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1084 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1085 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1086 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1087
1088 /* Gurmukhi */
1089 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
1090 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}}};
1091 static const shapeTest_glyph gurmukhi_g[] = {
1092 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1093 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1094 {1,{{SCRIPT_JUSTIFY_NONE,1,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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1098 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1099
1100 /* Gujarati */
1101 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
1102 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}}};
1103 static const shapeTest_glyph gujarati_g[] = {
1104 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1105 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1106 {1,{{SCRIPT_JUSTIFY_NONE,1,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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1110 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1111
1112 /* Oriya */
1113 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
1114 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1115 static const shapeTest_glyph oriya_g[] = {
1116 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1117 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1118 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1119 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1120
1121 /* Tamil */
1122 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1123 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1124 static const shapeTest_glyph tamil_g[] = {
1125 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1126 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1127 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1128 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1129
1130 /* Telugu */
1131 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1132 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1133 static const shapeTest_glyph telugu_g[] = {
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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1139 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1140
1141 /* Malayalam */
1142 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1143 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1144 static const shapeTest_glyph malayalam_g[] = {
1145 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1146 {1,{{SCRIPT_JUSTIFY_NONE,1,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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1150 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1151
1152 /* Kannada */
1153 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1154 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1155 static const shapeTest_glyph kannada_g[] = {
1156 {1,{{SCRIPT_JUSTIFY_NONE,1,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 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1160 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1161
1162 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
1163 {
1164 win_skip("ScriptShapeOpenType not available on this platform\n");
1165 return;
1166 }
1167
1168 memset(&Control, 0 , sizeof(Control));
1169 memset(&State, 0 , sizeof(State));
1170
1171 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
1172 ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
1173 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1174
1175 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
1176 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1177
1178 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
1179 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1180
1181 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1182 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
1183
1184 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1185 ok( hr == E_INVALIDARG,
1186 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1187 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
1188 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1189
1190 ScriptFreeCache(&sc);
1191
1192 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
1193
1194 /* newer Tahoma has zerowidth space glyphs for 0x202b and 0x202c */
1195 memcpy(glyph_test, t2_g, sizeof(glyph_test));
1196 GetGlyphIndicesW(hdc, test2, 4, glyphs, 0);
1197 if (glyphs[0] != 0)
1198 glyph_test[0].Glyph = 1;
1199 if (glyphs[3] != 0)
1200 glyph_test[3].Glyph = 1;
1201
1202 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, glyph_test);
1203
1204 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
1205 if (hfont != NULL)
1206 {
1207 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
1208 SelectObject(hdc, hfont_orig);
1209 DeleteObject(hfont);
1210 }
1211
1212 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
1213 if (hfont != NULL)
1214 {
1215 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
1216 SelectObject(hdc, hfont_orig);
1217 DeleteObject(hfont);
1218 }
1219
1220 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
1221 if (hfont != NULL)
1222 {
1223 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
1224 SelectObject(hdc, hfont_orig);
1225 DeleteObject(hfont);
1226 }
1227
1228 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
1229 if (hfont != NULL)
1230 {
1231 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
1232 SelectObject(hdc, hfont_orig);
1233 DeleteObject(hfont);
1234 }
1235
1236 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
1237 if (hfont != NULL)
1238 {
1239 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
1240 SelectObject(hdc, hfont_orig);
1241 DeleteObject(hfont);
1242 }
1243
1244 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
1245 if (hfont != NULL)
1246 {
1247 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
1248 SelectObject(hdc, hfont_orig);
1249 DeleteObject(hfont);
1250 }
1251
1252 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
1253 if (hfont != NULL)
1254 {
1255 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
1256 SelectObject(hdc, hfont_orig);
1257 DeleteObject(hfont);
1258 }
1259
1260 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
1261 if (hfont != NULL)
1262 {
1263 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
1264 SelectObject(hdc, hfont_orig);
1265 DeleteObject(hfont);
1266 }
1267
1268 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1269 if (hfont != NULL)
1270 {
1271 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1272 SelectObject(hdc, hfont_orig);
1273 DeleteObject(hfont);
1274 }
1275
1276 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1277 if (hfont != NULL)
1278 {
1279 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1280 SelectObject(hdc, hfont_orig);
1281 DeleteObject(hfont);
1282 }
1283
1284 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1285 if (hfont != NULL)
1286 {
1287 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1288 SelectObject(hdc, hfont_orig);
1289 DeleteObject(hfont);
1290 }
1291
1292 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1293 if (hfont != NULL)
1294 {
1295 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1296 SelectObject(hdc, hfont_orig);
1297 DeleteObject(hfont);
1298 }
1299
1300 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1301 if (hfont != NULL)
1302 {
1303 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1304 SelectObject(hdc, hfont_orig);
1305 DeleteObject(hfont);
1306 }
1307
1308 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1309 if (hfont != NULL)
1310 {
1311 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1312 SelectObject(hdc, hfont_orig);
1313 DeleteObject(hfont);
1314 }
1315
1316 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1317 if (hfont != NULL)
1318 {
1319 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1320 SelectObject(hdc, hfont_orig);
1321 DeleteObject(hfont);
1322 }
1323
1324 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1325 if (hfont != NULL)
1326 {
1327 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1328 SelectObject(hdc, hfont_orig);
1329 DeleteObject(hfont);
1330 }
1331
1332 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1333 if (hfont != NULL)
1334 {
1335 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1336 SelectObject(hdc, hfont_orig);
1337 DeleteObject(hfont);
1338 }
1339 }
1340
1341 static void test_ScriptShape(HDC hdc)
1342 {
1343 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1344 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1345 HRESULT hr;
1346 SCRIPT_CACHE sc = NULL;
1347 WORD glyphs[4], glyphs2[4], logclust[4], glyphs3[4];
1348 SCRIPT_VISATTR attrs[4];
1349 SCRIPT_ITEM items[2];
1350 int nb, i, j;
1351
1352 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1353 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1354 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1355
1356 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1357 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1358
1359 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1360 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1361
1362 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1363 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1364
1365 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1366 ok(broken(hr == S_OK) ||
1367 hr == E_INVALIDARG || /* Vista, W2K8 */
1368 hr == E_FAIL, /* WIN7 */
1369 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1370 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1371
1372 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1373 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1374 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1375
1376
1377 memset(glyphs,-1,sizeof(glyphs));
1378 memset(logclust,-1,sizeof(logclust));
1379 memset(attrs,-1,sizeof(attrs));
1380 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1381 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1382 ok(nb == 4, "Wrong number of items\n");
1383 ok(logclust[0] == 0, "clusters out of order\n");
1384 ok(logclust[1] == 1, "clusters out of order\n");
1385 ok(logclust[2] == 2, "clusters out of order\n");
1386 ok(logclust[3] == 3, "clusters out of order\n");
1387 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1388 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1389 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1390 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1391 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1392 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1393 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1394 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1395 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1396 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1397 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1398 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1399 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1400 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1401 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1402 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1403
1404 ScriptFreeCache(&sc);
1405 sc = NULL;
1406
1407 memset(glyphs2,-1,sizeof(glyphs2));
1408 memset(glyphs3,-1,sizeof(glyphs3));
1409 memset(logclust,-1,sizeof(logclust));
1410 memset(attrs,-1,sizeof(attrs));
1411
1412 GetGlyphIndicesW(hdc, test2, 4, glyphs3, 0);
1413
1414 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1415 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1416 ok(nb == 4, "Wrong number of items\n");
1417 ok(glyphs2[0] == glyphs3[0], "Incorrect glyph for 0x202B\n");
1418 ok(glyphs2[3] == glyphs3[3], "Incorrect glyph for 0x202C\n");
1419 ok(logclust[0] == 0, "clusters out of order\n");
1420 ok(logclust[1] == 1, "clusters out of order\n");
1421 ok(logclust[2] == 2, "clusters out of order\n");
1422 ok(logclust[3] == 3, "clusters out of order\n");
1423 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1424 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1425 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1426 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1427 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1428 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1429 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1430 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1431 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1432 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1433 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1434 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1435 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1436 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1437 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1438 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1439
1440 /* modify LTR to RTL */
1441 items[0].a.fRTL = 1;
1442 memset(glyphs2,-1,sizeof(glyphs2));
1443 memset(logclust,-1,sizeof(logclust));
1444 memset(attrs,-1,sizeof(attrs));
1445 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1446 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1447 ok(nb == 4, "Wrong number of items\n");
1448 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1449 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1450 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1451 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1452 ok(logclust[0] == 3, "clusters out of order\n");
1453 ok(logclust[1] == 2, "clusters out of order\n");
1454 ok(logclust[2] == 1, "clusters out of order\n");
1455 ok(logclust[3] == 0, "clusters out of order\n");
1456 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1457 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1458 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1459 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1460 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1461 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1462 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1463 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1464 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1465 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1466 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1467 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1468 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1469 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1470 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1471 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1472
1473 ScriptFreeCache(&sc);
1474
1475 /* some control characters are shown as blank */
1476 for (i = 0; i < 2; i++)
1477 {
1478 static const WCHAR space[] = {' ', 0};
1479 static const WCHAR blanks[] = {'\t', '\r', '\n', 0x001C, 0x001D, 0x001E, 0x001F,0};
1480 HFONT font, oldfont = NULL;
1481 LOGFONTA lf;
1482
1483 font = GetCurrentObject(hdc, OBJ_FONT);
1484 GetObjectA(font, sizeof(lf), &lf);
1485 if (i == 1) {
1486 lstrcpyA(lf.lfFaceName, "MS Sans Serif");
1487 font = CreateFontIndirectA(&lf);
1488 oldfont = SelectObject(hdc, font);
1489 }
1490
1491 hr = ScriptItemize(space, 1, 2, NULL, NULL, items, NULL);
1492 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1493
1494 hr = ScriptShape(hdc, &sc, space, 1, 1, &items[0].a, glyphs, logclust, attrs, &nb);
1495 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1496 ok(nb == 1, "%s: expected 1, got %d\n", lf.lfFaceName, nb);
1497
1498 for (j = 0; blanks[j]; j++)
1499 {
1500 hr = ScriptItemize(&blanks[j], 1, 2, NULL, NULL, items, NULL);
1501 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1502
1503 hr = ScriptShape(hdc, &sc, &blanks[j], 1, 1, &items[0].a, glyphs2, logclust, attrs, &nb);
1504 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1505 ok(nb == 1, "%s: [%02x] expected 1, got %d\n", lf.lfFaceName, blanks[j], nb);
1506
1507 ok(glyphs[0] == glyphs2[0] ||
1508 broken(glyphs2[0] == blanks[j] && (blanks[j] < 0x10)),
1509 "%s: [%02x] expected %04x, got %04x\n", lf.lfFaceName, blanks[j], glyphs[0], glyphs2[0]);
1510 }
1511 if (oldfont)
1512 DeleteObject(SelectObject(hdc, oldfont));
1513 ScriptFreeCache(&sc);
1514 }
1515 }
1516
1517 static void test_ScriptPlace(HDC hdc)
1518 {
1519 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1520 BOOL ret;
1521 HRESULT hr;
1522 SCRIPT_CACHE sc = NULL;
1523 WORD glyphs[4], logclust[4];
1524 SCRIPT_VISATTR attrs[4];
1525 SCRIPT_ITEM items[2];
1526 int nb, widths[4];
1527 GOFFSET offset[4];
1528 ABC abc[4];
1529
1530 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1531 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1532 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1533
1534 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1535 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1536 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1537
1538 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1539 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1540
1541 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1542 ok(broken(hr == E_PENDING) ||
1543 hr == E_INVALIDARG || /* Vista, W2K8 */
1544 hr == E_FAIL, /* WIN7 */
1545 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1546
1547 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1548 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1549
1550 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1551 ok(broken(hr == E_PENDING) ||
1552 hr == E_INVALIDARG || /* Vista, W2K8 */
1553 hr == E_FAIL, /* WIN7 */
1554 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1555
1556 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1557 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1558 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1559
1560 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1561 ok(ret, "ExtTextOutW should return TRUE\n");
1562
1563 ScriptFreeCache(&sc);
1564 }
1565
1566 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1567 {
1568 HRESULT hr;
1569 int iMaxProps;
1570 const SCRIPT_PROPERTIES **ppSp;
1571
1572 int cInChars;
1573 int cMaxItems;
1574 SCRIPT_ITEM pItem[255];
1575 int pcItems;
1576 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1577 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1578 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1579 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1580 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1581 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1582
1583 SCRIPT_CACHE psc;
1584 int cChars;
1585 int cMaxGlyphs;
1586 unsigned short pwOutGlyphs1[256];
1587 unsigned short pwOutGlyphs2[256];
1588 unsigned short pwLogClust[256];
1589 SCRIPT_VISATTR psva[256];
1590 int pcGlyphs;
1591 int piAdvance[256];
1592 GOFFSET pGoffset[256];
1593 ABC pABC[256];
1594 int cnt;
1595
1596 /* Start testing usp10 functions */
1597 /* This test determines that the pointer returned by ScriptGetProperties is valid
1598 * by checking a known value in the table */
1599 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1600 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1601 trace("number of script properties %d\n", iMaxProps);
1602 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1603 if (iMaxProps > 0)
1604 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1605 /* ptrs work */
1606
1607 /* This is a valid test that will cause parsing to take place */
1608 cInChars = 5;
1609 cMaxItems = 255;
1610 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1611 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1612 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1613 * returned. */
1614 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1615 if (pcItems > 0)
1616 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1617 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1618 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1619
1620 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1621 * ie. ScriptItemize has succeeded and that pItem has been set */
1622 cInChars = 5;
1623 if (hr == S_OK) {
1624 psc = NULL; /* must be null on first call */
1625 cChars = cInChars;
1626 cMaxGlyphs = cInChars;
1627 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1628 cMaxGlyphs, &pItem[0].a,
1629 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1630 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1631 cMaxGlyphs = 4;
1632 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1633 cMaxGlyphs, &pItem[0].a,
1634 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1635 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1636 "(%d) but not E_OUTOFMEMORY\n",
1637 cChars, cMaxGlyphs);
1638 cMaxGlyphs = 256;
1639 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1640 cMaxGlyphs, &pItem[0].a,
1641 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1642 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1643 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1644 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1645 if (hr ==0) {
1646 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1647 pGoffset, pABC);
1648 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1649 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1650 pGoffset, pABC);
1651 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1652 for (cnt=0; cnt < pcGlyphs; cnt++)
1653 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1654 }
1655
1656 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1657 * takes place if fNoGlyphIndex is set. */
1658
1659 cInChars = 5;
1660 cMaxItems = 255;
1661 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1662 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1663 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1664 * returned. */
1665 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1666 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1667 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1668 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1669 if (hr == S_OK) {
1670 cChars = cInChars;
1671 cMaxGlyphs = 256;
1672 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1673 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1674 cMaxGlyphs, &pItem[0].a,
1675 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1676 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1677 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1678 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1679 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1680 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1681 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1682 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1683 if (hr == S_OK) {
1684 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1685 pGoffset, pABC);
1686 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1687 }
1688 }
1689 ScriptFreeCache( &psc);
1690 ok (!psc, "psc is not null after ScriptFreeCache\n");
1691
1692 }
1693
1694 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1695 cInChars = (sizeof(TestItem3)/2)-1;
1696 cMaxItems = 255;
1697 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1698 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1699 if (hr == S_OK)
1700 {
1701 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1702 if (pcItems > 2)
1703 {
1704 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1705 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1706 pItem[0].iCharPos, pItem[1].iCharPos);
1707 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1708 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1709 pItem[1].iCharPos, pItem[2].iCharPos);
1710 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1711 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1712 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1713 }
1714 }
1715
1716 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1717 cInChars = (sizeof(TestItem4)/2)-1;
1718 cMaxItems = 255;
1719 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1720 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1721 if (hr == S_OK)
1722 {
1723 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1724 if (pcItems > 4)
1725 {
1726 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1727 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1728 pItem[0].iCharPos, pItem[1].iCharPos);
1729 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1730 pItem[0].a.s.uBidiLevel);
1731 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1732 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1733 pItem[1].iCharPos, pItem[2].iCharPos);
1734 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1735 pItem[1].a.s.uBidiLevel);
1736 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1737 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1738 pItem[2].iCharPos, pItem[3].iCharPos);
1739 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1740 pItem[2].a.s.uBidiLevel);
1741 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1742 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1743 pItem[3].iCharPos, pItem[4].iCharPos);
1744 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1745 pItem[3].a.s.uBidiLevel);
1746 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1747 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1748 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1749 }
1750 }
1751
1752 /*
1753 * This test is for when the first unicode character requires bidi support
1754 */
1755 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1756 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1757 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1758 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1759 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1760 pItem[0].a.s.uBidiLevel);
1761
1762 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1763 * the pointer to the last char works. Note that windows often needs a greater number of *
1764 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1765 cInChars = (sizeof(TestItem6)/2)-1;
1766 cMaxItems = 4;
1767 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1768 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1769
1770 }
1771
1772 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1773 {
1774 HRESULT hr;
1775 SCRIPT_CACHE psc = NULL;
1776 int cInChars;
1777 int cChars;
1778 unsigned short pwOutGlyphs2[256];
1779 unsigned short pwOutGlyphs3[256];
1780 DWORD dwFlags;
1781 int cnt;
1782
1783 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1784 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1785 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1786 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1787
1788 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1789 dwFlags = 0;
1790 cInChars = cChars = 5;
1791 /* Some sanity checks for ScriptGetCMap */
1792
1793 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1794 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
1795 "expected E_INVALIDARG, got %08x\n", hr);
1796
1797 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1798 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1799 "expected E_INVALIDARG, got %08x\n", hr);
1800
1801 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1802 psc = NULL;
1803 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1804 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1805 "got %08x\n", hr);
1806 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1807
1808 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1809 psc = NULL;
1810 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1811 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1812 "got %08x\n", hr);
1813 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
1814 ScriptFreeCache( &psc);
1815
1816 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1817 psc = NULL;
1818 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1819 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
1820 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1821 /* Check to see if the results are the same as those returned by ScriptShape */
1822 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1823 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1824 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1825 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
1826 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
1827 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
1828
1829 ScriptFreeCache( &psc);
1830 ok (!psc, "psc is not null after ScriptFreeCache\n");
1831
1832 /* ScriptGetCMap returns whatever font defines, no special treatment for control chars */
1833 cInChars = cChars = 4;
1834 GetGlyphIndicesW(hdc, TestItem2, cInChars, pwOutGlyphs2, 0);
1835
1836 hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
1837 if (pwOutGlyphs3[0] == 0 || pwOutGlyphs3[3] == 0)
1838 ok(hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
1839 else
1840 ok(hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1841
1842 ok(psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1843 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "expected glyph %d, got %d\n", pwOutGlyphs2[0], pwOutGlyphs3[0]);
1844 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "expected glyph %d, got %d\n", pwOutGlyphs2[3], pwOutGlyphs3[3]);
1845
1846 cInChars = cChars = 9;
1847 hr = ScriptGetCMap(hdc, &psc, TestItem3b, cInChars, dwFlags, pwOutGlyphs2);
1848 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1849 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1850
1851 cInChars = cChars = 9;
1852 dwFlags = SGCM_RTL;
1853 hr = ScriptGetCMap(hdc, &psc, TestItem3, cInChars, dwFlags, pwOutGlyphs3);
1854 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1855 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1856 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "glyph incorrectly altered\n");
1857 ok(pwOutGlyphs3[1] == pwOutGlyphs2[1], "glyph incorrectly altered\n");
1858 ok(pwOutGlyphs3[2] == pwOutGlyphs2[2], "glyph incorrectly altered\n");
1859 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "glyph incorrectly altered\n");
1860 ok(pwOutGlyphs3[4] == pwOutGlyphs2[4], "glyph not mirrored correctly\n");
1861 ok(pwOutGlyphs3[5] == pwOutGlyphs2[5], "glyph not mirrored correctly\n");
1862 ok(pwOutGlyphs3[6] == pwOutGlyphs2[6], "glyph not mirrored correctly\n");
1863 ok(pwOutGlyphs3[7] == pwOutGlyphs2[7], "glyph not mirrored correctly\n");
1864 ok(pwOutGlyphs3[8] == pwOutGlyphs2[8], "glyph not mirrored correctly\n");
1865
1866 ScriptFreeCache( &psc);
1867 ok (!psc, "psc is not null after ScriptFreeCache\n");
1868 }
1869
1870 #define MAX_ENUM_FONTS 4096
1871
1872 struct enum_font_data
1873 {
1874 int total;
1875 ENUMLOGFONTA elf[MAX_ENUM_FONTS];
1876 };
1877
1878 static INT CALLBACK enum_bitmap_font_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
1879 {
1880 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
1881
1882 if (type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE)) return 1;
1883
1884 if (efnd->total < MAX_ENUM_FONTS)
1885 {
1886 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
1887 }
1888 else
1889 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
1890
1891 return 1;
1892 }
1893
1894 static INT CALLBACK enum_truetype_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
1895 {
1896 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
1897
1898 if (!(type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE))) return 1;
1899
1900 if (efnd->total < MAX_ENUM_FONTS)
1901 {
1902 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
1903 }
1904 else
1905 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
1906
1907 return 1;
1908 }
1909
1910 static void test_ScriptGetFontProperties(HDC hdc)
1911 {
1912 HRESULT hr;
1913 SCRIPT_CACHE psc,old_psc;
1914 SCRIPT_FONTPROPERTIES sfp;
1915 HFONT font, oldfont;
1916 LOGFONTA lf;
1917 struct enum_font_data efnd;
1918 TEXTMETRICA tmA;
1919 WORD gi[3];
1920 WCHAR str[3];
1921 DWORD i, ret;
1922 WORD system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
1923 static const WCHAR invalids[] = {0x0020, 0x200B, 0xF71B};
1924 /* U+0020: numeric space
1925 U+200B: zero width space
1926 U+F71B: unknown, found by black box testing */
1927 BOOL is_arial, is_times_new_roman, is_arabic = (system_lang_id == LANG_ARABIC);
1928
1929 /* Some sanity checks for ScriptGetFontProperties */
1930
1931 hr = ScriptGetFontProperties(NULL,NULL,NULL);
1932 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1933
1934 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
1935 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1936
1937 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1938 psc = NULL;
1939 hr = ScriptGetFontProperties(NULL,&psc,NULL);
1940 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1941 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1942
1943 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1944 psc = NULL;
1945 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1946 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
1947 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1948
1949 hr = ScriptGetFontProperties(hdc,NULL,NULL);
1950 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1951
1952 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
1953 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1954
1955 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1956 psc = NULL;
1957 hr = ScriptGetFontProperties(hdc,&psc,NULL);
1958 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1959 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1960
1961 /* Pass an invalid sfp */
1962 psc = NULL;
1963 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES) - 1;
1964 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1965 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr);
1966 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1967 ScriptFreeCache(&psc);
1968 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1969
1970 /* Give it the correct cBytes, we don't care about what's coming back */
1971 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
1972 psc = NULL;
1973 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1974 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
1975 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1976
1977 /* Save the psc pointer */
1978 old_psc = psc;
1979 /* Now a NULL hdc again */
1980 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1981 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
1982 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
1983 ScriptFreeCache(&psc);
1984 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1985
1986 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
1987 if (!pGetGlyphIndicesW)
1988 {
1989 win_skip("Skip on WINNT4\n");
1990 return;
1991 }
1992 memset(&lf, 0, sizeof(lf));
1993 lf.lfCharSet = DEFAULT_CHARSET;
1994 efnd.total = 0;
1995 EnumFontFamiliesA(hdc, NULL, enum_bitmap_font_proc, (LPARAM)&efnd);
1996
1997 for (i = 0; i < efnd.total; i++)
1998 {
1999 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2000 {
2001 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2002 continue;
2003 }
2004 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2005 font = CreateFontIndirectA(&lf);
2006 oldfont = SelectObject(hdc, font);
2007
2008 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2009 psc = NULL;
2010 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2011 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2012 if (winetest_interactive)
2013 {
2014 trace("bitmap font %s\n", lf.lfFaceName);
2015 trace("wgBlank %04x\n", sfp.wgBlank);
2016 trace("wgDefault %04x\n", sfp.wgDefault);
2017 trace("wgInvalid %04x\n", sfp.wgInvalid);
2018 trace("wgKashida %04x\n", sfp.wgKashida);
2019 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2020 }
2021
2022 ret = GetTextMetricsA(hdc, &tmA);
2023 ok(ret != 0, "GetTextMetricsA failed!\n");
2024
2025 ret = pGetGlyphIndicesW(hdc, invalids, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2026 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2027
2028 ok(sfp.wgBlank == tmA.tmBreakChar || sfp.wgBlank == gi[0], "bitmap font %s wgBlank %04x tmBreakChar %04x Space %04x\n", lf.lfFaceName, sfp.wgBlank, tmA.tmBreakChar, gi[0]);
2029
2030 ok(sfp.wgDefault == 0 || sfp.wgDefault == tmA.tmDefaultChar || broken(sfp.wgDefault == (0x100 | tmA.tmDefaultChar)), "bitmap font %s wgDefault %04x, tmDefaultChar %04x\n", lf.lfFaceName, sfp.wgDefault, tmA.tmDefaultChar);
2031
2032 ok(sfp.wgInvalid == sfp.wgBlank || broken(is_arabic), "bitmap font %s wgInvalid %02x wgBlank %02x\n", lf.lfFaceName, sfp.wgInvalid, sfp.wgBlank);
2033
2034 ok(sfp.wgKashida == 0xFFFF || broken(is_arabic), "bitmap font %s wgKashida %02x\n", lf.lfFaceName, sfp.wgKashida);
2035
2036 ScriptFreeCache(&psc);
2037
2038 SelectObject(hdc, oldfont);
2039 DeleteObject(font);
2040 }
2041
2042 efnd.total = 0;
2043 EnumFontFamiliesA(hdc, NULL, enum_truetype_proc, (LPARAM)&efnd);
2044
2045 for (i = 0; i < efnd.total; i++)
2046 {
2047 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2048 {
2049 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2050 continue;
2051 }
2052 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2053 font = CreateFontIndirectA(&lf);
2054 oldfont = SelectObject(hdc, font);
2055
2056 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2057 psc = NULL;
2058 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2059 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2060 if (winetest_interactive)
2061 {
2062 trace("truetype font %s\n", lf.lfFaceName);
2063 trace("wgBlank %04x\n", sfp.wgBlank);
2064 trace("wgDefault %04x\n", sfp.wgDefault);
2065 trace("wgInvalid %04x\n", sfp.wgInvalid);
2066 trace("wgKashida %04x\n", sfp.wgKashida);
2067 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2068 }
2069
2070 str[0] = 0x0020; /* U+0020: numeric space */
2071 ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
2072 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2073 ok(sfp.wgBlank == gi[0], "truetype font %s wgBlank %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgBlank, gi[0]);
2074
2075 ok(sfp.wgDefault == 0 || broken(is_arabic), "truetype font %s wgDefault %04x\n", lf.lfFaceName, sfp.wgDefault);
2076
2077 ret = pGetGlyphIndicesW(hdc, invalids, 3, gi, GGI_MARK_NONEXISTING_GLYPHS);
2078 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2079 if (gi[2] != 0xFFFF) /* index of default non exist char */
2080 ok(sfp.wgInvalid == gi[2], "truetype font %s wgInvalid %04x gi[2] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[2]);
2081 else if (gi[1] != 0xFFFF)
2082 ok(sfp.wgInvalid == gi[1], "truetype font %s wgInvalid %04x gi[1] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[1]);
2083 else if (gi[0] != 0xFFFF)
2084 ok(sfp.wgInvalid == gi[0], "truetype font %s wgInvalid %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[0]);
2085 else
2086 ok(sfp.wgInvalid == 0, "truetype font %s wgInvalid %04x expect 0\n", lf.lfFaceName, sfp.wgInvalid);
2087
2088 str[0] = 0x0640; /* U+0640: kashida */
2089 ret = pGetGlyphIndicesW(hdc, str, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2090 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2091 is_arial = !lstrcmpA(lf.lfFaceName, "Arial");
2092 is_times_new_roman= !lstrcmpA(lf.lfFaceName, "Times New Roman");
2093 ok(sfp.wgKashida == gi[0] || broken(is_arial || is_times_new_roman) || broken(is_arabic), "truetype font %s wgKashida %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgKashida, gi[0]);
2094
2095 ScriptFreeCache(&psc);
2096
2097 SelectObject(hdc, oldfont);
2098 DeleteObject(font);
2099 }
2100 }
2101
2102 static void test_ScriptTextOut(HDC hdc)
2103 {
2104 HRESULT hr;
2105
2106 int cInChars;
2107 int cMaxItems;
2108 SCRIPT_ITEM pItem[255];
2109 int pcItems;
2110 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2111
2112 SCRIPT_CACHE psc;
2113 int cChars;
2114 int cMaxGlyphs;
2115 unsigned short pwOutGlyphs1[256];
2116 WORD pwLogClust[256];
2117 SCRIPT_VISATTR psva[256];
2118 int pcGlyphs;
2119 int piAdvance[256];
2120 GOFFSET pGoffset[256];
2121 ABC pABC[256];
2122 RECT rect;
2123 int piX;
2124 int iCP = 1;
2125 BOOL fTrailing = FALSE;
2126 SCRIPT_LOGATTR *psla;
2127 SCRIPT_LOGATTR sla[256];
2128
2129 /* This is a valid test that will cause parsing to take place */
2130 cInChars = 5;
2131 cMaxItems = 255;
2132 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2133 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2134 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2135 * returned. */
2136 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2137 if (pcItems > 0)
2138 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2139 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2140 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2141
2142 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2143 * ie. ScriptItemize has succeeded and that pItem has been set */
2144 cInChars = 5;
2145 if (hr == S_OK) {
2146 psc = NULL; /* must be null on first call */
2147 cChars = cInChars;
2148 cMaxGlyphs = 256;
2149 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2150 cMaxGlyphs, &pItem[0].a,
2151 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2152 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2153 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2154 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2155 if (hr == S_OK) {
2156 /* Note hdc is needed as glyph info is not yet in psc */
2157 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2158 pGoffset, pABC);
2159 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2160 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
2161 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2162
2163 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
2164 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
2165
2166 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2167 piAdvance, NULL, pGoffset);
2168 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
2169 "expected E_INVALIDARG, got %08x\n", hr);
2170
2171 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2172 psc = NULL;
2173 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
2174 NULL, NULL, NULL);
2175 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
2176 "got %08x\n", hr);
2177 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2178
2179 /* hdc is required for this one rather than the usual optional */
2180 psc = NULL;
2181 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2182 piAdvance, NULL, pGoffset);
2183 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
2184 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2185
2186 /* Set that it returns 0 status */
2187 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2188 piAdvance, NULL, pGoffset);
2189 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2190
2191 /* Test Rect Rgn is acceptable */
2192 rect.top = 10;
2193 rect.bottom = 20;
2194 rect.left = 10;
2195 rect.right = 40;
2196 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2197 piAdvance, NULL, pGoffset);
2198 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2199
2200 iCP = 1;
2201 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
2202 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
2203 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
2204
2205 psla = (SCRIPT_LOGATTR *)&sla;
2206 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
2207 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
2208
2209 /* Clean up and go */
2210 ScriptFreeCache(&psc);
2211 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2212 }
2213 }
2214 }
2215
2216 static void test_ScriptTextOut2(HDC hdc)
2217 {
2218 /* Intent is to validate that the HDC passed into ScriptTextOut is
2219 * used instead of the (possibly) invalid cached one
2220 */
2221 HRESULT hr;
2222
2223 HDC hdc1, hdc2;
2224 int cInChars;
2225 int cMaxItems;
2226 SCRIPT_ITEM pItem[255];
2227 int pcItems;
2228 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2229
2230 SCRIPT_CACHE psc;
2231 int cChars;
2232 int cMaxGlyphs;
2233 unsigned short pwOutGlyphs1[256];
2234 WORD pwLogClust[256];
2235 SCRIPT_VISATTR psva[256];
2236 int pcGlyphs;
2237 int piAdvance[256];
2238 GOFFSET pGoffset[256];
2239 ABC pABC[256];
2240
2241 /* Create an extra DC that will be used until the ScriptTextOut */
2242 hdc1 = CreateCompatibleDC(hdc);
2243 ok (hdc1 != 0, "CreateCompatibleDC failed to create a DC\n");
2244 hdc2 = CreateCompatibleDC(hdc);
2245 ok (hdc2 != 0, "CreateCompatibleDC failed to create a DC\n");
2246
2247 /* This is a valid test that will cause parsing to take place */
2248 cInChars = 5;
2249 cMaxItems = 255;
2250 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2251 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2252 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2253 * returned. */
2254 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2255 if (pcItems > 0)
2256 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2257 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2258 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2259
2260 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2261 * ie. ScriptItemize has succeeded and that pItem has been set */
2262 cInChars = 5;
2263 if (hr == S_OK) {
2264 psc = NULL; /* must be null on first call */
2265 cChars = cInChars;
2266 cMaxGlyphs = 256;
2267 hr = ScriptShape(hdc2, &psc, TestItem1, cChars,
2268 cMaxGlyphs, &pItem[0].a,
2269 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2270 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2271 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2272 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2273 if (hr == S_OK) {
2274 BOOL ret;
2275
2276 /* Note hdc is needed as glyph info is not yet in psc */
2277 hr = ScriptPlace(hdc2, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2278 pGoffset, pABC);
2279 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2280
2281 /* key part!!! cached dc is being deleted */
2282 ret = DeleteDC(hdc2);
2283 ok(ret, "DeleteDC should return 1 not %d\n", ret);
2284
2285 /* At this point the cached hdc (hdc2) has been destroyed,
2286 * however, we are passing in a *real* hdc (the original hdc).
2287 * The text should be written to that DC
2288 */
2289 hr = ScriptTextOut(hdc1, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2290 piAdvance, NULL, pGoffset);
2291 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2292 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2293
2294 DeleteDC(hdc1);
2295
2296 /* Clean up and go */
2297 ScriptFreeCache(&psc);
2298 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2299 }
2300 }
2301 }
2302
2303 static void test_ScriptTextOut3(HDC hdc)
2304 {
2305 HRESULT hr;
2306
2307 int cInChars;
2308 int cMaxItems;
2309 SCRIPT_ITEM pItem[255];
2310 int pcItems;
2311 WCHAR TestItem1[] = {' ','\r', 0};
2312
2313 SCRIPT_CACHE psc;
2314 int cChars;
2315 int cMaxGlyphs;
2316 unsigned short pwOutGlyphs1[256];
2317 WORD pwLogClust[256];
2318 SCRIPT_VISATTR psva[256];
2319 int pcGlyphs;
2320 int piAdvance[256];
2321 GOFFSET pGoffset[256];
2322 ABC pABC[256];
2323 RECT rect;
2324
2325 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
2326 cInChars = 2;
2327 cMaxItems = 255;
2328 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2329 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2330 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2331 * returned. */
2332 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2333 if (pcItems > 0)
2334 ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
2335 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2336 pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
2337
2338 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2339 * ie. ScriptItemize has succeeded and that pItem has been set */
2340 cInChars = 2;
2341 if (hr == S_OK) {
2342 psc = NULL; /* must be null on first call */
2343 cChars = cInChars;
2344 cMaxGlyphs = 256;
2345 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2346 cMaxGlyphs, &pItem[0].a,
2347 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2348 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2349 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2350 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2351 if (hr ==0) {
2352 /* Note hdc is needed as glyph info is not yet in psc */
2353 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2354 pGoffset, pABC);
2355 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2356
2357 /* Test Rect Rgn is acceptable */
2358 rect.top = 10;
2359 rect.bottom = 20;
2360 rect.left = 10;
2361 rect.right = 40;
2362 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2363 piAdvance, NULL, pGoffset);
2364 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2365 }
2366 /* Clean up and go */
2367 ScriptFreeCache(&psc);
2368 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2369 }
2370 }
2371
2372 #define test_item_ScriptXtoX(a,b,c,d,e,f) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_item_ScriptXtoX(a,b,c,d,e,f)
2373
2374 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2375 {
2376 int iX, iCP;
2377 int icChars, icGlyphs;
2378 int piCP, piX;
2379 HRESULT hr;
2380 SCRIPT_VISATTR psva[10];
2381 int piTrailing;
2382 BOOL fTrailing;
2383 int direction;
2384
2385 memset(psva,0,sizeof(psva));
2386 direction = (psa->fRTL)?-1:+1;
2387
2388 for(iCP = 0; iCP < cChars; iCP++)
2389 {
2390 iX = offsets[iCP];
2391 icChars = cChars;
2392 icGlyphs = cGlyphs;
2393 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2394 winetest_ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2395 winetest_ok(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2396 winetest_ok(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2397 }
2398
2399 for(iCP = 0; iCP < cChars; iCP++)
2400 {
2401 iX = offsets[iCP]+direction;
2402 icChars = cChars;
2403 icGlyphs = cGlyphs;
2404 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2405 winetest_ok(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2406 winetest_ok(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2407 winetest_ok(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2408 }
2409
2410 for(iCP = 0; iCP < cChars; iCP++)
2411 {
2412 iX = offsets[iCP+1]-direction;
2413 icChars = cChars;
2414 icGlyphs = cGlyphs;
2415 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2416 winetest_ok(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2417 winetest_ok(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2418 winetest_ok(piTrailing == 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2419 }
2420
2421 for(iCP = 0; iCP <= cChars+1; iCP++)
2422 {
2423 fTrailing = FALSE;
2424 icChars = cChars;
2425 icGlyphs = cGlyphs;
2426 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2427 winetest_ok(hr == S_OK, "ScriptCPtoX: should return S_OK not %08x\n", hr);
2428 winetest_ok(piX == offsets[iCP],
2429 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP], piX);
2430 }
2431
2432 for(iCP = 0; iCP <= cChars+1; iCP++)
2433 {
2434 fTrailing = TRUE;
2435 icChars = cChars;
2436 icGlyphs = cGlyphs;
2437 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2438 winetest_ok(hr == S_OK, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr);
2439 winetest_ok(piX == offsets[iCP+1],
2440 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP+1], piX);
2441 }
2442 }
2443
2444 static void test_ScriptXtoX(void)
2445 /****************************************************************************************
2446 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2447 ****************************************************************************************/
2448 {
2449 WORD pwLogClust[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2450 WORD pwLogClust_RTL[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2451 WORD pwLogClust_2[7] = {4, 3, 3, 2, 1, 0 ,0};
2452 int piAdvance[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2453 int piAdvance_2[5] = {39, 26, 19, 17, 11};
2454 static const int offsets[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2455 static const int offsets_RTL[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2456 static const int offsets_2[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2457 SCRIPT_VISATTR psva[10];
2458 SCRIPT_ANALYSIS sa;
2459 int iX;
2460 int piCP;
2461 int piTrailing;
2462 HRESULT hr;
2463
2464 memset(&sa, 0 , sizeof(SCRIPT_ANALYSIS));
2465 memset(psva, 0, sizeof(psva));
2466
2467 sa.fRTL = FALSE;
2468 hr = ScriptXtoCP(-1, 10, 10, pwLogClust, psva, piAdvance, &sa, &piCP, &piTrailing);
2469 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2470 if (piTrailing)
2471 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2472 else /* win2k3 */
2473 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2474
2475 for (iX = 0; iX <= 7; iX++)
2476 {
2477 WORD clust = 0;
2478 INT advance = 16;
2479 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2480 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing);
2481 }
2482 for (iX = 8; iX < 16; iX++)
2483 {
2484 WORD clust = 0;
2485 INT advance = 16;
2486 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2487 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing);
2488 }
2489
2490 sa.fRTL = TRUE;
2491 hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2492 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2493 if (piTrailing)
2494 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2495 else /* win2k3 */
2496 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2497
2498 iX = 1954;
2499 hr = ScriptXtoCP(1954, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2500 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2501 ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP);
2502 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2503
2504 for (iX = 1; iX <= 8; iX++)
2505 {
2506 WORD clust = 0;
2507 INT advance = 16;
2508 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2509 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing);
2510 }
2511 for (iX = 9; iX < 16; iX++)
2512 {
2513 WORD clust = 0;
2514 INT advance = 16;
2515 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2516 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing);
2517 }
2518
2519 sa.fRTL = FALSE;
2520 test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance);
2521 sa.fRTL = TRUE;
2522 test_item_ScriptXtoX(&sa, 10, 10, offsets_RTL, pwLogClust_RTL, piAdvance);
2523 test_item_ScriptXtoX(&sa, 7, 5, offsets_2, pwLogClust_2, piAdvance_2);
2524 }
2525
2526 static void test_ScriptString(HDC hdc)
2527 {
2528 /*******************************************************************************************
2529 *
2530 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2531 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2532 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2533 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2534 *
2535 */
2536
2537 HRESULT hr;
2538 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2539 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
2540 int Glyphs = len * 2 + 16;
2541 int Charset;
2542 DWORD Flags = SSA_GLYPHS;
2543 int ReqWidth = 100;
2544 const int Dx[5] = {10, 10, 10, 10, 10};
2545 const BYTE InClass = 0;
2546 SCRIPT_STRING_ANALYSIS ssa = NULL;
2547
2548 int X = 10;
2549 int Y = 100;
2550 UINT Options = 0;
2551 const RECT rc = {0, 50, 100, 100};
2552 int MinSel = 0;
2553 int MaxSel = 0;
2554 BOOL Disabled = FALSE;
2555 const int *clip_len;
2556 int i;
2557 UINT *order;
2558
2559
2560 Charset = -1; /* this flag indicates unicode input */
2561 /* Test without hdc to get E_PENDING */
2562 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
2563 ReqWidth, NULL, NULL, Dx, NULL,
2564 &InClass, &ssa);
2565 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
2566
2567 /* Test that 0 length string returns E_INVALIDARG */
2568 hr = ScriptStringAnalyse( hdc, teststr, 0, Glyphs, Charset, Flags,
2569 ReqWidth, NULL, NULL, Dx, NULL,
2570 &InClass, &ssa);
2571 ok(hr == E_INVALIDARG, "ScriptStringAnalyse should return E_INVALIDARG not %08x\n", hr);
2572
2573 /* test with hdc, this should be a valid test */
2574 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2575 ReqWidth, NULL, NULL, Dx, NULL,
2576 &InClass, &ssa);
2577 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2578 ScriptStringFree(&ssa);
2579
2580 /* test makes sure that a call with a valid pssa still works */
2581 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2582 ReqWidth, NULL, NULL, Dx, NULL,
2583 &InClass, &ssa);
2584 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2585 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
2586
2587 if (hr == S_OK)
2588 {
2589 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
2590 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
2591 }
2592
2593 clip_len = ScriptString_pcOutChars(ssa);
2594 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
2595
2596 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
2597 hr = ScriptStringGetOrder(ssa, order);
2598 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
2599
2600 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
2601 HeapFree(GetProcessHeap(), 0, order);
2602
2603 hr = ScriptStringFree(&ssa);
2604 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2605 }
2606
2607 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
2608 {
2609 /*****************************************************************************************
2610 *
2611 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2612 * nature of the fonts between Windows and Wine, the test is implemented by generating
2613 * values using one one function then checking the output of the second. In this way
2614 * the validity of the functions is established using Windows as a base and confirming
2615 * similar behaviour in wine.
2616 */
2617
2618 HRESULT hr;
2619 static const WCHAR teststr1[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2620 static const BOOL rtl[] = {1, 0, 1, 0, 1, 0, 1, 0};
2621 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
2622 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
2623 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
2624 int Charset = -1; /* unicode */
2625 DWORD Flags = SSA_GLYPHS;
2626 int ReqWidth = 100;
2627 const BYTE InClass = 0;
2628 SCRIPT_STRING_ANALYSIS ssa = NULL;
2629
2630 int Ch; /* Character position in string */
2631 int iTrailing;
2632 int Cp; /* Character position in string */
2633 int X;
2634 int trail,lead;
2635 BOOL fTrailing;
2636
2637 /* Test with hdc, this should be a valid test
2638 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2639 * following character positions to X and X to character position functions.
2640 */
2641
2642 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2643 ReqWidth, NULL, NULL, NULL, NULL,
2644 &InClass, &ssa);
2645 ok(hr == S_OK ||
2646 hr == E_INVALIDARG, /* NT */
2647 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
2648
2649 if (hr == S_OK)
2650 {
2651 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
2652
2653 /*
2654 * Loop to generate character positions to provide starting positions for the
2655 * ScriptStringCPtoX and ScriptStringXtoCP functions
2656 */
2657 for (Cp = 0; Cp < String_len; Cp++)
2658 {
2659 /* The fTrailing flag is used to indicate whether the X being returned is at
2660 * the beginning or the end of the character. What happens here is that if
2661 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2662 * returns the beginning of the next character and iTrailing is FALSE. So for this
2663 * loop iTrailing will be FALSE in both cases.
2664 */
2665 hr = ScriptStringCPtoX(ssa, Cp, TRUE, &trail);
2666 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2667 hr = ScriptStringCPtoX(ssa, Cp, FALSE, &lead);
2668 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2669 if (rtl[Cp])
2670 ok(lead > trail, "Leading values should be after trailing for rtl characters(%i)\n",Cp);
2671 else
2672 ok(lead < trail, "Trailing values should be after leading for ltr characters(%i)\n",Cp);
2673
2674 /* move by 1 pixel so that we are not between 2 characters. That could result in being the lead of a rtl and
2675 at the same time the trail of an ltr */
2676
2677 /* inside the leading edge */
2678 X = lead;
2679 if (rtl[Cp]) X--; else X++;
2680 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2681 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2682 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2683 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2684 iTrailing, X);
2685
2686 /* inside the trailing edge */
2687 X = trail;
2688 if (rtl[Cp]) X++; else X--;
2689 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2690 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2691 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2692 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2693 iTrailing, X);
2694
2695 /* outside the "trailing" edge */
2696 if (Cp < String_len-1)
2697 {
2698 if (rtl[Cp]) X = lead; else X = trail;
2699 X++;
2700 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2701 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2702 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, trail);
2703 if (rtl[Cp+1])
2704 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2705 iTrailing, X);
2706 else
2707 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2708 iTrailing, X);
2709 }
2710
2711 /* outside the "leading" edge */
2712 if (Cp != 0)
2713 {
2714 if (rtl[Cp]) X = trail; else X = lead;
2715 X--;
2716 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2717 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2718 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, trail);
2719 if (Cp != 0 && rtl[Cp-1])
2720 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2721 iTrailing, X);
2722 else
2723 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2724 iTrailing, X);
2725 }
2726 }
2727
2728 /* Check beyond the leading boundary of the whole string */
2729 if (rtl[0])
2730 {
2731 /* having a leading rtl character seems to confuse usp */
2732 /* this looks to be a windows bug we should emulate */
2733 hr = ScriptStringCPtoX(ssa, 0, TRUE, &X);
2734 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2735 X--;
2736 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2737 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2738 ok(Ch == 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch);
2739 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
2740 iTrailing);
2741 }
2742 else
2743 {
2744 hr = ScriptStringCPtoX(ssa, 0, FALSE, &X);
2745 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2746 X--;
2747 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2748 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2749 ok(Ch == -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch);
2750 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2751 iTrailing);
2752 }
2753
2754 /* Check beyond the end boundary of the whole string */
2755 if (rtl[String_len-1])
2756 {
2757 hr = ScriptStringCPtoX(ssa, String_len-1, FALSE, &X);
2758 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2759 }
2760 else
2761 {
2762 hr = ScriptStringCPtoX(ssa, String_len-1, TRUE, &X);
2763 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2764 }
2765 X++;
2766 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2767 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2768 ok(Ch == String_len, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len, Ch);
2769 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
2770 iTrailing);
2771
2772 /*
2773 * Cleanup the SSA for the next round of tests
2774 */
2775 hr = ScriptStringFree(&ssa);
2776 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2777
2778 /*
2779 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2780 * generate an SSA for the subsequent tests.
2781 */
2782 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2783 ReqWidth, NULL, NULL, NULL, NULL,
2784 &InClass, &ssa);
2785 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2786
2787 /*
2788 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2789 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2790 * ScriptStringFree should also fail.
2791 */
2792 fTrailing = FALSE;
2793 Cp = String_len + 1;
2794 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
2795 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
2796
2797 ScriptStringFree(&ssa);
2798 }
2799 }
2800
2801 static void test_ScriptCacheGetHeight(HDC hdc)
2802 {
2803 HRESULT hr;
2804 SCRIPT_CACHE sc = NULL;
2805 LONG height;
2806
2807 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
2808 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2809
2810 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
2811 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2812
2813 hr = ScriptCacheGetHeight(NULL, &sc, &height);
2814 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2815
2816 height = 0;
2817
2818 hr = ScriptCacheGetHeight(hdc, &sc, &height);
2819 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2820 ok(height > 0, "expected height > 0\n");
2821
2822 ScriptFreeCache(&sc);
2823 }
2824
2825 static void test_ScriptGetGlyphABCWidth(HDC hdc)
2826 {
2827 HRESULT hr;
2828 SCRIPT_CACHE sc = NULL;
2829 ABC abc;
2830
2831 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
2832 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2833
2834 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
2835 ok(broken(hr == E_PENDING) ||
2836 hr == E_INVALIDARG, /* WIN7 */
2837 "expected E_INVALIDARG, got 0x%08x\n", hr);
2838
2839 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', &abc);
2840 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2841
2842 if (0) { /* crashes on WinXP */
2843 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
2844 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2845 }
2846
2847 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
2848 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2849
2850 ScriptFreeCache(&sc);
2851 }
2852
2853 static void test_ScriptLayout(void)
2854 {
2855 HRESULT hr;
2856 static const BYTE levels[][10] =
2857 {
2858 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2859 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2860 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2861 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2862
2863 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2864 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2865 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2866 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2867 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2868
2869 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2870 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2871
2872 { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
2873 { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 },
2874 { 2, 2, 2, 4, 4, 4, 1, 1, 0, 0 },
2875 { 1, 2, 3, 0, 3, 2, 1, 0, 0, 0 }
2876 };
2877 static const int expect_l2v[][10] =
2878 {
2879 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2880 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2881 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2882 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2883
2884 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2885 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2886 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2887 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2888 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2889
2890 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2891 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2892
2893 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
2894 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
2895 { 2, 3, 4, 5, 6, 7, 1, 0, 8, 9},
2896 { 2, 0, 1, 3, 5, 6, 4, 7, 8, 9}
2897 };
2898 static const int expect_v2l[][10] =
2899 {
2900 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2901 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2902 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2903 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2904
2905 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2906 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2907 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2908 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2909 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2910
2911 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2912 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2913
2914 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
2915 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
2916 { 7, 6, 0, 1, 2, 3, 4, 5, 8, 9},
2917 { 1, 2, 0, 3, 6, 4, 5, 7, 8, 9}
2918 };
2919
2920 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
2921
2922 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
2923 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2924
2925 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
2926 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2927
2928 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
2929 {
2930 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
2931 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2932
2933 for (j = 0; j < sizeof(levels[i]); j++)
2934 {
2935 ok(expect_v2l[i][j] == vistolog[j],
2936 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2937 i, j, levels[i][j], j, vistolog[j] );
2938 }
2939
2940 for (j = 0; j < sizeof(levels[i]); j++)
2941 {
2942 ok(expect_l2v[i][j] == logtovis[j],
2943 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2944 i, j, levels[i][j], j, logtovis[j] );
2945 }
2946 }
2947 }
2948
2949 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
2950 {
2951 HRESULT hr;
2952 SCRIPT_DIGITSUBSTITUTE sds;
2953 SCRIPT_CONTROL sc;
2954 SCRIPT_STATE ss;
2955 LCID lcid_old;
2956
2957 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
2958
2959 memset(&sds, 0, sizeof(sds));
2960 memset(&sc, 0, sizeof(sc));
2961 memset(&ss, 0, sizeof(ss));
2962
2963 lcid_old = GetThreadLocale();
2964 if (!SetThreadLocale(lcid)) return TRUE;
2965
2966 hr = ScriptRecordDigitSubstitution(lcid, &sds);
2967 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
2968
2969 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
2970 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
2971
2972 SetThreadLocale(lcid_old);
2973 return TRUE;
2974 }
2975
2976 static void test_digit_substitution(void)
2977 {
2978 BOOL ret;
2979 unsigned int i;
2980 static const LGRPID groups[] =
2981 {
2982 LGRPID_WESTERN_EUROPE,
2983 LGRPID_CENTRAL_EUROPE,
2984 LGRPID_BALTIC,
2985 LGRPID_GREEK,
2986 LGRPID_CYRILLIC,
2987 LGRPID_TURKISH,
2988 LGRPID_JAPANESE,
2989 LGRPID_KOREAN,
2990 LGRPID_TRADITIONAL_CHINESE,
2991 LGRPID_SIMPLIFIED_CHINESE,
2992 LGRPID_THAI,
2993 LGRPID_HEBREW,
2994 LGRPID_ARABIC,
2995 LGRPID_VIETNAMESE,
2996 LGRPID_INDIC,
2997 LGRPID_GEORGIAN,
2998 LGRPID_ARMENIAN
2999 };
3000 HMODULE hKernel32;
3001 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROCA,LGRPID,DWORD,LONG_PTR);
3002
3003 hKernel32 = GetModuleHandleA("kernel32.dll");
3004 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
3005
3006 if (!pEnumLanguageGroupLocalesA)
3007 {
3008 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
3009 return;
3010 }
3011
3012 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
3013 {
3014 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
3015 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
3016 {
3017 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
3018 break;
3019 }
3020
3021 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
3022 }
3023 }
3024
3025 static void test_ScriptGetProperties(void)
3026 {
3027 const SCRIPT_PROPERTIES **props;
3028 HRESULT hr;
3029 int num;
3030
3031 hr = ScriptGetProperties(NULL, NULL);
3032 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
3033
3034 hr = ScriptGetProperties(NULL, &num);
3035 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3036
3037 hr = ScriptGetProperties(&props, NULL);
3038 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3039
3040 hr = ScriptGetProperties(&props, &num);
3041 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3042 }
3043
3044 static void test_ScriptBreak(void)
3045 {
3046 static const WCHAR test[] = {' ','\r','\n',0};
3047 SCRIPT_ITEM items[4];
3048 SCRIPT_LOGATTR la;
3049 HRESULT hr;
3050
3051 hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL);
3052 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
3053
3054 /*
3055 * This Test crashes pre Vista.
3056
3057 hr = ScriptBreak(test, 1, &items[0].a, NULL);
3058 ok(hr == E_INVALIDARG, "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3059 */
3060
3061 hr = ScriptBreak(test, 0, &items[0].a, &la);
3062 ok(hr == E_FAIL || broken(hr == S_OK), "ScriptBreak should return E_FAIL not %08x\n", hr);
3063
3064 hr = ScriptBreak(test, -1, &items[0].a, &la);
3065 ok(hr == E_INVALIDARG || broken(hr == S_OK), "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3066
3067 memset(&la, 0, sizeof(la));
3068 hr = ScriptBreak(test, 1, &items[0].a, &la);
3069 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3070
3071 ok(!la.fSoftBreak, "fSoftBreak set\n");
3072 ok(la.fWhiteSpace, "fWhiteSpace not set\n");
3073 ok(la.fCharStop, "fCharStop not set\n");
3074 ok(!la.fWordStop, "fWordStop set\n");
3075 ok(!la.fInvalid, "fInvalid set\n");
3076 ok(!la.fReserved, "fReserved set\n");
3077
3078 memset(&la, 0, sizeof(la));
3079 hr = ScriptBreak(test + 1, 1, &items[1].a, &la);
3080 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3081
3082 ok(!la.fSoftBreak, "fSoftBreak set\n");
3083 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3084 ok(la.fCharStop, "fCharStop not set\n");
3085 ok(!la.fWordStop, "fWordStop set\n");
3086 ok(!la.fInvalid, "fInvalid set\n");
3087 ok(!la.fReserved, "fReserved set\n");
3088
3089 memset(&la, 0, sizeof(la));
3090 hr = ScriptBreak(test + 2, 1, &items[2].a, &la);
3091 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3092
3093 ok(!la.fSoftBreak, "fSoftBreak set\n");
3094 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3095 ok(la.fCharStop, "fCharStop not set\n");
3096 ok(!la.fWordStop, "fWordStop set\n");
3097 ok(!la.fInvalid, "fInvalid set\n");
3098 ok(!la.fReserved, "fReserved set\n");
3099 }
3100
3101 static void test_newlines(void)
3102 {
3103 static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
3104 static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
3105 static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
3106 static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
3107 static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
3108 SCRIPT_ITEM items[5];
3109 HRESULT hr;
3110 int count;
3111
3112 count = 0;
3113 hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
3114 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3115 ok(count == 3, "got %d expected 3\n", count);
3116
3117 count = 0;
3118 hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
3119 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3120 ok(count == 3, "got %d expected 3\n", count);
3121
3122 count = 0;
3123 hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
3124 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3125 ok(count == 4, "got %d expected 4\n", count);
3126
3127 count = 0;
3128 hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
3129 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3130 ok(count == 4, "got %d expected 4\n", count);
3131
3132 count = 0;
3133 hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
3134 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3135 ok(count == 4, "got %d expected 4\n", count);
3136 }
3137
3138 static void test_ScriptGetFontFunctions(HDC hdc)
3139 {
3140 HRESULT hr;
3141 pScriptGetFontScriptTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontScriptTags");
3142 pScriptGetFontLanguageTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontLanguageTags");
3143 pScriptGetFontFeatureTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontFeatureTags");
3144 if (!pScriptGetFontScriptTags || !pScriptGetFontLanguageTags || !pScriptGetFontFeatureTags)
3145 {
3146 win_skip("ScriptGetFontScriptTags,ScriptGetFontLanguageTags or ScriptGetFontFeatureTags not available on this platform\n");
3147 }
3148 else
3149 {
3150 SCRIPT_CACHE sc = NULL;
3151 OPENTYPE_TAG tags[5];
3152 int count = 0;
3153 int outnItems=0;
3154 SCRIPT_ITEM outpItems[15];
3155 SCRIPT_CONTROL Control;
3156 SCRIPT_STATE State;
3157 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
3158
3159 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, NULL);
3160 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3161 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3162 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, &count);
3163 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3164 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3165 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, NULL);
3166 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3167 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3168 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, tags, &count);
3169 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3170 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3171 hr = pScriptGetFontScriptTags(NULL, &sc, NULL, 5, tags, &count);
3172 ok(hr == E_PENDING,"Incorrect return code\n");
3173 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3174 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, &count);
3175 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3176 if (hr == S_OK)
3177 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3178 else if (hr == E_OUTOFMEMORY)
3179 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3180 ok(sc != NULL, "ScriptCache should be initialized\n");
3181
3182 ScriptFreeCache(&sc);
3183 sc = NULL;
3184
3185 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, NULL);
3186 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3187 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3188 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, &count);
3189 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3190 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3191 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, NULL);
3192 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3193 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3194 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, tags, &count);
3195 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3196 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3197 hr = pScriptGetFontLanguageTags(NULL, &sc, NULL, latn_tag, 5, tags, &count);
3198 ok(hr == E_PENDING,"Incorrect return code\n");
3199 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3200 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, &count);
3201 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3202 if (hr == S_OK)
3203 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3204 else if (hr == E_OUTOFMEMORY)
3205 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3206
3207 ScriptFreeCache(&sc);
3208 sc = NULL;
3209
3210 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, NULL);
3211 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3212 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3213 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, &count);
3214 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3215 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3216 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, NULL);
3217 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3218 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3219 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, tags, &count);
3220 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3221 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3222 hr = pScriptGetFontFeatureTags(NULL, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3223 ok(hr == E_PENDING,"Incorrect return code\n");
3224 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3225 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3226 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3227 if (hr == S_OK)
3228 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3229 else if (hr == E_OUTOFMEMORY)
3230 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3231
3232 memset(&Control, 0, sizeof(Control));
3233 memset(&State, 0, sizeof(State));
3234
3235 hr = ScriptItemize(test_phagspa, 10, 15, &Control, &State, outpItems, &outnItems);
3236 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3237 memset(tags,0,sizeof(tags));
3238 hr = pScriptGetFontScriptTags(hdc, &sc, &outpItems[0].a, 5, tags, &count);
3239 ok( hr == USP_E_SCRIPT_NOT_IN_FONT || broken(hr == S_OK), "wrong return code\n");
3240
3241 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, dsrt_tag, 5, tags, &count);
3242 ok( hr == S_OK, "wrong return code\n");
3243 hr = pScriptGetFontLanguageTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 5, tags, &count);
3244 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3245
3246 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, dsrt_tag, 0x0, 5, tags, &count);
3247 ok( hr == S_OK, "wrong return code\n");
3248 hr = pScriptGetFontFeatureTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 0x0, 5, tags, &count);
3249 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3250
3251 ScriptFreeCache(&sc);
3252 }
3253 }
3254
3255 START_TEST(usp10)
3256 {
3257 HWND hwnd;
3258 HDC hdc;
3259 LOGFONTA lf;
3260 HFONT hfont;
3261
3262 unsigned short pwOutGlyphs[256];
3263
3264 /* We need a valid HDC to drive a lot of Script functions which requires the following *
3265 * to set up for the tests. */
3266 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
3267 0, 0, 0, NULL);
3268 assert(hwnd != 0);
3269 ShowWindow(hwnd, SW_SHOW);
3270 UpdateWindow(hwnd);
3271
3272 hdc = GetDC(hwnd); /* We now have a hdc */
3273 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
3274
3275 memset(&lf, 0, sizeof(LOGFONTA));
3276 lstrcpyA(lf.lfFaceName, "Tahoma");
3277 lf.lfHeight = 10;
3278 lf.lfWeight = 3;
3279 lf.lfWidth = 10;
3280
3281 hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
3282 ok(hfont != NULL, "SelectObject failed: %p\n", hfont);
3283
3284 test_ScriptItemize();
3285 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
3286 test_ScriptGetCMap(hdc, pwOutGlyphs);
3287 test_ScriptCacheGetHeight(hdc);
3288 test_ScriptGetGlyphABCWidth(hdc);
3289 test_ScriptShape(hdc);
3290 test_ScriptShapeOpenType(hdc);
3291 test_ScriptPlace(hdc);
3292
3293 test_ScriptGetFontProperties(hdc);
3294 test_ScriptTextOut(hdc);
3295 test_ScriptTextOut2(hdc);
3296 test_ScriptTextOut3(hdc);
3297 test_ScriptXtoX();
3298 test_ScriptString(hdc);
3299 test_ScriptStringXtoCP_CPtoX(hdc);
3300
3301 test_ScriptLayout();
3302 test_digit_substitution();
3303 test_ScriptGetProperties();
3304 test_ScriptBreak();
3305 test_newlines();
3306
3307 test_ScriptGetFontFunctions(hdc);
3308
3309 ReleaseDC(hwnd, hdc);
3310 DestroyWindow(hwnd);
3311 }