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