msi: Name all or none of the formal arguments in function prototypes.
[wine] / dlls / usp10 / tests / usp10.c
1 /*
2  * Tests for usp10 dll
3  *
4  * Copyright 2006 Jeff Latimer
5  * Copyright 2006 Hans Leidekker
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  * Notes:
22  * Uniscribe allows for processing of complex scripts such as joining
23  * and filtering characters and bi-directional text with custom line breaks.
24  */
25
26 #include <assert.h>
27 #include <stdio.h>
28
29 #include <wine/test.h>
30 #include <winbase.h>
31 #include <wingdi.h>
32 #include <winuser.h>
33 #include <winerror.h>
34 #include <winnls.h>
35 #include <usp10.h>
36
37 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
38 {
39     HRESULT         hr;
40     int             iMaxProps;
41     const SCRIPT_PROPERTIES **ppSp;
42
43     int             cInChars;
44     int             cMaxItems;
45     SCRIPT_ITEM     pItem[255];
46     int             pcItems;
47     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
48     WCHAR           TestItem2[] = {'T', 'e', 's', 't', 'b', 0}; 
49     WCHAR           TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0}; 
50     WCHAR           TestItem4[] = {'T', 'e', 's', 't', 'c',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
51     WCHAR           TestItem5[] = {0x0684,'T','e','s','t','c',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0}; 
52
53     SCRIPT_CACHE    psc;
54     int             cChars;
55     int             cMaxGlyphs;
56     unsigned short  pwOutGlyphs1[256];
57     unsigned short  pwOutGlyphs2[256];
58     unsigned short  pwLogClust[256];
59     SCRIPT_VISATTR  psva[256];
60     int             pcGlyphs;
61     int             piAdvance[256];
62     GOFFSET         pGoffset[256];
63     ABC             pABC[256];
64     int             cnt;
65
66     /* Start testing usp10 functions                                                         */
67     /* This test determines that the pointer returned by ScriptGetProperties is valid
68      * by checking a known value in the table                                                */
69     hr = ScriptGetProperties(&ppSp, &iMaxProps);
70     trace("number of script properties %d\n", iMaxProps);
71     ok (iMaxProps > 0, "Number of scripts returned should not be 0\n"); 
72     if  (iMaxProps > 0)
73          ok( ppSp[5]->langid == 9, "Langid[5] not = to 9\n"); /* Check a known value to ensure   */
74                                                               /* ptrs work                       */
75
76
77     /* This set of tests are to check that the various edits in ScriptIemize work           */
78     cInChars = 5;                                        /* Length of test without NULL     */
79     cMaxItems = 1;                                       /* Check threshold value           */
80     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
81     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.  Was %d\n",
82         cMaxItems);
83     cInChars = 5;
84     cMaxItems = 255;
85     hr = ScriptItemize(NULL, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
86     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
87
88     cInChars = 5;
89     cMaxItems = 255;
90     hr = ScriptItemize(TestItem1, 0, cMaxItems, NULL, NULL, pItem, &pcItems);
91     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
92
93     cInChars = 5;
94     cMaxItems = 255;
95     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, NULL, &pcItems);
96     ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
97
98     /* This is a valid test that will cause parsing to take place                             */
99     cInChars = 5;
100     cMaxItems = 255;
101     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
102     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
103     /*  This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
104      *  returned.                                                                             */
105     ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
106     if (pcItems > 0)
107         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
108             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
109             pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
110
111     /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
112      * ie. ScriptItemize has succeeded and that pItem has been set                            */
113     cInChars = 5;
114     cMaxItems = 255;
115     if (hr == 0) {
116         psc = NULL;                                   /* must be null on first call           */
117         cChars = cInChars;
118         cMaxGlyphs = cInChars;
119         hr = ScriptShape(NULL, &psc, TestItem1, cChars,
120                          cMaxGlyphs, &pItem[0].a,
121                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
122         ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
123         cMaxGlyphs = 4;
124         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
125                          cMaxGlyphs, &pItem[0].a,
126                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
127         ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
128                                  "(%d) but not E_OUTOFMEMORY\n",
129                                  cChars, cMaxGlyphs);
130         cMaxGlyphs = 256;
131         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
132                          cMaxGlyphs, &pItem[0].a,
133                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
134         ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
135         ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
136         ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
137         if (hr ==0) {
138             hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
139                              pGoffset, pABC);
140             ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
141             hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
142                              pGoffset, pABC);
143             ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
144             for (cnt=0; cnt < pcGlyphs; cnt++)
145                 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt];                 /* Send to next function */
146         }
147
148         /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation   *
149          * takes place if fNoGlyphIndex is set.                                                     */
150
151         cInChars = 5;
152         cMaxItems = 255;
153         hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
154         ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
155         /*  This test is for the intertrim operation of ScriptItemize where only one SCRIPT_ITEM is *
156          *  returned.                                                                               */
157         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
158                             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
159                              pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
160         /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue                    */
161         if (hr == 0) {
162              cChars = cInChars;
163              cMaxGlyphs = 256;
164              pItem[0].a.fNoGlyphIndex = 1;                /* say no translate                     */
165              hr = ScriptShape(NULL, &psc, TestItem2, cChars,
166                               cMaxGlyphs, &pItem[0].a,
167                               pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
168              ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
169              ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
170              ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
171              ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
172              for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
173              ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
174                            cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
175              if (hr ==0) {
176                  hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
177                                   pGoffset, pABC);
178                  ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
179              }
180         }
181         hr = ScriptFreeCache( &psc);
182         ok (!psc, "psc is not null after ScriptFreeCache\n");
183
184     }
185
186     /* This is a valid test that will cause parsing to take place and create 3 script_items   */
187     cInChars = (sizeof(TestItem3)/2)-1;
188     cMaxItems = 255;
189     hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
190     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
191     if  (hr == 0)
192         {
193         ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
194         if (pcItems > 2)
195         {
196             ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
197                 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
198                 pItem[0].iCharPos, pItem[1].iCharPos);
199             ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
200                 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
201                 pItem[1].iCharPos, pItem[2].iCharPos);
202             ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
203                 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
204                 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
205         }
206         hr = ScriptFreeCache( &psc);
207         ok (!psc, "psc is not null after ScriptFreeCache\n");
208     }
209
210     /* This is a valid test that will cause parsing to take place and create 3 script_items   */
211     cInChars = (sizeof(TestItem4)/2)-1;
212     cMaxItems = 255;
213     hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
214     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
215     if  (hr == 0)
216         {
217         ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
218         if (pcItems > 2)
219         {
220             ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
221                 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
222                 pItem[0].iCharPos, pItem[1].iCharPos);
223             ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
224                 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
225                 pItem[1].iCharPos, pItem[2].iCharPos);
226             ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
227                 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
228                 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
229         }
230         hr = ScriptFreeCache( &psc);
231         ok (!psc, "psc is not null after ScriptFreeCache\n");
232     }
233
234     /*
235      * This test is for when the first unicode character requires bidi support
236      */ 
237     cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
238     hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
239     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
240     ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
241     ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n", 
242                                        pItem[0].a.s.uBidiLevel);
243 }
244
245 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
246 {
247     HRESULT         hr;
248     SCRIPT_CACHE    psc = NULL;
249     int             cInChars;
250     int             cChars;
251     unsigned short  pwOutGlyphs3[256];
252     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
253     DWORD           dwFlags;
254     int             cnt;
255
256     /*  Check to make sure that SCRIPT_CACHE gets allocated ok                     */
257     dwFlags = 0;
258     cInChars = cChars = 5;
259     /* Some sanity checks for ScriptGetCMap */
260
261     hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
262     ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
263                             "expected E_INVALIDARG, got %08x\n", hr);
264
265     hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
266     ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
267                             "expected E_INVALIDARG, got %08x\n", hr);
268
269     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
270     psc = NULL;
271     hr = ScriptGetCMap(NULL, &psc, NULL, 0, 0, NULL);
272     ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0NULL), expected E_PENDING, "
273                          "got %08x\n", hr);
274     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
275
276     /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
277     psc = NULL;
278     hr = ScriptGetCMap(hdc, &psc, NULL, 0, 0, NULL);
279     ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
280                     "got %08x\n", hr);
281     ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
282
283     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
284     psc = NULL;
285     hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
286     ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
287     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
288     /*  Check to see if the results are the same as those returned by ScriptShape  */
289     hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
290     ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", hr);
291     ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
292     for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
293     ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
294                          cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
295         
296     hr = ScriptFreeCache( &psc);
297     ok (!psc, "psc is not null after ScriptFreeCache\n");
298
299 }
300
301 static void test_ScriptGetFontProperties(HDC hdc)
302 {
303     HRESULT         hr;
304     SCRIPT_CACHE    psc,old_psc;
305     SCRIPT_FONTPROPERTIES sfp;
306
307     /* Some sanity checks for ScriptGetFontProperties */
308
309     hr = ScriptGetFontProperties(NULL,NULL,NULL);
310     ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
311
312     hr = ScriptGetFontProperties(NULL,NULL,&sfp);
313     ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
314
315     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
316     psc = NULL;
317     hr = ScriptGetFontProperties(NULL,&psc,NULL);
318     ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
319     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
320
321     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
322     psc = NULL;
323     hr = ScriptGetFontProperties(NULL,&psc,&sfp);
324     ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
325     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
326
327     hr = ScriptGetFontProperties(hdc,NULL,NULL);
328     ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
329
330     hr = ScriptGetFontProperties(hdc,NULL,&sfp);
331     ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
332
333     /* Set psc to NULL, to be able to check if a pointer is returned in psc */
334     psc = NULL;
335     hr = ScriptGetFontProperties(hdc,&psc,NULL);
336     ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
337     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
338
339     /* Pass an uninitialized sfp */
340     psc = NULL;
341     hr = ScriptGetFontProperties(hdc,&psc,&sfp);
342     ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) partly uninitialized, expected E_INVALIDARG, got %08x\n", hr);
343     ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
344     ScriptFreeCache(&psc);
345     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
346
347     /* Give it the correct cBytes, we don't care about what's coming back */
348     sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
349     psc = NULL;
350     hr = ScriptGetFontProperties(hdc,&psc,&sfp);
351     ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
352     ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
353
354     /* Save the psc pointer */
355     old_psc = psc;
356     /* Now a NULL hdc again */
357     hr = ScriptGetFontProperties(NULL,&psc,&sfp);
358     ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
359     ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
360     ScriptFreeCache(&psc);
361     ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
362 }
363
364 static void test_ScriptTextOut(HDC hdc)
365 {
366     HRESULT         hr;
367
368     int             cInChars;
369     int             cMaxItems;
370     SCRIPT_ITEM     pItem[255];
371     int             pcItems;
372     WCHAR           TestItem1[] = {'T', 'e', 's', 't', 'a', 0}; 
373
374     SCRIPT_CACHE    psc;
375     int             cChars;
376     int             cMaxGlyphs;
377     unsigned short  pwOutGlyphs1[256];
378     WORD            pwLogClust[256];
379     SCRIPT_VISATTR  psva[256];
380     int             pcGlyphs;
381     int             piAdvance[256];
382     GOFFSET         pGoffset[256];
383     ABC             pABC[256];
384     RECT            rect;
385     int             piX;
386     int             iCP = 1;
387     BOOL            fTrailing = FALSE;
388     SCRIPT_LOGATTR  *psla;
389     SCRIPT_LOGATTR  sla[256];
390
391     /* This is a valid test that will cause parsing to take place                             */
392     cInChars = 5;
393     cMaxItems = 255;
394     hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
395     ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
396     /*  This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
397      *  returned.                                                                             */
398     ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
399     if (pcItems > 0)
400         ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
401             "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
402             pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
403
404     /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
405      * ie. ScriptItemize has succeeded and that pItem has been set                            */
406     cInChars = 5;
407     cMaxItems = 255;
408     if (hr == 0) {
409         psc = NULL;                                   /* must be null on first call           */
410         cChars = cInChars;
411         cMaxGlyphs = cInChars;
412         cMaxGlyphs = 256;
413         hr = ScriptShape(hdc, &psc, TestItem1, cChars,
414                          cMaxGlyphs, &pItem[0].a,
415                          pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
416         ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
417         ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
418         ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
419         if (hr ==0) {
420             /* Note hdc is needed as glyph info is not yet in psc                  */
421             hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
422                              pGoffset, pABC);
423             ok (hr == 0, "Should return 0 not (%08x)\n", hr);
424             ScriptFreeCache(&psc);              /* Get rid of psc for next test set */
425             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
426
427             hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
428             ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
429
430             hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
431                                piAdvance, NULL, pGoffset);
432             ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
433                                     "expected E_INVALIDARG, got %08x\n", hr);
434
435             /* Set psc to NULL, to be able to check if a pointer is returned in psc */
436             psc = NULL;
437             hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
438                                NULL, NULL, NULL);
439             ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
440                                     "got %08x\n", hr);
441             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
442
443             /* Set psc to NULL, to be able to check if a pointer is returned in psc
444              * hdc is required for this one rather than the usual optional          */
445             psc = NULL;
446             hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
447                                piAdvance, NULL, pGoffset);
448             ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
449             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
450
451             /* Set that is gets a psc and that returns 0 status */
452             hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
453                                piAdvance, NULL, pGoffset);
454             ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
455             ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
456
457             /* Test Rect Rgn is acceptable */
458             rect.top = 10;
459             rect.bottom = 20;
460             rect.left = 10;
461             rect.right = 40;
462             hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
463                                piAdvance, NULL, pGoffset);
464             ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
465             ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
466
467             iCP = 1;
468             hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
469                             (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
470             ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
471
472             psla = (SCRIPT_LOGATTR *)&sla;
473             hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
474             ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
475
476             /* Clean up and go   */
477             ScriptFreeCache(&psc);
478             ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
479         }
480     }
481 }
482
483 static void test_ScriptXtoX(void)
484 /****************************************************************************************
485  *  This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
486  ****************************************************************************************/
487 {
488     int iX, iCP;
489     int cChars;
490     int cGlyphs;
491     WORD pwLogClust[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
492     SCRIPT_VISATTR psva[10];
493     int piAdvance[10] = {200, 190, 210, 180, 170, 204, 189, 195, 212, 203};
494     SCRIPT_ANALYSIS psa;
495     int piCP, piX;
496     int piTrailing;
497     BOOL fTrailing;
498     HRESULT hr;
499
500     iX = -1;
501     cChars = 10;
502     cGlyphs = 10;
503     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
504     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
505     ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
506     ok(piTrailing == TRUE, "Negative iX should return piTrailing=TRUE not %d\n", piTrailing);
507     iX = 1954;
508     cChars = 10;
509     cGlyphs = 10;
510     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
511     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
512     ok(piCP == 10, "Excessive iX should return piCP=10 not %d\n", piCP);
513     ok(piTrailing == FALSE, "Excessive iX should return piTrailing=FALSE not %d\n", piTrailing);
514     iX = 779;
515     cChars = 10;
516     cGlyphs = 10;
517     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
518     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
519     ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
520     ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
521     iX = 780;
522     cChars = 10;
523     cGlyphs = 10;
524     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
525     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
526     ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
527     ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
528     iX = 868;
529     cChars = 10;
530     cGlyphs = 10;
531     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
532     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
533     ok(piCP == 4, "iX=%d should return piCP=4 not %d\n", iX, piCP);
534
535     iX = 0;
536     cChars = 10;
537     cGlyphs = 10;
538     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
539     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
540     ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
541     iX = 195;
542     cChars = 10;
543     cGlyphs = 10;
544     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
545     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
546     ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
547     iX = 196;
548     cChars = 10;
549     cGlyphs = 10;
550     hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
551     ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
552     ok(piCP == 1, "iX=%d should return piCP=1 not %d\n", iX, piCP);
553
554     iCP=5;
555     fTrailing = FALSE;
556     cChars = 10;
557     cGlyphs = 10;
558     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
559     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
560     ok(piX == 976, "iCP=%d should return piX=976 not %d\n", iCP, piX);
561     iCP=5;
562     fTrailing = TRUE;
563     cChars = 10;
564     cGlyphs = 10;
565     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
566     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
567     ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);   
568     iCP=6;
569     fTrailing = FALSE;
570     cChars = 10;
571     cGlyphs = 10;
572     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
573     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
574     ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);
575     iCP=11;
576     fTrailing = FALSE;
577     cChars = 10;
578     cGlyphs = 10;
579     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
580     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
581     ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX);
582     iCP=11;
583     fTrailing = TRUE;
584     cChars = 10;
585     cGlyphs = 10;
586     hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
587     ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
588     ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX); 
589
590 }
591
592 static void test_ScriptString(HDC hdc)
593 {
594 /*******************************************************************************************
595  *
596  * This set of tests are for the string functions of uniscribe.  The ScriptStringAnalyse
597  * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer.  This
598  * memory if freed by ScriptStringFree.  There needs to be a valid hdc for this as
599  * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
600  *
601  */
602
603     HRESULT         hr;
604     WCHAR           teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
605     int             len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
606     int             Glyphs = len * 2 + 16;
607     int             Charset;
608     DWORD           Flags = SSA_GLYPHS;
609     int             ReqWidth = 100;
610     SCRIPT_CONTROL  Control;
611     SCRIPT_STATE    State;
612     const int       Dx[5] = {10, 10, 10, 10, 10};
613     SCRIPT_TABDEF   Tabdef;
614     const BYTE      InClass = 0;
615     SCRIPT_STRING_ANALYSIS ssa = NULL;
616
617     int             X = 10; 
618     int             Y = 100;
619     UINT            Options = 0; 
620     const RECT      rc = {0, 50, 100, 100}; 
621     int             MinSel = 0;
622     int             MaxSel = 0;
623     BOOL            Disabled = FALSE;
624     const int      *clip_len;
625     int            i;
626     UINT           *order;
627
628
629     Charset = -1;     /* this flag indicates unicode input */
630     /* Test without hdc to get E_PENDING */
631     hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
632                              ReqWidth, &Control, &State, Dx, &Tabdef,
633                              &InClass, &ssa);
634     ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
635
636     /* test with hdc, this should be a valid test  */
637     hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
638                               ReqWidth, &Control, &State, Dx, &Tabdef,
639                               &InClass, &ssa);
640     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
641
642     /* test makes sure that a call with a valid pssa still works */
643     hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
644                               ReqWidth, &Control, &State, Dx, &Tabdef,
645                               &InClass, &ssa);
646     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
647     ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
648
649     if (hr == S_OK)
650     {
651         hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
652         ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
653     }
654
655      clip_len = ScriptString_pcOutChars(ssa);
656      ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
657
658      order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
659      hr = ScriptStringGetOrder(ssa, order);
660      ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
661
662      for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
663      HeapFree(GetProcessHeap(), 0, order);
664
665      hr = ScriptStringFree(&ssa);
666      ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
667 }
668
669 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
670 {
671 /*****************************************************************************************
672  *
673  * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions.  Due to the
674  * nature of the fonts between Windows and Wine, the test is implemented by generating
675  * values using one one function then checking the output of the second.  In this way
676  * the validity of the functions is established using Windows as a base and confirming
677  * similar behaviour in wine.
678  */
679
680     HRESULT         hr;
681     WCHAR           teststr1[] = {'T', 'e', 's', 't', 'e', '1', '2', ' ', 'a', '\0'};
682     void            *String = (WCHAR *) &teststr1;      /* ScriptStringAnalysis needs void */
683     int             String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
684     int             Glyphs = String_len * 2 + 16;       /* size of buffer as recommended  */
685     int             Charset = -1;                       /* unicode                        */
686     DWORD           Flags = SSA_GLYPHS;
687     int             ReqWidth = 100;
688     SCRIPT_CONTROL  Control;
689     SCRIPT_STATE    State;
690     SCRIPT_TABDEF   Tabdef;
691     const BYTE      InClass = 0;
692     SCRIPT_STRING_ANALYSIS ssa = NULL;
693
694     int             Ch;                                  /* Character position in string */
695     int             iTrailing;
696     int             Cp;                                  /* Character position in string */
697     int             X;
698     BOOL            fTrailing;
699
700     /* Test with hdc, this should be a valid test
701      * Here we generrate an SCRIPT_STRING_ANALYSIS that will be used as input to the
702      * following character positions to X and X to character position functions.
703      */
704     hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
705                               ReqWidth, &Control, &State, NULL, &Tabdef,
706                               &InClass, &ssa);
707     ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
708     ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
709     if  (hr == 0)
710     {
711         /*
712          * Loop to generate character positions to provide starting positions for the
713          * ScriptStringCPtoX and ScriptStringXtoCP functions
714          */
715         for (Cp = 0; Cp < String_len; Cp++)
716         {
717             /* The fTrailing flag is used to indicate whether the X being returned is at
718              * the beginning or the end of the character. What happens here is that if
719              * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
720              * returns the beginning of the next character and iTrailing is FALSE.  So for this
721              * loop iTrailing will be FALSE in both cases.
722              */
723             fTrailing = FALSE;
724             hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
725             ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
726             hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
727             ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
728             ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
729             ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
730                                   iTrailing, X);
731             fTrailing = TRUE;
732             hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
733             ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
734             hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
735             ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
736
737             /*
738              * Check that character position returned by ScriptStringXtoCP in Ch matches the
739              * one input to ScriptStringCPtoX.  This means that the Cp to X position and back
740              * again works
741              */
742             ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
743             ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
744                                    iTrailing, X);
745         }
746         /*
747          * This test is to check that if the X position is just inside the trailing edge of the
748          * character then iTrailing will indicate the trailing edge, ie. TRUE
749          */
750         fTrailing = TRUE;
751         Cp = 3;
752         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
753         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
754         X--;                                /* put X just inside the trailing edge */
755         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
756         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
757         ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
758         ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n", 
759                                   iTrailing, X);
760
761         /*
762          * This test is to check that if the X position is just outside the trailing edge of the
763          * character then iTrailing will indicate the leading edge, ie. FALSE, and Ch will indicate
764          * the next character, ie. Cp + 1 
765          */
766         fTrailing = TRUE;
767         Cp = 3;
768         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
769         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
770         X++;                                /* put X just outside the trailing edge */
771         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
772         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
773         ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
774         ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n", 
775                                   iTrailing, X);
776
777         /*
778          * This test is to check that if the X position is just outside the leading edge of the
779          * character then iTrailing will indicate the trailing edge, ie. TRUE, and Ch will indicate
780          * the next character down , ie. Cp - 1 
781          */
782         fTrailing = FALSE;
783         Cp = 3;
784         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
785         ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
786         X--;                                /* put X just outside the leading edge */
787         hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
788         ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
789         ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, X);
790         ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n", 
791                                   iTrailing, X);
792
793         /*
794          * Cleanup the the SSA for the next round of tests
795          */
796         hr = ScriptStringFree(&ssa);
797         ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
798
799         /*
800          * Test to see that exceeding the number of chars returns E_INVALIDARG.  First
801          * generate an SSA for the subsequent tests.
802          */
803         hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
804                                   ReqWidth, &Control, &State, NULL, &Tabdef,
805                                   &InClass, &ssa);
806         ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
807
808         /*
809          * When ScriptStringCPtoX is called with a character position Cp that exceeds the
810          * string length, return E_INVALIDARG.  This also invalidates the ssa so a 
811          * ScriptStringFree should also fail.
812          */
813         fTrailing = FALSE;
814         Cp = String_len + 1; 
815         hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
816         ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
817
818         hr = ScriptStringFree(&ssa);
819         /*
820          * ScriptStringCPtoX should free ssa, hence ScriptStringFree should fail
821          */
822         ok(hr == E_INVALIDARG, "ScriptStringFree should return E_INVALIDARG not %08x\n", hr);
823     }
824 }
825
826 static void test_ScriptCacheGetHeight(HDC hdc)
827 {
828     HRESULT hr;
829     SCRIPT_CACHE sc = NULL;
830     LONG height;
831
832     hr = ScriptCacheGetHeight(NULL, NULL, NULL);
833     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
834
835     hr = ScriptCacheGetHeight(NULL, &sc, NULL);
836     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
837
838     hr = ScriptCacheGetHeight(NULL, &sc, &height);
839     ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
840
841     height = 0;
842
843     hr = ScriptCacheGetHeight(hdc, &sc, &height);
844     ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
845
846     ok(height > 0, "expected height > 0\n");
847 }
848
849 static void test_ScriptGetGlyphABCWidth(HDC hdc)
850 {
851     HRESULT hr;
852     SCRIPT_CACHE sc = NULL;
853     ABC abc;
854
855     hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
856     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
857
858     hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
859     ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
860
861     if (0) {    /* crashes on WinXP */
862     hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
863     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
864     }
865
866     hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
867     ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
868 }
869
870 static void test_ScriptLayout(void)
871 {
872     HRESULT hr;
873     static const BYTE levels[][5] =
874     {
875         { 0, 0, 0, 0, 0 },
876         { 1, 1, 1, 1, 1 },
877         { 2, 2, 2, 2, 2 },
878         { 3, 3, 3, 3, 3 },
879     };
880     static const int expect[][5] =
881     {
882         { 0, 1, 2, 3, 4 },
883         { 4, 3, 2, 1, 0 },
884         { 0, 1, 2, 3, 4 },
885         { 4, 3, 2, 1, 0 }
886     };
887     int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
888
889     hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
890     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
891
892     hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
893     ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
894
895     for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
896     {
897         hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
898         ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
899
900         for (j = 0; j < sizeof(levels[i]); j++)
901         {
902             ok(expect[i][j] == vistolog[j],
903                "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
904                i, j, levels[i][j], j, vistolog[j] );
905         }
906
907         for (j = 0; j < sizeof(levels[i]); j++)
908         {
909             ok(expect[i][j] == logtovis[j],
910                "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
911                i, j, levels[i][j], j, logtovis[j] );
912         }
913     }
914 }
915
916 static const struct
917 {
918     LGRPID group;
919     LCID lcid;
920     SCRIPT_DIGITSUBSTITUTE sds;
921     DWORD uDefaultLanguage;
922     DWORD fContextDigits;
923     WORD fDigitSubstitute;
924 }
925 subst_data[] =
926 {
927     { 0x01, 0x00403, { 9, 3, 1, 0 }, 9, 0, 0 },
928     { 0x01, 0x00406, { 9, 6, 1, 0 }, 9, 0, 0 },
929     { 0x01, 0x00407, { 9, 7, 1, 0 }, 9, 0, 0 },
930     { 0x01, 0x00409, { 9, 9, 1, 0 }, 9, 0, 0 },
931     { 0x01, 0x0040a, { 9, 10, 1, 0 }, 9, 0, 0 },
932     { 0x01, 0x0040b, { 9, 11, 1, 0 }, 9, 0, 0 },
933     { 0x01, 0x0040c, { 9, 12, 1, 0 }, 9, 0, 0 },
934     { 0x01, 0x0040f, { 9, 15, 1, 0 }, 9, 0, 0 },
935     { 0x01, 0x00410, { 9, 16, 1, 0 }, 9, 0, 0 },
936     { 0x01, 0x00413, { 9, 19, 1, 0 }, 9, 0, 0 },
937     { 0x01, 0x00414, { 9, 20, 1, 0 }, 9, 0, 0 },
938     { 0x01, 0x00416, { 9, 22, 1, 0 }, 9, 0, 0 },
939     { 0x01, 0x0041d, { 9, 29, 1, 0 }, 9, 0, 0 },
940     { 0x01, 0x00421, { 9, 33, 1, 0 }, 9, 0, 0 },
941     { 0x01, 0x0042d, { 9, 45, 1, 0 }, 9, 0, 0 },
942     { 0x01, 0x00432, { 9, 50, 1, 0 }, 9, 0, 0 },
943     { 0x01, 0x00434, { 9, 52, 1, 0 }, 9, 0, 0 },
944     { 0x01, 0x00435, { 9, 53, 1, 0 }, 9, 0, 0 },
945     { 0x01, 0x00436, { 9, 54, 1, 0 }, 9, 0, 0 },
946     { 0x01, 0x00438, { 9, 56, 1, 0 }, 9, 0, 0 },
947     { 0x01, 0x0043a, { 9, 58, 1, 0 }, 9, 0, 0 },
948     { 0x01, 0x0043b, { 9, 59, 1, 0 }, 9, 0, 0 },
949     { 0x01, 0x0043e, { 9, 62, 1, 0 }, 9, 0, 0 },
950     { 0x01, 0x00441, { 9, 65, 1, 0 }, 9, 0, 0 },
951     { 0x01, 0x00452, { 9, 82, 1, 0 }, 9, 0, 0 },
952     { 0x01, 0x00456, { 9, 86, 1, 0 }, 9, 0, 0 },
953     { 0x01, 0x0046b, { 9, 107, 1, 0 }, 9, 0, 0 },
954     { 0x01, 0x0046c, { 9, 108, 1, 0 }, 9, 0, 0 },
955     { 0x01, 0x00481, { 9, 129, 1, 0 }, 9, 0, 0 },
956     { 0x01, 0x00807, { 9, 7, 1, 0 }, 9, 0, 0 },
957     { 0x01, 0x00809, { 9, 9, 1, 0 }, 9, 0, 0 },
958     { 0x01, 0x0080a, { 9, 10, 1, 0 }, 9, 0, 0 },
959     { 0x01, 0x0080c, { 9, 12, 1, 0 }, 9, 0, 0 },
960     { 0x01, 0x00810, { 9, 16, 1, 0 }, 9, 0, 0 },
961     { 0x01, 0x00813, { 9, 19, 1, 0 }, 9, 0, 0 },
962     { 0x01, 0x00814, { 9, 20, 1, 0 }, 9, 0, 0 },
963     { 0x01, 0x00816, { 9, 22, 1, 0 }, 9, 0, 0 },
964     { 0x01, 0x0081d, { 9, 29, 1, 0 }, 9, 0, 0 },
965     { 0x01, 0x0083b, { 9, 59, 1, 0 }, 9, 0, 0 },
966     { 0x01, 0x0083e, { 9, 62, 1, 0 }, 9, 0, 0 },
967     { 0x01, 0x0086b, { 9, 107, 1, 0 }, 9, 0, 0 },
968     { 0x01, 0x00c07, { 9, 7, 1, 0 }, 9, 0, 0 },
969     { 0x01, 0x00c09, { 9, 9, 1, 0 }, 9, 0, 0 },
970     { 0x01, 0x00c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
971     { 0x01, 0x00c0c, { 9, 12, 1, 0 }, 9, 0, 0 },
972     { 0x01, 0x00c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
973     { 0x01, 0x00c6b, { 9, 107, 1, 0 }, 9, 0, 0 },
974     { 0x01, 0x01007, { 9, 7, 1, 0 }, 9, 0, 0 },
975     { 0x01, 0x01009, { 9, 9, 1, 0 }, 9, 0, 0 },
976     { 0x01, 0x0100a, { 9, 10, 1, 0 }, 9, 0, 0 },
977     { 0x01, 0x0100c, { 9, 12, 1, 0 }, 9, 0, 0 },
978     { 0x01, 0x0103b, { 9, 59, 1, 0 }, 9, 0, 0 },
979     { 0x01, 0x01407, { 9, 7, 1, 0 }, 9, 0, 0 },
980     { 0x01, 0x01409, { 9, 9, 1, 0 }, 9, 0, 0 },
981     { 0x01, 0x0140a, { 9, 10, 1, 0 }, 9, 0, 0 },
982     { 0x01, 0x0140c, { 9, 12, 1, 0 }, 9, 0, 0 },
983     { 0x01, 0x0143b, { 9, 59, 1, 0 }, 9, 0, 0 },
984     { 0x01, 0x01809, { 9, 9, 1, 0 }, 9, 0, 0 },
985     { 0x01, 0x0180a, { 9, 10, 1, 0 }, 9, 0, 0 },
986     { 0x01, 0x0180c, { 9, 12, 1, 0 }, 9, 0, 0 },
987     { 0x01, 0x0183b, { 9, 59, 1, 0 }, 9, 0, 0 },
988     { 0x01, 0x01c09, { 9, 9, 1, 0 }, 9, 0, 0 },
989     { 0x01, 0x01c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
990     { 0x01, 0x01c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
991     { 0x01, 0x02009, { 9, 9, 1, 0 }, 9, 0, 0 },
992     { 0x01, 0x0200a, { 9, 10, 1, 0 }, 9, 0, 0 },
993     { 0x01, 0x0203b, { 9, 59, 1, 0 }, 9, 0, 0 },
994     { 0x01, 0x02409, { 9, 9, 1, 0 }, 9, 0, 0 },
995     { 0x01, 0x0240a, { 9, 10, 1, 0 }, 9, 0, 0 },
996     { 0x01, 0x0243b, { 9, 59, 1, 0 }, 9, 0, 0 },
997     { 0x01, 0x02809, { 9, 9, 1, 0 }, 9, 0, 0 },
998     { 0x01, 0x0280a, { 9, 10, 1, 0 }, 9, 0, 0 },
999     { 0x01, 0x02c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1000     { 0x01, 0x02c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1001     { 0x01, 0x03009, { 9, 9, 1, 0 }, 9, 0, 0 },
1002     { 0x01, 0x0300a, { 9, 10, 1, 0 }, 9, 0, 0 },
1003     { 0x01, 0x03409, { 9, 9, 1, 0 }, 9, 0, 0 },
1004     { 0x01, 0x0340a, { 9, 10, 1, 0 }, 9, 0, 0 },
1005     { 0x01, 0x0380a, { 9, 10, 1, 0 }, 9, 0, 0 },
1006     { 0x01, 0x03c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1007     { 0x01, 0x0400a, { 9, 10, 1, 0 }, 9, 0, 0 },
1008     { 0x01, 0x0440a, { 9, 10, 1, 0 }, 9, 0, 0 },
1009     { 0x01, 0x0480a, { 9, 10, 1, 0 }, 9, 0, 0 },
1010     { 0x01, 0x04c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1011     { 0x01, 0x0500a, { 9, 10, 1, 0 }, 9, 0, 0 },
1012     { 0x01, 0x10407, { 9, 7, 1, 0 }, 9, 0, 0 },
1013     { 0x02, 0x00405, { 9, 5, 1, 0 }, 9, 0, 0 },
1014     { 0x02, 0x0040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1015     { 0x02, 0x00415, { 9, 21, 1, 0 }, 9, 0, 0 },
1016     { 0x02, 0x00418, { 9, 24, 1, 0 }, 9, 0, 0 },
1017     { 0x02, 0x0041a, { 9, 26, 1, 0 }, 9, 0, 0 },
1018     { 0x02, 0x0041b, { 9, 27, 1, 0 }, 9, 0, 0 },
1019     { 0x02, 0x0041c, { 9, 28, 1, 0 }, 9, 0, 0 },
1020     { 0x02, 0x00424, { 9, 36, 1, 0 }, 9, 0, 0 },
1021     { 0x02, 0x0081a, { 9, 26, 1, 0 }, 9, 0, 0 },
1022     { 0x02, 0x0101a, { 9, 26, 1, 0 }, 9, 0, 0 },
1023     { 0x02, 0x0141a, { 9, 26, 1, 0 }, 9, 0, 0 },
1024     { 0x02, 0x0181a, { 9, 26, 1, 0 }, 9, 0, 0 },
1025     { 0x02, 0x1040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1026     { 0x03, 0x00425, { 9, 37, 1, 0 }, 9, 0, 0 },
1027     { 0x03, 0x00426, { 9, 38, 1, 0 }, 9, 0, 0 },
1028     { 0x03, 0x00427, { 9, 39, 1, 0 }, 9, 0, 0 },
1029     { 0x04, 0x00408, { 9, 8, 1, 0 }, 9, 0, 0 },
1030     { 0x05, 0x00402, { 9, 2, 1, 0 }, 9, 0, 0 },
1031     { 0x05, 0x00419, { 9, 25, 1, 0 }, 9, 0, 0 },
1032     { 0x05, 0x00422, { 9, 34, 1, 0 }, 9, 0, 0 },
1033     { 0x05, 0x00423, { 9, 35, 1, 0 }, 9, 0, 0 },
1034     { 0x05, 0x0042f, { 9, 47, 1, 0 }, 9, 0, 0 },
1035     { 0x05, 0x0043f, { 9, 63, 1, 0 }, 9, 0, 0 },
1036     { 0x05, 0x00440, { 9, 64, 1, 0 }, 9, 0, 0 },
1037     { 0x05, 0x00444, { 9, 68, 1, 0 }, 9, 0, 0 },
1038     { 0x05, 0x00450, { 9, 80, 1, 0 }, 9, 0, 0 },
1039     { 0x05, 0x0082c, { 9, 44, 1, 0 }, 9, 0, 0 },
1040     { 0x05, 0x00843, { 9, 67, 1, 0 }, 9, 0, 0 },
1041     { 0x05, 0x00c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1042     { 0x05, 0x01c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1043     { 0x06, 0x0041f, { 9, 31, 1, 0 }, 9, 0, 0 },
1044     { 0x06, 0x0042c, { 9, 44, 1, 0 }, 9, 0, 0 },
1045     { 0x06, 0x00443, { 9, 67, 1, 0 }, 9, 0, 0 },
1046     { 0x07, 0x00411, { 9, 17, 1, 0 }, 9, 0, 0 },
1047     { 0x08, 0x00412, { 9, 18, 1, 0 }, 9, 0, 0 },
1048     { 0x09, 0x00404, { 9, 4, 1, 0 }, 9, 0, 0 },
1049     { 0x09, 0x00c04, { 9, 4, 1, 0 }, 9, 0, 0 },
1050     { 0x09, 0x01404, { 9, 4, 1, 0 }, 9, 0, 0 },
1051     { 0x09, 0x21404, { 9, 4, 1, 0 }, 9, 0, 0 },
1052     { 0x09, 0x30404, { 9, 4, 1, 0 }, 9, 0, 0 },
1053     { 0x0a, 0x00804, { 9, 4, 1, 0 }, 9, 0, 0 },
1054     { 0x0a, 0x01004, { 9, 4, 1, 0 }, 9, 0, 0 },
1055     { 0x0a, 0x20804, { 9, 4, 1, 0 }, 9, 0, 0 },
1056     { 0x0a, 0x21004, { 9, 4, 1, 0 }, 9, 0, 0 },
1057     { 0x0b, 0x0041e, { 9, 30, 1, 0 }, 9, 0, 0 },
1058     { 0x0c, 0x0040d, { 9, 13, 1, 0 }, 9, 0, 0 },
1059     { 0x0d, 0x00401, { 1, 1, 0, 0 }, 9, 0, 0 },
1060     { 0x0d, 0x00420, { 9, 32, 1, 0 }, 9, 0, 0 },
1061     { 0x0d, 0x00429, { 41, 41, 0, 0 }, 9, 0, 0 },
1062     { 0x0d, 0x0045a, { 9, 90, 1, 0 }, 9, 0, 0 },
1063     { 0x0d, 0x00465, { 9, 101, 1, 0 }, 9, 0, 0 },
1064     { 0x0d, 0x00801, { 1, 1, 0, 0 }, 9, 0, 0 },
1065     { 0x0d, 0x00c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1066     { 0x0d, 0x01001, { 1, 1, 0, 0 }, 9, 0, 0 },
1067     { 0x0d, 0x01401, { 1, 1, 0, 0 }, 9, 0, 0 },
1068     { 0x0d, 0x01801, { 1, 1, 0, 0 }, 9, 0, 0 },
1069     { 0x0d, 0x01c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1070     { 0x0d, 0x02001, { 1, 1, 0, 0 }, 9, 0, 0 },
1071     { 0x0d, 0x02401, { 1, 1, 0, 0 }, 9, 0, 0 },
1072     { 0x0d, 0x02801, { 1, 1, 0, 0 }, 9, 0, 0 },
1073     { 0x0d, 0x02c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1074     { 0x0d, 0x03001, { 1, 1, 0, 0 }, 9, 0, 0 },
1075     { 0x0d, 0x03401, { 1, 1, 0, 0 }, 9, 0, 0 },
1076     { 0x0d, 0x03801, { 1, 1, 0, 0 }, 9, 0, 0 },
1077     { 0x0d, 0x03c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1078     { 0x0d, 0x04001, { 1, 1, 0, 0 }, 9, 0, 0 },
1079     { 0x0e, 0x0042a, { 9, 42, 1, 0 }, 9, 0, 0 },
1080     { 0x0f, 0x00439, { 9, 57, 1, 0 }, 9, 0, 0 },
1081     { 0x0f, 0x00446, { 9, 70, 1, 0 }, 9, 0, 0 },
1082     { 0x0f, 0x00447, { 9, 71, 1, 0 }, 9, 0, 0 },
1083     { 0x0f, 0x00449, { 9, 73, 1, 0 }, 9, 0, 0 },
1084     { 0x0f, 0x0044a, { 9, 74, 1, 0 }, 9, 0, 0 },
1085     { 0x0f, 0x0044b, { 9, 75, 1, 0 }, 9, 0, 0 },
1086     { 0x0f, 0x0044e, { 9, 78, 1, 0 }, 9, 0, 0 },
1087     { 0x0f, 0x0044f, { 9, 79, 1, 0 }, 9, 0, 0 },
1088     { 0x0f, 0x00457, { 9, 87, 1, 0 }, 9, 0, 0 },
1089     { 0x10, 0x00437, { 9, 55, 1, 0 }, 9, 0, 0 },
1090     { 0x10, 0x10437, { 9, 55, 1, 0 }, 9, 0, 0 },
1091     { 0x11, 0x0042b, { 9, 43, 1, 0 }, 9, 0, 0 }
1092 };
1093
1094 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
1095 {
1096     HRESULT hr;
1097     SCRIPT_DIGITSUBSTITUTE sds;
1098     SCRIPT_CONTROL sc;
1099     SCRIPT_STATE ss;
1100     LCID lcid_old;
1101     unsigned int i;
1102
1103     if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
1104
1105     memset(&sds, 0, sizeof(sds));
1106     memset(&sc, 0, sizeof(sc));
1107     memset(&ss, 0, sizeof(ss));
1108
1109     lcid_old = GetThreadLocale();
1110     if (!SetThreadLocale(lcid)) return TRUE;
1111
1112     hr = ScriptRecordDigitSubstitution(lcid, &sds);
1113     ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
1114
1115     hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
1116     ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
1117
1118     for (i = 0; i < sizeof(subst_data)/sizeof(subst_data[0]); i++)
1119     {
1120         if (group == subst_data[i].group && lcid == subst_data[i].lcid)
1121         {
1122             ok(!memcmp(&sds, &subst_data[i].sds, sizeof(sds)),
1123                "substitution data does not match\n");
1124
1125             ok(sc.uDefaultLanguage == subst_data[i].uDefaultLanguage,
1126                "sc.uDefaultLanguage does not match\n");
1127             ok(sc.fContextDigits == subst_data[i].fContextDigits,
1128                "sc.fContextDigits does not match\n");
1129             ok(ss.fDigitSubstitute == subst_data[i].fDigitSubstitute,
1130                "ss.fDigitSubstitute does not match\n");
1131         }
1132     }
1133     SetThreadLocale(lcid_old);
1134     return TRUE;
1135 }
1136
1137 static void test_digit_substitution(void)
1138 {
1139     BOOL ret;
1140     unsigned int i;
1141     static const LGRPID groups[] =
1142     {
1143         LGRPID_WESTERN_EUROPE,
1144         LGRPID_CENTRAL_EUROPE,
1145         LGRPID_BALTIC,
1146         LGRPID_GREEK,
1147         LGRPID_CYRILLIC,
1148         LGRPID_TURKISH,
1149         LGRPID_JAPANESE,
1150         LGRPID_KOREAN,
1151         LGRPID_TRADITIONAL_CHINESE,
1152         LGRPID_SIMPLIFIED_CHINESE,
1153         LGRPID_THAI,
1154         LGRPID_HEBREW,
1155         LGRPID_ARABIC,
1156         LGRPID_VIETNAMESE,
1157         LGRPID_INDIC,
1158         LGRPID_GEORGIAN,
1159         LGRPID_ARMENIAN
1160     };
1161     HMODULE hKernel32;
1162     static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROC,LGRPID,DWORD,LONG_PTR);
1163
1164     hKernel32 = GetModuleHandleA("kernel32.dll");
1165     pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
1166
1167     if (!pEnumLanguageGroupLocalesA)
1168     {
1169         trace("EnumLanguageGroupLocalesA not available on this platform\n");
1170         return;
1171     }
1172
1173     for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
1174     {
1175         ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
1176         ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
1177     }
1178 }
1179
1180 static void test_ScriptGetProperties(void)
1181 {
1182     const SCRIPT_PROPERTIES **props;
1183     HRESULT hr;
1184     int num;
1185
1186     hr = ScriptGetProperties(NULL, NULL);
1187     ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
1188
1189     hr = ScriptGetProperties(NULL, &num);
1190     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1191
1192     hr = ScriptGetProperties(&props, NULL);
1193     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1194
1195     hr = ScriptGetProperties(&props, &num);
1196     ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1197 }
1198
1199 START_TEST(usp10)
1200 {
1201     HWND            hwnd;
1202     HDC             hdc;
1203     LOGFONTA        lf;
1204     HFONT           hfont;
1205
1206     unsigned short  pwOutGlyphs[256];
1207
1208     /* We need a valid HDC to drive a lot of Script functions which requires the following    *
1209      * to set up for the tests.                                                               */
1210     hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
1211                            0, 0, 0, NULL);
1212     assert(hwnd != 0);
1213     ShowWindow(hwnd, SW_SHOW);
1214     UpdateWindow(hwnd);
1215
1216     hdc = GetDC(hwnd);                                      /* We now have a hdc             */
1217     ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
1218
1219     memset(&lf, 0, sizeof(HFONT));
1220     lstrcpyA(lf.lfFaceName, "Symbol");
1221     lf.lfHeight = 10;
1222     lf.lfWeight = 3;
1223     lf.lfWidth = 10;
1224
1225     hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
1226
1227     test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
1228     test_ScriptGetCMap(hdc, pwOutGlyphs);
1229     test_ScriptCacheGetHeight(hdc);
1230     test_ScriptGetGlyphABCWidth(hdc);
1231
1232     test_ScriptGetFontProperties(hdc);
1233     test_ScriptTextOut(hdc);
1234     test_ScriptXtoX();
1235     test_ScriptString(hdc);
1236     test_ScriptStringXtoCP_CPtoX(hdc);
1237
1238     test_ScriptLayout();
1239     test_digit_substitution();
1240     test_ScriptGetProperties();
1241
1242     ReleaseDC(hwnd, hdc);
1243     DestroyWindow(hwnd);
1244 }