0a99a13af0ca0bc690b49f3b77747f8ec1e2283e
[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[6];
39 int iCharPos;
40 int fRTL;
41 int fLayoutRTL;
42 int uBidiLevel;
43 int fOverrideDirection;
44 ULONG scriptTag;
45 BOOL isBroken;
46 int broken_value[6];
47 } itemTest;
48
49 typedef struct _shapeTest_char {
50 WORD wLogClust;
51 SCRIPT_CHARPROP CharProp;
52 } shapeTest_char;
53
54 typedef struct _shapeTest_glyph {
55 int Glyph;
56 SCRIPT_GLYPHPROP GlyphProp;
57 } shapeTest_glyph;
58
59 /* Uniscribe 1.6 calls */
60 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);
61
62 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);
63
64 static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
65
66 static HRESULT (WINAPI *pScriptGetFontScriptTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags);
67 static HRESULT (WINAPI *pScriptGetFontLanguageTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags);
68 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);
69
70 static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
71 SCRIPT_CONTROL *Control, SCRIPT_STATE *State,
72 DWORD nItems, const itemTest* items, BOOL nItemsToDo,
73 const INT nItemsBroken[2])
74 {
75 HRESULT hr;
76 int x, outnItems;
77 SCRIPT_ITEM outpItems[15];
78 ULONG tags[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
79
80 if (pScriptItemizeOpenType)
81 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
82 else
83 hr = ScriptItemize(string, cchString, 15, Control, State, outpItems, &outnItems);
84
85 winetest_ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
86 if (nItemsBroken && (broken(nItemsBroken[0] == outnItems) || broken(nItemsBroken[1] == outnItems)))
87 {
88 winetest_win_skip("This test broken on this platform\n");
89 return;
90 }
91 todo_wine_if (nItemsToDo)
92 winetest_ok(outnItems == nItems, "Wrong number of items\n");
93 for (x = 0; x <= outnItems; x++)
94 {
95 if (items[x].isBroken && broken(outpItems[x].iCharPos == items[x].broken_value[0]))
96 winetest_win_skip("This test broken on this platform\n");
97 else todo_wine_if (items[x].todo_flag[0])
98 winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos (%i)\n",x,outpItems[x].iCharPos);
99
100 if (items[x].isBroken && broken(outpItems[x].a.fRTL== items[x].broken_value[1]))
101 winetest_win_skip("This test broken on this platform\n");
102 else todo_wine_if (items[x].todo_flag[1])
103 winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL(%i)\n",x,outpItems[x].a.fRTL);
104
105 if (items[x].isBroken && broken(outpItems[x].a.fLayoutRTL == items[x].broken_value[2]))
106 winetest_win_skip("This test broken on this platform\n");
107 else todo_wine_if (items[x].todo_flag[2])
108 winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL(%i)\n",x,outpItems[x].a.fLayoutRTL);
109
110 if (items[x].isBroken && broken(outpItems[x].a.s.uBidiLevel == items[x].broken_value[3]))
111 winetest_win_skip("This test broken on this platform\n");
112 else todo_wine_if (items[x].todo_flag[3])
113 winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel(%i)\n",x,outpItems[x].a.s.uBidiLevel);
114 if (x != outnItems)
115 winetest_ok(outpItems[x].a.eScript != SCRIPT_UNDEFINED, "%i: Undefined script\n",x);
116 if (pScriptItemizeOpenType)
117 {
118 if (items[x].isBroken && broken(tags[x] == items[x].broken_value[4]))
119 winetest_win_skip("This test broken on this platform\n");
120 else todo_wine_if (items[x].todo_flag[4])
121 winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
122 }
123
124 if (items[x].isBroken && broken(outpItems[x].a.s.fOverrideDirection == items[x].broken_value[5]))
125 winetest_win_skip("This test broken on this platform\n");
126 else todo_wine_if (items[x].todo_flag[5])
127 winetest_ok(outpItems[x].a.s.fOverrideDirection == items[x].fOverrideDirection, "%i:Wrong fOverrideDirection(%i)\n",x,outpItems[x].a.s.fOverrideDirection);
128 }
129 }
130
131 #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)
132
133 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
134 ( ( (ULONG)_x4 << 24 ) | \
135 ( (ULONG)_x3 << 16 ) | \
136 ( (ULONG)_x2 << 8 ) | \
137 (ULONG)_x1 )
138
139 #define latn_tag MS_MAKE_TAG('l','a','t','n')
140 #define arab_tag MS_MAKE_TAG('a','r','a','b')
141 #define thai_tag MS_MAKE_TAG('t','h','a','i')
142 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
143 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
144 #define deva_tag MS_MAKE_TAG('d','e','v','a')
145 #define beng_tag MS_MAKE_TAG('b','e','n','g')
146 #define guru_tag MS_MAKE_TAG('g','u','r','u')
147 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
148 #define orya_tag MS_MAKE_TAG('o','r','y','a')
149 #define taml_tag MS_MAKE_TAG('t','a','m','l')
150 #define telu_tag MS_MAKE_TAG('t','e','l','u')
151 #define knda_tag MS_MAKE_TAG('k','n','d','a')
152 #define mlym_tag MS_MAKE_TAG('m','l','y','m')
153 #define mymr_tag MS_MAKE_TAG('m','y','m','r')
154 #define tale_tag MS_MAKE_TAG('t','a','l','e')
155 #define talu_tag MS_MAKE_TAG('t','a','l','u')
156 #define khmr_tag MS_MAKE_TAG('k','h','m','r')
157 #define hani_tag MS_MAKE_TAG('h','a','n','i')
158 #define bopo_tag MS_MAKE_TAG('b','o','p','o')
159 #define kana_tag MS_MAKE_TAG('k','a','n','a')
160 #define hang_tag MS_MAKE_TAG('h','a','n','g')
161 #define yi_tag MS_MAKE_TAG('y','i',' ',' ')
162 #define ethi_tag MS_MAKE_TAG('e','t','h','i')
163 #define mong_tag MS_MAKE_TAG('m','o','n','g')
164 #define tfng_tag MS_MAKE_TAG('t','f','n','g')
165 #define nko_tag MS_MAKE_TAG('n','k','o',' ')
166 #define vai_tag MS_MAKE_TAG('v','a','i',' ')
167 #define cher_tag MS_MAKE_TAG('c','h','e','r')
168 #define cans_tag MS_MAKE_TAG('c','a','n','s')
169 #define ogam_tag MS_MAKE_TAG('o','g','a','m')
170 #define runr_tag MS_MAKE_TAG('r','u','n','r')
171 #define brai_tag MS_MAKE_TAG('b','r','a','i')
172 #define dsrt_tag MS_MAKE_TAG('d','s','r','t')
173 #define osma_tag MS_MAKE_TAG('o','s','m','a')
174 #define math_tag MS_MAKE_TAG('m','a','t','h')
175
176 static void test_ScriptItemize( void )
177 {
178 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
179 static const itemTest t11[2] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1}};
180 static const itemTest t12[2] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
181
182 static const WCHAR test1b[] = {' ', ' ', ' ', ' ',0};
183 static const itemTest t1b1[2] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
184 static const itemTest t1b2[2] = {{{0,0,0,0,0,0},0,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
185
186 static const WCHAR test1c[] = {' ', ' ', ' ', '1', '2', ' ',0};
187 static const itemTest t1c1[2] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
188 static const itemTest t1c2[4] = {{{0,0,0,0,0,0},0,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},3,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},5,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
189
190 /* Arabic, English*/
191 static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
192 static const itemTest t21[7] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},15,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
193 static const itemTest t22[5] = {{{0,0,0,0,0,0},0,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},15,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
194 static const itemTest t23[5] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},15,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
195 static const itemTest t24[5] = {{{0,0,0,0,0,0},0,0,0,0,1,0,FALSE},
196 {{0,0,0,0,0,0},6,0,0,0,1,arab_tag,FALSE},
197 {{0,0,0,0,0,0},13,0,1,0,1,0,FALSE},
198 {{0,0,0,0,0,0},15,0,0,0,1,0,FALSE},
199 {{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
200
201 static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
202 static const itemTest t2b1[5] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},8,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
203 static const itemTest t2b2[5] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
204 static const itemTest t2b3[3] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
205 static const itemTest t2b4[5] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
206 {{0,0,0,0,0,0},3,0,0,0,1,0,FALSE},
207 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
208 {{0,0,0,0,0,0},8,0,0,0,1,arab_tag,FALSE},
209 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
210 static const int b2[2] = {4,4};
211
212 /* leading space */
213 static const WCHAR test2c[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
214 static const itemTest t2c1[5] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
215 static const itemTest t2c2[6] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},1,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
216 static const itemTest t2c3[5] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
217 static const itemTest t2c4[3] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
218 static const itemTest t2c5[5] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
219 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
220 {{0,0,0,0,0,0},7,0,0,0,1,0,FALSE},
221 {{0,0,0,0,0,0},8,0,0,0,1,latn_tag,FALSE},
222 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
223
224 /* trailing space */
225 static const WCHAR test2d[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
226 static const itemTest t2d1[5] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
227 static const itemTest t2d2[6] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
228 static const itemTest t2d3[5] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
229 static const itemTest t2d4[3] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
230 static const itemTest t2d5[5] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
231 {{0,0,0,0,0,0},3,0,0,0,1,0,FALSE},
232 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
233 {{0,0,0,0,0,0},7,0,0,0,1,arab_tag,FALSE},
234 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
235
236 /* Thai */
237 static const WCHAR test3[] =
238 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
239 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
240 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
241 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
242
243 static const itemTest t31[2] = {{{0,0,0,0,0,0},0,0,0,0,0,thai_tag,FALSE},{{0,0,0,0,0,0},41,0,0,0,0,-1,FALSE}};
244 static const itemTest t32[2] = {{{0,0,0,0,0,0},0,0,0,2,0,thai_tag,FALSE},{{0,0,0,0,0,0},41,0,0,0,0,-1,FALSE}};
245
246 static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
247
248 static const itemTest t41[6] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
249 static const itemTest t42[5] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},10,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
250 static const itemTest t43[4] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
251 static const int b43[2] = {4,4};
252
253 /* Arabic */
254 static const WCHAR test5[] =
255 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
256 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
257 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
258 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
259 static const itemTest t51[2] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},38,0,0,0,0,-1,FALSE}};
260 static const itemTest t52[2] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
261 {{0,0,0,0,0,0},38,0,0,0,0,-1,FALSE}};
262
263
264 /* Hebrew */
265 static const WCHAR test6[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
266 static const itemTest t61[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
267 static const itemTest t62[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},4,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
268 static const itemTest t63[2] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
269 static const itemTest t64[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
270 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
271 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
272
273 static const int b63[2] = {2,2};
274 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};
275 static const itemTest t71[4] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},9,1,1,1,0,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0,0},19,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
276 static const itemTest t72[4] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},9,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},18,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
277 static const itemTest t73[4] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},8,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},19,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
278 static const itemTest t74[4] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
279 {{0,0,0,0,0,0},9,0,0,0,1,hebr_tag,FALSE},
280 {{0,0,0,0,0,0},19,0,0,0,1,latn_tag,FALSE},
281 {{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
282
283 static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
284 static const itemTest t81[2] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
285 static const itemTest t82[2] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
286 {{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
287
288 /* Syriac (Like Arabic )*/
289 static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
290 static const itemTest t91[3] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
291 static const itemTest t92[3] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag},{{0,0,0,0,0,0},4,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
292 static const itemTest t93[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
293 static const itemTest t94[3] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
294 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
295 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
296 static const int b93[2] = {2,2};
297
298 static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
299 static const itemTest t101[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
300 static const itemTest t102[2] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
301 {{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
302
303 /* Devanagari */
304 static const WCHAR test11[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
305 static const itemTest t111[2] = {{{0,0,0,0,0,0},0,0,0,0,0,deva_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
306 static const itemTest t112[2] = {{{0,0,0,0,0,0},0,0,0,2,0,deva_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
307
308 /* Bengali */
309 static const WCHAR test12[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
310 static const itemTest t121[2] = {{{0,0,0,0,0,0},0,0,0,0,0,beng_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
311 static const itemTest t122[2] = {{{0,0,0,0,0,0},0,0,0,2,0,beng_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
312
313 /* Gurmukhi */
314 static const WCHAR test13[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
315 static const itemTest t131[2] = {{{0,0,0,0,0,0},0,0,0,0,0,guru_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
316 static const itemTest t132[2] = {{{0,0,0,0,0,0},0,0,0,2,0,guru_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
317
318 /* Gujarati */
319 static const WCHAR test14[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
320 static const itemTest t141[2] = {{{0,0,0,0,0,0},0,0,0,0,0,gujr_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
321 static const itemTest t142[2] = {{{0,0,0,0,0,0},0,0,0,2,0,gujr_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
322
323 /* Oriya */
324 static const WCHAR test15[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
325 static const itemTest t151[2] = {{{0,0,0,0,0,0},0,0,0,0,0,orya_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
326 static const itemTest t152[2] = {{{0,0,0,0,0,0},0,0,0,2,0,orya_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
327
328 /* Tamil */
329 static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
330 static const itemTest t161[2] = {{{0,0,0,0,0,0},0,0,0,0,0,taml_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
331 static const itemTest t162[2] = {{{0,0,0,0,0,0},0,0,0,2,0,taml_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
332
333 /* Telugu */
334 static const WCHAR test17[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
335 static const itemTest t171[2] = {{{0,0,0,0,0,0},0,0,0,0,0,telu_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
336 static const itemTest t172[2] = {{{0,0,0,0,0,0},0,0,0,2,0,telu_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
337
338 /* Kannada */
339 static const WCHAR test18[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
340 static const itemTest t181[2] = {{{0,0,0,0,0,0},0,0,0,0,0,knda_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
341 static const itemTest t182[2] = {{{0,0,0,0,0,0},0,0,0,2,0,knda_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
342
343 /* Malayalam */
344 static const WCHAR test19[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
345 static const itemTest t191[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
346 static const itemTest t192[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mlym_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
347
348 /* Diacritical */
349 static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
350 static const itemTest t201[3] = {{{0,0,0,0,0,0},0,0,0,0,0x0,0,FALSE},{{0,0,0,0,0,0},1,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
351 static const itemTest t202[3] = {{{0,0,0,0,0,0},0,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},1,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
352
353 static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
354 static const itemTest t211[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
355 static const itemTest t212[2] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
356 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
357
358 /* Latin Punctuation */
359 static const WCHAR test22[] = {'#','$',',','!','\"','*',0};
360 static const itemTest t221[3] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
361 static const itemTest t222[3] = {{{0,0,0,0,0,0},0,1,1,1,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
362 static const itemTest t223[2] = {{{0,0,0,0,0,0},0,1,1,1,0,latn_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
363 static const int b222[2] = {1,1};
364 static const int b223[2] = {2,2};
365
366 /* Number 2*/
367 static const WCHAR test23[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
368 static const itemTest t231[3] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
369 static const itemTest t232[3] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},3,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
370
371 /* Myanmar */
372 static const WCHAR test24[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
373 static const itemTest t241[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mymr_tag,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
374 static const itemTest t242[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mymr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
375
376 /* Tai Le */
377 static const WCHAR test25[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
378 static const itemTest t251[2] = {{{0,0,0,0,0,0},0,0,0,0,0,tale_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
379 static const itemTest t252[2] = {{{0,0,0,0,0,0},0,0,0,2,0,tale_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
380
381 /* New Tai Lue */
382 static const WCHAR test26[] = {0x1992,0x19c4};
383 static const itemTest t261[2] = {{{0,0,0,0,0,0},0,0,0,0,0,talu_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
384 static const itemTest t262[2] = {{{0,0,0,0,0,0},0,0,0,2,0,talu_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
385
386 /* Khmer */
387 static const WCHAR test27[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
388 static const itemTest t271[2] = {{{0,0,0,0,0,0},0,0,0,0,0,khmr_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
389 static const itemTest t272[2] = {{{0,0,0,0,0,0},0,0,0,2,0,khmr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
390
391 /* CJK Han */
392 static const WCHAR test28[] = {0x8bed,0x7d20,0x6587,0x5b57};
393 static const itemTest t281[2] = {{{0,0,0,0,0,0},0,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
394 static const itemTest t282[2] = {{{0,0,0,0,0,0},0,0,0,2,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
395
396 /* Ideographic */
397 static const WCHAR test29[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
398 static const itemTest t291[3] = {{{0,0,0,0,0,0},0,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
399 static const itemTest t292[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,hani_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
400
401 /* Bopomofo */
402 static const WCHAR test30[] = {0x3113,0x3128,0x3127,0x3123,0x3108,0x3128,0x310f,0x3120};
403 static const itemTest t301[2] = {{{0,0,0,0,0,0},0,0,0,0,0,bopo_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
404 static const itemTest t302[2] = {{{0,0,0,0,0,0},0,0,0,2,0,bopo_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
405
406 /* Kana */
407 static const WCHAR test31[] = {0x3072,0x3089,0x304b,0x306a,0x30ab,0x30bf,0x30ab,0x30ca};
408 static const itemTest t311[2] = {{{0,0,0,0,0,0},0,0,0,0,0,kana_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
409 static const itemTest t312[2] = {{{0,0,0,0,0,0},0,0,0,2,0,kana_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
410 static const int b311[2] = {2,2};
411 static const int b312[2] = {2,2};
412
413 /* Hangul */
414 static const WCHAR test32[] = {0xd55c,0xad6d,0xc5b4};
415 static const itemTest t321[2] = {{{0,0,0,0,0,0},0,0,0,0,0,hang_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
416 static const itemTest t322[2] = {{{0,0,0,0,0,0},0,0,0,2,0,hang_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
417
418 /* Yi */
419 static const WCHAR test33[] = {0xa188,0xa320,0xa071,0xa0b7};
420 static const itemTest t331[2] = {{{0,0,0,0,0,0},0,0,0,0,0,yi_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
421 static const itemTest t332[2] = {{{0,0,0,0,0,0},0,0,0,2,0,yi_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
422
423 /* Ethiopic */
424 static const WCHAR test34[] = {0x130d,0x12d5,0x12dd};
425 static const itemTest t341[2] = {{{0,0,0,0,0,0},0,0,0,0,0,ethi_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
426 static const itemTest t342[2] = {{{0,0,0,0,0,0},0,0,0,2,0,ethi_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
427 static const int b342[2] = {2,2};
428
429 /* Mongolian */
430 static const WCHAR test35[] = {0x182e,0x1823,0x1829,0x182d,0x1823,0x182f,0x0020,0x182a,0x1822,0x1834,0x1822,0x182d,0x180c};
431 static const itemTest t351[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mong_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
432 static const int b351[2] = {2,2};
433 static const itemTest t352[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mong_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
434 static const int b352[2] = {2,3};
435 static const itemTest t353[2] = {{{0,0,0,0,0,1},0,0,0,0,1,mong_tag,TRUE,{0,0,0,0,0}},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
436
437 /* Tifinagh */
438 static const WCHAR test36[] = {0x2d5c,0x2d49,0x2d3c,0x2d49,0x2d4f,0x2d30,0x2d56};
439 static const itemTest t361[2] = {{{0,0,0,0,0,0},0,0,0,0,0,tfng_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
440 static const itemTest t362[2] = {{{0,0,0,0,0,0},0,0,0,2,0,tfng_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
441
442 /* N'Ko */
443 static const WCHAR test37[] = {0x07d2,0x07de,0x07cf};
444 static const itemTest t371[2] = {{{0,0,0,0,0,0},0,1,1,1,0,nko_tag,TRUE,{-1,0,0,0,arab_tag,0}},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
445 static const itemTest t372[2] = {{{0,0,0,0,0,0},0,1,1,1,0,nko_tag,TRUE,{-1,0,0,2,arab_tag,0}},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
446 static const itemTest t373[2] = {{{0,0,0,0,0,0},0,0,0,0,1,nko_tag,TRUE,{-1,0,0,2,arab_tag,0}}, {{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
447
448 /* Vai */
449 static const WCHAR test38[] = {0xa559,0xa524};
450 static const itemTest t381[2] = {{{0,0,0,0,0,0},0,0,0,0,0,vai_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
451 static const itemTest t382[2] = {{{0,0,0,0,0,0},0,0,0,2,0,vai_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
452
453 /* Cherokee */
454 static const WCHAR test39[] = {0x13e3,0x13b3,0x13a9,0x0020,0x13a6,0x13ec,0x13c2,0x13af,0x13cd,0x13d7};
455 static const itemTest t391[2] = {{{0,0,0,0,0,0},0,0,0,0,0,cher_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
456 static const itemTest t392[2] = {{{0,0,0,0,0,0},0,0,0,2,0,cher_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
457
458 /* Canadian Aboriginal Syllabics */
459 static const WCHAR test40[] = {0x1403,0x14c4,0x1483,0x144e,0x1450,0x1466};
460 static const itemTest t401[2] = {{{0,0,0,0,0,0},0,0,0,0,0,cans_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
461 static const itemTest t402[2] = {{{0,0,0,0,0,0},0,0,0,2,0,cans_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
462
463 /* Ogham */
464 static const WCHAR test41[] = {0x169b,0x1691,0x168c,0x1690,0x168b,0x169c};
465 static const itemTest t411[2] = {{{0,0,0,0,0,0},0,0,0,0,0,ogam_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
466 static const itemTest t412[4] = {{{0,0,0,0,0,0},0,1,1,1,0,ogam_tag,FALSE},{{0,0,0,0,0,0},1,0,0,2,0,ogam_tag,FALSE},{{0,0,0,0,0,0},5,1,1,1,0,ogam_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
467 static const int b412[2] = {1,1};
468
469 /* Runic */
470 static const WCHAR test42[] = {0x16a0,0x16a1,0x16a2,0x16a3,0x16a4,0x16a5};
471 static const itemTest t421[2] = {{{0,0,0,0,0,0},0,0,0,0,0,runr_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
472 static const itemTest t422[4] = {{{0,0,0,0,0,0},0,0,0,2,0,runr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
473
474 /* Braille */
475 static const WCHAR test43[] = {0x280f,0x2817,0x2811,0x280d,0x280a,0x2811,0x2817};
476 static const itemTest t431[2] = {{{0,0,0,0,0,0},0,0,0,0,0,brai_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
477 static const itemTest t432[4] = {{{0,0,0,0,0,0},0,0,0,2,0,brai_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
478
479 /* Private and Surrogates Area */
480 static const WCHAR test44[] = {0xe000, 0xe001, 0xd800, 0xd801};
481 static const itemTest t441[3] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},2,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
482 static const itemTest t442[4] = {{{0,0,0,0,0,0},0,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},2,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
483
484 /* Deseret */
485 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};
486 static const itemTest t451[2] = {{{0,0,0,0,0,0},0,0,0,0,0,dsrt_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},24,0,0,0,0,-1,FALSE}};
487 static const itemTest t452[2] = {{{0,0,0,0,0,0},0,0,0,2,0,dsrt_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},24,0,0,0,0,-1,FALSE}};
488
489 /* Osmanya */
490 static const WCHAR test46[] = {0xd801,0xdc8b,0xd801,0xdc98,0xd801,0xdc88,0xd801,0xdc91,0xd801,0xdc9b,0xd801,0xdc92,0xd801,0xdc95,0xd801,0xdc80};
491 static const itemTest t461[2] = {{{0,0,0,0,0,0},0,0,0,0,0,osma_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
492 static const itemTest t462[2] = {{{0,0,0,0,0,0},0,0,0,2,0,osma_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
493
494 /* Mathematical Alphanumeric Symbols */
495 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};
496 static const itemTest t471[2] = {{{0,0,0,0,0,0},0,0,0,0,0,math_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},26,0,0,0,0,-1,FALSE}};
497 static const itemTest t472[2] = {{{0,0,0,0,0,0},0,0,0,2,0,math_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},26,0,0,0,0,-1,FALSE}};
498
499 /* Mathematical and Numeric combinations */
500 /* These have a leading hebrew character to force complicated itemization */
501 static const WCHAR test48[] = {0x05e9,' ','1','2','3','.'};
502 static const itemTest t481[4] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
503 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,0,0,FALSE},
504 {{0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
505 static const itemTest t482[4] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
506 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
507 {{0,0,0,0,0,0},5,0,0,0,1,0,FALSE},
508 {{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
509
510 static const WCHAR test49[] = {0x05e9,' ','1','2','.','1','2'};
511 static const itemTest t491[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
512 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
513 static const itemTest t492[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
514 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
515 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
516
517 static const WCHAR test50[] = {0x05e9,' ','.','1','2','3'};
518 static const itemTest t501[4] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
519 {{0,0,0,0,0},2,1,1,1,0,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,0,FALSE},
520 {{0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
521 static const itemTest t502[4] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
522 {{0,0,0,0,0,0},2,0,0,0,1,0,FALSE},
523 {{0,0,0,0,0,0},3,0,1,0,1,0,FALSE},
524 {{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
525
526 static const WCHAR test51[] = {0x05e9,' ','a','b','.','1','2'};
527 static const itemTest t511[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
528 {{0,0,0,0,0},1,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,0,FALSE},
529 {{0,0,0,0,0},5,0,0,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
530 static const itemTest t512[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
531 {{0,0,0,0,0,0},2,0,0,0,1,latn_tag,FALSE},
532 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
533 {{0,0,0,0,0,0},5,0,0,0,1,0,FALSE},
534 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
535
536 static const WCHAR test52[] = {0x05e9,' ','1','2','.','a','b'};
537 static const itemTest t521[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
538 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,0,FALSE},
539 {{0,0,0,0,0},5,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
540 static const itemTest t522[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
541 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
542 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
543 {{0,0,0,0,0,0},5,0,0,0,1,latn_tag,FALSE},
544 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
545
546 static const WCHAR test53[] = {0x05e9,' ','1','2','.','.','1','2'};
547 static const itemTest t531[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
548 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},4,1,1,1,0,0,FALSE},
549 {{0,0,0,0,0},6,0,1,2,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
550 static const itemTest t532[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
551 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
552 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
553 {{0,0,0,0,0,0},6,0,1,0,1,0,FALSE},
554 {{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
555
556 static const WCHAR test54[] = {0x05e9,' ','1','2','+','1','2'};
557 static const itemTest t541[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
558 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
559 static const itemTest t542[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
560 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
561 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
562 static const WCHAR test55[] = {0x05e9,' ','1','2','+','+','1','2'};
563 static const itemTest t551[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
564 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
565 static const itemTest t552[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
566 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
567 {{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
568
569 /* ZWNJ */
570 static const WCHAR test56[] = {0x0645, 0x06cc, 0x200c, 0x06a9, 0x0646, 0x0645}; /* می‌کنم */
571 static const itemTest t561[] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
572 static const itemTest t562[] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
573
574 SCRIPT_ITEM items[15];
575 SCRIPT_CONTROL Control;
576 SCRIPT_STATE State;
577 HRESULT hr;
578 HMODULE usp10;
579 int nItems;
580
581 usp10 = LoadLibraryA("usp10.dll");
582 ok (usp10 != 0,"Unable to LoadLibrary on usp10.dll\n");
583 pScriptItemizeOpenType = (void*)GetProcAddress(usp10, "ScriptItemizeOpenType");
584 pScriptShapeOpenType = (void*)GetProcAddress(usp10, "ScriptShapeOpenType");
585 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
586
587 memset(&Control, 0, sizeof(Control));
588 memset(&State, 0, sizeof(State));
589
590 hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
591 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
592
593 hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
594 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
595
596 hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
597 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
598
599 hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
600 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
601
602 test_items_ok(test1,4,NULL,NULL,1,t11,FALSE,0);
603 test_items_ok(test1b,4,NULL,NULL,1,t1b1,FALSE,0);
604 test_items_ok(test1c,6,NULL,NULL,1,t1c1,FALSE,0);
605 test_items_ok(test2,16,NULL,NULL,6,t21,FALSE,0);
606 test_items_ok(test2b,11,NULL,NULL,4,t2b1,FALSE,0);
607 test_items_ok(test2c,11,NULL,NULL,4,t2c1,FALSE,0);
608 test_items_ok(test2d,11,NULL,NULL,4,t2d1,FALSE,0);
609 test_items_ok(test3,41,NULL,NULL,1,t31,FALSE,0);
610 test_items_ok(test4,12,NULL,NULL,5,t41,FALSE,0);
611 test_items_ok(test5,38,NULL,NULL,1,t51,FALSE,0);
612 test_items_ok(test6,5,NULL,NULL,2,t61,FALSE,0);
613 test_items_ok(test7,29,NULL,NULL,3,t71,FALSE,0);
614 test_items_ok(test8,4,NULL,NULL,1,t81,FALSE,0);
615 test_items_ok(test9,5,NULL,NULL,2,t91,FALSE,0);
616 test_items_ok(test10,4,NULL,NULL,1,t101,FALSE,0);
617 test_items_ok(test11,8,NULL,NULL,1,t111,FALSE,0);
618 test_items_ok(test12,5,NULL,NULL,1,t121,FALSE,0);
619 test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
620 test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
621 test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
622 test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
623 test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
624 test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
625 test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
626 test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
627 test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
628 test_items_ok(test22,6,NULL,NULL,2,t221,FALSE,0);
629 test_items_ok(test23,6,NULL,NULL,2,t231,FALSE,0);
630 test_items_ok(test24,12,NULL,NULL,1,t241,FALSE,0);
631 test_items_ok(test25,10,NULL,NULL,1,t251,FALSE,0);
632 test_items_ok(test26,2,NULL,NULL,1,t261,FALSE,0);
633 test_items_ok(test27,8,NULL,NULL,1,t271,FALSE,0);
634 test_items_ok(test28,4,NULL,NULL,1,t281,FALSE,0);
635 test_items_ok(test29,10,NULL,NULL,2,t291,FALSE,0);
636 test_items_ok(test30,8,NULL,NULL,1,t301,FALSE,0);
637 test_items_ok(test31,8,NULL,NULL,1,t311,FALSE,b311);
638 test_items_ok(test32,3,NULL,NULL,1,t321,FALSE,0);
639 test_items_ok(test33,4,NULL,NULL,1,t331,FALSE,0);
640 test_items_ok(test34,3,NULL,NULL,1,t341,FALSE,0);
641 test_items_ok(test35,13,NULL,NULL,1,t351,FALSE,b351);
642 test_items_ok(test36,7,NULL,NULL,1,t361,FALSE,0);
643 test_items_ok(test37,3,NULL,NULL,1,t371,FALSE,0);
644 test_items_ok(test38,2,NULL,NULL,1,t381,FALSE,0);
645 test_items_ok(test39,10,NULL,NULL,1,t391,FALSE,0);
646 test_items_ok(test40,6,NULL,NULL,1,t401,FALSE,0);
647 test_items_ok(test41,6,NULL,NULL,1,t411,FALSE,0);
648 test_items_ok(test42,6,NULL,NULL,1,t421,FALSE,0);
649 test_items_ok(test43,7,NULL,NULL,1,t431,FALSE,0);
650 test_items_ok(test44,4,NULL,NULL,2,t441,FALSE,0);
651 test_items_ok(test45,24,NULL,NULL,1,t451,FALSE,0);
652 test_items_ok(test46,16,NULL,NULL,1,t461,FALSE,0);
653 test_items_ok(test47,26,NULL,NULL,1,t471,FALSE,0);
654 test_items_ok(test56,6,NULL,NULL,1,t561,FALSE,0);
655
656 State.uBidiLevel = 0;
657 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
658 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
659 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
660 test_items_ok(test2,16,&Control,&State,4,t22,FALSE,0);
661 test_items_ok(test2b,11,&Control,&State,4,t2b1,FALSE,0);
662 test_items_ok(test2c,11,&Control,&State,5,t2c2,FALSE,0);
663 test_items_ok(test2d,11,&Control,&State,5,t2d2,FALSE,0);
664 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
665 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
666 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
667 test_items_ok(test6,5,&Control,&State,2,t61,FALSE,0);
668 test_items_ok(test7,29,&Control,&State,3,t72,FALSE,0);
669 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
670 test_items_ok(test9,5,&Control,&State,2,t91,FALSE,0);
671 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
672 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
673 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
674 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
675 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
676 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
677 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
678 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
679 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
680 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
681 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
682 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
683 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
684 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
685 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
686 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
687 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
688 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
689 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
690 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
691 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
692 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
693 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
694 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
695 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
696 test_items_ok(test35,13,&Control,&State,1,t351,FALSE,b351);
697 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
698 test_items_ok(test37,3,&Control,&State,1,t371,FALSE,0);
699 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
700 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
701 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
702 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
703 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
704 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
705 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
706 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
707 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
708 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
709 test_items_ok(test48,6,&Control,&State,3,t481,FALSE,0);
710 test_items_ok(test49,7,&Control,&State,2,t491,FALSE,0);
711 test_items_ok(test50,6,&Control,&State,3,t501,FALSE,0);
712 test_items_ok(test51,7,&Control,&State,4,t511,FALSE,0);
713 test_items_ok(test52,7,&Control,&State,4,t521,FALSE,0);
714 test_items_ok(test53,8,&Control,&State,4,t531,FALSE,0);
715 test_items_ok(test54,7,&Control,&State,2,t541,FALSE,0);
716 test_items_ok(test55,8,&Control,&State,2,t551,FALSE,0);
717 test_items_ok(test56,6,&Control,&State,1,t561,FALSE,0);
718
719 State.uBidiLevel = 1;
720 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
721 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
722 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
723 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
724 test_items_ok(test2b,11,&Control,&State,4,t2b2,FALSE,0);
725 test_items_ok(test2c,11,&Control,&State,4,t2c3,FALSE,0);
726 test_items_ok(test2d,11,&Control,&State,4,t2d3,FALSE,0);
727 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
728 test_items_ok(test4,12,&Control,&State,4,t42,FALSE,0);
729 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
730 test_items_ok(test6,5,&Control,&State,2,t62,FALSE,0);
731 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
732 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
733 test_items_ok(test9,5,&Control,&State,2,t92,FALSE,0);
734 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
735 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
736 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
737 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
738 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
739 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
740 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
741 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
742 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
743 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
744 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
745 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
746 test_items_ok(test22,6,&Control,&State,2,t222,FALSE,b222);
747 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
748 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
749 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
750 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
751 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
752 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
753 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
754 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
755 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
756 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
757 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
758 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
759 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
760 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
761 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
762 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
763 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
764 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
765 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
766 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
767 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
768 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
769 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
770 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
771 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
772 test_items_ok(test56,6,&Control,&State,1,t561,FALSE,0);
773
774 State.uBidiLevel = 1;
775 Control.fMergeNeutralItems = TRUE;
776 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
777 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
778 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
779 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
780 test_items_ok(test2b,11,&Control,&State,2,t2b3,FALSE,b2);
781 test_items_ok(test2c,11,&Control,&State,2,t2c4,FALSE,b2);
782 test_items_ok(test2d,11,&Control,&State,2,t2d4,FALSE,b2);
783 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
784 test_items_ok(test4,12,&Control,&State,3,t43,FALSE,b43);
785 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
786 test_items_ok(test6,5,&Control,&State,1,t63,FALSE,b63);
787 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
788 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
789 test_items_ok(test9,5,&Control,&State,1,t93,FALSE,b93);
790 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
791 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
792 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
793 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
794 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
795 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
796 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
797 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
798 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
799 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
800 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
801 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
802 test_items_ok(test22,6,&Control,&State,1,t223,FALSE,b223);
803 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
804 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
805 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
806 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
807 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
808 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
809 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
810 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
811 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
812 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
813 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
814 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
815 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
816 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
817 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
818 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
819 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
820 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
821 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
822 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
823 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
824 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
825 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
826 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
827 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
828 test_items_ok(test56,6,&Control,&State,1,t561,FALSE,0);
829
830 State.uBidiLevel = 0;
831 Control.fMergeNeutralItems = FALSE;
832 State.fOverrideDirection = 1;
833 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
834 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
835 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
836 test_items_ok(test2,16,&Control,&State,4,t24,FALSE,0);
837 test_items_ok(test2b,11,&Control,&State,4,t2b4,FALSE,0);
838 test_items_ok(test2c,11,&Control,&State,4,t2c5,FALSE,0);
839 test_items_ok(test2d,11,&Control,&State,4,t2d5,FALSE,0);
840 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
841 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
842 test_items_ok(test5,38,&Control,&State,1,t52,FALSE,0);
843 test_items_ok(test6,5,&Control,&State,2,t64,FALSE,0);
844 test_items_ok(test7,29,&Control,&State,3,t74,FALSE,0);
845 test_items_ok(test8,4,&Control,&State,1,t82,FALSE,0);
846 test_items_ok(test9,5,&Control,&State,2,t94,FALSE,0);
847 test_items_ok(test10,4,&Control,&State,1,t102,FALSE,0);
848 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
849 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
850 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
851 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
852 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
853 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
854 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
855 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
856 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
857 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
858 test_items_ok(test21,5,&Control,&State,1,t212,FALSE,0);
859 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
860 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
861 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
862 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
863 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
864 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
865 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
866 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
867 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
868 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
869 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
870 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
871 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
872 test_items_ok(test35,13,&Control,&State,1,t353,FALSE,b351);
873 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
874 test_items_ok(test37,3,&Control,&State,1,t373,FALSE,0);
875 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
876 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
877 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
878 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
879 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
880 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
881 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
882 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
883 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
884 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
885 test_items_ok(test48,6,&Control,&State,3,t482,FALSE,0);
886 test_items_ok(test49,7,&Control,&State,2,t492,FALSE,0);
887 test_items_ok(test50,6,&Control,&State,3,t502,FALSE,0);
888 test_items_ok(test51,7,&Control,&State,4,t512,FALSE,0);
889 test_items_ok(test52,7,&Control,&State,4,t522,FALSE,0);
890 test_items_ok(test53,8,&Control,&State,4,t532,FALSE,0);
891 test_items_ok(test54,7,&Control,&State,2,t542,FALSE,0);
892 test_items_ok(test55,8,&Control,&State,2,t552,FALSE,0);
893 test_items_ok(test56,6,&Control,&State,1,t562,FALSE,0);
894 }
895
896 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
897 DWORD cchString, SCRIPT_CONTROL *Control,
898 SCRIPT_STATE *State, DWORD item, DWORD nGlyphs,
899 const shapeTest_char* charItems,
900 const shapeTest_glyph* glyphItems)
901 {
902 HRESULT hr;
903 int x, outnItems=0, outnGlyphs=0;
904 SCRIPT_ITEM outpItems[15];
905 SCRIPT_CACHE sc = NULL;
906 WORD *glyphs;
907 WORD *logclust;
908 int maxGlyphs = cchString * 1.5;
909 SCRIPT_GLYPHPROP *glyphProp;
910 SCRIPT_CHARPROP *charProp;
911 ULONG tags[15];
912
913 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
914 if (hr == USP_E_SCRIPT_NOT_IN_FONT)
915 {
916 if (valid > 0)
917 winetest_win_skip("Select font does not support script\n");
918 else
919 winetest_trace("Select font does not support script\n");
920 return;
921 }
922 if (valid > 0)
923 winetest_ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
924 else if (hr != S_OK)
925 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr);
926
927 if (outnItems <= item)
928 {
929 if (valid > 0)
930 winetest_win_skip("Did not get enough items\n");
931 else
932 winetest_trace("Did not get enough items\n");
933 return;
934 }
935
936 logclust = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * cchString);
937 memset(logclust,'a',sizeof(WORD) * cchString);
938 charProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP) * cchString);
939 memset(charProp,'a',sizeof(SCRIPT_CHARPROP) * cchString);
940 glyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * maxGlyphs);
941 memset(glyphs,'a',sizeof(WORD) * cchString);
942 glyphProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP) * maxGlyphs);
943 memset(glyphProp,'a',sizeof(SCRIPT_GLYPHPROP) * cchString);
944
945 hr = pScriptShapeOpenType(hdc, &sc, &outpItems[item].a, tags[item], 0x00000000, NULL, NULL, 0, string, cchString, maxGlyphs, logclust, charProp, glyphs, glyphProp, &outnGlyphs);
946 if (valid > 0)
947 winetest_ok(hr == S_OK, "ScriptShapeOpenType failed (%x)\n",hr);
948 else if (hr != S_OK)
949 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr);
950 if (FAILED(hr))
951 goto cleanup;
952
953 for (x = 0; x < cchString; x++)
954 {
955 if (valid > 0)
956 winetest_ok(logclust[x] == charItems[x].wLogClust, "%i: invalid LogClust(%i)\n",x,logclust[x]);
957 else if (logclust[x] != charItems[x].wLogClust)
958 winetest_trace("%i: invalid LogClust(%i)\n",x,logclust[x]);
959 if (valid > 0)
960 winetest_ok(charProp[x].fCanGlyphAlone == charItems[x].CharProp.fCanGlyphAlone, "%i: invalid fCanGlyphAlone\n",x);
961 else if (charProp[x].fCanGlyphAlone != charItems[x].CharProp.fCanGlyphAlone)
962 winetest_trace("%i: invalid fCanGlyphAlone\n",x);
963 }
964
965 if (valid > 0)
966 winetest_ok(nGlyphs == outnGlyphs, "got incorrect number of glyphs (%i)\n",outnGlyphs);
967 else if (nGlyphs != outnGlyphs)
968 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs);
969 for (x = 0; x < outnGlyphs; x++)
970 {
971 if (glyphItems[x].Glyph)
972 {
973 if (valid > 0)
974 winetest_ok(glyphs[x]!=0, "%i: Glyph not present when it should be\n",x);
975 else if (glyphs[x]==0)
976 winetest_trace("%i: Glyph not present when it should be\n",x);
977 }
978 else
979 {
980 if (valid > 0)
981 winetest_ok(glyphs[x]==0, "%i: Glyph present when it should not be\n",x);
982 else if (glyphs[x]!=0)
983 winetest_trace("%i: Glyph present when it should not be\n",x);
984 }
985 if (valid > 0)
986 winetest_ok(glyphProp[x].sva.uJustification == glyphItems[x].GlyphProp.sva.uJustification, "%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
987 else if (glyphProp[x].sva.uJustification != glyphItems[x].GlyphProp.sva.uJustification)
988 winetest_trace("%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
989 if (valid > 0)
990 winetest_ok(glyphProp[x].sva.fClusterStart == glyphItems[x].GlyphProp.sva.fClusterStart, "%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
991 else if (glyphProp[x].sva.fClusterStart != glyphItems[x].GlyphProp.sva.fClusterStart)
992 winetest_trace("%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
993 if (valid > 0)
994 winetest_ok(glyphProp[x].sva.fDiacritic == glyphItems[x].GlyphProp.sva.fDiacritic, "%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
995 else if (glyphProp[x].sva.fDiacritic != glyphItems[x].GlyphProp.sva.fDiacritic)
996 winetest_trace("%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
997 if (valid > 0)
998 winetest_ok(glyphProp[x].sva.fZeroWidth == glyphItems[x].GlyphProp.sva.fZeroWidth, "%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
999 else if (glyphProp[x].sva.fZeroWidth != glyphItems[x].GlyphProp.sva.fZeroWidth)
1000 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
1001 }
1002
1003 cleanup:
1004 HeapFree(GetProcessHeap(),0,logclust);
1005 HeapFree(GetProcessHeap(),0,charProp);
1006 HeapFree(GetProcessHeap(),0,glyphs);
1007 HeapFree(GetProcessHeap(),0,glyphProp);
1008 ScriptFreeCache(&sc);
1009 }
1010
1011 #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)
1012
1013 #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)
1014
1015 typedef struct tagRangeP {
1016 BYTE range;
1017 LOGFONTA lf;
1018 } fontEnumParam;
1019
1020 static int CALLBACK enumFontProc( const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam )
1021 {
1022 NEWTEXTMETRICEXA *ntme = (NEWTEXTMETRICEXA*)lpntme;
1023 fontEnumParam *rp = (fontEnumParam*) lParam;
1024 int idx = 0;
1025 DWORD i;
1026 DWORD mask = 0;
1027
1028 if (FontType != TRUETYPE_FONTTYPE)
1029 return 1;
1030
1031 i = rp->range;
1032 while (i >= sizeof(DWORD)*8)
1033 {
1034 idx++;
1035 i -= (sizeof(DWORD)*8);
1036 }
1037 if (idx > 3)
1038 return 0;
1039
1040 mask = 1 << i;
1041
1042 if (ntme->ntmFontSig.fsUsb[idx] & mask)
1043 {
1044 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONTA));
1045 return 0;
1046 }
1047 return 1;
1048 }
1049
1050 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
1051 {
1052 int rc = 0;
1053 fontEnumParam lParam;
1054
1055 lParam.range = range;
1056 memset(&lParam.lf,0,sizeof(LOGFONTA));
1057 *hfont = NULL;
1058
1059 if (recommended)
1060 {
1061 lstrcpyA(lParam.lf.lfFaceName, recommended);
1062 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
1063 {
1064 *hfont = CreateFontIndirectA(&lParam.lf);
1065 if (*hfont)
1066 {
1067 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
1068 rc = 1;
1069 }
1070 }
1071 }
1072
1073 if (!*hfont)
1074 {
1075 memset(&lParam.lf,0,sizeof(LOGFONTA));
1076 lParam.lf.lfCharSet = DEFAULT_CHARSET;
1077
1078 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
1079 {
1080 *hfont = CreateFontIndirectA(&lParam.lf);
1081 if (*hfont)
1082 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
1083 }
1084 }
1085
1086 if (*hfont)
1087 {
1088 WORD glyph = 0;
1089
1090 *origFont = SelectObject(hdc,*hfont);
1091 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
1092 {
1093 winetest_trace(" Font fails to contain required glyphs\n");
1094 SelectObject(hdc,*origFont);
1095 DeleteObject(*hfont);
1096 *hfont=NULL;
1097 rc = 0;
1098 }
1099 else if (!rc)
1100 rc = -1;
1101 }
1102 else
1103 winetest_trace("Failed to find usable font\n");
1104
1105 return rc;
1106 }
1107
1108 #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)
1109
1110 static void test_ScriptShapeOpenType(HDC hdc)
1111 {
1112 HRESULT hr;
1113 SCRIPT_CACHE sc = NULL;
1114 WORD glyphs[4], logclust[4];
1115 SCRIPT_GLYPHPROP glyphProp[4];
1116 SCRIPT_ITEM items[2];
1117 ULONG tags[2];
1118 SCRIPT_CONTROL Control;
1119 SCRIPT_STATE State;
1120 int nb, outnItems;
1121 HFONT hfont, hfont_orig;
1122 int test_valid;
1123 shapeTest_glyph glyph_test[4];
1124
1125 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1126 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
1127 static const shapeTest_glyph t1_g[] = {
1128 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1129 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1130 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1131 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1132
1133 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1134 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
1135 static const shapeTest_glyph t2_g[] = {
1136 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1137 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1138 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1139 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1140
1141 /* Hebrew */
1142 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
1143 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
1144 static const shapeTest_glyph hebrew_g[] = {
1145 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1146 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1147 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1148 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1149
1150 /* Arabic */
1151 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
1152 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
1153 static const shapeTest_glyph arabic_g[] = {
1154 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1155 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
1156 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
1157
1158 /* Thai */
1159 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
1160 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}}};
1161 static const shapeTest_glyph thai_g[] = {
1162 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1163 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1164 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1165 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1166 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1167 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1168 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1169 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1170 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1171 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
1172
1173 /* Syriac */
1174 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
1175 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
1176 static const shapeTest_glyph syriac_g[] = {
1177 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1178 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1179 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1180 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1181 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1182 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1183
1184 /* Thaana */
1185 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
1186 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}}};
1187 static const shapeTest_glyph thaana_g[] = {
1188 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1189 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1190 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1191 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1192 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1193 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1194 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1195 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1196 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1197 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1198 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1199 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1200 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1201
1202 /* Phags-pa */
1203 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
1204 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}}};
1205 static const shapeTest_glyph phagspa_g[] = {
1206 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1207 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1208 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1209 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1210 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1211 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1212 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1213 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1214 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1215 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1216 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1217
1218 /* Lao */
1219 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
1220 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}}};
1221 static const shapeTest_glyph lao_g[] = {
1222 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1223 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1224 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1225 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1226 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1227 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1228 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1229 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1230 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1231
1232 /* Tibetan */
1233 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
1234 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}}};
1235 static const shapeTest_glyph tibetan_g[] = {
1236 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1237 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1238 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1239 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
1240 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1241 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1242 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1243 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1244 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1245 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1246 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1247 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1248 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1249 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1250 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1251 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1252 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1253
1254 /* Devanagari */
1255 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
1256 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}}};
1257 static const shapeTest_glyph devanagari_g[] = {
1258 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1259 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1260 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1261 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1262 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1263 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1264 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1265 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1266
1267 /* Bengali */
1268 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
1269 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
1270 static const shapeTest_glyph bengali_g[] = {
1271 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1272 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1273 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1274 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1275 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1276
1277 /* Gurmukhi */
1278 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
1279 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}}};
1280 static const shapeTest_glyph gurmukhi_g[] = {
1281 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1282 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1283 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1284 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1285 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1286 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1287 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1288
1289 /* Gujarati */
1290 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
1291 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}}};
1292 static const shapeTest_glyph gujarati_g[] = {
1293 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1294 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1295 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1296 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1297 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1298 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1299 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1300
1301 /* Oriya */
1302 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
1303 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1304 static const shapeTest_glyph oriya_g[] = {
1305 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1306 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1307 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1308 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1309
1310 /* Tamil */
1311 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1312 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1313 static const shapeTest_glyph tamil_g[] = {
1314 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1315 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1316 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1317 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1318
1319 /* Telugu */
1320 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1321 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1322 static const shapeTest_glyph telugu_g[] = {
1323 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1324 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1325 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1326 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1327 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1328 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1329
1330 /* Malayalam */
1331 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1332 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1333 static const shapeTest_glyph malayalam_g[] = {
1334 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1335 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1336 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1337 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1338 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1339 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1340
1341 /* Kannada */
1342 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1343 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1344 static const shapeTest_glyph kannada_g[] = {
1345 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1346 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1347 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1348 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1349 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1350
1351 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
1352 {
1353 win_skip("ScriptShapeOpenType not available on this platform\n");
1354 return;
1355 }
1356
1357 memset(&Control, 0 , sizeof(Control));
1358 memset(&State, 0 , sizeof(State));
1359
1360 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
1361 ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
1362 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1363
1364 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
1365 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1366
1367 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
1368 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1369
1370 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1371 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
1372
1373 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1374 ok( hr == E_INVALIDARG,
1375 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1376 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
1377 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1378
1379 ScriptFreeCache(&sc);
1380
1381 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
1382
1383 /* newer Tahoma has zerowidth space glyphs for 0x202b and 0x202c */
1384 memcpy(glyph_test, t2_g, sizeof(glyph_test));
1385 GetGlyphIndicesW(hdc, test2, 4, glyphs, 0);
1386 if (glyphs[0] != 0)
1387 glyph_test[0].Glyph = 1;
1388 if (glyphs[3] != 0)
1389 glyph_test[3].Glyph = 1;
1390
1391 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, glyph_test);
1392
1393 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
1394 if (hfont != NULL)
1395 {
1396 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
1397 SelectObject(hdc, hfont_orig);
1398 DeleteObject(hfont);
1399 }
1400
1401 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
1402 if (hfont != NULL)
1403 {
1404 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
1405 SelectObject(hdc, hfont_orig);
1406 DeleteObject(hfont);
1407 }
1408
1409 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
1410 if (hfont != NULL)
1411 {
1412 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
1413 SelectObject(hdc, hfont_orig);
1414 DeleteObject(hfont);
1415 }
1416
1417 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
1418 if (hfont != NULL)
1419 {
1420 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
1421 SelectObject(hdc, hfont_orig);
1422 DeleteObject(hfont);
1423 }
1424
1425 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
1426 if (hfont != NULL)
1427 {
1428 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
1429 SelectObject(hdc, hfont_orig);
1430 DeleteObject(hfont);
1431 }
1432
1433 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
1434 if (hfont != NULL)
1435 {
1436 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
1437 SelectObject(hdc, hfont_orig);
1438 DeleteObject(hfont);
1439 }
1440
1441 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
1442 if (hfont != NULL)
1443 {
1444 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
1445 SelectObject(hdc, hfont_orig);
1446 DeleteObject(hfont);
1447 }
1448
1449 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
1450 if (hfont != NULL)
1451 {
1452 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
1453 SelectObject(hdc, hfont_orig);
1454 DeleteObject(hfont);
1455 }
1456
1457 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1458 if (hfont != NULL)
1459 {
1460 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1461 SelectObject(hdc, hfont_orig);
1462 DeleteObject(hfont);
1463 }
1464
1465 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1466 if (hfont != NULL)
1467 {
1468 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1469 SelectObject(hdc, hfont_orig);
1470 DeleteObject(hfont);
1471 }
1472
1473 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1474 if (hfont != NULL)
1475 {
1476 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1477 SelectObject(hdc, hfont_orig);
1478 DeleteObject(hfont);
1479 }
1480
1481 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1482 if (hfont != NULL)
1483 {
1484 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1485 SelectObject(hdc, hfont_orig);
1486 DeleteObject(hfont);
1487 }
1488
1489 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1490 if (hfont != NULL)
1491 {
1492 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1493 SelectObject(hdc, hfont_orig);
1494 DeleteObject(hfont);
1495 }
1496
1497 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1498 if (hfont != NULL)
1499 {
1500 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1501 SelectObject(hdc, hfont_orig);
1502 DeleteObject(hfont);
1503 }
1504
1505 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1506 if (hfont != NULL)
1507 {
1508 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1509 SelectObject(hdc, hfont_orig);
1510 DeleteObject(hfont);
1511 }
1512
1513 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1514 if (hfont != NULL)
1515 {
1516 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1517 SelectObject(hdc, hfont_orig);
1518 DeleteObject(hfont);
1519 }
1520
1521 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1522 if (hfont != NULL)
1523 {
1524 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1525 SelectObject(hdc, hfont_orig);
1526 DeleteObject(hfont);
1527 }
1528 }
1529
1530 static void test_ScriptShape(HDC hdc)
1531 {
1532 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1533 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1534 HRESULT hr;
1535 SCRIPT_CACHE sc = NULL;
1536 WORD glyphs[4], glyphs2[4], logclust[4], glyphs3[4];
1537 SCRIPT_VISATTR attrs[4];
1538 SCRIPT_ITEM items[2];
1539 int nb, i, j;
1540
1541 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1542 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1543 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1544
1545 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1546 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1547
1548 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1549 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1550
1551 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1552 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1553
1554 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1555 ok(broken(hr == S_OK) ||
1556 hr == E_INVALIDARG || /* Vista, W2K8 */
1557 hr == E_FAIL, /* WIN7 */
1558 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1559 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1560
1561 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1562 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1563 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1564
1565
1566 memset(glyphs,-1,sizeof(glyphs));
1567 memset(logclust,-1,sizeof(logclust));
1568 memset(attrs,-1,sizeof(attrs));
1569 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1570 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1571 ok(nb == 4, "Wrong number of items\n");
1572 ok(logclust[0] == 0, "clusters out of order\n");
1573 ok(logclust[1] == 1, "clusters out of order\n");
1574 ok(logclust[2] == 2, "clusters out of order\n");
1575 ok(logclust[3] == 3, "clusters out of order\n");
1576 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1577 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1578 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1579 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1580 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1581 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1582 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1583 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1584 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1585 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1586 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1587 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1588 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1589 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1590 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1591 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1592
1593 ScriptFreeCache(&sc);
1594 sc = NULL;
1595
1596 memset(glyphs2,-1,sizeof(glyphs2));
1597 memset(glyphs3,-1,sizeof(glyphs3));
1598 memset(logclust,-1,sizeof(logclust));
1599 memset(attrs,-1,sizeof(attrs));
1600
1601 GetGlyphIndicesW(hdc, test2, 4, glyphs3, 0);
1602
1603 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1604 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1605 ok(nb == 4, "Wrong number of items\n");
1606 ok(glyphs2[0] == glyphs3[0], "Incorrect glyph for 0x202B\n");
1607 ok(glyphs2[3] == glyphs3[3], "Incorrect glyph for 0x202C\n");
1608 ok(logclust[0] == 0, "clusters out of order\n");
1609 ok(logclust[1] == 1, "clusters out of order\n");
1610 ok(logclust[2] == 2, "clusters out of order\n");
1611 ok(logclust[3] == 3, "clusters out of order\n");
1612 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1613 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1614 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1615 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1616 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1617 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1618 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1619 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1620 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1621 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1622 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1623 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1624 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1625 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1626 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1627 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1628
1629 /* modify LTR to RTL */
1630 items[0].a.fRTL = 1;
1631 memset(glyphs2,-1,sizeof(glyphs2));
1632 memset(logclust,-1,sizeof(logclust));
1633 memset(attrs,-1,sizeof(attrs));
1634 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1635 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1636 ok(nb == 4, "Wrong number of items\n");
1637 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1638 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1639 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1640 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1641 ok(logclust[0] == 3, "clusters out of order\n");
1642 ok(logclust[1] == 2, "clusters out of order\n");
1643 ok(logclust[2] == 1, "clusters out of order\n");
1644 ok(logclust[3] == 0, "clusters out of order\n");
1645 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1646 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1647 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1648 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1649 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1650 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1651 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1652 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1653 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1654 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1655 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1656 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1657 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1658 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1659 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1660 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1661
1662 ScriptFreeCache(&sc);
1663
1664 /* some control characters are shown as blank */
1665 for (i = 0; i < 2; i++)
1666 {
1667 static const WCHAR space[] = {' ', 0};
1668 static const WCHAR blanks[] = {'\t', '\r', '\n', 0x001C, 0x001D, 0x001E, 0x001F,0};
1669 HFONT font, oldfont = NULL;
1670 LOGFONTA lf;
1671
1672 font = GetCurrentObject(hdc, OBJ_FONT);
1673 GetObjectA(font, sizeof(lf), &lf);
1674 if (i == 1) {
1675 lstrcpyA(lf.lfFaceName, "MS Sans Serif");
1676 font = CreateFontIndirectA(&lf);
1677 oldfont = SelectObject(hdc, font);
1678 }
1679
1680 hr = ScriptItemize(space, 1, 2, NULL, NULL, items, NULL);
1681 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1682
1683 hr = ScriptShape(hdc, &sc, space, 1, 1, &items[0].a, glyphs, logclust, attrs, &nb);
1684 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1685 ok(nb == 1, "%s: expected 1, got %d\n", lf.lfFaceName, nb);
1686
1687 for (j = 0; blanks[j]; j++)
1688 {
1689 hr = ScriptItemize(&blanks[j], 1, 2, NULL, NULL, items, NULL);
1690 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1691
1692 hr = ScriptShape(hdc, &sc, &blanks[j], 1, 1, &items[0].a, glyphs2, logclust, attrs, &nb);
1693 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1694 ok(nb == 1, "%s: [%02x] expected 1, got %d\n", lf.lfFaceName, blanks[j], nb);
1695
1696 ok(glyphs[0] == glyphs2[0] ||
1697 broken(glyphs2[0] == blanks[j] && (blanks[j] < 0x10)),
1698 "%s: [%02x] expected %04x, got %04x\n", lf.lfFaceName, blanks[j], glyphs[0], glyphs2[0]);
1699 }
1700 if (oldfont)
1701 DeleteObject(SelectObject(hdc, oldfont));
1702 ScriptFreeCache(&sc);
1703 }
1704 }
1705
1706 static void test_ScriptPlace(HDC hdc)
1707 {
1708 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1709 BOOL ret;
1710 HRESULT hr;
1711 SCRIPT_CACHE sc = NULL;
1712 WORD glyphs[4], logclust[4];
1713 SCRIPT_VISATTR attrs[4];
1714 SCRIPT_ITEM items[2];
1715 int nb, widths[4];
1716 GOFFSET offset[4];
1717 ABC abc[4];
1718
1719 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1720 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1721 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1722
1723 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1724 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1725 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1726
1727 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1728 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1729
1730 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1731 ok(broken(hr == E_PENDING) ||
1732 hr == E_INVALIDARG || /* Vista, W2K8 */
1733 hr == E_FAIL, /* WIN7 */
1734 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1735
1736 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1737 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1738
1739 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1740 ok(broken(hr == E_PENDING) ||
1741 hr == E_INVALIDARG || /* Vista, W2K8 */
1742 hr == E_FAIL, /* WIN7 */
1743 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1744
1745 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1746 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1747 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1748
1749 if (widths[0] != 0)
1750 {
1751 int old_width = widths[0];
1752 attrs[0].fZeroWidth = 1;
1753
1754 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1755 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1756 ok(widths[0] == 0, "got width %d\n", widths[0]);
1757 widths[0] = old_width;
1758 }
1759 else
1760 skip("Glyph already has zero-width - skipping fZeroWidth test\n");
1761
1762 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1763 ok(ret, "ExtTextOutW should return TRUE\n");
1764
1765 ScriptFreeCache(&sc);
1766 }
1767
1768 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1769 {
1770 HRESULT hr;
1771 int iMaxProps;
1772 const SCRIPT_PROPERTIES **ppSp;
1773
1774 int cInChars;
1775 int cMaxItems;
1776 SCRIPT_ITEM pItem[255];
1777 int pcItems;
1778 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1779 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1780 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1781 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1782 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1783 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1784
1785 SCRIPT_CACHE psc;
1786 int cChars;
1787 int cMaxGlyphs;
1788 unsigned short pwOutGlyphs1[256];
1789 unsigned short pwOutGlyphs2[256];
1790 unsigned short pwLogClust[256];
1791 SCRIPT_VISATTR psva[256];
1792 int pcGlyphs;
1793 int piAdvance[256];
1794 GOFFSET pGoffset[256];
1795 ABC pABC[256];
1796 int cnt;
1797
1798 /* Start testing usp10 functions */
1799 /* This test determines that the pointer returned by ScriptGetProperties is valid
1800 * by checking a known value in the table */
1801 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1802 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1803 trace("number of script properties %d\n", iMaxProps);
1804 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1805 if (iMaxProps > 0)
1806 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1807 /* ptrs work */
1808
1809 /* This is a valid test that will cause parsing to take place */
1810 cInChars = 5;
1811 cMaxItems = 255;
1812 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1813 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1814 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1815 * returned. */
1816 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1817 if (pcItems > 0)
1818 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1819 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1820 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1821
1822 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1823 * ie. ScriptItemize has succeeded and that pItem has been set */
1824 cInChars = 5;
1825 if (hr == S_OK) {
1826 psc = NULL; /* must be null on first call */
1827 cChars = cInChars;
1828 cMaxGlyphs = cInChars;
1829 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1830 cMaxGlyphs, &pItem[0].a,
1831 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1832 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1833 cMaxGlyphs = 4;
1834 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1835 cMaxGlyphs, &pItem[0].a,
1836 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1837 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1838 "(%d) but not E_OUTOFMEMORY\n",
1839 cChars, cMaxGlyphs);
1840 cMaxGlyphs = 256;
1841 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1842 cMaxGlyphs, &pItem[0].a,
1843 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1844 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1845 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1846 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1847 if (hr ==0) {
1848 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1849 pGoffset, pABC);
1850 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1851 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1852 pGoffset, pABC);
1853 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1854 for (cnt=0; cnt < pcGlyphs; cnt++)
1855 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1856 }
1857
1858 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1859 * takes place if fNoGlyphIndex is set. */
1860
1861 cInChars = 5;
1862 cMaxItems = 255;
1863 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1864 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1865 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1866 * returned. */
1867 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1868 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1869 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1870 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1871 if (hr == S_OK) {
1872 cChars = cInChars;
1873 cMaxGlyphs = 256;
1874 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1875 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1876 cMaxGlyphs, &pItem[0].a,
1877 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1878 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1879 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1880 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1881 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1882 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1883 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1884 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1885 if (hr == S_OK) {
1886 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1887 pGoffset, pABC);
1888 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1889 }
1890 }
1891 ScriptFreeCache( &psc);
1892 ok (!psc, "psc is not null after ScriptFreeCache\n");
1893
1894 }
1895
1896 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1897 cInChars = (sizeof(TestItem3)/2)-1;
1898 cMaxItems = 255;
1899 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1900 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1901 if (hr == S_OK)
1902 {
1903 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1904 if (pcItems > 2)
1905 {
1906 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1907 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1908 pItem[0].iCharPos, pItem[1].iCharPos);
1909 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1910 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1911 pItem[1].iCharPos, pItem[2].iCharPos);
1912 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1913 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1914 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1915 }
1916 }
1917
1918 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1919 cInChars = (sizeof(TestItem4)/2)-1;
1920 cMaxItems = 255;
1921 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1922 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1923 if (hr == S_OK)
1924 {
1925 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1926 if (pcItems > 4)
1927 {
1928 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1929 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1930 pItem[0].iCharPos, pItem[1].iCharPos);
1931 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1932 pItem[0].a.s.uBidiLevel);
1933 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1934 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1935 pItem[1].iCharPos, pItem[2].iCharPos);
1936 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1937 pItem[1].a.s.uBidiLevel);
1938 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1939 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1940 pItem[2].iCharPos, pItem[3].iCharPos);
1941 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1942 pItem[2].a.s.uBidiLevel);
1943 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1944 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1945 pItem[3].iCharPos, pItem[4].iCharPos);
1946 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1947 pItem[3].a.s.uBidiLevel);
1948 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1949 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1950 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1951 }
1952 }
1953
1954 /*
1955 * This test is for when the first unicode character requires bidi support
1956 */
1957 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1958 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1959 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1960 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1961 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1962 pItem[0].a.s.uBidiLevel);
1963
1964 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1965 * the pointer to the last char works. Note that windows often needs a greater number of *
1966 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1967 cInChars = (sizeof(TestItem6)/2)-1;
1968 cMaxItems = 4;
1969 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1970 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1971
1972 }
1973
1974 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1975 {
1976 HRESULT hr;
1977 SCRIPT_CACHE psc = NULL;
1978 int cInChars;
1979 int cChars;
1980 unsigned short pwOutGlyphs2[256];
1981 unsigned short pwOutGlyphs3[256];
1982 DWORD dwFlags;
1983 int cnt;
1984
1985 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1986 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1987 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1988 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1989
1990 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1991 dwFlags = 0;
1992 cInChars = cChars = 5;
1993 /* Some sanity checks for ScriptGetCMap */
1994
1995 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1996 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
1997 "expected E_INVALIDARG, got %08x\n", hr);
1998
1999 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
2000 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
2001 "expected E_INVALIDARG, got %08x\n", hr);
2002
2003 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2004 psc = NULL;
2005 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
2006 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
2007 "got %08x\n", hr);
2008 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2009
2010 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
2011 psc = NULL;
2012 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
2013 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
2014 "got %08x\n", hr);
2015 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
2016 ScriptFreeCache( &psc);
2017
2018 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2019 psc = NULL;
2020 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
2021 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
2022 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2023 /* Check to see if the results are the same as those returned by ScriptShape */
2024 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
2025 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2026 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2027 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
2028 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
2029 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
2030
2031 ScriptFreeCache( &psc);
2032 ok (!psc, "psc is not null after ScriptFreeCache\n");
2033
2034 /* ScriptGetCMap returns whatever font defines, no special treatment for control chars */
2035 cInChars = cChars = 4;
2036 GetGlyphIndicesW(hdc, TestItem2, cInChars, pwOutGlyphs2, 0);
2037
2038 hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
2039 if (pwOutGlyphs3[0] == 0 || pwOutGlyphs3[3] == 0)
2040 ok(hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
2041 else
2042 ok(hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2043
2044 ok(psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2045 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "expected glyph %d, got %d\n", pwOutGlyphs2[0], pwOutGlyphs3[0]);
2046 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "expected glyph %d, got %d\n", pwOutGlyphs2[3], pwOutGlyphs3[3]);
2047
2048 cInChars = cChars = 9;
2049 hr = ScriptGetCMap(hdc, &psc, TestItem3b, cInChars, dwFlags, pwOutGlyphs2);
2050 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2051 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2052
2053 cInChars = cChars = 9;
2054 dwFlags = SGCM_RTL;
2055 hr = ScriptGetCMap(hdc, &psc, TestItem3, cInChars, dwFlags, pwOutGlyphs3);
2056 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2057 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2058 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "glyph incorrectly altered\n");
2059 ok(pwOutGlyphs3[1] == pwOutGlyphs2[1], "glyph incorrectly altered\n");
2060 ok(pwOutGlyphs3[2] == pwOutGlyphs2[2], "glyph incorrectly altered\n");
2061 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "glyph incorrectly altered\n");
2062 ok(pwOutGlyphs3[4] == pwOutGlyphs2[4], "glyph not mirrored correctly\n");
2063 ok(pwOutGlyphs3[5] == pwOutGlyphs2[5], "glyph not mirrored correctly\n");
2064 ok(pwOutGlyphs3[6] == pwOutGlyphs2[6], "glyph not mirrored correctly\n");
2065 ok(pwOutGlyphs3[7] == pwOutGlyphs2[7], "glyph not mirrored correctly\n");
2066 ok(pwOutGlyphs3[8] == pwOutGlyphs2[8], "glyph not mirrored correctly\n");
2067
2068 ScriptFreeCache( &psc);
2069 ok (!psc, "psc is not null after ScriptFreeCache\n");
2070 }
2071
2072 #define MAX_ENUM_FONTS 4096
2073
2074 struct enum_font_data
2075 {
2076 int total;
2077 ENUMLOGFONTA elf[MAX_ENUM_FONTS];
2078 };
2079
2080 static INT CALLBACK enum_bitmap_font_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
2081 {
2082 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
2083
2084 if (type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE)) return 1;
2085
2086 if (efnd->total < MAX_ENUM_FONTS)
2087 {
2088 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
2089 }
2090 else
2091 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
2092
2093 return 1;
2094 }
2095
2096 static INT CALLBACK enum_truetype_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
2097 {
2098 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
2099
2100 if (!(type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE))) return 1;
2101
2102 if (efnd->total < MAX_ENUM_FONTS)
2103 {
2104 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
2105 }
2106 else
2107 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
2108
2109 return 1;
2110 }
2111
2112 static void test_ScriptGetFontProperties(HDC hdc)
2113 {
2114 HRESULT hr;
2115 SCRIPT_CACHE psc,old_psc;
2116 SCRIPT_FONTPROPERTIES sfp;
2117 HFONT font, oldfont;
2118 LOGFONTA lf;
2119 struct enum_font_data efnd;
2120 TEXTMETRICA tmA;
2121 WORD gi[3];
2122 WCHAR str[3];
2123 DWORD i, ret;
2124 WORD system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
2125 static const WCHAR invalids[] = {0x0020, 0x200B, 0xF71B};
2126 /* U+0020: numeric space
2127 U+200B: zero width space
2128 U+F71B: unknown, found by black box testing */
2129 BOOL is_arial, is_times_new_roman, is_arabic = (system_lang_id == LANG_ARABIC);
2130
2131 /* Some sanity checks for ScriptGetFontProperties */
2132
2133 hr = ScriptGetFontProperties(NULL,NULL,NULL);
2134 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
2135
2136 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
2137 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
2138
2139 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2140 psc = NULL;
2141 hr = ScriptGetFontProperties(NULL,&psc,NULL);
2142 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
2143 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2144
2145 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2146 psc = NULL;
2147 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
2148 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
2149 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2150
2151 hr = ScriptGetFontProperties(hdc,NULL,NULL);
2152 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
2153
2154 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
2155 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
2156
2157 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2158 psc = NULL;
2159 hr = ScriptGetFontProperties(hdc,&psc,NULL);
2160 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
2161 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2162
2163 /* Pass an invalid sfp */
2164 psc = NULL;
2165 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES) - 1;
2166 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
2167 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr);
2168 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
2169 ScriptFreeCache(&psc);
2170 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2171
2172 /* Give it the correct cBytes, we don't care about what's coming back */
2173 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2174 psc = NULL;
2175 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
2176 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
2177 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
2178
2179 /* Save the psc pointer */
2180 old_psc = psc;
2181 /* Now a NULL hdc again */
2182 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
2183 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
2184 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
2185 ScriptFreeCache(&psc);
2186 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2187
2188 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
2189 if (!pGetGlyphIndicesW)
2190 {
2191 win_skip("Skip on WINNT4\n");
2192 return;
2193 }
2194 memset(&lf, 0, sizeof(lf));
2195 lf.lfCharSet = DEFAULT_CHARSET;
2196 efnd.total = 0;
2197 EnumFontFamiliesA(hdc, NULL, enum_bitmap_font_proc, (LPARAM)&efnd);
2198
2199 for (i = 0; i < efnd.total; i++)
2200 {
2201 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2202 {
2203 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2204 continue;
2205 }
2206 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2207 font = CreateFontIndirectA(&lf);
2208 oldfont = SelectObject(hdc, font);
2209
2210 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2211 psc = NULL;
2212 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2213 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2214 if (winetest_interactive)
2215 {
2216 trace("bitmap font %s\n", lf.lfFaceName);
2217 trace("wgBlank %04x\n", sfp.wgBlank);
2218 trace("wgDefault %04x\n", sfp.wgDefault);
2219 trace("wgInvalid %04x\n", sfp.wgInvalid);
2220 trace("wgKashida %04x\n", sfp.wgKashida);
2221 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2222 }
2223
2224 ret = GetTextMetricsA(hdc, &tmA);
2225 ok(ret != 0, "GetTextMetricsA failed!\n");
2226
2227 ret = pGetGlyphIndicesW(hdc, invalids, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2228 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2229
2230 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]);
2231
2232 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);
2233
2234 ok(sfp.wgInvalid == sfp.wgBlank || broken(is_arabic), "bitmap font %s wgInvalid %02x wgBlank %02x\n", lf.lfFaceName, sfp.wgInvalid, sfp.wgBlank);
2235
2236 ok(sfp.wgKashida == 0xFFFF || broken(is_arabic), "bitmap font %s wgKashida %02x\n", lf.lfFaceName, sfp.wgKashida);
2237
2238 ScriptFreeCache(&psc);
2239
2240 SelectObject(hdc, oldfont);
2241 DeleteObject(font);
2242 }
2243
2244 efnd.total = 0;
2245 EnumFontFamiliesA(hdc, NULL, enum_truetype_proc, (LPARAM)&efnd);
2246
2247 for (i = 0; i < efnd.total; i++)
2248 {
2249 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2250 {
2251 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2252 continue;
2253 }
2254 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2255 font = CreateFontIndirectA(&lf);
2256 oldfont = SelectObject(hdc, font);
2257
2258 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2259 psc = NULL;
2260 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2261 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2262 if (winetest_interactive)
2263 {
2264 trace("truetype font %s\n", lf.lfFaceName);
2265 trace("wgBlank %04x\n", sfp.wgBlank);
2266 trace("wgDefault %04x\n", sfp.wgDefault);
2267 trace("wgInvalid %04x\n", sfp.wgInvalid);
2268 trace("wgKashida %04x\n", sfp.wgKashida);
2269 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2270 }
2271
2272 str[0] = 0x0020; /* U+0020: numeric space */
2273 ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
2274 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2275 ok(sfp.wgBlank == gi[0], "truetype font %s wgBlank %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgBlank, gi[0]);
2276
2277 ok(sfp.wgDefault == 0 || broken(is_arabic), "truetype font %s wgDefault %04x\n", lf.lfFaceName, sfp.wgDefault);
2278
2279 ret = pGetGlyphIndicesW(hdc, invalids, 3, gi, GGI_MARK_NONEXISTING_GLYPHS);
2280 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2281 if (gi[2] != 0xFFFF) /* index of default non exist char */
2282 ok(sfp.wgInvalid == gi[2], "truetype font %s wgInvalid %04x gi[2] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[2]);
2283 else if (gi[1] != 0xFFFF)
2284 ok(sfp.wgInvalid == gi[1], "truetype font %s wgInvalid %04x gi[1] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[1]);
2285 else if (gi[0] != 0xFFFF)
2286 ok(sfp.wgInvalid == gi[0], "truetype font %s wgInvalid %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[0]);
2287 else
2288 ok(sfp.wgInvalid == 0, "truetype font %s wgInvalid %04x expect 0\n", lf.lfFaceName, sfp.wgInvalid);
2289
2290 str[0] = 0x0640; /* U+0640: kashida */
2291 ret = pGetGlyphIndicesW(hdc, str, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2292 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2293 is_arial = !lstrcmpA(lf.lfFaceName, "Arial");
2294 is_times_new_roman= !lstrcmpA(lf.lfFaceName, "Times New Roman");
2295 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]);
2296
2297 ScriptFreeCache(&psc);
2298
2299 SelectObject(hdc, oldfont);
2300 DeleteObject(font);
2301 }
2302 }
2303
2304 static void test_ScriptTextOut(HDC hdc)
2305 {
2306 HRESULT hr;
2307
2308 int cInChars;
2309 int cMaxItems;
2310 SCRIPT_ITEM pItem[255];
2311 int pcItems;
2312 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2313
2314 SCRIPT_CACHE psc;
2315 int cChars;
2316 int cMaxGlyphs;
2317 unsigned short pwOutGlyphs1[256];
2318 WORD pwLogClust[256];
2319 SCRIPT_VISATTR psva[256];
2320 int pcGlyphs;
2321 int piAdvance[256];
2322 GOFFSET pGoffset[256];
2323 ABC pABC[256];
2324 RECT rect;
2325 int piX;
2326 int iCP = 1;
2327 BOOL fTrailing = FALSE;
2328 SCRIPT_LOGATTR *psla;
2329 SCRIPT_LOGATTR sla[256];
2330
2331 /* This is a valid test that will cause parsing to take place */
2332 cInChars = 5;
2333 cMaxItems = 255;
2334 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2335 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2336 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2337 * returned. */
2338 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2339 if (pcItems > 0)
2340 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2341 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2342 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2343
2344 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2345 * ie. ScriptItemize has succeeded and that pItem has been set */
2346 cInChars = 5;
2347 if (hr == S_OK) {
2348 psc = NULL; /* must be null on first call */
2349 cChars = cInChars;
2350 cMaxGlyphs = 256;
2351 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2352 cMaxGlyphs, &pItem[0].a,
2353 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2354 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2355 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2356 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2357 if (hr == S_OK) {
2358 /* Note hdc is needed as glyph info is not yet in psc */
2359 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2360 pGoffset, pABC);
2361 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2362 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
2363 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2364
2365 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
2366 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
2367
2368 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2369 piAdvance, NULL, pGoffset);
2370 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
2371 "expected E_INVALIDARG, got %08x\n", hr);
2372
2373 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2374 psc = NULL;
2375 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
2376 NULL, NULL, NULL);
2377 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
2378 "got %08x\n", hr);
2379 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2380
2381 /* hdc is required for this one rather than the usual optional */
2382 psc = NULL;
2383 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2384 piAdvance, NULL, pGoffset);
2385 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
2386 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2387
2388 /* Set that it returns 0 status */
2389 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2390 piAdvance, NULL, pGoffset);
2391 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2392
2393 /* Test Rect Rgn is acceptable */
2394 rect.top = 10;
2395 rect.bottom = 20;
2396 rect.left = 10;
2397 rect.right = 40;
2398 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2399 piAdvance, NULL, pGoffset);
2400 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2401
2402 iCP = 1;
2403 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
2404 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
2405 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
2406
2407 psla = (SCRIPT_LOGATTR *)&sla;
2408 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
2409 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
2410
2411 /* Clean up and go */
2412 ScriptFreeCache(&psc);
2413 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2414 }
2415 }
2416 }
2417
2418 static void test_ScriptTextOut2(HDC hdc)
2419 {
2420 /* Intent is to validate that the HDC passed into ScriptTextOut is
2421 * used instead of the (possibly) invalid cached one
2422 */
2423 HRESULT hr;
2424
2425 HDC hdc1, hdc2;
2426 int cInChars;
2427 int cMaxItems;
2428 SCRIPT_ITEM pItem[255];
2429 int pcItems;
2430 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2431
2432 SCRIPT_CACHE psc;
2433 int cChars;
2434 int cMaxGlyphs;
2435 unsigned short pwOutGlyphs1[256];
2436 WORD pwLogClust[256];
2437 SCRIPT_VISATTR psva[256];
2438 int pcGlyphs;
2439 int piAdvance[256];
2440 GOFFSET pGoffset[256];
2441 ABC pABC[256];
2442
2443 /* Create an extra DC that will be used until the ScriptTextOut */
2444 hdc1 = CreateCompatibleDC(hdc);
2445 ok (hdc1 != 0, "CreateCompatibleDC failed to create a DC\n");
2446 hdc2 = CreateCompatibleDC(hdc);
2447 ok (hdc2 != 0, "CreateCompatibleDC failed to create a DC\n");
2448
2449 /* This is a valid test that will cause parsing to take place */
2450 cInChars = 5;
2451 cMaxItems = 255;
2452 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2453 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2454 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2455 * returned. */
2456 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2457 if (pcItems > 0)
2458 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2459 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2460 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2461
2462 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2463 * ie. ScriptItemize has succeeded and that pItem has been set */
2464 cInChars = 5;
2465 if (hr == S_OK) {
2466 psc = NULL; /* must be null on first call */
2467 cChars = cInChars;
2468 cMaxGlyphs = 256;
2469 hr = ScriptShape(hdc2, &psc, TestItem1, cChars,
2470 cMaxGlyphs, &pItem[0].a,
2471 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2472 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2473 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2474 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2475 if (hr == S_OK) {
2476 BOOL ret;
2477
2478 /* Note hdc is needed as glyph info is not yet in psc */
2479 hr = ScriptPlace(hdc2, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2480 pGoffset, pABC);
2481 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2482
2483 /* key part!!! cached dc is being deleted */
2484 ret = DeleteDC(hdc2);
2485 ok(ret, "DeleteDC should return 1 not %d\n", ret);
2486
2487 /* At this point the cached hdc (hdc2) has been destroyed,
2488 * however, we are passing in a *real* hdc (the original hdc).
2489 * The text should be written to that DC
2490 */
2491 hr = ScriptTextOut(hdc1, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2492 piAdvance, NULL, pGoffset);
2493 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2494 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2495
2496 DeleteDC(hdc1);
2497
2498 /* Clean up and go */
2499 ScriptFreeCache(&psc);
2500 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2501 }
2502 }
2503 }
2504
2505 static void test_ScriptTextOut3(HDC hdc)
2506 {
2507 HRESULT hr;
2508
2509 int cInChars;
2510 int cMaxItems;
2511 SCRIPT_ITEM pItem[255];
2512 int pcItems;
2513 WCHAR TestItem1[] = {' ','\r', 0};
2514
2515 SCRIPT_CACHE psc;
2516 int cChars;
2517 int cMaxGlyphs;
2518 unsigned short pwOutGlyphs1[256];
2519 WORD pwLogClust[256];
2520 SCRIPT_VISATTR psva[256];
2521 int pcGlyphs;
2522 int piAdvance[256];
2523 GOFFSET pGoffset[256];
2524 ABC pABC[256];
2525 RECT rect;
2526
2527 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
2528 cInChars = 2;
2529 cMaxItems = 255;
2530 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2531 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2532 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2533 * returned. */
2534 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2535 if (pcItems > 0)
2536 ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
2537 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2538 pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
2539
2540 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2541 * ie. ScriptItemize has succeeded and that pItem has been set */
2542 cInChars = 2;
2543 if (hr == S_OK) {
2544 psc = NULL; /* must be null on first call */
2545 cChars = cInChars;
2546 cMaxGlyphs = 256;
2547 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2548 cMaxGlyphs, &pItem[0].a,
2549 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2550 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2551 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2552 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2553 if (hr ==0) {
2554 /* Note hdc is needed as glyph info is not yet in psc */
2555 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2556 pGoffset, pABC);
2557 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2558
2559 /* Test Rect Rgn is acceptable */
2560 rect.top = 10;
2561 rect.bottom = 20;
2562 rect.left = 10;
2563 rect.right = 40;
2564 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2565 piAdvance, NULL, pGoffset);
2566 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2567 }
2568 /* Clean up and go */
2569 ScriptFreeCache(&psc);
2570 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2571 }
2572 }
2573
2574 #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)
2575
2576 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2577 {
2578 int iX, iCP;
2579 int icChars, icGlyphs;
2580 int piCP, piX;
2581 HRESULT hr;
2582 SCRIPT_VISATTR psva[10];
2583 int piTrailing;
2584 BOOL fTrailing;
2585 int direction;
2586
2587 memset(psva,0,sizeof(psva));
2588 direction = (psa->fRTL)?-1:+1;
2589
2590 for(iCP = 0; iCP < cChars; iCP++)
2591 {
2592 iX = offsets[iCP];
2593 icChars = cChars;
2594 icGlyphs = cGlyphs;
2595 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2596 winetest_ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2597 winetest_ok(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2598 winetest_ok(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2599 }
2600
2601 for(iCP = 0; iCP < cChars; iCP++)
2602 {
2603 iX = offsets[iCP]+direction;
2604 icChars = cChars;
2605 icGlyphs = cGlyphs;
2606 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2607 winetest_ok(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2608 winetest_ok(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2609 winetest_ok(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2610 }
2611
2612 for(iCP = 0; iCP < cChars; iCP++)
2613 {
2614 iX = offsets[iCP+1]-direction;
2615 icChars = cChars;
2616 icGlyphs = cGlyphs;
2617 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2618 winetest_ok(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2619 winetest_ok(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2620 winetest_ok(piTrailing == 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2621 }
2622
2623 for(iCP = 0; iCP <= cChars+1; iCP++)
2624 {
2625 fTrailing = FALSE;
2626 icChars = cChars;
2627 icGlyphs = cGlyphs;
2628 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2629 winetest_ok(hr == S_OK, "ScriptCPtoX: should return S_OK not %08x\n", hr);
2630 winetest_ok(piX == offsets[iCP],
2631 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP], piX);
2632 }
2633
2634 for(iCP = 0; iCP <= cChars+1; iCP++)
2635 {
2636 fTrailing = TRUE;
2637 icChars = cChars;
2638 icGlyphs = cGlyphs;
2639 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2640 winetest_ok(hr == S_OK, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr);
2641 winetest_ok(piX == offsets[iCP+1],
2642 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP+1], piX);
2643 }
2644 }
2645
2646 #define test_caret_item_ScriptXtoCP(a,b,c,d,e,f) _test_caret_item_ScriptXtoCP(__LINE__,a,b,c,d,e,f)
2647
2648 static void _test_caret_item_ScriptXtoCP(int line, SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2649 {
2650 int iX, iCP, i;
2651 int icChars, icGlyphs;
2652 int piCP;
2653 int clusterSize;
2654 HRESULT hr;
2655 SCRIPT_VISATTR psva[10];
2656 int piTrailing;
2657 int direction;
2658
2659 memset(psva,0,sizeof(psva));
2660 direction = (psa->fRTL)?-1:+1;
2661
2662 for(iX = -1, i = iCP = 0; i < cChars; i++)
2663 {
2664 if (offsets[i] != iX)
2665 {
2666 iX = offsets[i];
2667 iCP = i;
2668 }
2669 icChars = cChars;
2670 icGlyphs = cGlyphs;
2671 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2672 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2673 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2674 ok_(__FILE__,line)(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2675 }
2676
2677 for(iX = -2, i = 0; i < cChars; i++)
2678 {
2679 if (offsets[i]+direction != iX)
2680 {
2681 iX = offsets[i] + direction;
2682 iCP = i;
2683 }
2684 icChars = cChars;
2685 icGlyphs = cGlyphs;
2686 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2687 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2688 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2689 ok_(__FILE__,line)(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2690 }
2691
2692 for(clusterSize = 0, iCP = 0, iX = -2, i = 0; i < cChars; i++)
2693 {
2694 clusterSize++;
2695 if (offsets[i] != offsets[i+1])
2696 {
2697 iX = offsets[i+1]-direction;
2698 icChars = cChars;
2699 icGlyphs = cGlyphs;
2700 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2701 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2702 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2703 ok_(__FILE__,line)(piTrailing == clusterSize, "ScriptXtoCP trailing: iX=%d should return piTrailing=%d not %d\n", iX, clusterSize, piTrailing);
2704 iCP = i+1;
2705 clusterSize = 0;
2706 }
2707 }
2708 }
2709
2710 static void test_ScriptXtoX(void)
2711 /****************************************************************************************
2712 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2713 ****************************************************************************************/
2714 {
2715 WORD pwLogClust[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2716 WORD pwLogClust_RTL[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2717 WORD pwLogClust_2[7] = {4, 3, 3, 2, 1, 0 ,0};
2718 WORD pwLogClust_3[17] = {0, 1, 1, 1, 1, 4, 5, 6, 6, 8, 8, 8, 8, 11, 11, 13, 13};
2719 WORD pwLogClust_3_RTL[17] = {13, 13, 11, 11, 8, 8, 8, 8, 6, 6, 5, 4, 1, 1, 1, 1, 0};
2720 int piAdvance[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2721 int piAdvance_2[5] = {39, 26, 19, 17, 11};
2722 int piAdvance_3[15] = {6, 6, 0, 0, 10, 5, 10, 0, 12, 0, 0, 9, 0, 10, 0};
2723 static const int offsets[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2724 static const int offsets_RTL[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2725 static const int offsets_2[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2726
2727 static const int offsets_3[19] = {0, 6, 6, 6, 6, 12, 22, 27, 27, 37, 37, 37, 37, 49, 49, 58, 58, 68, 68};
2728 static const int offsets_3_RTL[19] = {68, 68, 58, 58, 49, 49, 49, 49, 37, 37, 27, 22, 12, 12, 12, 12, 6, 6};
2729
2730 SCRIPT_VISATTR psva[15];
2731 SCRIPT_ANALYSIS sa;
2732 SCRIPT_ITEM items[2];
2733 int iX, i;
2734 int piCP;
2735 int piTrailing;
2736 HRESULT hr;
2737 static const WCHAR hebrW[] = { 0x5be, 0};
2738 static const WCHAR thaiW[] = { 0xe2a, 0};
2739 const SCRIPT_PROPERTIES **ppScriptProperties;
2740
2741 memset(&sa, 0 , sizeof(SCRIPT_ANALYSIS));
2742 memset(psva, 0, sizeof(psva));
2743
2744 sa.fRTL = FALSE;
2745 hr = ScriptXtoCP(-1, 10, 10, pwLogClust, psva, piAdvance, &sa, &piCP, &piTrailing);
2746 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2747 if (piTrailing)
2748 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2749 else /* win2k3 */
2750 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2751
2752 for (iX = 0; iX <= 7; iX++)
2753 {
2754 WORD clust = 0;
2755 INT advance = 16;
2756 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2757 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing);
2758 }
2759 for (iX = 8; iX < 16; iX++)
2760 {
2761 WORD clust = 0;
2762 INT advance = 16;
2763 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2764 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing);
2765 }
2766
2767 sa.fRTL = TRUE;
2768 hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2769 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2770 if (piTrailing)
2771 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2772 else /* win2k3 */
2773 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2774
2775 iX = 1954;
2776 hr = ScriptXtoCP(1954, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2777 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2778 ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP);
2779 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2780
2781 for (iX = 1; iX <= 8; iX++)
2782 {
2783 WORD clust = 0;
2784 INT advance = 16;
2785 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2786 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing);
2787 }
2788 for (iX = 9; iX < 16; iX++)
2789 {
2790 WORD clust = 0;
2791 INT advance = 16;
2792 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2793 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing);
2794 }
2795
2796 sa.fRTL = FALSE;
2797 test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance);
2798 sa.fRTL = TRUE;
2799 test_item_ScriptXtoX(&sa, 10, 10, offsets_RTL, pwLogClust_RTL, piAdvance);
2800 test_item_ScriptXtoX(&sa, 7, 5, offsets_2, pwLogClust_2, piAdvance_2);
2801
2802 /* Get thai eScript, This will do LTR and fNeedsCaretInfo */
2803 hr = ScriptItemize(thaiW, 1, 2, NULL, NULL, items, &i);
2804 ok(hr == S_OK, "got %08x\n", hr);
2805 ok(i == 1, "got %d\n", i);
2806 sa = items[0].a;
2807
2808 test_caret_item_ScriptXtoCP(&sa, 17, 15, offsets_3, pwLogClust_3, piAdvance_3);
2809
2810 /* Get hebrew eScript, This will do RTL and fNeedsCaretInfo */
2811 hr = ScriptItemize(hebrW, 1, 2, NULL, NULL, items, &i);
2812 ok(hr == S_OK, "got %08x\n", hr);
2813 ok(i == 1, "got %d\n", i);
2814 sa = items[0].a;
2815
2816 /* Note: This behavior CHANGED in uniscribe versions...
2817 * so we only want to test if fNeedsCaretInfo is set */
2818 hr = ScriptGetProperties(&ppScriptProperties, &i);
2819 if (ppScriptProperties[sa.eScript]->fNeedsCaretInfo)
2820 {
2821 test_caret_item_ScriptXtoCP(&sa, 17, 15, offsets_3_RTL, pwLogClust_3_RTL, piAdvance_3);
2822 hr = ScriptXtoCP(0, 17, 15, pwLogClust_3_RTL, psva, piAdvance_3, &sa, &piCP, &piTrailing);
2823 ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2824 ok(piCP == 16, "ScriptXtoCP: iX=0 should return piCP=16 not %d\n", piCP);
2825 ok(piTrailing == 1, "ScriptXtoCP: iX=0 should return piTrailing=1 not %d\n", piTrailing);
2826 }
2827 else
2828 win_skip("Uniscribe version too old to test Hebrew clusters\n");
2829 }
2830
2831 static void test_ScriptString(HDC hdc)
2832 {
2833 /*******************************************************************************************
2834 *
2835 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2836 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2837 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2838 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2839 *
2840 */
2841
2842 HRESULT hr;
2843 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2844 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
2845 int Glyphs = len * 2 + 16;
2846 int Charset;
2847 DWORD Flags = SSA_GLYPHS;
2848 int ReqWidth = 100;
2849 const int Dx[5] = {10, 10, 10, 10, 10};
2850 const BYTE InClass = 0;
2851 SCRIPT_STRING_ANALYSIS ssa = NULL;
2852
2853 int X = 10;
2854 int Y = 100;
2855 UINT Options = 0;
2856 const RECT rc = {0, 50, 100, 100};
2857 int MinSel = 0;
2858 int MaxSel = 0;
2859 BOOL Disabled = FALSE;
2860 const int *clip_len;
2861 int i;
2862 UINT *order;
2863
2864
2865 Charset = -1; /* this flag indicates unicode input */
2866 /* Test without hdc to get E_PENDING */
2867 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
2868 ReqWidth, NULL, NULL, Dx, NULL,
2869 &InClass, &ssa);
2870 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
2871
2872 /* Test that 0 length string returns E_INVALIDARG */
2873 hr = ScriptStringAnalyse( hdc, teststr, 0, Glyphs, Charset, Flags,
2874 ReqWidth, NULL, NULL, Dx, NULL,
2875 &InClass, &ssa);
2876 ok(hr == E_INVALIDARG, "ScriptStringAnalyse should return E_INVALIDARG not %08x\n", hr);
2877
2878 /* test with hdc, this should be a valid test */
2879 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2880 ReqWidth, NULL, NULL, Dx, NULL,
2881 &InClass, &ssa);
2882 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2883 ScriptStringFree(&ssa);
2884
2885 /* test makes sure that a call with a valid pssa still works */
2886 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2887 ReqWidth, NULL, NULL, Dx, NULL,
2888 &InClass, &ssa);
2889 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2890 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
2891
2892 if (hr == S_OK)
2893 {
2894 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
2895 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
2896 }
2897
2898 clip_len = ScriptString_pcOutChars(ssa);
2899 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
2900
2901 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
2902 hr = ScriptStringGetOrder(ssa, order);
2903 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
2904
2905 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
2906 HeapFree(GetProcessHeap(), 0, order);
2907
2908 hr = ScriptStringFree(&ssa);
2909 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2910 }
2911
2912 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
2913 {
2914 /*****************************************************************************************
2915 *
2916 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2917 * nature of the fonts between Windows and Wine, the test is implemented by generating
2918 * values using one one function then checking the output of the second. In this way
2919 * the validity of the functions is established using Windows as a base and confirming
2920 * similar behaviour in wine.
2921 */
2922
2923 HRESULT hr;
2924 static const WCHAR teststr1[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2925 static const BOOL rtl[] = {1, 0, 1, 0, 1, 0, 1, 0};
2926 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
2927 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
2928 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
2929 int Charset = -1; /* unicode */
2930 DWORD Flags = SSA_GLYPHS;
2931 int ReqWidth = 100;
2932 const BYTE InClass = 0;
2933 SCRIPT_STRING_ANALYSIS ssa = NULL;
2934
2935 int Ch; /* Character position in string */
2936 int iTrailing;
2937 int Cp; /* Character position in string */
2938 int X;
2939 int trail,lead;
2940 BOOL fTrailing;
2941
2942 /* Test with hdc, this should be a valid test
2943 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2944 * following character positions to X and X to character position functions.
2945 */
2946
2947 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2948 ReqWidth, NULL, NULL, NULL, NULL,
2949 &InClass, &ssa);
2950 ok(hr == S_OK ||
2951 hr == E_INVALIDARG, /* NT */
2952 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
2953
2954 if (hr == S_OK)
2955 {
2956 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
2957
2958 /*
2959 * Loop to generate character positions to provide starting positions for the
2960 * ScriptStringCPtoX and ScriptStringXtoCP functions
2961 */
2962 for (Cp = 0; Cp < String_len; Cp++)
2963 {
2964 /* The fTrailing flag is used to indicate whether the X being returned is at
2965 * the beginning or the end of the character. What happens here is that if
2966 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2967 * returns the beginning of the next character and iTrailing is FALSE. So for this
2968 * loop iTrailing will be FALSE in both cases.
2969 */
2970 hr = ScriptStringCPtoX(ssa, Cp, TRUE, &trail);
2971 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2972 hr = ScriptStringCPtoX(ssa, Cp, FALSE, &lead);
2973 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2974 if (rtl[Cp])
2975 ok(lead > trail, "Leading values should be after trailing for rtl characters(%i)\n",Cp);
2976 else
2977 ok(lead < trail, "Trailing values should be after leading for ltr characters(%i)\n",Cp);
2978
2979 /* move by 1 pixel so that we are not between 2 characters. That could result in being the lead of a rtl and
2980 at the same time the trail of an ltr */
2981
2982 /* inside the leading edge */
2983 X = lead;
2984 if (rtl[Cp]) X--; else X++;
2985 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2986 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2987 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2988 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2989 iTrailing, X);
2990
2991 /* inside the trailing edge */
2992 X = trail;
2993 if (rtl[Cp]) X++; else X--;
2994 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2995 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2996 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2997 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2998 iTrailing, X);
2999
3000 /* outside the "trailing" edge */
3001 if (Cp < String_len-1)
3002 {
3003 if (rtl[Cp]) X = lead; else X = trail;
3004 X++;
3005 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3006 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3007 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, trail);
3008 if (rtl[Cp+1])
3009 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
3010 iTrailing, X);
3011 else
3012 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
3013 iTrailing, X);
3014 }
3015
3016 /* outside the "leading" edge */
3017 if (Cp != 0)
3018 {
3019 if (rtl[Cp]) X = trail; else X = lead;
3020 X--;
3021 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3022 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3023 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, trail);
3024 if (Cp != 0 && rtl[Cp-1])
3025 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
3026 iTrailing, X);
3027 else
3028 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
3029 iTrailing, X);
3030 }
3031 }
3032
3033 /* Check beyond the leading boundary of the whole string */
3034 if (rtl[0])
3035 {
3036 /* having a leading rtl character seems to confuse usp */
3037 /* this looks to be a windows bug we should emulate */
3038 hr = ScriptStringCPtoX(ssa, 0, TRUE, &X);
3039 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3040 X--;
3041 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3042 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3043 ok(Ch == 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch);
3044 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
3045 iTrailing);
3046 }
3047 else
3048 {
3049 hr = ScriptStringCPtoX(ssa, 0, FALSE, &X);
3050 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3051 X--;
3052 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3053 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3054 ok(Ch == -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch);
3055 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
3056 iTrailing);
3057 }
3058
3059 /* Check beyond the end boundary of the whole string */
3060 if (rtl[String_len-1])
3061 {
3062 hr = ScriptStringCPtoX(ssa, String_len-1, FALSE, &X);
3063 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3064 }
3065 else
3066 {
3067 hr = ScriptStringCPtoX(ssa, String_len-1, TRUE, &X);
3068 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3069 }
3070 X++;
3071 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3072 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3073 ok(Ch == String_len, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len, Ch);
3074 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
3075 iTrailing);
3076
3077 /*
3078 * Cleanup the SSA for the next round of tests
3079 */
3080 hr = ScriptStringFree(&ssa);
3081 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
3082
3083 /*
3084 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
3085 * generate an SSA for the subsequent tests.
3086 */
3087 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
3088 ReqWidth, NULL, NULL, NULL, NULL,
3089 &InClass, &ssa);
3090 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
3091
3092 /*
3093 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
3094 * string length, return E_INVALIDARG. This also invalidates the ssa so a
3095 * ScriptStringFree should also fail.
3096 */
3097 fTrailing = FALSE;
3098 Cp = String_len + 1;
3099 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
3100 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
3101
3102 ScriptStringFree(&ssa);
3103 }
3104 }
3105
3106 static void test_ScriptCacheGetHeight(HDC hdc)
3107 {
3108 HRESULT hr;
3109 SCRIPT_CACHE sc = NULL;
3110 LONG height;
3111
3112 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
3113 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3114
3115 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
3116 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3117
3118 hr = ScriptCacheGetHeight(NULL, &sc, &height);
3119 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
3120
3121 height = 0;
3122
3123 hr = ScriptCacheGetHeight(hdc, &sc, &height);
3124 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3125 ok(height > 0, "expected height > 0\n");
3126
3127 ScriptFreeCache(&sc);
3128 }
3129
3130 static void test_ScriptGetGlyphABCWidth(HDC hdc)
3131 {
3132 HRESULT hr;
3133 SCRIPT_CACHE sc = NULL;
3134 ABC abc;
3135
3136 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
3137 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3138
3139 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
3140 ok(broken(hr == E_PENDING) ||
3141 hr == E_INVALIDARG, /* WIN7 */
3142 "expected E_INVALIDARG, got 0x%08x\n", hr);
3143
3144 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', &abc);
3145 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
3146
3147 if (0) { /* crashes on WinXP */
3148 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
3149 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3150 }
3151
3152 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
3153 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3154
3155 ScriptFreeCache(&sc);
3156 }
3157
3158 static void test_ScriptLayout(void)
3159 {
3160 HRESULT hr;
3161 static const BYTE levels[][10] =
3162 {
3163 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
3164 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
3165 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
3166 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
3167
3168 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
3169 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
3170 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
3171 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
3172 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
3173
3174 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
3175 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
3176
3177 { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
3178 { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 },
3179 { 2, 2, 2, 4, 4, 4, 1, 1, 0, 0 },
3180 { 1, 2, 3, 0, 3, 2, 1, 0, 0, 0 }
3181 };
3182 static const int expect_l2v[][10] =
3183 {
3184 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3185 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3186 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3187 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3188
3189 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
3190 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
3191 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
3192 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3193 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
3194
3195 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3196 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
3197
3198 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
3199 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
3200 { 2, 3, 4, 5, 6, 7, 1, 0, 8, 9},
3201 { 2, 0, 1, 3, 5, 6, 4, 7, 8, 9}
3202 };
3203 static const int expect_v2l[][10] =
3204 {
3205 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3206 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3207 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3208 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3209
3210 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
3211 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
3212 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
3213 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3214 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
3215
3216 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3217 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
3218
3219 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
3220 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
3221 { 7, 6, 0, 1, 2, 3, 4, 5, 8, 9},
3222 { 1, 2, 0, 3, 6, 4, 5, 7, 8, 9}
3223 };
3224
3225 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
3226
3227 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
3228 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3229
3230 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
3231 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3232
3233 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
3234 {
3235 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
3236 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3237
3238 for (j = 0; j < sizeof(levels[i]); j++)
3239 {
3240 ok(expect_v2l[i][j] == vistolog[j],
3241 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
3242 i, j, levels[i][j], j, vistolog[j] );
3243 }
3244
3245 for (j = 0; j < sizeof(levels[i]); j++)
3246 {
3247 ok(expect_l2v[i][j] == logtovis[j],
3248 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
3249 i, j, levels[i][j], j, logtovis[j] );
3250 }
3251 }
3252 }
3253
3254 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
3255 {
3256 HRESULT hr;
3257 SCRIPT_DIGITSUBSTITUTE sds;
3258 SCRIPT_CONTROL sc;
3259 SCRIPT_STATE ss;
3260 LCID lcid_old;
3261
3262 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
3263
3264 memset(&sds, 0, sizeof(sds));
3265 memset(&sc, 0, sizeof(sc));
3266 memset(&ss, 0, sizeof(ss));
3267
3268 lcid_old = GetThreadLocale();
3269 if (!SetThreadLocale(lcid)) return TRUE;
3270
3271 hr = ScriptRecordDigitSubstitution(lcid, &sds);
3272 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
3273
3274 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
3275 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
3276
3277 SetThreadLocale(lcid_old);
3278 return TRUE;
3279 }
3280
3281 static void test_digit_substitution(void)
3282 {
3283 BOOL ret;
3284 unsigned int i;
3285 static const LGRPID groups[] =
3286 {
3287 LGRPID_WESTERN_EUROPE,
3288 LGRPID_CENTRAL_EUROPE,
3289 LGRPID_BALTIC,
3290 LGRPID_GREEK,
3291 LGRPID_CYRILLIC,
3292 LGRPID_TURKISH,
3293 LGRPID_JAPANESE,
3294 LGRPID_KOREAN,
3295 LGRPID_TRADITIONAL_CHINESE,
3296 LGRPID_SIMPLIFIED_CHINESE,
3297 LGRPID_THAI,
3298 LGRPID_HEBREW,
3299 LGRPID_ARABIC,
3300 LGRPID_VIETNAMESE,
3301 LGRPID_INDIC,
3302 LGRPID_GEORGIAN,
3303 LGRPID_ARMENIAN
3304 };
3305 HMODULE hKernel32;
3306 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROCA,LGRPID,DWORD,LONG_PTR);
3307
3308 hKernel32 = GetModuleHandleA("kernel32.dll");
3309 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
3310
3311 if (!pEnumLanguageGroupLocalesA)
3312 {
3313 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
3314 return;
3315 }
3316
3317 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
3318 {
3319 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
3320 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
3321 {
3322 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
3323 break;
3324 }
3325
3326 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
3327 }
3328 }
3329
3330 static void test_ScriptGetProperties(void)
3331 {
3332 const SCRIPT_PROPERTIES **props;
3333 HRESULT hr;
3334 int num;
3335
3336 hr = ScriptGetProperties(NULL, NULL);
3337 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
3338
3339 hr = ScriptGetProperties(NULL, &num);
3340 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3341
3342 hr = ScriptGetProperties(&props, NULL);
3343 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3344
3345 hr = ScriptGetProperties(&props, &num);
3346 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3347 }
3348
3349 static void test_ScriptBreak(void)
3350 {
3351 static const WCHAR test[] = {' ','\r','\n',0};
3352 SCRIPT_ITEM items[4];
3353 SCRIPT_LOGATTR la;
3354 HRESULT hr;
3355
3356 hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL);
3357 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
3358
3359 /*
3360 * This Test crashes pre Vista.
3361
3362 hr = ScriptBreak(test, 1, &items[0].a, NULL);
3363 ok(hr == E_INVALIDARG, "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3364 */
3365
3366 hr = ScriptBreak(test, 0, &items[0].a, &la);
3367 ok(hr == E_FAIL || broken(hr == S_OK), "ScriptBreak should return E_FAIL not %08x\n", hr);
3368
3369 hr = ScriptBreak(test, -1, &items[0].a, &la);
3370 ok(hr == E_INVALIDARG || broken(hr == S_OK), "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3371
3372 memset(&la, 0, sizeof(la));
3373 hr = ScriptBreak(test, 1, &items[0].a, &la);
3374 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3375
3376 ok(!la.fSoftBreak, "fSoftBreak set\n");
3377 ok(la.fWhiteSpace, "fWhiteSpace not set\n");
3378 ok(la.fCharStop, "fCharStop not set\n");
3379 ok(!la.fWordStop, "fWordStop set\n");
3380 ok(!la.fInvalid, "fInvalid set\n");
3381 ok(!la.fReserved, "fReserved set\n");
3382
3383 memset(&la, 0, sizeof(la));
3384 hr = ScriptBreak(test + 1, 1, &items[1].a, &la);
3385 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3386
3387 ok(!la.fSoftBreak, "fSoftBreak set\n");
3388 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3389 ok(la.fCharStop, "fCharStop not set\n");
3390 ok(!la.fWordStop, "fWordStop set\n");
3391 ok(!la.fInvalid, "fInvalid set\n");
3392 ok(!la.fReserved, "fReserved set\n");
3393
3394 memset(&la, 0, sizeof(la));
3395 hr = ScriptBreak(test + 2, 1, &items[2].a, &la);
3396 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3397
3398 ok(!la.fSoftBreak, "fSoftBreak set\n");
3399 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3400 ok(la.fCharStop, "fCharStop not set\n");
3401 ok(!la.fWordStop, "fWordStop set\n");
3402 ok(!la.fInvalid, "fInvalid set\n");
3403 ok(!la.fReserved, "fReserved set\n");
3404 }
3405
3406 static void test_newlines(void)
3407 {
3408 static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
3409 static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
3410 static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
3411 static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
3412 static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
3413 SCRIPT_ITEM items[5];
3414 HRESULT hr;
3415 int count;
3416
3417 count = 0;
3418 hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
3419 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3420 ok(count == 3, "got %d expected 3\n", count);
3421
3422 count = 0;
3423 hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
3424 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3425 ok(count == 3, "got %d expected 3\n", count);
3426
3427 count = 0;
3428 hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
3429 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3430 ok(count == 4, "got %d expected 4\n", count);
3431
3432 count = 0;
3433 hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
3434 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3435 ok(count == 4, "got %d expected 4\n", count);
3436
3437 count = 0;
3438 hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
3439 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3440 ok(count == 4, "got %d expected 4\n", count);
3441 }
3442
3443 static void test_ScriptGetFontFunctions(HDC hdc)
3444 {
3445 HRESULT hr;
3446 pScriptGetFontScriptTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontScriptTags");
3447 pScriptGetFontLanguageTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontLanguageTags");
3448 pScriptGetFontFeatureTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontFeatureTags");
3449 if (!pScriptGetFontScriptTags || !pScriptGetFontLanguageTags || !pScriptGetFontFeatureTags)
3450 {
3451 win_skip("ScriptGetFontScriptTags,ScriptGetFontLanguageTags or ScriptGetFontFeatureTags not available on this platform\n");
3452 }
3453 else
3454 {
3455 SCRIPT_CACHE sc = NULL;
3456 OPENTYPE_TAG tags[5];
3457 int count = 0;
3458 int outnItems=0;
3459 SCRIPT_ITEM outpItems[15];
3460 SCRIPT_CONTROL Control;
3461 SCRIPT_STATE State;
3462 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
3463
3464 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, NULL);
3465 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3466 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3467 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, &count);
3468 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3469 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3470 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, NULL);
3471 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3472 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3473 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, tags, &count);
3474 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3475 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3476 hr = pScriptGetFontScriptTags(NULL, &sc, NULL, 5, tags, &count);
3477 ok(hr == E_PENDING,"Incorrect return code\n");
3478 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3479 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, &count);
3480 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3481 if (hr == S_OK)
3482 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3483 else if (hr == E_OUTOFMEMORY)
3484 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3485 ok(sc != NULL, "ScriptCache should be initialized\n");
3486
3487 ScriptFreeCache(&sc);
3488 sc = NULL;
3489
3490 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, NULL);
3491 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3492 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3493 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, &count);
3494 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3495 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3496 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, NULL);
3497 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3498 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3499 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, tags, &count);
3500 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3501 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3502 hr = pScriptGetFontLanguageTags(NULL, &sc, NULL, latn_tag, 5, tags, &count);
3503 ok(hr == E_PENDING,"Incorrect return code\n");
3504 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3505 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, &count);
3506 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3507 if (hr == S_OK)
3508 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3509 else if (hr == E_OUTOFMEMORY)
3510 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3511
3512 ScriptFreeCache(&sc);
3513 sc = NULL;
3514
3515 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, NULL);
3516 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3517 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3518 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, &count);
3519 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3520 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3521 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, NULL);
3522 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3523 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3524 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, tags, &count);
3525 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3526 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3527 hr = pScriptGetFontFeatureTags(NULL, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3528 ok(hr == E_PENDING,"Incorrect return code\n");
3529 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3530 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3531 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3532 if (hr == S_OK)
3533 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3534 else if (hr == E_OUTOFMEMORY)
3535 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3536
3537 memset(&Control, 0, sizeof(Control));
3538 memset(&State, 0, sizeof(State));
3539
3540 hr = ScriptItemize(test_phagspa, 10, 15, &Control, &State, outpItems, &outnItems);
3541 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3542 memset(tags,0,sizeof(tags));
3543 hr = pScriptGetFontScriptTags(hdc, &sc, &outpItems[0].a, 5, tags, &count);
3544 ok( hr == USP_E_SCRIPT_NOT_IN_FONT || broken(hr == S_OK), "wrong return code\n");
3545
3546 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, dsrt_tag, 5, tags, &count);
3547 ok( hr == S_OK, "wrong return code\n");
3548 hr = pScriptGetFontLanguageTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 5, tags, &count);
3549 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3550
3551 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, dsrt_tag, 0x0, 5, tags, &count);
3552 ok( hr == S_OK, "wrong return code\n");
3553 hr = pScriptGetFontFeatureTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 0x0, 5, tags, &count);
3554 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3555
3556 ScriptFreeCache(&sc);
3557 }
3558 }
3559
3560 START_TEST(usp10)
3561 {
3562 HWND hwnd;
3563 HDC hdc;
3564 LOGFONTA lf;
3565 HFONT hfont;
3566
3567 unsigned short pwOutGlyphs[256];
3568
3569 /* We need a valid HDC to drive a lot of Script functions which requires the following *
3570 * to set up for the tests. */
3571 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
3572 0, 0, 0, NULL);
3573 assert(hwnd != 0);
3574 ShowWindow(hwnd, SW_SHOW);
3575 UpdateWindow(hwnd);
3576
3577 hdc = GetDC(hwnd); /* We now have a hdc */
3578 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
3579
3580 memset(&lf, 0, sizeof(LOGFONTA));
3581 lstrcpyA(lf.lfFaceName, "Tahoma");
3582 lf.lfHeight = 10;
3583 lf.lfWeight = 3;
3584 lf.lfWidth = 10;
3585
3586 hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
3587 ok(hfont != NULL, "SelectObject failed: %p\n", hfont);
3588
3589 test_ScriptItemize();
3590 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
3591 test_ScriptGetCMap(hdc, pwOutGlyphs);
3592 test_ScriptCacheGetHeight(hdc);
3593 test_ScriptGetGlyphABCWidth(hdc);
3594 test_ScriptShape(hdc);
3595 test_ScriptShapeOpenType(hdc);
3596 test_ScriptPlace(hdc);
3597
3598 test_ScriptGetFontProperties(hdc);
3599 test_ScriptTextOut(hdc);
3600 test_ScriptTextOut2(hdc);
3601 test_ScriptTextOut3(hdc);
3602 test_ScriptXtoX();
3603 test_ScriptString(hdc);
3604 test_ScriptStringXtoCP_CPtoX(hdc);
3605
3606 test_ScriptLayout();
3607 test_digit_substitution();
3608 test_ScriptGetProperties();
3609 test_ScriptBreak();
3610 test_newlines();
3611
3612 test_ScriptGetFontFunctions(hdc);
3613
3614 ReleaseDC(hwnd, hdc);
3615 DestroyWindow(hwnd);
3616 }