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