usp10: Itemize numbers outside of the basic ascii set in a seperate script.
[wine.git] / dlls / usp10 / tests / usp10.c
blobdffc6a12ab10a89b2d964871cba3e8599584ee68
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[5];
36 int iCharPos;
37 int fRTL;
38 int fLayoutRTL;
39 int uBidiLevel;
40 ULONG scriptTag;
41 BOOL isBroken;
42 int broken_value[5];
43 } itemTest;
45 typedef struct _shapeTest_char {
46 WORD wLogClust;
47 SCRIPT_CHARPROP CharProp;
48 } shapeTest_char;
50 typedef struct _shapeTest_glyph {
51 int Glyph;
52 SCRIPT_GLYPHPROP GlyphProp;
53 } shapeTest_glyph;
55 /* Uniscribe 1.6 calls */
56 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);
58 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);
60 static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
62 static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
63 SCRIPT_CONTROL *Control, SCRIPT_STATE *State,
64 DWORD nItems, const itemTest* items, BOOL nItemsToDo,
65 INT nItemsBroken)
67 HRESULT hr;
68 int x, outnItems;
69 SCRIPT_ITEM outpItems[15];
70 ULONG tags[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
72 if (pScriptItemizeOpenType)
73 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
74 else
75 hr = ScriptItemize(string, cchString, 15, Control, State, outpItems, &outnItems);
77 winetest_ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
78 if (nItemsBroken && broken(nItemsBroken == outnItems))
80 winetest_win_skip("This test broken on this platform\n");
81 return;
83 if (nItemsToDo)
84 todo_wine winetest_ok(outnItems == nItems, "Wrong number of items\n");
85 else
86 winetest_ok(outnItems == nItems, "Wrong number of items\n");
87 for (x = 0; x <= outnItems; x++)
89 if (items[x].isBroken && broken(outpItems[x].iCharPos == items[x].broken_value[0]))
90 winetest_win_skip("This test broken on this platform\n");
91 else if (items[x].todo_flag[0])
92 todo_wine winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos\n",x);
93 else
94 winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos (%i)\n",x,outpItems[x].iCharPos);
96 if (items[x].isBroken && broken(outpItems[x].a.fRTL== items[x].broken_value[1]))
97 winetest_win_skip("This test broken on this platform\n");
98 else if (items[x].todo_flag[1])
99 todo_wine winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL\n",x);
100 else
101 winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL(%i)\n",x,outpItems[x].a.fRTL);
103 if (items[x].isBroken && broken(outpItems[x].a.fLayoutRTL == items[x].broken_value[2]))
104 winetest_win_skip("This test broken on this platform\n");
105 else if (items[x].todo_flag[2])
106 todo_wine winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL\n",x);
107 else
108 winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL(%i)\n",x,outpItems[x].a.fLayoutRTL);
110 if (items[x].isBroken && broken(outpItems[x].a.s.uBidiLevel == items[x].broken_value[3]))
111 winetest_win_skip("This test broken on this platform\n");
112 else if (items[x].todo_flag[3])
113 todo_wine winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel\n",x);
114 else
115 winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel(%i)\n",x,outpItems[x].a.s.uBidiLevel);
116 if (x != outnItems)
117 winetest_ok(outpItems[x].a.eScript != SCRIPT_UNDEFINED, "%i: Undefined script\n",x);
118 if (pScriptItemizeOpenType)
120 if (items[x].todo_flag[4])
121 todo_wine winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
122 else
123 winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
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')
151 static void test_ScriptItemize( void )
153 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
154 static const itemTest t11[2] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1}};
155 static const itemTest t12[2] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
157 static const WCHAR test1b[] = {' ', ' ', ' ', ' ',0};
158 static const itemTest t1b1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
159 static const itemTest t1b2[2] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
161 static const WCHAR test1c[] = {' ', ' ', ' ', '1', '2', ' ',0};
162 static const itemTest t1c1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
163 static const itemTest t1c2[4] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},5,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
165 /* Arabic, English*/
166 static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
167 static const itemTest t21[7] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,0,0,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
168 static const itemTest t22[5] = {{{0,0,0,0,0},0,0,0,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
169 static const itemTest t23[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,1,1,1,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
171 static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
172 static const itemTest t2b1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
173 static const itemTest t2b2[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
174 static const itemTest t2b3[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
176 /* leading space */
177 static const WCHAR test2c[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
178 static const itemTest t2c1[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
179 static const itemTest t2c2[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},1,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
180 static const itemTest t2c3[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,2,0,FALSE},{{0,0,0,0,0},8,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
181 static const itemTest t2c4[3] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
183 /* trailing space */
184 static const WCHAR test2d[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
185 static const itemTest t2d1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
186 static const itemTest t2d2[6] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
187 static const itemTest t2d3[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
188 static const itemTest t2d4[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
190 /* Thai */
191 static const WCHAR test3[] =
192 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
193 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
194 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
195 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
197 static const itemTest t31[2] = {{{0,0,0,0,0},0,0,0,0,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
198 static const itemTest t32[2] = {{{0,0,0,0,0},0,0,0,2,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
200 static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
202 static const itemTest t41[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
203 static const itemTest t42[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,2,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
204 static const itemTest t43[4] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
206 /* Arabic */
207 static const WCHAR test5[] =
208 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
209 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
210 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
211 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
212 static const itemTest t51[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},38,0,0,0,-1,FALSE}};
214 /* Hebrew */
215 static const WCHAR test6[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
216 static const itemTest t61[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
217 static const itemTest t62[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
218 static const itemTest t63[2] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
219 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};
220 static const itemTest t71[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},19,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
221 static const itemTest t72[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},18,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
222 static const itemTest t73[4] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},19,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
223 static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
224 static const itemTest t81[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
226 /* Syriac (Like Arabic )*/
227 static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
228 static const itemTest t91[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
229 static const itemTest t92[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
230 static const itemTest t93[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
232 static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
233 static const itemTest t101[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
235 /* Devanagari */
236 static const WCHAR test11[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
237 static const itemTest t111[2] = {{{0,0,0,0,0},0,0,0,0,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
238 static const itemTest t112[2] = {{{0,0,0,0,0},0,0,0,2,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
240 /* Bengali */
241 static const WCHAR test12[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
242 static const itemTest t121[2] = {{{0,0,0,0,0},0,0,0,0,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
243 static const itemTest t122[2] = {{{0,0,0,0,0},0,0,0,2,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
245 /* Gurmukhi */
246 static const WCHAR test13[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
247 static const itemTest t131[2] = {{{0,0,0,0,0},0,0,0,0,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
248 static const itemTest t132[2] = {{{0,0,0,0,0},0,0,0,2,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
250 /* Gujarati */
251 static const WCHAR test14[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
252 static const itemTest t141[2] = {{{0,0,0,0,0},0,0,0,0,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
253 static const itemTest t142[2] = {{{0,0,0,0,0},0,0,0,2,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
255 /* Oriya */
256 static const WCHAR test15[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
257 static const itemTest t151[2] = {{{0,0,0,0,0},0,0,0,0,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
258 static const itemTest t152[2] = {{{0,0,0,0,0},0,0,0,2,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
260 /* Tamil */
261 static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
262 static const itemTest t161[2] = {{{0,0,0,0,0},0,0,0,0,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
263 static const itemTest t162[2] = {{{0,0,0,0,0},0,0,0,2,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
265 /* Telugu */
266 static const WCHAR test17[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
267 static const itemTest t171[2] = {{{0,0,0,0,0},0,0,0,0,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
268 static const itemTest t172[2] = {{{0,0,0,0,0},0,0,0,2,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
270 /* Kannada */
271 static const WCHAR test18[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
272 static const itemTest t181[2] = {{{0,0,0,0,0},0,0,0,0,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
273 static const itemTest t182[2] = {{{0,0,0,0,0},0,0,0,2,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
275 /* Malayalam */
276 static const WCHAR test19[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
277 static const itemTest t191[2] = {{{0,0,0,0,0},0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
278 static const itemTest t192[2] = {{{0,0,0,0,0},0,0,0,2,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
280 /* Diacritical */
281 static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
282 static const itemTest t201[3] = {{{0,0,0,0,0},0,0,0,0,0x0,FALSE},{{0,0,0,0,0},1,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
283 static const itemTest t202[3] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},1,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
285 static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
286 static const itemTest t211[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
288 /* Latin Punctuation */
289 static const WCHAR test22[] = {'#','$',',','!','\"','*',0};
290 static const itemTest t221[3] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
291 static const itemTest t222[3] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},3,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
292 static const itemTest t223[2] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
294 /* Number 2*/
295 static const WCHAR test23[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
296 static const itemTest t231[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
297 static const itemTest t232[3] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
300 SCRIPT_ITEM items[15];
301 SCRIPT_CONTROL Control;
302 SCRIPT_STATE State;
303 HRESULT hr;
304 HMODULE usp10;
305 int nItems;
307 usp10 = LoadLibraryA("usp10.dll");
308 ok (usp10 != 0,"Unable to LoadLibrary on usp10.dll\n");
309 pScriptItemizeOpenType = (void*)GetProcAddress(usp10, "ScriptItemizeOpenType");
310 pScriptShapeOpenType = (void*)GetProcAddress(usp10, "ScriptShapeOpenType");
311 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
313 memset(&Control, 0, sizeof(Control));
314 memset(&State, 0, sizeof(State));
316 hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
317 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
319 hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
320 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
322 hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
323 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
325 hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
326 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
328 test_items_ok(test1,4,NULL,NULL,1,t11,FALSE,0);
329 test_items_ok(test1b,4,NULL,NULL,1,t1b1,FALSE,0);
330 test_items_ok(test1c,6,NULL,NULL,1,t1c1,FALSE,0);
331 test_items_ok(test2,16,NULL,NULL,6,t21,FALSE,0);
332 test_items_ok(test2b,11,NULL,NULL,4,t2b1,FALSE,0);
333 test_items_ok(test2c,11,NULL,NULL,4,t2c1,FALSE,0);
334 test_items_ok(test2d,11,NULL,NULL,4,t2d1,FALSE,0);
335 test_items_ok(test3,41,NULL,NULL,1,t31,FALSE,0);
336 test_items_ok(test4,12,NULL,NULL,5,t41,FALSE,0);
337 test_items_ok(test5,38,NULL,NULL,1,t51,FALSE,0);
338 test_items_ok(test6,5,NULL,NULL,2,t61,FALSE,0);
339 test_items_ok(test7,29,NULL,NULL,3,t71,FALSE,0);
340 test_items_ok(test8,4,NULL,NULL,1,t81,FALSE,0);
341 test_items_ok(test9,5,NULL,NULL,2,t91,FALSE,0);
342 test_items_ok(test10,4,NULL,NULL,1,t101,FALSE,0);
343 test_items_ok(test11,8,NULL,NULL,1,t111,FALSE,0);
344 test_items_ok(test12,5,NULL,NULL,1,t121,FALSE,0);
345 test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
346 test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
347 test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
348 test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
349 test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
350 test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
351 test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
352 test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
353 test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
354 test_items_ok(test22,6,NULL,NULL,2,t221,FALSE,0);
355 test_items_ok(test23,6,NULL,NULL,2,t231,FALSE,0);
357 State.uBidiLevel = 0;
358 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
359 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
360 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
361 test_items_ok(test2,16,&Control,&State,4,t22,FALSE,0);
362 test_items_ok(test2b,11,&Control,&State,4,t2b1,FALSE,0);
363 test_items_ok(test2c,11,&Control,&State,5,t2c2,FALSE,0);
364 test_items_ok(test2d,11,&Control,&State,5,t2d2,FALSE,0);
365 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
366 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
367 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
368 test_items_ok(test6,5,&Control,&State,2,t61,FALSE,0);
369 test_items_ok(test7,29,&Control,&State,3,t72,FALSE,0);
370 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
371 test_items_ok(test9,5,&Control,&State,2,t91,FALSE,0);
372 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
373 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
374 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
375 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
376 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
377 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
378 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
379 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
380 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
381 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
382 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
383 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
384 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
385 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
387 State.uBidiLevel = 1;
388 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
389 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
390 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
391 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
392 test_items_ok(test2b,11,&Control,&State,4,t2b2,FALSE,0);
393 test_items_ok(test2c,11,&Control,&State,4,t2c3,FALSE,0);
394 test_items_ok(test2d,11,&Control,&State,4,t2d3,FALSE,0);
395 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
396 test_items_ok(test4,12,&Control,&State,4,t42,FALSE,0);
397 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
398 test_items_ok(test6,5,&Control,&State,2,t62,FALSE,0);
399 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
400 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
401 test_items_ok(test9,5,&Control,&State,2,t92,FALSE,0);
402 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
403 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
404 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
405 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
406 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
407 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
408 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
409 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
410 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
411 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
412 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
413 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
414 test_items_ok(test22,6,&Control,&State,2,t222,FALSE,1);
415 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
417 State.uBidiLevel = 1;
418 Control.fMergeNeutralItems = TRUE;
419 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
420 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
421 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
422 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
423 test_items_ok(test2b,11,&Control,&State,2,t2b3,FALSE,4);
424 test_items_ok(test2c,11,&Control,&State,2,t2c4,FALSE,4);
425 test_items_ok(test2d,11,&Control,&State,2,t2d4,FALSE,4);
426 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
427 test_items_ok(test4,12,&Control,&State,3,t43,FALSE,4);
428 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
429 test_items_ok(test6,5,&Control,&State,1,t63,FALSE,2);
430 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
431 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
432 test_items_ok(test9,5,&Control,&State,1,t93,FALSE,2);
433 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
434 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
435 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
436 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
437 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
438 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
439 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
440 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
441 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
442 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
443 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
444 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
445 test_items_ok(test22,6,&Control,&State,1,t223,FALSE,2);
446 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
449 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
450 DWORD cchString, SCRIPT_CONTROL *Control,
451 SCRIPT_STATE *State, DWORD item, DWORD nGlyphs,
452 const shapeTest_char* charItems,
453 const shapeTest_glyph* glyphItems)
455 HRESULT hr;
456 int x, outnItems=0, outnGlyphs=0;
457 SCRIPT_ITEM outpItems[15];
458 SCRIPT_CACHE sc = NULL;
459 WORD *glyphs;
460 WORD *logclust;
461 int maxGlyphs = cchString * 1.5;
462 SCRIPT_GLYPHPROP *glyphProp;
463 SCRIPT_CHARPROP *charProp;
464 ULONG tags[15];
466 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
467 if (hr == USP_E_SCRIPT_NOT_IN_FONT)
469 if (valid > 0)
470 winetest_win_skip("Select font does not support script\n");
471 else
472 winetest_trace("Select font does not support script\n");
473 return;
475 if (valid > 0)
476 winetest_ok(!hr, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
477 else if (hr)
478 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr);
481 if (outnItems <= item)
483 if (valid > 0)
484 winetest_win_skip("Did not get enough items\n");
485 else
486 winetest_trace("Did not get enough items\n");
487 return;
490 logclust = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * cchString);
491 memset(logclust,'a',sizeof(WORD) * cchString);
492 charProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP) * cchString);
493 memset(charProp,'a',sizeof(SCRIPT_CHARPROP) * cchString);
494 glyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * maxGlyphs);
495 memset(glyphs,'a',sizeof(WORD) * cchString);
496 glyphProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP) * maxGlyphs);
497 memset(glyphProp,'a',sizeof(SCRIPT_GLYPHPROP) * cchString);
499 hr = pScriptShapeOpenType(hdc, &sc, &outpItems[item].a, tags[item], 0x00000000, NULL, NULL, 0, string, cchString, maxGlyphs, logclust, charProp, glyphs, glyphProp, &outnGlyphs);
500 if (valid > 0)
501 winetest_ok(hr == S_OK, "ScriptShapeOpenType failed (%x)\n",hr);
502 else if (hr != S_OK)
503 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr);
504 if (FAILED(hr))
505 return;
507 for (x = 0; x < cchString; x++)
509 if (valid > 0)
510 winetest_ok(logclust[x] == charItems[x].wLogClust, "%i: invalid LogClust(%i)\n",x,logclust[x]);
511 else if (logclust[x] != charItems[x].wLogClust)
512 winetest_trace("%i: invalid LogClust(%i)\n",x,logclust[x]);
513 if (valid > 0)
514 winetest_ok(charProp[x].fCanGlyphAlone == charItems[x].CharProp.fCanGlyphAlone, "%i: invalid fCanGlyphAlone\n",x);
515 else if (charProp[x].fCanGlyphAlone != charItems[x].CharProp.fCanGlyphAlone)
516 winetest_trace("%i: invalid fCanGlyphAlone\n",x);
519 if (valid > 0)
520 winetest_ok(nGlyphs == outnGlyphs, "got incorrect number of glyphs (%i)\n",outnGlyphs);
521 else if (nGlyphs != outnGlyphs)
522 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs);
523 for (x = 0; x < outnGlyphs; x++)
525 if (glyphItems[x].Glyph)
527 if (valid > 0)
528 winetest_ok(glyphs[x]!=0, "%i: Glyph not present when it should be\n",x);
529 else if (glyphs[x]==0)
530 winetest_trace("%i: Glyph not present when it should be\n",x);
532 else
534 if (valid > 0)
535 winetest_ok(glyphs[x]==0, "%i: Glyph present when it should not be\n",x);
536 else if (glyphs[x]!=0)
537 winetest_trace("%i: Glyph present when it should not be\n",x);
539 if (valid > 0)
540 winetest_ok(glyphProp[x].sva.uJustification == glyphItems[x].GlyphProp.sva.uJustification, "%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
541 else if (glyphProp[x].sva.uJustification != glyphItems[x].GlyphProp.sva.uJustification)
542 winetest_trace("%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
543 if (valid > 0)
544 winetest_ok(glyphProp[x].sva.fClusterStart == glyphItems[x].GlyphProp.sva.fClusterStart, "%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
545 else if (glyphProp[x].sva.fClusterStart != glyphItems[x].GlyphProp.sva.fClusterStart)
546 winetest_trace("%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
547 if (valid > 0)
548 winetest_ok(glyphProp[x].sva.fDiacritic == glyphItems[x].GlyphProp.sva.fDiacritic, "%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
549 else if (glyphProp[x].sva.fDiacritic != glyphItems[x].GlyphProp.sva.fDiacritic)
550 winetest_trace("%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
551 if (valid > 0)
552 winetest_ok(glyphProp[x].sva.fZeroWidth == glyphItems[x].GlyphProp.sva.fZeroWidth, "%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
553 else if (glyphProp[x].sva.fZeroWidth != glyphItems[x].GlyphProp.sva.fZeroWidth)
554 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
557 HeapFree(GetProcessHeap(),0,logclust);
558 HeapFree(GetProcessHeap(),0,charProp);
559 HeapFree(GetProcessHeap(),0,glyphs);
560 HeapFree(GetProcessHeap(),0,glyphProp);
561 ScriptFreeCache(&sc);
564 #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)
566 #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)
568 typedef struct tagRangeP {
569 BYTE range;
570 LOGFONTA lf;
571 } fontEnumParam;
573 static int CALLBACK enumFontProc( const LOGFONT *lpelfe, const TEXTMETRIC *lpntme,
574 DWORD FontType, LPARAM lParam)
576 NEWTEXTMETRICEX *ntme = (NEWTEXTMETRICEX*)lpntme;
577 fontEnumParam *rp = (fontEnumParam*) lParam;
578 int idx = 0;
579 DWORD i;
580 DWORD mask = 0;
582 if (FontType != TRUETYPE_FONTTYPE)
583 return 1;
585 i = rp->range;
586 while (i > sizeof(DWORD)*8)
588 idx++;
589 i -= (sizeof(DWORD)*8);
591 if (idx > 3)
592 return 0;
594 mask = 1 << i;
596 if (ntme->ntmFontSig.fsUsb[idx] & mask)
598 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONT));
599 return 0;
601 return 1;
604 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
606 int rc = 0;
607 fontEnumParam lParam;
609 lParam.range = range;
610 memset(&lParam.lf,0,sizeof(LOGFONT));
611 *hfont = NULL;
613 if (recommended)
615 lstrcpyA(lParam.lf.lfFaceName, recommended);
616 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
618 *hfont = CreateFontIndirectA(&lParam.lf);
619 if (*hfont)
621 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
622 rc = 1;
627 if (!*hfont)
629 memset(&lParam.lf,0,sizeof(LOGFONT));
630 lParam.lf.lfCharSet = DEFAULT_CHARSET;
632 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
634 *hfont = CreateFontIndirectA(&lParam.lf);
635 if (*hfont)
636 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
640 if (*hfont)
642 WORD glyph = 0;
644 *origFont = SelectObject(hdc,*hfont);
645 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
647 winetest_trace(" Font fails to contain required glyphs\n");
648 SelectObject(hdc,*origFont);
649 DeleteObject(*hfont);
650 *hfont=NULL;
651 rc = 0;
653 else if (!rc)
654 rc = -1;
656 else
657 winetest_trace("Failed to find usable font\n");
659 return rc;
662 #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)
664 static void test_ScriptShapeOpenType(HDC hdc)
666 HRESULT hr;
667 SCRIPT_CACHE sc = NULL;
668 WORD glyphs[4], logclust[4];
669 SCRIPT_GLYPHPROP glyphProp[4];
670 SCRIPT_ITEM items[2];
671 ULONG tags[2];
672 SCRIPT_CONTROL Control;
673 SCRIPT_STATE State;
674 int nb, outnItems;
675 HFONT hfont, hfont_orig;
676 int test_valid;
678 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
679 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
680 static const shapeTest_glyph t1_g[] = {
681 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
682 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
683 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
684 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
686 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
687 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
688 static const shapeTest_glyph t2_g[] = {
689 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
690 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
691 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
692 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
694 /* Hebrew */
695 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
696 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
697 static const shapeTest_glyph hebrew_g[] = {
698 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
699 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
700 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
701 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
703 /* Arabic */
704 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
705 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
706 static const shapeTest_glyph arabic_g[] = {
707 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
708 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
709 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
711 /* Thai */
712 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
713 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}}};
714 static const shapeTest_glyph thai_g[] = {
715 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
716 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
717 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
718 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
719 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
720 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
721 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
722 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
723 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
724 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
726 /* Syriac */
727 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
728 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
729 static const shapeTest_glyph syriac_g[] = {
730 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
731 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
732 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
733 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
734 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
735 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
737 /* Thaana */
738 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
739 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}}};
740 static const shapeTest_glyph thaana_g[] = {
741 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
742 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
743 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
744 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
745 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
746 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
747 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
748 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
749 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
750 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
751 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
752 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
753 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
755 /* Phags-pa */
756 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
757 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}}};
758 static const shapeTest_glyph phagspa_g[] = {
759 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
760 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
761 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
762 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
763 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
764 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
765 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
766 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
767 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
768 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
769 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
771 /* Lao */
772 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
773 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}}};
774 static const shapeTest_glyph lao_g[] = {
775 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
776 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
777 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
778 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
779 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
780 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
781 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
782 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
783 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
785 /* Tibetan */
786 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
787 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}}};
788 static const shapeTest_glyph tibetan_g[] = {
789 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
790 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
791 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
792 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
793 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
794 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
795 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
796 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
797 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
798 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
799 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
800 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
801 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
802 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
803 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
804 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
805 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
807 /* Devanagari */
808 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
809 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}}};
810 static const shapeTest_glyph devanagari_g[] = {
811 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
812 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
813 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
814 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
815 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
816 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
817 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
818 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
820 /* Bengali */
821 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
822 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
823 static const shapeTest_glyph bengali_g[] = {
824 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
825 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
826 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
827 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
828 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
830 /* Gurmukhi */
831 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
832 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}}};
833 static const shapeTest_glyph gurmukhi_g[] = {
834 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
835 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
836 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
837 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
838 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
839 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
840 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
842 /* Gujarati */
843 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
844 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}}};
845 static const shapeTest_glyph gujarati_g[] = {
846 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
847 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
848 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
849 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
850 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
851 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
852 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
854 /* Oriya */
855 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
856 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
857 static const shapeTest_glyph oriya_g[] = {
858 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
859 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
860 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
861 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
863 /* Tamil */
864 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
865 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
866 static const shapeTest_glyph tamil_g[] = {
867 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
868 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
869 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
870 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
872 /* Telugu */
873 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
874 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
875 static const shapeTest_glyph telugu_g[] = {
876 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
877 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
878 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
879 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
880 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
881 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
883 /* Malayalam */
884 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
885 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
886 static const shapeTest_glyph malayalam_g[] = {
887 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
888 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
889 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
890 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
891 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
892 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
894 /* Kannada */
895 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
896 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
897 static const shapeTest_glyph kannada_g[] = {
898 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
899 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
900 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
901 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
902 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
904 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
906 win_skip("ScriptShapeOpenType not available on this platform\n");
907 return;
910 memset(&Control, 0 , sizeof(Control));
911 memset(&State, 0 , sizeof(State));
913 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
914 ok(!hr, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
915 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
917 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
918 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
920 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
921 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
923 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
924 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
926 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
927 ok( hr == E_INVALIDARG,
928 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
929 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
930 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
932 ScriptFreeCache(&sc);
934 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
935 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, t2_g);
937 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
938 if (hfont != NULL)
940 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
941 SelectObject(hdc, hfont_orig);
942 DeleteObject(hfont);
945 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
946 if (hfont != NULL)
948 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
949 SelectObject(hdc, hfont_orig);
950 DeleteObject(hfont);
953 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
954 if (hfont != NULL)
956 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
957 SelectObject(hdc, hfont_orig);
958 DeleteObject(hfont);
961 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
962 if (hfont != NULL)
964 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
965 SelectObject(hdc, hfont_orig);
966 DeleteObject(hfont);
969 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
970 if (hfont != NULL)
972 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
973 SelectObject(hdc, hfont_orig);
974 DeleteObject(hfont);
977 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
978 if (hfont != NULL)
980 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
981 SelectObject(hdc, hfont_orig);
982 DeleteObject(hfont);
985 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
986 if (hfont != NULL)
988 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
989 SelectObject(hdc, hfont_orig);
990 DeleteObject(hfont);
993 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
994 if (hfont != NULL)
996 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
997 SelectObject(hdc, hfont_orig);
998 DeleteObject(hfont);
1001 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1002 if (hfont != NULL)
1004 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1005 SelectObject(hdc, hfont_orig);
1006 DeleteObject(hfont);
1009 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1010 if (hfont != NULL)
1012 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1013 SelectObject(hdc, hfont_orig);
1014 DeleteObject(hfont);
1017 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1018 if (hfont != NULL)
1020 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1021 SelectObject(hdc, hfont_orig);
1022 DeleteObject(hfont);
1025 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1026 if (hfont != NULL)
1028 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1029 SelectObject(hdc, hfont_orig);
1030 DeleteObject(hfont);
1033 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1034 if (hfont != NULL)
1036 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1037 SelectObject(hdc, hfont_orig);
1038 DeleteObject(hfont);
1041 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1042 if (hfont != NULL)
1044 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1045 SelectObject(hdc, hfont_orig);
1046 DeleteObject(hfont);
1049 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1050 if (hfont != NULL)
1052 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1053 SelectObject(hdc, hfont_orig);
1054 DeleteObject(hfont);
1057 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1058 if (hfont != NULL)
1060 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1061 SelectObject(hdc, hfont_orig);
1062 DeleteObject(hfont);
1065 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1066 if (hfont != NULL)
1068 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1069 SelectObject(hdc, hfont_orig);
1070 DeleteObject(hfont);
1074 static void test_ScriptShape(HDC hdc)
1076 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1077 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1078 HRESULT hr;
1079 SCRIPT_CACHE sc = NULL;
1080 WORD glyphs[4], glyphs2[4], logclust[4];
1081 SCRIPT_VISATTR attrs[4];
1082 SCRIPT_ITEM items[2];
1083 int nb;
1085 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1086 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
1087 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1089 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1090 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1092 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1093 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1095 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1096 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1098 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1099 ok(broken(hr == S_OK) ||
1100 hr == E_INVALIDARG || /* Vista, W2K8 */
1101 hr == E_FAIL, /* WIN7 */
1102 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1103 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1105 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1106 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1107 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1110 memset(glyphs,-1,sizeof(glyphs));
1111 memset(logclust,-1,sizeof(logclust));
1112 memset(attrs,-1,sizeof(attrs));
1113 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1114 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1115 ok(nb == 4, "Wrong number of items\n");
1116 ok(logclust[0] == 0, "clusters out of order\n");
1117 ok(logclust[1] == 1, "clusters out of order\n");
1118 ok(logclust[2] == 2, "clusters out of order\n");
1119 ok(logclust[3] == 3, "clusters out of order\n");
1120 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1121 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1122 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1123 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1124 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1125 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1126 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1127 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1128 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1129 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1130 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1131 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1132 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1133 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1134 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1135 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1137 ScriptFreeCache(&sc);
1138 sc = NULL;
1140 memset(glyphs2,-1,sizeof(glyphs2));
1141 memset(logclust,-1,sizeof(logclust));
1142 memset(attrs,-1,sizeof(attrs));
1143 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1144 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1145 ok(nb == 4, "Wrong number of items\n");
1146 ok(glyphs2[0] == 0 || broken(glyphs2[0] == 0x80), "Incorrect glyph for 0x202B\n");
1147 ok(glyphs2[3] == 0 || broken(glyphs2[3] == 0x80), "Incorrect glyph for 0x202C\n");
1148 ok(logclust[0] == 0, "clusters out of order\n");
1149 ok(logclust[1] == 1, "clusters out of order\n");
1150 ok(logclust[2] == 2, "clusters out of order\n");
1151 ok(logclust[3] == 3, "clusters out of order\n");
1152 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1153 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1154 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1155 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1156 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1157 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1158 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1159 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1160 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1161 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1162 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1163 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1164 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1165 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1166 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1167 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1169 /* modify LTR to RTL */
1170 items[0].a.fRTL = 1;
1171 memset(glyphs2,-1,sizeof(glyphs2));
1172 memset(logclust,-1,sizeof(logclust));
1173 memset(attrs,-1,sizeof(attrs));
1174 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1175 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1176 ok(nb == 4, "Wrong number of items\n");
1177 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1178 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1179 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1180 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1181 ok(logclust[0] == 3, "clusters out of order\n");
1182 ok(logclust[1] == 2, "clusters out of order\n");
1183 ok(logclust[2] == 1, "clusters out of order\n");
1184 ok(logclust[3] == 0, "clusters out of order\n");
1185 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1186 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1187 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1188 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1189 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1190 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1191 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1192 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1193 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1194 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1195 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1196 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1197 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1198 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1199 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1200 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1202 ScriptFreeCache(&sc);
1205 static void test_ScriptPlace(HDC hdc)
1207 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1208 BOOL ret;
1209 HRESULT hr;
1210 SCRIPT_CACHE sc = NULL;
1211 WORD glyphs[4], logclust[4];
1212 SCRIPT_VISATTR attrs[4];
1213 SCRIPT_ITEM items[2];
1214 int nb, widths[4];
1215 GOFFSET offset[4];
1216 ABC abc[4];
1218 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1219 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
1220 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1222 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1223 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1224 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1226 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1227 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1229 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1230 ok(broken(hr == E_PENDING) ||
1231 hr == E_INVALIDARG || /* Vista, W2K8 */
1232 hr == E_FAIL, /* WIN7 */
1233 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1235 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1236 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1238 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1239 ok(broken(hr == E_PENDING) ||
1240 hr == E_INVALIDARG || /* Vista, W2K8 */
1241 hr == E_FAIL, /* WIN7 */
1242 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1244 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1245 ok(!hr, "ScriptPlace should return S_OK not %08x\n", hr);
1246 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1248 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1249 ok(ret, "ExtTextOutW should return TRUE\n");
1251 ScriptFreeCache(&sc);
1254 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1256 HRESULT hr;
1257 int iMaxProps;
1258 const SCRIPT_PROPERTIES **ppSp;
1260 int cInChars;
1261 int cMaxItems;
1262 SCRIPT_ITEM pItem[255];
1263 int pcItems;
1264 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1265 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1266 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1267 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1268 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1269 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1271 SCRIPT_CACHE psc;
1272 int cChars;
1273 int cMaxGlyphs;
1274 unsigned short pwOutGlyphs1[256];
1275 unsigned short pwOutGlyphs2[256];
1276 unsigned short pwLogClust[256];
1277 SCRIPT_VISATTR psva[256];
1278 int pcGlyphs;
1279 int piAdvance[256];
1280 GOFFSET pGoffset[256];
1281 ABC pABC[256];
1282 int cnt;
1284 /* Start testing usp10 functions */
1285 /* This test determines that the pointer returned by ScriptGetProperties is valid
1286 * by checking a known value in the table */
1287 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1288 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1289 trace("number of script properties %d\n", iMaxProps);
1290 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1291 if (iMaxProps > 0)
1292 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1293 /* ptrs work */
1295 /* This is a valid test that will cause parsing to take place */
1296 cInChars = 5;
1297 cMaxItems = 255;
1298 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1299 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1300 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1301 * returned. */
1302 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1303 if (pcItems > 0)
1304 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1305 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1306 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1308 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1309 * ie. ScriptItemize has succeeded and that pItem has been set */
1310 cInChars = 5;
1311 if (hr == 0) {
1312 psc = NULL; /* must be null on first call */
1313 cChars = cInChars;
1314 cMaxGlyphs = cInChars;
1315 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1316 cMaxGlyphs, &pItem[0].a,
1317 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1318 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1319 cMaxGlyphs = 4;
1320 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1321 cMaxGlyphs, &pItem[0].a,
1322 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1323 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1324 "(%d) but not E_OUTOFMEMORY\n",
1325 cChars, cMaxGlyphs);
1326 cMaxGlyphs = 256;
1327 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1328 cMaxGlyphs, &pItem[0].a,
1329 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1330 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1331 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1332 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1333 if (hr ==0) {
1334 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1335 pGoffset, pABC);
1336 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1337 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1338 pGoffset, pABC);
1339 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1340 for (cnt=0; cnt < pcGlyphs; cnt++)
1341 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1344 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1345 * takes place if fNoGlyphIndex is set. */
1347 cInChars = 5;
1348 cMaxItems = 255;
1349 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1350 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1351 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1352 * returned. */
1353 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1354 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1355 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1356 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1357 if (hr == 0) {
1358 cChars = cInChars;
1359 cMaxGlyphs = 256;
1360 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1361 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1362 cMaxGlyphs, &pItem[0].a,
1363 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1364 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1365 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1366 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1367 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1368 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1369 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1370 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1371 if (hr ==0) {
1372 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1373 pGoffset, pABC);
1374 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1377 ScriptFreeCache( &psc);
1378 ok (!psc, "psc is not null after ScriptFreeCache\n");
1382 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1383 cInChars = (sizeof(TestItem3)/2)-1;
1384 cMaxItems = 255;
1385 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1386 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1387 if (hr == 0)
1389 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1390 if (pcItems > 2)
1392 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1393 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1394 pItem[0].iCharPos, pItem[1].iCharPos);
1395 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1396 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1397 pItem[1].iCharPos, pItem[2].iCharPos);
1398 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1399 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1400 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1404 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1405 cInChars = (sizeof(TestItem4)/2)-1;
1406 cMaxItems = 255;
1407 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1408 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1409 if (hr == 0)
1411 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1412 if (pcItems > 4)
1414 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1415 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1416 pItem[0].iCharPos, pItem[1].iCharPos);
1417 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1418 pItem[0].a.s.uBidiLevel);
1419 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1420 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1421 pItem[1].iCharPos, pItem[2].iCharPos);
1422 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1423 pItem[1].a.s.uBidiLevel);
1424 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1425 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1426 pItem[2].iCharPos, pItem[3].iCharPos);
1427 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1428 pItem[2].a.s.uBidiLevel);
1429 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1430 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1431 pItem[3].iCharPos, pItem[4].iCharPos);
1432 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1433 pItem[3].a.s.uBidiLevel);
1434 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1435 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1436 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1441 * This test is for when the first unicode character requires bidi support
1443 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1444 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1445 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1446 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1447 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1448 pItem[0].a.s.uBidiLevel);
1450 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1451 * the pointer to the last char works. Note that windows often needs a greater number of *
1452 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1453 cInChars = (sizeof(TestItem6)/2)-1;
1454 cMaxItems = 4;
1455 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1456 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1460 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1462 HRESULT hr;
1463 SCRIPT_CACHE psc = NULL;
1464 int cInChars;
1465 int cChars;
1466 unsigned short pwOutGlyphs2[256];
1467 unsigned short pwOutGlyphs3[256];
1468 DWORD dwFlags;
1469 int cnt;
1471 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1472 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1473 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1474 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1476 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1477 dwFlags = 0;
1478 cInChars = cChars = 5;
1479 /* Some sanity checks for ScriptGetCMap */
1481 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1482 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
1483 "expected E_INVALIDARG, got %08x\n", hr);
1485 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1486 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1487 "expected E_INVALIDARG, got %08x\n", hr);
1489 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1490 psc = NULL;
1491 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1492 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1493 "got %08x\n", hr);
1494 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1496 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1497 psc = NULL;
1498 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1499 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1500 "got %08x\n", hr);
1501 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
1502 ScriptFreeCache( &psc);
1504 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1505 psc = NULL;
1506 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1507 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
1508 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1509 /* Check to see if the results are the same as those returned by ScriptShape */
1510 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1511 ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", hr);
1512 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1513 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
1514 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
1515 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
1517 ScriptFreeCache( &psc);
1518 ok (!psc, "psc is not null after ScriptFreeCache\n");
1520 cInChars = cChars = 4;
1521 hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
1522 ok (hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
1523 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1524 ok(pwOutGlyphs3[0] == 0 || broken(pwOutGlyphs3[0] == 0x80), "Glyph 0 should be default glyph\n");
1525 ok(pwOutGlyphs3[3] == 0 || broken(pwOutGlyphs3[0] == 0x80), "Glyph 0 should be default glyph\n");
1528 cInChars = cChars = 9;
1529 hr = ScriptGetCMap(hdc, &psc, TestItem3b, cInChars, dwFlags, pwOutGlyphs2);
1530 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1531 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1533 cInChars = cChars = 9;
1534 dwFlags = SGCM_RTL;
1535 hr = ScriptGetCMap(hdc, &psc, TestItem3, cInChars, dwFlags, pwOutGlyphs3);
1536 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1537 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1538 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "glyph incorrectly altered\n");
1539 ok(pwOutGlyphs3[1] == pwOutGlyphs2[1], "glyph incorreclty altered\n");
1540 ok(pwOutGlyphs3[2] == pwOutGlyphs2[2], "glyph incorreclty altered\n");
1541 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "glyph incorreclty altered\n");
1542 ok(pwOutGlyphs3[4] == pwOutGlyphs2[4], "glyph not mirrored correctly\n");
1543 ok(pwOutGlyphs3[5] == pwOutGlyphs2[5], "glyph not mirrored correctly\n");
1544 ok(pwOutGlyphs3[6] == pwOutGlyphs2[6], "glyph not mirrored correctly\n");
1545 ok(pwOutGlyphs3[7] == pwOutGlyphs2[7], "glyph not mirrored correctly\n");
1546 ok(pwOutGlyphs3[8] == pwOutGlyphs2[8], "glyph not mirrored correctly\n");
1548 ScriptFreeCache( &psc);
1549 ok (!psc, "psc is not null after ScriptFreeCache\n");
1552 static void test_ScriptGetFontProperties(HDC hdc)
1554 HRESULT hr;
1555 SCRIPT_CACHE psc,old_psc;
1556 SCRIPT_FONTPROPERTIES sfp;
1558 /* Some sanity checks for ScriptGetFontProperties */
1560 hr = ScriptGetFontProperties(NULL,NULL,NULL);
1561 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1563 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
1564 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1566 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1567 psc = NULL;
1568 hr = ScriptGetFontProperties(NULL,&psc,NULL);
1569 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1570 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1572 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1573 psc = NULL;
1574 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1575 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
1576 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1578 hr = ScriptGetFontProperties(hdc,NULL,NULL);
1579 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1581 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
1582 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1584 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1585 psc = NULL;
1586 hr = ScriptGetFontProperties(hdc,&psc,NULL);
1587 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1588 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1590 /* Pass an invalid sfp */
1591 psc = NULL;
1592 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES) - 1;
1593 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1594 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr);
1595 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1596 ScriptFreeCache(&psc);
1597 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1599 /* Give it the correct cBytes, we don't care about what's coming back */
1600 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
1601 psc = NULL;
1602 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1603 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
1604 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1606 /* Save the psc pointer */
1607 old_psc = psc;
1608 /* Now a NULL hdc again */
1609 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1610 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
1611 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
1612 ScriptFreeCache(&psc);
1613 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1616 static void test_ScriptTextOut(HDC hdc)
1618 HRESULT hr;
1620 int cInChars;
1621 int cMaxItems;
1622 SCRIPT_ITEM pItem[255];
1623 int pcItems;
1624 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1626 SCRIPT_CACHE psc;
1627 int cChars;
1628 int cMaxGlyphs;
1629 unsigned short pwOutGlyphs1[256];
1630 WORD pwLogClust[256];
1631 SCRIPT_VISATTR psva[256];
1632 int pcGlyphs;
1633 int piAdvance[256];
1634 GOFFSET pGoffset[256];
1635 ABC pABC[256];
1636 RECT rect;
1637 int piX;
1638 int iCP = 1;
1639 BOOL fTrailing = FALSE;
1640 SCRIPT_LOGATTR *psla;
1641 SCRIPT_LOGATTR sla[256];
1643 /* This is a valid test that will cause parsing to take place */
1644 cInChars = 5;
1645 cMaxItems = 255;
1646 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1647 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1648 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1649 * returned. */
1650 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1651 if (pcItems > 0)
1652 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1653 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1654 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1656 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1657 * ie. ScriptItemize has succeeded and that pItem has been set */
1658 cInChars = 5;
1659 if (hr == 0) {
1660 psc = NULL; /* must be null on first call */
1661 cChars = cInChars;
1662 cMaxGlyphs = 256;
1663 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1664 cMaxGlyphs, &pItem[0].a,
1665 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1666 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1667 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1668 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1669 if (hr ==0) {
1670 /* Note hdc is needed as glyph info is not yet in psc */
1671 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1672 pGoffset, pABC);
1673 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
1674 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
1675 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1677 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
1678 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
1680 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1681 piAdvance, NULL, pGoffset);
1682 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1683 "expected E_INVALIDARG, got %08x\n", hr);
1685 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1686 psc = NULL;
1687 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
1688 NULL, NULL, NULL);
1689 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
1690 "got %08x\n", hr);
1691 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1693 /* hdc is required for this one rather than the usual optional */
1694 psc = NULL;
1695 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1696 piAdvance, NULL, pGoffset);
1697 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
1698 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1700 /* Set that it returns 0 status */
1701 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1702 piAdvance, NULL, pGoffset);
1703 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
1705 /* Test Rect Rgn is acceptable */
1706 rect.top = 10;
1707 rect.bottom = 20;
1708 rect.left = 10;
1709 rect.right = 40;
1710 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1711 piAdvance, NULL, pGoffset);
1712 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
1714 iCP = 1;
1715 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
1716 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
1717 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
1719 psla = (SCRIPT_LOGATTR *)&sla;
1720 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
1721 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
1723 /* Clean up and go */
1724 ScriptFreeCache(&psc);
1725 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1730 static void test_ScriptTextOut2(HDC hdc)
1732 /* Intent is to validate that the HDC passed into ScriptTextOut is
1733 * used instead of the (possibly) invalid cached one
1735 HRESULT hr;
1737 HDC hdc1, hdc2;
1738 int cInChars;
1739 int cMaxItems;
1740 SCRIPT_ITEM pItem[255];
1741 int pcItems;
1742 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1744 SCRIPT_CACHE psc;
1745 int cChars;
1746 int cMaxGlyphs;
1747 unsigned short pwOutGlyphs1[256];
1748 WORD pwLogClust[256];
1749 SCRIPT_VISATTR psva[256];
1750 int pcGlyphs;
1751 int piAdvance[256];
1752 GOFFSET pGoffset[256];
1753 ABC pABC[256];
1755 /* Create an extra DC that will be used until the ScriptTextOut */
1756 hdc1 = CreateCompatibleDC(hdc);
1757 ok (hdc1 != 0, "CreateCompatibleDC failed to create a DC\n");
1758 hdc2 = CreateCompatibleDC(hdc);
1759 ok (hdc2 != 0, "CreateCompatibleDC failed to create a DC\n");
1761 /* This is a valid test that will cause parsing to take place */
1762 cInChars = 5;
1763 cMaxItems = 255;
1764 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1765 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1766 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1767 * returned. */
1768 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1769 if (pcItems > 0)
1770 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1771 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1772 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1774 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1775 * ie. ScriptItemize has succeeded and that pItem has been set */
1776 cInChars = 5;
1777 if (hr == 0) {
1778 psc = NULL; /* must be null on first call */
1779 cChars = cInChars;
1780 cMaxGlyphs = 256;
1781 hr = ScriptShape(hdc2, &psc, TestItem1, cChars,
1782 cMaxGlyphs, &pItem[0].a,
1783 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1784 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1785 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1786 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1787 if (hr ==0) {
1788 /* Note hdc is needed as glyph info is not yet in psc */
1789 hr = ScriptPlace(hdc2, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1790 pGoffset, pABC);
1791 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
1793 /* key part!!! cached dc is being deleted */
1794 hr = DeleteDC(hdc2);
1795 ok(hr == 1, "DeleteDC should return 1 not %08x\n", hr);
1797 /* At this point the cached hdc (hdc2) has been destroyed,
1798 * however, we are passing in a *real* hdc (the original hdc).
1799 * The text should be written to that DC
1801 hr = ScriptTextOut(hdc1, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1802 piAdvance, NULL, pGoffset);
1803 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
1804 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1806 DeleteDC(hdc1);
1808 /* Clean up and go */
1809 ScriptFreeCache(&psc);
1810 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1815 static void test_ScriptTextOut3(HDC hdc)
1817 HRESULT hr;
1819 int cInChars;
1820 int cMaxItems;
1821 SCRIPT_ITEM pItem[255];
1822 int pcItems;
1823 WCHAR TestItem1[] = {' ','\r', 0};
1825 SCRIPT_CACHE psc;
1826 int cChars;
1827 int cMaxGlyphs;
1828 unsigned short pwOutGlyphs1[256];
1829 WORD pwLogClust[256];
1830 SCRIPT_VISATTR psva[256];
1831 int pcGlyphs;
1832 int piAdvance[256];
1833 GOFFSET pGoffset[256];
1834 ABC pABC[256];
1835 RECT rect;
1837 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
1838 cInChars = 2;
1839 cMaxItems = 255;
1840 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1841 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1842 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1843 * returned. */
1844 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1845 if (pcItems > 0)
1846 ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
1847 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1848 pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
1850 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1851 * ie. ScriptItemize has succeeded and that pItem has been set */
1852 cInChars = 2;
1853 if (hr == 0) {
1854 psc = NULL; /* must be null on first call */
1855 cChars = cInChars;
1856 cMaxGlyphs = 256;
1857 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1858 cMaxGlyphs, &pItem[0].a,
1859 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1860 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1861 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1862 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1863 if (hr ==0) {
1864 /* Note hdc is needed as glyph info is not yet in psc */
1865 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1866 pGoffset, pABC);
1867 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
1869 /* Test Rect Rgn is acceptable */
1870 rect.top = 10;
1871 rect.bottom = 20;
1872 rect.left = 10;
1873 rect.right = 40;
1874 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
1875 piAdvance, NULL, pGoffset);
1876 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
1879 /* Clean up and go */
1880 ScriptFreeCache(&psc);
1881 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1885 #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)
1887 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
1889 int iX, iCP;
1890 int icChars, icGlyphs;
1891 int piCP, piX;
1892 HRESULT hr;
1893 SCRIPT_VISATTR psva[10];
1894 int piTrailing;
1895 BOOL fTrailing;
1896 int direction;
1898 memset(psva,0,sizeof(psva));
1899 direction = (psa->fRTL)?-1:+1;
1901 for(iCP = 0; iCP < cChars; iCP++)
1903 iX = offsets[iCP];
1904 icChars = cChars;
1905 icGlyphs = cGlyphs;
1906 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
1907 winetest_ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
1908 winetest_ok(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
1909 winetest_ok(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
1912 for(iCP = 0; iCP < cChars; iCP++)
1914 iX = offsets[iCP]+direction;
1915 icChars = cChars;
1916 icGlyphs = cGlyphs;
1917 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
1918 winetest_ok(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
1919 winetest_ok(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
1920 winetest_ok(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
1923 for(iCP = 0; iCP < cChars; iCP++)
1925 iX = offsets[iCP+1]-direction;
1926 icChars = cChars;
1927 icGlyphs = cGlyphs;
1928 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
1929 winetest_ok(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
1930 winetest_ok(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
1931 winetest_ok(piTrailing == 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
1934 for(iCP = 0; iCP <= cChars+1; iCP++)
1936 fTrailing = FALSE;
1937 icChars = cChars;
1938 icGlyphs = cGlyphs;
1939 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
1940 winetest_ok(hr == S_OK, "ScriptCPtoX: should return S_OK not %08x\n", hr);
1941 winetest_ok(piX == offsets[iCP],
1942 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP], piX);
1945 for(iCP = 0; iCP <= cChars+1; iCP++)
1947 fTrailing = TRUE;
1948 icChars = cChars;
1949 icGlyphs = cGlyphs;
1950 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
1951 winetest_ok(hr == S_OK, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr);
1952 winetest_ok(piX == offsets[iCP+1],
1953 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP+1], piX);
1957 static void test_ScriptXtoX(void)
1958 /****************************************************************************************
1959 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
1960 ****************************************************************************************/
1962 WORD pwLogClust[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
1963 WORD pwLogClust_RTL[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
1964 WORD pwLogClust_2[7] = {4, 3, 3, 2, 1, 0 ,0};
1965 int piAdvance[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
1966 int piAdvance_2[5] = {39, 26, 19, 17, 11};
1967 static const int offsets[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
1968 static const int offsets_RTL[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
1969 static const int offsets_2[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
1970 SCRIPT_VISATTR psva[10];
1971 SCRIPT_ANALYSIS sa;
1972 int iX;
1973 int piCP;
1974 int piTrailing;
1975 HRESULT hr;
1977 memset(&sa, 0 , sizeof(SCRIPT_ANALYSIS));
1978 memset(psva, 0, sizeof(psva));
1980 sa.fRTL = FALSE;
1981 hr = ScriptXtoCP(-1, 10, 10, pwLogClust, psva, piAdvance, &sa, &piCP, &piTrailing);
1982 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
1983 if (piTrailing)
1984 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
1985 else /* win2k3 */
1986 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
1988 for (iX = 0; iX <= 7; iX++)
1990 WORD clust = 0;
1991 INT advance = 16;
1992 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
1993 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing);
1995 for (iX = 8; iX < 16; iX++)
1997 WORD clust = 0;
1998 INT advance = 16;
1999 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2000 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing);
2003 sa.fRTL = TRUE;
2004 hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2005 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2006 if (piTrailing)
2007 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2008 else /* win2k3 */
2009 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2011 iX = 1954;
2012 hr = ScriptXtoCP(1954, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2013 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2014 ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP);
2015 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2017 for (iX = 1; iX <= 8; iX++)
2019 WORD clust = 0;
2020 INT advance = 16;
2021 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2022 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing);
2024 for (iX = 9; iX < 16; iX++)
2026 WORD clust = 0;
2027 INT advance = 16;
2028 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2029 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing);
2032 sa.fRTL = FALSE;
2033 test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance);
2034 sa.fRTL = TRUE;
2035 test_item_ScriptXtoX(&sa, 10, 10, offsets_RTL, pwLogClust_RTL, piAdvance);
2036 test_item_ScriptXtoX(&sa, 7, 5, offsets_2, pwLogClust_2, piAdvance_2);
2039 static void test_ScriptString(HDC hdc)
2041 /*******************************************************************************************
2043 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2044 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2045 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2046 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2050 HRESULT hr;
2051 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2052 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
2053 int Glyphs = len * 2 + 16;
2054 int Charset;
2055 DWORD Flags = SSA_GLYPHS;
2056 int ReqWidth = 100;
2057 const int Dx[5] = {10, 10, 10, 10, 10};
2058 const BYTE InClass = 0;
2059 SCRIPT_STRING_ANALYSIS ssa = NULL;
2061 int X = 10;
2062 int Y = 100;
2063 UINT Options = 0;
2064 const RECT rc = {0, 50, 100, 100};
2065 int MinSel = 0;
2066 int MaxSel = 0;
2067 BOOL Disabled = FALSE;
2068 const int *clip_len;
2069 int i;
2070 UINT *order;
2073 Charset = -1; /* this flag indicates unicode input */
2074 /* Test without hdc to get E_PENDING */
2075 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
2076 ReqWidth, NULL, NULL, Dx, NULL,
2077 &InClass, &ssa);
2078 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
2080 /* test with hdc, this should be a valid test */
2081 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2082 ReqWidth, NULL, NULL, Dx, NULL,
2083 &InClass, &ssa);
2084 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2085 ScriptStringFree(&ssa);
2087 /* test makes sure that a call with a valid pssa still works */
2088 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2089 ReqWidth, NULL, NULL, Dx, NULL,
2090 &InClass, &ssa);
2091 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2092 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
2094 if (hr == S_OK)
2096 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
2097 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
2100 clip_len = ScriptString_pcOutChars(ssa);
2101 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
2103 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
2104 hr = ScriptStringGetOrder(ssa, order);
2105 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
2107 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
2108 HeapFree(GetProcessHeap(), 0, order);
2110 hr = ScriptStringFree(&ssa);
2111 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2114 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
2116 /*****************************************************************************************
2118 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2119 * nature of the fonts between Windows and Wine, the test is implemented by generating
2120 * values using one one function then checking the output of the second. In this way
2121 * the validity of the functions is established using Windows as a base and confirming
2122 * similar behaviour in wine.
2125 HRESULT hr;
2126 static const WCHAR teststr1[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2127 static const BOOL rtl[] = {1, 0, 1, 0, 1, 0, 1, 0};
2128 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
2129 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
2130 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
2131 int Charset = -1; /* unicode */
2132 DWORD Flags = SSA_GLYPHS;
2133 int ReqWidth = 100;
2134 const BYTE InClass = 0;
2135 SCRIPT_STRING_ANALYSIS ssa = NULL;
2137 int Ch; /* Character position in string */
2138 int iTrailing;
2139 int Cp; /* Character position in string */
2140 int X;
2141 int trail,lead;
2142 BOOL fTrailing;
2144 /* Test with hdc, this should be a valid test
2145 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2146 * following character positions to X and X to character position functions.
2149 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2150 ReqWidth, NULL, NULL, NULL, NULL,
2151 &InClass, &ssa);
2152 ok(hr == S_OK ||
2153 hr == E_INVALIDARG, /* NT */
2154 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
2156 if (hr == S_OK)
2158 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
2161 * Loop to generate character positions to provide starting positions for the
2162 * ScriptStringCPtoX and ScriptStringXtoCP functions
2164 for (Cp = 0; Cp < String_len; Cp++)
2166 /* The fTrailing flag is used to indicate whether the X being returned is at
2167 * the beginning or the end of the character. What happens here is that if
2168 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2169 * returns the beginning of the next character and iTrailing is FALSE. So for this
2170 * loop iTrailing will be FALSE in both cases.
2172 hr = ScriptStringCPtoX(ssa, Cp, TRUE, &trail);
2173 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2174 hr = ScriptStringCPtoX(ssa, Cp, FALSE, &lead);
2175 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2176 if (rtl[Cp])
2177 ok(lead > trail, "Leading values should be after trailing for rtl characters(%i)\n",Cp);
2178 else
2179 ok(lead < trail, "Trailing values should be after leading for ltr characters(%i)\n",Cp);
2181 /* move by 1 pixel so that we are not inbetween 2 characters. That could result in being the lead of a rtl and
2182 at the same time the trail of an ltr */
2184 /* inside the leading edge */
2185 X = lead;
2186 if (rtl[Cp]) X--; else X++;
2187 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2188 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2189 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2190 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2191 iTrailing, X);
2193 /* inside the trailing edge */
2194 X = trail;
2195 if (rtl[Cp]) X++; else X--;
2196 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2197 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2198 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2199 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2200 iTrailing, X);
2202 /* outside the "trailing" edge */
2203 if (Cp < String_len-1)
2205 if (rtl[Cp]) X = lead; else X = trail;
2206 X++;
2207 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2208 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2209 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, trail);
2210 if (rtl[Cp+1])
2211 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2212 iTrailing, X);
2213 else
2214 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2215 iTrailing, X);
2218 /* outside the "leading" edge */
2219 if (Cp != 0)
2221 if (rtl[Cp]) X = trail; else X = lead;
2222 X--;
2223 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2224 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2225 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, trail);
2226 if (Cp != 0 && rtl[Cp-1])
2227 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2228 iTrailing, X);
2229 else
2230 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2231 iTrailing, X);
2235 /* Check beyond the leading boundary of the whole string */
2236 if (rtl[0])
2238 /* having a leading rtl character seems to confuse usp */
2239 /* this looks to be a windows bug we should emulate */
2240 hr = ScriptStringCPtoX(ssa, 0, TRUE, &X);
2241 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2242 X--;
2243 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2244 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2245 ok(Ch == 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch);
2246 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
2247 iTrailing);
2249 else
2251 hr = ScriptStringCPtoX(ssa, 0, FALSE, &X);
2252 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2253 X--;
2254 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2255 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2256 ok(Ch == -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch);
2257 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2258 iTrailing);
2261 /* Check beyond the end boundary of the whole string */
2262 if (rtl[String_len-1])
2264 hr = ScriptStringCPtoX(ssa, String_len-1, FALSE, &X);
2265 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2267 else
2269 hr = ScriptStringCPtoX(ssa, String_len-1, TRUE, &X);
2270 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2272 X++;
2273 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2274 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2275 ok(Ch == String_len, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len, Ch);
2276 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
2277 iTrailing);
2280 * Cleanup the SSA for the next round of tests
2282 hr = ScriptStringFree(&ssa);
2283 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2286 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2287 * generate an SSA for the subsequent tests.
2289 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2290 ReqWidth, NULL, NULL, NULL, NULL,
2291 &InClass, &ssa);
2292 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2295 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2296 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2297 * ScriptStringFree should also fail.
2299 fTrailing = FALSE;
2300 Cp = String_len + 1;
2301 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
2302 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
2304 ScriptStringFree(&ssa);
2308 static void test_ScriptCacheGetHeight(HDC hdc)
2310 HRESULT hr;
2311 SCRIPT_CACHE sc = NULL;
2312 LONG height;
2314 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
2315 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2317 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
2318 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2320 hr = ScriptCacheGetHeight(NULL, &sc, &height);
2321 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2323 height = 0;
2325 hr = ScriptCacheGetHeight(hdc, &sc, &height);
2326 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2327 ok(height > 0, "expected height > 0\n");
2329 ScriptFreeCache(&sc);
2332 static void test_ScriptGetGlyphABCWidth(HDC hdc)
2334 HRESULT hr;
2335 SCRIPT_CACHE sc = NULL;
2336 ABC abc;
2338 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
2339 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2341 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
2342 ok(broken(hr == E_PENDING) ||
2343 hr == E_INVALIDARG, /* WIN7 */
2344 "expected E_INVALIDARG, got 0x%08x\n", hr);
2346 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', &abc);
2347 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2349 if (0) { /* crashes on WinXP */
2350 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
2351 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2354 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
2355 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2357 ScriptFreeCache(&sc);
2360 static void test_ScriptLayout(void)
2362 HRESULT hr;
2363 static const BYTE levels[][10] =
2365 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2366 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2367 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2368 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2370 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2371 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2372 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2373 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2374 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2376 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2377 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2379 static const int expect_l2v[][10] =
2381 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2382 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2383 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2384 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2386 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2387 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2388 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2389 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2390 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2392 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2393 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2395 static const int expect_v2l[][10] =
2397 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2398 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2399 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2400 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2402 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2403 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2404 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2405 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2406 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2408 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2409 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2412 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
2414 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
2415 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2417 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
2418 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2420 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
2422 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
2423 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2425 for (j = 0; j < sizeof(levels[i]); j++)
2427 ok(expect_v2l[i][j] == vistolog[j],
2428 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2429 i, j, levels[i][j], j, vistolog[j] );
2432 for (j = 0; j < sizeof(levels[i]); j++)
2434 ok(expect_l2v[i][j] == logtovis[j],
2435 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2436 i, j, levels[i][j], j, logtovis[j] );
2441 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
2443 HRESULT hr;
2444 SCRIPT_DIGITSUBSTITUTE sds;
2445 SCRIPT_CONTROL sc;
2446 SCRIPT_STATE ss;
2447 LCID lcid_old;
2449 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
2451 memset(&sds, 0, sizeof(sds));
2452 memset(&sc, 0, sizeof(sc));
2453 memset(&ss, 0, sizeof(ss));
2455 lcid_old = GetThreadLocale();
2456 if (!SetThreadLocale(lcid)) return TRUE;
2458 hr = ScriptRecordDigitSubstitution(lcid, &sds);
2459 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
2461 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
2462 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
2464 SetThreadLocale(lcid_old);
2465 return TRUE;
2468 static void test_digit_substitution(void)
2470 BOOL ret;
2471 unsigned int i;
2472 static const LGRPID groups[] =
2474 LGRPID_WESTERN_EUROPE,
2475 LGRPID_CENTRAL_EUROPE,
2476 LGRPID_BALTIC,
2477 LGRPID_GREEK,
2478 LGRPID_CYRILLIC,
2479 LGRPID_TURKISH,
2480 LGRPID_JAPANESE,
2481 LGRPID_KOREAN,
2482 LGRPID_TRADITIONAL_CHINESE,
2483 LGRPID_SIMPLIFIED_CHINESE,
2484 LGRPID_THAI,
2485 LGRPID_HEBREW,
2486 LGRPID_ARABIC,
2487 LGRPID_VIETNAMESE,
2488 LGRPID_INDIC,
2489 LGRPID_GEORGIAN,
2490 LGRPID_ARMENIAN
2492 HMODULE hKernel32;
2493 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROCA,LGRPID,DWORD,LONG_PTR);
2495 hKernel32 = GetModuleHandleA("kernel32.dll");
2496 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
2498 if (!pEnumLanguageGroupLocalesA)
2500 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
2501 return;
2504 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
2506 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
2507 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
2509 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
2510 break;
2513 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
2517 static void test_ScriptGetProperties(void)
2519 const SCRIPT_PROPERTIES **props;
2520 HRESULT hr;
2521 int num;
2523 hr = ScriptGetProperties(NULL, NULL);
2524 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
2526 hr = ScriptGetProperties(NULL, &num);
2527 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2529 hr = ScriptGetProperties(&props, NULL);
2530 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2532 hr = ScriptGetProperties(&props, &num);
2533 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2536 static void test_ScriptBreak(void)
2538 static const WCHAR test[] = {' ','\r','\n',0};
2539 SCRIPT_ITEM items[4];
2540 SCRIPT_LOGATTR la;
2541 HRESULT hr;
2543 hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL);
2544 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
2546 memset(&la, 0, sizeof(la));
2547 hr = ScriptBreak(test, 1, &items[0].a, &la);
2548 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
2550 ok(!la.fSoftBreak, "fSoftBreak set\n");
2551 ok(la.fWhiteSpace, "fWhiteSpace not set\n");
2552 ok(la.fCharStop, "fCharStop not set\n");
2553 ok(!la.fWordStop, "fWordStop set\n");
2554 ok(!la.fInvalid, "fInvalid set\n");
2555 ok(!la.fReserved, "fReserved set\n");
2557 memset(&la, 0, sizeof(la));
2558 hr = ScriptBreak(test + 1, 1, &items[1].a, &la);
2559 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
2561 ok(!la.fSoftBreak, "fSoftBreak set\n");
2562 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
2563 ok(la.fCharStop, "fCharStop not set\n");
2564 ok(!la.fWordStop, "fWordStop set\n");
2565 ok(!la.fInvalid, "fInvalid set\n");
2566 ok(!la.fReserved, "fReserved set\n");
2568 memset(&la, 0, sizeof(la));
2569 hr = ScriptBreak(test + 2, 1, &items[2].a, &la);
2570 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
2572 ok(!la.fSoftBreak, "fSoftBreak set\n");
2573 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
2574 ok(la.fCharStop, "fCharStop not set\n");
2575 ok(!la.fWordStop, "fWordStop set\n");
2576 ok(!la.fInvalid, "fInvalid set\n");
2577 ok(!la.fReserved, "fReserved set\n");
2580 static void test_newlines(void)
2582 static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
2583 static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
2584 static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
2585 static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
2586 static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
2587 SCRIPT_ITEM items[5];
2588 HRESULT hr;
2589 int count;
2591 count = 0;
2592 hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
2593 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
2594 ok(count == 3, "got %d expected 3\n", count);
2596 count = 0;
2597 hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
2598 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
2599 ok(count == 3, "got %d expected 3\n", count);
2601 count = 0;
2602 hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
2603 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
2604 ok(count == 4, "got %d expected 4\n", count);
2606 count = 0;
2607 hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
2608 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
2609 ok(count == 4, "got %d expected 4\n", count);
2611 count = 0;
2612 hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
2613 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
2614 ok(count == 4, "got %d expected 4\n", count);
2617 START_TEST(usp10)
2619 HWND hwnd;
2620 HDC hdc;
2621 LOGFONTA lf;
2622 HFONT hfont;
2624 unsigned short pwOutGlyphs[256];
2626 /* We need a valid HDC to drive a lot of Script functions which requires the following *
2627 * to set up for the tests. */
2628 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
2629 0, 0, 0, NULL);
2630 assert(hwnd != 0);
2631 ShowWindow(hwnd, SW_SHOW);
2632 UpdateWindow(hwnd);
2634 hdc = GetDC(hwnd); /* We now have a hdc */
2635 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
2637 memset(&lf, 0, sizeof(LOGFONTA));
2638 lstrcpyA(lf.lfFaceName, "Tahoma");
2639 lf.lfHeight = 10;
2640 lf.lfWeight = 3;
2641 lf.lfWidth = 10;
2643 hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
2644 ok(hfont != NULL, "SelectObject failed: %p\n", hfont);
2646 test_ScriptItemize();
2647 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
2648 test_ScriptGetCMap(hdc, pwOutGlyphs);
2649 test_ScriptCacheGetHeight(hdc);
2650 test_ScriptGetGlyphABCWidth(hdc);
2651 test_ScriptShape(hdc);
2652 test_ScriptShapeOpenType(hdc);
2653 test_ScriptPlace(hdc);
2655 test_ScriptGetFontProperties(hdc);
2656 test_ScriptTextOut(hdc);
2657 test_ScriptTextOut2(hdc);
2658 test_ScriptTextOut3(hdc);
2659 test_ScriptXtoX();
2660 test_ScriptString(hdc);
2661 test_ScriptStringXtoCP_CPtoX(hdc);
2663 test_ScriptLayout();
2664 test_digit_substitution();
2665 test_ScriptGetProperties();
2666 test_ScriptBreak();
2667 test_newlines();
2669 ReleaseDC(hwnd, hdc);
2670 DestroyWindow(hwnd);