4 * Copyright 2006 Jeff Latimer
5 * Copyright 2006 Hans Leidekker
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.
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.
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
22 * Uniscribe allows for processing of complex scripts such as joining
23 * and filtering characters and bi-directional text with custom line breaks.
29 #include <wine/test.h>
37 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
41 const SCRIPT_PROPERTIES **ppSp;
45 SCRIPT_ITEM pItem[255];
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};
56 unsigned short pwOutGlyphs1[256];
57 unsigned short pwOutGlyphs2[256];
58 unsigned short pwLogClust[256];
59 SCRIPT_VISATTR psva[256];
62 GOFFSET pGoffset[256];
69 lstrcpyA(lf.lfFaceName, "Symbol");
79 zfont = (HFONT) SelectObject(hdc, CreateFontIndirectA(&lf));
81 /* Start testing usp10 functions */
82 /* This test determines that the pointer returned by ScriptGetProperties is valid
83 * by checking a known value in the table */
84 hr = ScriptGetProperties(&ppSp, &iMaxProps);
85 trace("number of script properties %d\n", iMaxProps);
86 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
88 ok( ppSp[5]->langid == 9, "Langid[5] not = to 9\n"); /* Check a known value to ensure */
92 /* This set of tests are to check that the various edits in ScriptIemize work */
93 cInChars = 5; /* Length of test without NULL */
94 cMaxItems = 1; /* Check threshold value */
95 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
96 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2. Was %d\n",
100 hr = ScriptItemize(NULL, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
101 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
105 hr = ScriptItemize(TestItem1, 0, cMaxItems, NULL, NULL, pItem, &pcItems);
106 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
110 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, NULL, &pcItems);
111 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
113 /* This is a valid test that will cause parsing to take place */
116 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
117 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
118 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
120 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
122 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
123 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
124 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
126 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
127 * ie. ScriptItemize has succeeded and that pItem has been set */
131 psc = NULL; /* must be null on first call */
133 cMaxGlyphs = cInChars;
134 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
135 cMaxGlyphs, &pItem[0].a,
136 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
137 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
139 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
140 cMaxGlyphs, &pItem[0].a,
141 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
142 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
143 "(%d) but not E_OUTOFMEMORY\n",
146 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
147 cMaxGlyphs, &pItem[0].a,
148 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
149 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
150 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
151 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
153 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
155 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
156 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
158 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
159 for (cnt=0; cnt < pcGlyphs; cnt++)
160 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
163 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
164 * takes place if fNoGlyphIndex is set. */
168 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
169 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
170 /* This test is for the intertrim operation of ScriptItemize where only one SCRIPT_ITEM is *
172 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
173 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
174 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
175 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
179 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
180 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
181 cMaxGlyphs, &pItem[0].a,
182 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
183 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
184 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
185 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
186 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
187 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
188 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
189 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
191 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
193 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
196 hr = ScriptFreeCache( &psc);
197 ok (!psc, "psc is not null after ScriptFreeCache\n");
201 /* This is a valid test that will cause parsing to take place and create 3 script_items */
202 cInChars = (sizeof(TestItem3)/2)-1;
204 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
205 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
208 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
211 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
212 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
213 pItem[0].iCharPos, pItem[1].iCharPos);
214 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
215 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
216 pItem[1].iCharPos, pItem[2].iCharPos);
217 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
218 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
219 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
221 hr = ScriptFreeCache( &psc);
222 ok (!psc, "psc is not null after ScriptFreeCache\n");
225 /* This is a valid test that will cause parsing to take place and create 3 script_items */
226 cInChars = (sizeof(TestItem4)/2)-1;
228 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
229 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
232 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
235 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
236 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
237 pItem[0].iCharPos, pItem[1].iCharPos);
238 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
239 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
240 pItem[1].iCharPos, pItem[2].iCharPos);
241 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
242 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
243 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
245 hr = ScriptFreeCache( &psc);
246 ok (!psc, "psc is not null after ScriptFreeCache\n");
250 * This test is for when the first unicode character requires bidi support
252 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
253 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
254 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
255 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
256 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
257 pItem[0].a.s.uBidiLevel);
260 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
263 SCRIPT_CACHE psc = NULL;
266 unsigned short pwOutGlyphs3[256];
267 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
271 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
273 cInChars = cChars = 5;
274 /* Some sanity checks for ScriptGetCMap */
276 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
277 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
278 "expected E_INVALIDARG, got %08x\n", hr);
280 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
281 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
282 "expected E_INVALIDARG, got %08x\n", hr);
284 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
286 hr = ScriptGetCMap(NULL, &psc, NULL, 0, 0, NULL);
287 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0NULL), expected E_PENDING, "
289 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
291 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
293 hr = ScriptGetCMap(hdc, &psc, NULL, 0, 0, NULL);
294 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
296 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
298 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
300 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
301 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
302 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
303 /* Check to see if the results are the same as those returned by ScriptShape */
304 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
305 ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", hr);
306 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
307 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
308 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
309 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
311 hr = ScriptFreeCache( &psc);
312 ok (!psc, "psc is not null after ScriptFreeCache\n");
316 static void test_ScriptGetFontProperties(HDC hdc)
319 SCRIPT_CACHE psc,old_psc;
320 SCRIPT_FONTPROPERTIES sfp;
322 /* Some sanity checks for ScriptGetFontProperties */
324 hr = ScriptGetFontProperties(NULL,NULL,NULL);
325 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
327 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
328 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
330 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
332 hr = ScriptGetFontProperties(NULL,&psc,NULL);
333 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
334 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
336 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
338 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
339 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
340 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
342 hr = ScriptGetFontProperties(hdc,NULL,NULL);
343 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
345 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
346 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
348 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
350 hr = ScriptGetFontProperties(hdc,&psc,NULL);
351 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
352 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
354 /* Pass an uninitialized sfp */
356 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
357 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) partly uninitialized, expected E_INVALIDARG, got %08x\n", hr);
358 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
359 ScriptFreeCache(&psc);
360 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
362 /* Give it the correct cBytes, we don't care about what's coming back */
363 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
365 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
366 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
367 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
369 /* Save the psc pointer */
371 /* Now a NULL hdc again */
372 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
373 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
374 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
375 ScriptFreeCache(&psc);
376 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
379 static void test_ScriptTextOut(HDC hdc)
385 SCRIPT_ITEM pItem[255];
387 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
392 unsigned short pwOutGlyphs1[256];
393 WORD pwLogClust[256];
394 SCRIPT_VISATTR psva[256];
397 GOFFSET pGoffset[256];
402 BOOL fTrailing = FALSE;
403 SCRIPT_LOGATTR *psla;
404 SCRIPT_LOGATTR sla[256];
406 /* This is a valid test that will cause parsing to take place */
409 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
410 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
411 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
413 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
415 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
416 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
417 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
419 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
420 * ie. ScriptItemize has succeeded and that pItem has been set */
424 psc = NULL; /* must be null on first call */
426 cMaxGlyphs = cInChars;
428 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
429 cMaxGlyphs, &pItem[0].a,
430 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
431 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
432 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
433 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
435 /* Note hdc is needed as glyph info is not yet in psc */
436 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
438 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
439 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
440 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
442 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
443 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
445 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
446 piAdvance, NULL, pGoffset);
447 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
448 "expected E_INVALIDARG, got %08x\n", hr);
450 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
452 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
454 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
456 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
458 /* Set psc to NULL, to be able to check if a pointer is returned in psc
459 * hdc is required for this one rather than the usual optional */
461 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
462 piAdvance, NULL, pGoffset);
463 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
464 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
466 /* Set that is gets a psc and that returns 0 status */
467 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
468 piAdvance, NULL, pGoffset);
469 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
470 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
472 /* Test Rect Rgn is acceptable */
477 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
478 piAdvance, NULL, pGoffset);
479 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
480 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
483 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
484 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
485 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
487 psla = (SCRIPT_LOGATTR *)&sla;
488 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
489 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
491 /* Clean up and go */
492 ScriptFreeCache(&psc);
493 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
498 static void test_ScriptXtoX(void)
499 /****************************************************************************************
500 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
501 ****************************************************************************************/
506 WORD pwLogClust[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
507 SCRIPT_VISATTR psva[10];
508 int piAdvance[10] = {200, 190, 210, 180, 170, 204, 189, 195, 212, 203};
518 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
519 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
520 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
521 ok(piTrailing == TRUE, "Negative iX should return piTrailing=TRUE not %d\n", piTrailing);
525 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
526 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
527 ok(piCP == 10, "Excessive iX should return piCP=10 not %d\n", piCP);
528 ok(piTrailing == FALSE, "Excessive iX should return piTrailing=FALSE not %d\n", piTrailing);
532 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
533 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
534 ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
535 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
539 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
540 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
541 ok(piCP == 3, "iX=%d should return piCP=3 not %d\n", iX, piCP);
542 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
546 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
547 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
548 ok(piCP == 4, "iX=%d should return piCP=4 not %d\n", iX, piCP);
553 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
554 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
555 ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
559 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
560 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
561 ok(piCP == 0, "iX=%d should return piCP=0 not %d\n", iX, piCP);
565 hr = ScriptXtoCP(iX, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piCP, &piTrailing);
566 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
567 ok(piCP == 1, "iX=%d should return piCP=1 not %d\n", iX, piCP);
573 hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
574 ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
575 ok(piX == 976, "iCP=%d should return piX=976 not %d\n", iCP, piX);
580 hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
581 ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
582 ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);
587 hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
588 ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
589 ok(piX == 1171, "iCP=%d should return piX=1171 not %d\n", iCP, piX);
594 hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
595 ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
596 ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX);
601 hr = ScriptCPtoX(iCP, fTrailing, cChars, cGlyphs, pwLogClust, psva, piAdvance, &psa, &piX);
602 ok(hr == S_OK, "ScriptCPtoX should return S_OK not %08x\n", hr);
603 ok(piX == 1953, "iCP=%d should return piX=1953 not %d\n", iCP, piX);
607 static void test_ScriptString(HDC hdc)
609 /*******************************************************************************************
611 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
612 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
613 * memory if freed by ScriptStringFree. There needs to be a valid hdc for this as
614 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
619 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
620 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
621 int Glyphs = len * 2 + 16;
623 DWORD Flags = SSA_GLYPHS;
625 SCRIPT_CONTROL Control;
627 const int Dx[5] = {10, 10, 10, 10, 10};
628 SCRIPT_TABDEF Tabdef;
629 const BYTE InClass = 0;
630 SCRIPT_STRING_ANALYSIS ssa = NULL;
635 const RECT rc = {0, 50, 100, 100};
638 BOOL Disabled = FALSE;
643 Charset = -1; /* this flag indicates unicode input */
644 /* Test without hdc to get E_PENDING */
645 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
646 ReqWidth, &Control, &State, Dx, &Tabdef,
648 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
650 /* test with hdc, this should be a valid test */
651 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
652 ReqWidth, &Control, &State, Dx, &Tabdef,
654 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
656 /* test makes sure that a call with a valid pssa still works */
657 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
658 ReqWidth, &Control, &State, Dx, &Tabdef,
660 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
661 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
665 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
666 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
669 clip_len = ScriptString_pcOutChars(ssa);
670 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
672 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
673 hr = ScriptStringGetOrder(ssa, order);
674 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
676 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
677 HeapFree(GetProcessHeap(), 0, order);
679 hr = ScriptStringFree(&ssa);
680 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
683 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
685 /*****************************************************************************************
687 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
688 * nature of the fonts between Windows and Wine, the test is implemented by generating
689 * values using one one function then checking the output of the second. In this way
690 * the validity of the functions is established using Windows as a base and confirming
691 * similar behaviour in wine.
695 WCHAR teststr1[] = {'T', 'e', 's', 't', 'e', '1', '2', ' ', 'a', '\0'};
696 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
697 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
698 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
699 int Charset = -1; /* unicode */
700 DWORD Flags = SSA_GLYPHS;
702 SCRIPT_CONTROL Control;
704 SCRIPT_TABDEF Tabdef;
705 const BYTE InClass = 0;
706 SCRIPT_STRING_ANALYSIS ssa = NULL;
708 int Ch; /* Character position in string */
710 int Cp; /* Character position in string */
717 lstrcpyA(lf.lfFaceName, "Symbol");
722 lf.lfOrientation = 0;
727 lf.lfPitchAndFamily = 0;
729 zfont = (HFONT) SelectObject(hdc, CreateFontIndirectA(&lf));
731 /* Test with hdc, this should be a valid test
732 * Here we generrate an SCRIPT_STRING_ANALYSIS that will be used as input to the
733 * following character positions to X and X to character position functions.
735 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
736 ReqWidth, &Control, &State, NULL, &Tabdef,
738 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
739 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
743 * Loop to generate character positions to provide starting positions for the
744 * ScriptStringCPtoX and ScriptStringXtoCP functions
746 for (Cp = 0; Cp < String_len; Cp++)
748 /* The fTrailing flag is used to indicate whether the X being returned is at
749 * the beginning or the end of the character. What happens here is that if
750 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
751 * returns the beginning of the next character and iTrailing is FALSE. So for this
752 * loop iTrailing will be FALSE in both cases.
755 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
756 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
757 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
758 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
759 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
760 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
763 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
764 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
765 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
766 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
769 * Check that character position returned by ScriptStringXtoCP in Ch matches the
770 * one input to ScriptStringCPtoX. This means that the Cp to X position and back
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",
778 * This test is to check that if the X position is just inside the trailing edge of the
779 * character then iTrailing will indicate the trailing edge, ie. TRUE
783 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
784 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
785 X--; /* put X just inside the trailing edge */
786 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
787 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
788 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, X);
789 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
793 * This test is to check that if the X position is just outside the trailing edge of the
794 * character then iTrailing will indicate the leading edge, ie. FALSE, and Ch will indicate
795 * the next character, ie. Cp + 1
799 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
800 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
801 X++; /* put X just outside the trailing edge */
802 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
803 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
804 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, X);
805 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
809 * This test is to check that if the X position is just outside the leading edge of the
810 * character then iTrailing will indicate the trailing edge, ie. TRUE, and Ch will indicate
811 * the next character down , ie. Cp - 1
815 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
816 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
817 X--; /* put X just outside the leading edge */
818 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
819 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
820 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, X);
821 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
825 * Cleanup the the SSA for the next round of tests
827 hr = ScriptStringFree(&ssa);
828 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
831 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
832 * generate an SSA for the subsequent tests.
834 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
835 ReqWidth, &Control, &State, NULL, &Tabdef,
837 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
840 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
841 * string length, return E_INVALIDARG. This also invalidates the ssa so a
842 * ScriptStringFree should also fail.
846 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
847 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
849 hr = ScriptStringFree(&ssa);
851 * ScriptStringCPtoX should free ssa, hence ScriptStringFree should fail
853 ok(hr == E_INVALIDARG, "ScriptStringFree should return E_INVALIDARG not %08x\n", hr);
857 static void test_ScriptCacheGetHeight(HDC hdc)
860 SCRIPT_CACHE sc = NULL;
863 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
864 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
866 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
867 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
869 hr = ScriptCacheGetHeight(NULL, &sc, &height);
870 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
874 hr = ScriptCacheGetHeight(hdc, &sc, &height);
875 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
877 ok(height > 0, "expected height > 0\n");
880 static void test_ScriptGetGlyphABCWidth(HDC hdc)
885 SCRIPT_CACHE sc = NULL;
888 memset(&lf, 0, sizeof(lf));
890 lstrcpyA(lf.lfFaceName, "Symbol");
891 hfont = CreateFontIndirectA(&lf);
892 hfont = SelectObject(hdc, hfont);
894 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
895 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
897 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
898 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
900 if (0) { /* crashes on WinXP */
901 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
902 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
905 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
906 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
909 static void test_ScriptLayout(void)
912 static const BYTE levels[][5] =
919 static const int expect[][5] =
926 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
928 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
929 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
931 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
932 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
934 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
936 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
937 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
939 for (j = 0; j < sizeof(levels[i]); j++)
941 ok(expect[i][j] == vistolog[j],
942 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
943 i, j, levels[i][j], j, vistolog[j] );
946 for (j = 0; j < sizeof(levels[i]); j++)
948 ok(expect[i][j] == logtovis[j],
949 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
950 i, j, levels[i][j], j, logtovis[j] );
959 SCRIPT_DIGITSUBSTITUTE sds;
960 DWORD uDefaultLanguage;
961 DWORD fContextDigits;
962 WORD fDigitSubstitute;
966 { 0x01, 0x00403, { 9, 3, 1, 0 }, 9, 0, 0 },
967 { 0x01, 0x00406, { 9, 6, 1, 0 }, 9, 0, 0 },
968 { 0x01, 0x00407, { 9, 7, 1, 0 }, 9, 0, 0 },
969 { 0x01, 0x00409, { 9, 9, 1, 0 }, 9, 0, 0 },
970 { 0x01, 0x0040a, { 9, 10, 1, 0 }, 9, 0, 0 },
971 { 0x01, 0x0040b, { 9, 11, 1, 0 }, 9, 0, 0 },
972 { 0x01, 0x0040c, { 9, 12, 1, 0 }, 9, 0, 0 },
973 { 0x01, 0x0040f, { 9, 15, 1, 0 }, 9, 0, 0 },
974 { 0x01, 0x00410, { 9, 16, 1, 0 }, 9, 0, 0 },
975 { 0x01, 0x00413, { 9, 19, 1, 0 }, 9, 0, 0 },
976 { 0x01, 0x00414, { 9, 20, 1, 0 }, 9, 0, 0 },
977 { 0x01, 0x00416, { 9, 22, 1, 0 }, 9, 0, 0 },
978 { 0x01, 0x0041d, { 9, 29, 1, 0 }, 9, 0, 0 },
979 { 0x01, 0x00421, { 9, 33, 1, 0 }, 9, 0, 0 },
980 { 0x01, 0x0042d, { 9, 45, 1, 0 }, 9, 0, 0 },
981 { 0x01, 0x00432, { 9, 50, 1, 0 }, 9, 0, 0 },
982 { 0x01, 0x00434, { 9, 52, 1, 0 }, 9, 0, 0 },
983 { 0x01, 0x00435, { 9, 53, 1, 0 }, 9, 0, 0 },
984 { 0x01, 0x00436, { 9, 54, 1, 0 }, 9, 0, 0 },
985 { 0x01, 0x00438, { 9, 56, 1, 0 }, 9, 0, 0 },
986 { 0x01, 0x0043a, { 9, 58, 1, 0 }, 9, 0, 0 },
987 { 0x01, 0x0043b, { 9, 59, 1, 0 }, 9, 0, 0 },
988 { 0x01, 0x0043e, { 9, 62, 1, 0 }, 9, 0, 0 },
989 { 0x01, 0x00441, { 9, 65, 1, 0 }, 9, 0, 0 },
990 { 0x01, 0x00452, { 9, 82, 1, 0 }, 9, 0, 0 },
991 { 0x01, 0x00456, { 9, 86, 1, 0 }, 9, 0, 0 },
992 { 0x01, 0x0046b, { 9, 107, 1, 0 }, 9, 0, 0 },
993 { 0x01, 0x0046c, { 9, 108, 1, 0 }, 9, 0, 0 },
994 { 0x01, 0x00481, { 9, 129, 1, 0 }, 9, 0, 0 },
995 { 0x01, 0x00807, { 9, 7, 1, 0 }, 9, 0, 0 },
996 { 0x01, 0x00809, { 9, 9, 1, 0 }, 9, 0, 0 },
997 { 0x01, 0x0080a, { 9, 10, 1, 0 }, 9, 0, 0 },
998 { 0x01, 0x0080c, { 9, 12, 1, 0 }, 9, 0, 0 },
999 { 0x01, 0x00810, { 9, 16, 1, 0 }, 9, 0, 0 },
1000 { 0x01, 0x00813, { 9, 19, 1, 0 }, 9, 0, 0 },
1001 { 0x01, 0x00814, { 9, 20, 1, 0 }, 9, 0, 0 },
1002 { 0x01, 0x00816, { 9, 22, 1, 0 }, 9, 0, 0 },
1003 { 0x01, 0x0081d, { 9, 29, 1, 0 }, 9, 0, 0 },
1004 { 0x01, 0x0083b, { 9, 59, 1, 0 }, 9, 0, 0 },
1005 { 0x01, 0x0083e, { 9, 62, 1, 0 }, 9, 0, 0 },
1006 { 0x01, 0x0086b, { 9, 107, 1, 0 }, 9, 0, 0 },
1007 { 0x01, 0x00c07, { 9, 7, 1, 0 }, 9, 0, 0 },
1008 { 0x01, 0x00c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1009 { 0x01, 0x00c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1010 { 0x01, 0x00c0c, { 9, 12, 1, 0 }, 9, 0, 0 },
1011 { 0x01, 0x00c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
1012 { 0x01, 0x00c6b, { 9, 107, 1, 0 }, 9, 0, 0 },
1013 { 0x01, 0x01007, { 9, 7, 1, 0 }, 9, 0, 0 },
1014 { 0x01, 0x01009, { 9, 9, 1, 0 }, 9, 0, 0 },
1015 { 0x01, 0x0100a, { 9, 10, 1, 0 }, 9, 0, 0 },
1016 { 0x01, 0x0100c, { 9, 12, 1, 0 }, 9, 0, 0 },
1017 { 0x01, 0x0103b, { 9, 59, 1, 0 }, 9, 0, 0 },
1018 { 0x01, 0x01407, { 9, 7, 1, 0 }, 9, 0, 0 },
1019 { 0x01, 0x01409, { 9, 9, 1, 0 }, 9, 0, 0 },
1020 { 0x01, 0x0140a, { 9, 10, 1, 0 }, 9, 0, 0 },
1021 { 0x01, 0x0140c, { 9, 12, 1, 0 }, 9, 0, 0 },
1022 { 0x01, 0x0143b, { 9, 59, 1, 0 }, 9, 0, 0 },
1023 { 0x01, 0x01809, { 9, 9, 1, 0 }, 9, 0, 0 },
1024 { 0x01, 0x0180a, { 9, 10, 1, 0 }, 9, 0, 0 },
1025 { 0x01, 0x0180c, { 9, 12, 1, 0 }, 9, 0, 0 },
1026 { 0x01, 0x0183b, { 9, 59, 1, 0 }, 9, 0, 0 },
1027 { 0x01, 0x01c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1028 { 0x01, 0x01c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1029 { 0x01, 0x01c3b, { 9, 59, 1, 0 }, 9, 0, 0 },
1030 { 0x01, 0x02009, { 9, 9, 1, 0 }, 9, 0, 0 },
1031 { 0x01, 0x0200a, { 9, 10, 1, 0 }, 9, 0, 0 },
1032 { 0x01, 0x0203b, { 9, 59, 1, 0 }, 9, 0, 0 },
1033 { 0x01, 0x02409, { 9, 9, 1, 0 }, 9, 0, 0 },
1034 { 0x01, 0x0240a, { 9, 10, 1, 0 }, 9, 0, 0 },
1035 { 0x01, 0x0243b, { 9, 59, 1, 0 }, 9, 0, 0 },
1036 { 0x01, 0x02809, { 9, 9, 1, 0 }, 9, 0, 0 },
1037 { 0x01, 0x0280a, { 9, 10, 1, 0 }, 9, 0, 0 },
1038 { 0x01, 0x02c09, { 9, 9, 1, 0 }, 9, 0, 0 },
1039 { 0x01, 0x02c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1040 { 0x01, 0x03009, { 9, 9, 1, 0 }, 9, 0, 0 },
1041 { 0x01, 0x0300a, { 9, 10, 1, 0 }, 9, 0, 0 },
1042 { 0x01, 0x03409, { 9, 9, 1, 0 }, 9, 0, 0 },
1043 { 0x01, 0x0340a, { 9, 10, 1, 0 }, 9, 0, 0 },
1044 { 0x01, 0x0380a, { 9, 10, 1, 0 }, 9, 0, 0 },
1045 { 0x01, 0x03c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1046 { 0x01, 0x0400a, { 9, 10, 1, 0 }, 9, 0, 0 },
1047 { 0x01, 0x0440a, { 9, 10, 1, 0 }, 9, 0, 0 },
1048 { 0x01, 0x0480a, { 9, 10, 1, 0 }, 9, 0, 0 },
1049 { 0x01, 0x04c0a, { 9, 10, 1, 0 }, 9, 0, 0 },
1050 { 0x01, 0x0500a, { 9, 10, 1, 0 }, 9, 0, 0 },
1051 { 0x01, 0x10407, { 9, 7, 1, 0 }, 9, 0, 0 },
1052 { 0x02, 0x00405, { 9, 5, 1, 0 }, 9, 0, 0 },
1053 { 0x02, 0x0040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1054 { 0x02, 0x00415, { 9, 21, 1, 0 }, 9, 0, 0 },
1055 { 0x02, 0x00418, { 9, 24, 1, 0 }, 9, 0, 0 },
1056 { 0x02, 0x0041a, { 9, 26, 1, 0 }, 9, 0, 0 },
1057 { 0x02, 0x0041b, { 9, 27, 1, 0 }, 9, 0, 0 },
1058 { 0x02, 0x0041c, { 9, 28, 1, 0 }, 9, 0, 0 },
1059 { 0x02, 0x00424, { 9, 36, 1, 0 }, 9, 0, 0 },
1060 { 0x02, 0x0081a, { 9, 26, 1, 0 }, 9, 0, 0 },
1061 { 0x02, 0x0101a, { 9, 26, 1, 0 }, 9, 0, 0 },
1062 { 0x02, 0x0141a, { 9, 26, 1, 0 }, 9, 0, 0 },
1063 { 0x02, 0x0181a, { 9, 26, 1, 0 }, 9, 0, 0 },
1064 { 0x02, 0x1040e, { 9, 14, 1, 0 }, 9, 0, 0 },
1065 { 0x03, 0x00425, { 9, 37, 1, 0 }, 9, 0, 0 },
1066 { 0x03, 0x00426, { 9, 38, 1, 0 }, 9, 0, 0 },
1067 { 0x03, 0x00427, { 9, 39, 1, 0 }, 9, 0, 0 },
1068 { 0x04, 0x00408, { 9, 8, 1, 0 }, 9, 0, 0 },
1069 { 0x05, 0x00402, { 9, 2, 1, 0 }, 9, 0, 0 },
1070 { 0x05, 0x00419, { 9, 25, 1, 0 }, 9, 0, 0 },
1071 { 0x05, 0x00422, { 9, 34, 1, 0 }, 9, 0, 0 },
1072 { 0x05, 0x00423, { 9, 35, 1, 0 }, 9, 0, 0 },
1073 { 0x05, 0x0042f, { 9, 47, 1, 0 }, 9, 0, 0 },
1074 { 0x05, 0x0043f, { 9, 63, 1, 0 }, 9, 0, 0 },
1075 { 0x05, 0x00440, { 9, 64, 1, 0 }, 9, 0, 0 },
1076 { 0x05, 0x00444, { 9, 68, 1, 0 }, 9, 0, 0 },
1077 { 0x05, 0x00450, { 9, 80, 1, 0 }, 9, 0, 0 },
1078 { 0x05, 0x0082c, { 9, 44, 1, 0 }, 9, 0, 0 },
1079 { 0x05, 0x00843, { 9, 67, 1, 0 }, 9, 0, 0 },
1080 { 0x05, 0x00c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1081 { 0x05, 0x01c1a, { 9, 26, 1, 0 }, 9, 0, 0 },
1082 { 0x06, 0x0041f, { 9, 31, 1, 0 }, 9, 0, 0 },
1083 { 0x06, 0x0042c, { 9, 44, 1, 0 }, 9, 0, 0 },
1084 { 0x06, 0x00443, { 9, 67, 1, 0 }, 9, 0, 0 },
1085 { 0x07, 0x00411, { 9, 17, 1, 0 }, 9, 0, 0 },
1086 { 0x08, 0x00412, { 9, 18, 1, 0 }, 9, 0, 0 },
1087 { 0x09, 0x00404, { 9, 4, 1, 0 }, 9, 0, 0 },
1088 { 0x09, 0x00c04, { 9, 4, 1, 0 }, 9, 0, 0 },
1089 { 0x09, 0x01404, { 9, 4, 1, 0 }, 9, 0, 0 },
1090 { 0x09, 0x21404, { 9, 4, 1, 0 }, 9, 0, 0 },
1091 { 0x09, 0x30404, { 9, 4, 1, 0 }, 9, 0, 0 },
1092 { 0x0a, 0x00804, { 9, 4, 1, 0 }, 9, 0, 0 },
1093 { 0x0a, 0x01004, { 9, 4, 1, 0 }, 9, 0, 0 },
1094 { 0x0a, 0x20804, { 9, 4, 1, 0 }, 9, 0, 0 },
1095 { 0x0a, 0x21004, { 9, 4, 1, 0 }, 9, 0, 0 },
1096 { 0x0b, 0x0041e, { 9, 30, 1, 0 }, 9, 0, 0 },
1097 { 0x0c, 0x0040d, { 9, 13, 1, 0 }, 9, 0, 0 },
1098 { 0x0d, 0x00401, { 1, 1, 0, 0 }, 9, 0, 0 },
1099 { 0x0d, 0x00420, { 9, 32, 1, 0 }, 9, 0, 0 },
1100 { 0x0d, 0x00429, { 41, 41, 0, 0 }, 9, 0, 0 },
1101 { 0x0d, 0x0045a, { 9, 90, 1, 0 }, 9, 0, 0 },
1102 { 0x0d, 0x00465, { 9, 101, 1, 0 }, 9, 0, 0 },
1103 { 0x0d, 0x00801, { 1, 1, 0, 0 }, 9, 0, 0 },
1104 { 0x0d, 0x00c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1105 { 0x0d, 0x01001, { 1, 1, 0, 0 }, 9, 0, 0 },
1106 { 0x0d, 0x01401, { 1, 1, 0, 0 }, 9, 0, 0 },
1107 { 0x0d, 0x01801, { 1, 1, 0, 0 }, 9, 0, 0 },
1108 { 0x0d, 0x01c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1109 { 0x0d, 0x02001, { 1, 1, 0, 0 }, 9, 0, 0 },
1110 { 0x0d, 0x02401, { 1, 1, 0, 0 }, 9, 0, 0 },
1111 { 0x0d, 0x02801, { 1, 1, 0, 0 }, 9, 0, 0 },
1112 { 0x0d, 0x02c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1113 { 0x0d, 0x03001, { 1, 1, 0, 0 }, 9, 0, 0 },
1114 { 0x0d, 0x03401, { 1, 1, 0, 0 }, 9, 0, 0 },
1115 { 0x0d, 0x03801, { 1, 1, 0, 0 }, 9, 0, 0 },
1116 { 0x0d, 0x03c01, { 1, 1, 0, 0 }, 9, 0, 0 },
1117 { 0x0d, 0x04001, { 1, 1, 0, 0 }, 9, 0, 0 },
1118 { 0x0e, 0x0042a, { 9, 42, 1, 0 }, 9, 0, 0 },
1119 { 0x0f, 0x00439, { 9, 57, 1, 0 }, 9, 0, 0 },
1120 { 0x0f, 0x00446, { 9, 70, 1, 0 }, 9, 0, 0 },
1121 { 0x0f, 0x00447, { 9, 71, 1, 0 }, 9, 0, 0 },
1122 { 0x0f, 0x00449, { 9, 73, 1, 0 }, 9, 0, 0 },
1123 { 0x0f, 0x0044a, { 9, 74, 1, 0 }, 9, 0, 0 },
1124 { 0x0f, 0x0044b, { 9, 75, 1, 0 }, 9, 0, 0 },
1125 { 0x0f, 0x0044e, { 9, 78, 1, 0 }, 9, 0, 0 },
1126 { 0x0f, 0x0044f, { 9, 79, 1, 0 }, 9, 0, 0 },
1127 { 0x0f, 0x00457, { 9, 87, 1, 0 }, 9, 0, 0 },
1128 { 0x10, 0x00437, { 9, 55, 1, 0 }, 9, 0, 0 },
1129 { 0x10, 0x10437, { 9, 55, 1, 0 }, 9, 0, 0 },
1130 { 0x11, 0x0042b, { 9, 43, 1, 0 }, 9, 0, 0 }
1133 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
1136 SCRIPT_DIGITSUBSTITUTE sds;
1142 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
1144 memset(&sds, 0, sizeof(sds));
1145 memset(&sc, 0, sizeof(sc));
1146 memset(&ss, 0, sizeof(ss));
1148 lcid_old = GetThreadLocale();
1149 if (!SetThreadLocale(lcid)) return TRUE;
1151 hr = ScriptRecordDigitSubstitution(lcid, &sds);
1152 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
1154 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
1155 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
1157 for (i = 0; i < sizeof(subst_data)/sizeof(subst_data[0]); i++)
1159 if (group == subst_data[i].group && lcid == subst_data[i].lcid)
1161 ok(!memcmp(&sds, &subst_data[i].sds, sizeof(sds)),
1162 "substitution data does not match\n");
1164 ok(sc.uDefaultLanguage == subst_data[i].uDefaultLanguage,
1165 "sc.uDefaultLanguage does not match\n");
1166 ok(sc.fContextDigits == subst_data[i].fContextDigits,
1167 "sc.fContextDigits does not match\n");
1168 ok(ss.fDigitSubstitute == subst_data[i].fDigitSubstitute,
1169 "ss.fDigitSubstitute does not match\n");
1172 SetThreadLocale(lcid_old);
1176 static void test_digit_substitution(void)
1180 static const LGRPID groups[] =
1182 LGRPID_WESTERN_EUROPE,
1183 LGRPID_CENTRAL_EUROPE,
1190 LGRPID_TRADITIONAL_CHINESE,
1191 LGRPID_SIMPLIFIED_CHINESE,
1201 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROC,LGRPID,DWORD,LONG_PTR);
1203 hKernel32 = GetModuleHandleA("kernel32.dll");
1204 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
1206 if (!pEnumLanguageGroupLocalesA)
1208 trace("EnumLanguageGroupLocalesA not available on this platform\n");
1212 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
1214 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
1215 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: 0x%08x\n", GetLastError());
1219 static void test_ScriptGetProperties(void)
1221 const SCRIPT_PROPERTIES **props;
1225 hr = ScriptGetProperties(NULL, NULL);
1226 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
1228 hr = ScriptGetProperties(NULL, &num);
1229 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1231 hr = ScriptGetProperties(&props, NULL);
1232 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1234 hr = ScriptGetProperties(&props, &num);
1235 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1243 unsigned short pwOutGlyphs[256];
1245 /* We need a valid HDC to drive a lot of Script functions which requires the following *
1246 * to set up for the tests. */
1247 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
1250 ShowWindow(hwnd, SW_SHOW);
1253 hdc = GetDC(hwnd); /* We now have a hdc */
1254 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
1256 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
1257 test_ScriptGetCMap(hdc, pwOutGlyphs);
1258 test_ScriptCacheGetHeight(hdc);
1259 test_ScriptGetGlyphABCWidth(hdc);
1261 test_ScriptGetFontProperties(hdc);
1262 test_ScriptTextOut(hdc);
1264 test_ScriptString(hdc);
1265 test_ScriptStringXtoCP_CPtoX(hdc);
1267 test_ScriptLayout();
1268 test_digit_substitution();
1269 test_ScriptGetProperties();
1271 ReleaseDC(hwnd, hdc);
1272 DestroyWindow(hwnd);