usp10/tests: Use todo_wine_if() in tests.
[wine.git] / dlls / usp10 / tests / usp10.c
blob78816674d8f83bbe965306f353b2108d5fab301a
1 /*
2 * Tests for usp10 dll
4 * Copyright 2006 Jeff Latimer
5 * Copyright 2006 Hans Leidekker
6 * Copyright 2010 CodeWeavers, Aric Stewart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Notes:
23 * Uniscribe allows for processing of complex scripts such as joining
24 * and filtering characters and bi-directional text with custom line breaks.
27 #include <assert.h>
28 #include <stdio.h>
30 #include <wine/test.h>
31 #include <windows.h>
32 #include <usp10.h>
34 typedef struct _itemTest {
35 char todo_flag[6];
36 int iCharPos;
37 int fRTL;
38 int fLayoutRTL;
39 int uBidiLevel;
40 int fOverrideDirection;
41 ULONG scriptTag;
42 BOOL isBroken;
43 int broken_value[6];
44 } itemTest;
46 typedef struct _shapeTest_char {
47 WORD wLogClust;
48 SCRIPT_CHARPROP CharProp;
49 } shapeTest_char;
51 typedef struct _shapeTest_glyph {
52 int Glyph;
53 SCRIPT_GLYPHPROP GlyphProp;
54 } shapeTest_glyph;
56 /* Uniscribe 1.6 calls */
57 static HRESULT (WINAPI *pScriptItemizeOpenType)( const WCHAR *pwcInChars, int cInChars, int cMaxItems, const SCRIPT_CONTROL *psControl, const SCRIPT_STATE *psState, SCRIPT_ITEM *pItems, ULONG *pScriptTags, int *pcItems);
59 static HRESULT (WINAPI *pScriptShapeOpenType)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int *rcRangeChars, TEXTRANGE_PROPERTIES **rpRangeProperties, int cRanges, const WCHAR *pwcChars, int cChars, int cMaxGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProps, WORD *pwOutGlyphs, SCRIPT_GLYPHPROP *pOutGlyphProps, int *pcGlyphs);
61 static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
63 static HRESULT (WINAPI *pScriptGetFontScriptTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags);
64 static HRESULT (WINAPI *pScriptGetFontLanguageTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags);
65 static HRESULT (WINAPI *pScriptGetFontFeatureTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags);
67 static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
68 SCRIPT_CONTROL *Control, SCRIPT_STATE *State,
69 DWORD nItems, const itemTest* items, BOOL nItemsToDo,
70 const INT nItemsBroken[2])
72 HRESULT hr;
73 int x, outnItems;
74 SCRIPT_ITEM outpItems[15];
75 ULONG tags[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
77 if (pScriptItemizeOpenType)
78 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
79 else
80 hr = ScriptItemize(string, cchString, 15, Control, State, outpItems, &outnItems);
82 winetest_ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
83 if (nItemsBroken && (broken(nItemsBroken[0] == outnItems) || broken(nItemsBroken[1] == outnItems)))
85 winetest_win_skip("This test broken on this platform\n");
86 return;
88 todo_wine_if (nItemsToDo)
89 winetest_ok(outnItems == nItems, "Wrong number of items\n");
90 for (x = 0; x <= outnItems; x++)
92 if (items[x].isBroken && broken(outpItems[x].iCharPos == items[x].broken_value[0]))
93 winetest_win_skip("This test broken on this platform\n");
94 else todo_wine_if (items[x].todo_flag[0])
95 winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos (%i)\n",x,outpItems[x].iCharPos);
97 if (items[x].isBroken && broken(outpItems[x].a.fRTL== items[x].broken_value[1]))
98 winetest_win_skip("This test broken on this platform\n");
99 else todo_wine_if (items[x].todo_flag[1])
100 winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL(%i)\n",x,outpItems[x].a.fRTL);
102 if (items[x].isBroken && broken(outpItems[x].a.fLayoutRTL == items[x].broken_value[2]))
103 winetest_win_skip("This test broken on this platform\n");
104 else todo_wine_if (items[x].todo_flag[2])
105 winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL(%i)\n",x,outpItems[x].a.fLayoutRTL);
107 if (items[x].isBroken && broken(outpItems[x].a.s.uBidiLevel == items[x].broken_value[3]))
108 winetest_win_skip("This test broken on this platform\n");
109 else todo_wine_if (items[x].todo_flag[3])
110 winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel(%i)\n",x,outpItems[x].a.s.uBidiLevel);
111 if (x != outnItems)
112 winetest_ok(outpItems[x].a.eScript != SCRIPT_UNDEFINED, "%i: Undefined script\n",x);
113 if (pScriptItemizeOpenType)
115 if (items[x].isBroken && broken(tags[x] == items[x].broken_value[4]))
116 winetest_win_skip("This test broken on this platform\n");
117 else todo_wine_if (items[x].todo_flag[4])
118 winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
121 if (items[x].isBroken && broken(outpItems[x].a.s.fOverrideDirection == items[x].broken_value[5]))
122 winetest_win_skip("This test broken on this platform\n");
123 else todo_wine_if (items[x].todo_flag[5])
124 winetest_ok(outpItems[x].a.s.fOverrideDirection == items[x].fOverrideDirection, "%i:Wrong fOverrideDirection(%i)\n",x,outpItems[x].a.s.fOverrideDirection);
128 #define test_items_ok(a,b,c,d,e,f,g,h) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_items_ok(a,b,c,d,e,f,g,h)
130 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
131 ( ( (ULONG)_x4 << 24 ) | \
132 ( (ULONG)_x3 << 16 ) | \
133 ( (ULONG)_x2 << 8 ) | \
134 (ULONG)_x1 )
136 #define latn_tag MS_MAKE_TAG('l','a','t','n')
137 #define arab_tag MS_MAKE_TAG('a','r','a','b')
138 #define thai_tag MS_MAKE_TAG('t','h','a','i')
139 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
140 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
141 #define deva_tag MS_MAKE_TAG('d','e','v','a')
142 #define beng_tag MS_MAKE_TAG('b','e','n','g')
143 #define guru_tag MS_MAKE_TAG('g','u','r','u')
144 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
145 #define orya_tag MS_MAKE_TAG('o','r','y','a')
146 #define taml_tag MS_MAKE_TAG('t','a','m','l')
147 #define telu_tag MS_MAKE_TAG('t','e','l','u')
148 #define knda_tag MS_MAKE_TAG('k','n','d','a')
149 #define mlym_tag MS_MAKE_TAG('m','l','y','m')
150 #define mymr_tag MS_MAKE_TAG('m','y','m','r')
151 #define tale_tag MS_MAKE_TAG('t','a','l','e')
152 #define talu_tag MS_MAKE_TAG('t','a','l','u')
153 #define khmr_tag MS_MAKE_TAG('k','h','m','r')
154 #define hani_tag MS_MAKE_TAG('h','a','n','i')
155 #define bopo_tag MS_MAKE_TAG('b','o','p','o')
156 #define kana_tag MS_MAKE_TAG('k','a','n','a')
157 #define hang_tag MS_MAKE_TAG('h','a','n','g')
158 #define yi_tag MS_MAKE_TAG('y','i',' ',' ')
159 #define ethi_tag MS_MAKE_TAG('e','t','h','i')
160 #define mong_tag MS_MAKE_TAG('m','o','n','g')
161 #define tfng_tag MS_MAKE_TAG('t','f','n','g')
162 #define nko_tag MS_MAKE_TAG('n','k','o',' ')
163 #define vai_tag MS_MAKE_TAG('v','a','i',' ')
164 #define cher_tag MS_MAKE_TAG('c','h','e','r')
165 #define cans_tag MS_MAKE_TAG('c','a','n','s')
166 #define ogam_tag MS_MAKE_TAG('o','g','a','m')
167 #define runr_tag MS_MAKE_TAG('r','u','n','r')
168 #define brai_tag MS_MAKE_TAG('b','r','a','i')
169 #define dsrt_tag MS_MAKE_TAG('d','s','r','t')
170 #define osma_tag MS_MAKE_TAG('o','s','m','a')
171 #define math_tag MS_MAKE_TAG('m','a','t','h')
173 static void test_ScriptItemize( void )
175 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
176 static const itemTest t11[2] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1}};
177 static const itemTest t12[2] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
179 static const WCHAR test1b[] = {' ', ' ', ' ', ' ',0};
180 static const itemTest t1b1[2] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
181 static const itemTest t1b2[2] = {{{0,0,0,0,0,0},0,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
183 static const WCHAR test1c[] = {' ', ' ', ' ', '1', '2', ' ',0};
184 static const itemTest t1c1[2] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
185 static const itemTest t1c2[4] = {{{0,0,0,0,0,0},0,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},3,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},5,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
187 /* Arabic, English*/
188 static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
189 static const itemTest t21[7] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},15,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
190 static const itemTest t22[5] = {{{0,0,0,0,0,0},0,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},15,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
191 static const itemTest t23[5] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},15,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
192 static const itemTest t24[5] = {{{0,0,0,0,0,0},0,0,0,0,1,0,FALSE},
193 {{0,0,0,0,0,0},6,0,0,0,1,arab_tag,FALSE},
194 {{0,0,0,0,0,0},13,0,1,0,1,0,FALSE},
195 {{0,0,0,0,0,0},15,0,0,0,1,0,FALSE},
196 {{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
198 static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
199 static const itemTest t2b1[5] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},8,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
200 static const itemTest t2b2[5] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
201 static const itemTest t2b3[3] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
202 static const itemTest t2b4[5] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
203 {{0,0,0,0,0,0},3,0,0,0,1,0,FALSE},
204 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
205 {{0,0,0,0,0,0},8,0,0,0,1,arab_tag,FALSE},
206 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
207 static const int b2[2] = {4,4};
209 /* leading space */
210 static const WCHAR test2c[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
211 static const itemTest t2c1[5] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
212 static const itemTest t2c2[6] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},1,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
213 static const itemTest t2c3[5] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},8,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
214 static const itemTest t2c4[3] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
215 static const itemTest t2c5[5] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
216 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
217 {{0,0,0,0,0,0},7,0,0,0,1,0,FALSE},
218 {{0,0,0,0,0,0},8,0,0,0,1,latn_tag,FALSE},
219 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
221 /* trailing space */
222 static const WCHAR test2d[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
223 static const itemTest t2d1[5] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
224 static const itemTest t2d2[6] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
225 static const itemTest t2d3[5] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
226 static const itemTest t2d4[3] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},7,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
227 static const itemTest t2d5[5] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
228 {{0,0,0,0,0,0},3,0,0,0,1,0,FALSE},
229 {{0,0,0,0,0,0},4,0,0,0,1,latn_tag,FALSE},
230 {{0,0,0,0,0,0},7,0,0,0,1,arab_tag,FALSE},
231 {{0,0,0,0,0,0},11,0,0,0,0,-1,FALSE}};
233 /* Thai */
234 static const WCHAR test3[] =
235 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
236 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
237 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
238 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
240 static const itemTest t31[2] = {{{0,0,0,0,0,0},0,0,0,0,0,thai_tag,FALSE},{{0,0,0,0,0,0},41,0,0,0,0,-1,FALSE}};
241 static const itemTest t32[2] = {{{0,0,0,0,0,0},0,0,0,2,0,thai_tag,FALSE},{{0,0,0,0,0,0},41,0,0,0,0,-1,FALSE}};
243 static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
245 static const itemTest t41[6] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
246 static const itemTest t42[5] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},10,0,0,2,0,0,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
247 static const itemTest t43[4] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},7,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
248 static const int b43[2] = {4,4};
250 /* Arabic */
251 static const WCHAR test5[] =
252 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
253 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
254 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
255 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
256 static const itemTest t51[2] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},38,0,0,0,0,-1,FALSE}};
257 static const itemTest t52[2] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
258 {{0,0,0,0,0,0},38,0,0,0,0,-1,FALSE}};
261 /* Hebrew */
262 static const WCHAR test6[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
263 static const itemTest t61[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
264 static const itemTest t62[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},4,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
265 static const itemTest t63[2] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
266 static const itemTest t64[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
267 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
268 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
270 static const int b63[2] = {2,2};
271 static const WCHAR test7[] = {'p','a','r','t',' ','o','n','e',' ',0x05d7, 0x05dc, 0x05e7, ' ', 0x05e9, 0x05ea, 0x05d9, 0x05d9, 0x05dd, ' ','p','a','r','t',' ','t','h','r','e','e', 0};
272 static const itemTest t71[4] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},9,1,1,1,0,hebr_tag,TRUE,{-1,0,0,0,-1}},{{0,0,0,0,0,0},19,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
273 static const itemTest t72[4] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},9,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},18,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
274 static const itemTest t73[4] = {{{0,0,0,0,0,0},0,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},8,1,1,1,0,hebr_tag,FALSE},{{0,0,0,0,0,0},19,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
275 static const itemTest t74[4] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
276 {{0,0,0,0,0,0},9,0,0,0,1,hebr_tag,FALSE},
277 {{0,0,0,0,0,0},19,0,0,0,1,latn_tag,FALSE},
278 {{0,0,0,0,0,0},29,0,0,0,0,-1,FALSE}};
280 static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
281 static const itemTest t81[2] = {{{0,0,0,0,0,0},0,1,1,1,0,arab_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
282 static const itemTest t82[2] = {{{0,0,0,0,0,0},0,0,0,0,1,arab_tag,FALSE},
283 {{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
285 /* Syriac (Like Arabic )*/
286 static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
287 static const itemTest t91[3] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
288 static const itemTest t92[3] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag},{{0,0,0,0,0,0},4,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
289 static const itemTest t93[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
290 static const itemTest t94[3] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
291 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
292 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
293 static const int b93[2] = {2,2};
295 static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
296 static const itemTest t101[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
297 static const itemTest t102[2] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
298 {{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
300 /* Devanagari */
301 static const WCHAR test11[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
302 static const itemTest t111[2] = {{{0,0,0,0,0,0},0,0,0,0,0,deva_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
303 static const itemTest t112[2] = {{{0,0,0,0,0,0},0,0,0,2,0,deva_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
305 /* Bengali */
306 static const WCHAR test12[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
307 static const itemTest t121[2] = {{{0,0,0,0,0,0},0,0,0,0,0,beng_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
308 static const itemTest t122[2] = {{{0,0,0,0,0,0},0,0,0,2,0,beng_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
310 /* Gurmukhi */
311 static const WCHAR test13[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
312 static const itemTest t131[2] = {{{0,0,0,0,0,0},0,0,0,0,0,guru_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
313 static const itemTest t132[2] = {{{0,0,0,0,0,0},0,0,0,2,0,guru_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
315 /* Gujarati */
316 static const WCHAR test14[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
317 static const itemTest t141[2] = {{{0,0,0,0,0,0},0,0,0,0,0,gujr_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
318 static const itemTest t142[2] = {{{0,0,0,0,0,0},0,0,0,2,0,gujr_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
320 /* Oriya */
321 static const WCHAR test15[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
322 static const itemTest t151[2] = {{{0,0,0,0,0,0},0,0,0,0,0,orya_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
323 static const itemTest t152[2] = {{{0,0,0,0,0,0},0,0,0,2,0,orya_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
325 /* Tamil */
326 static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
327 static const itemTest t161[2] = {{{0,0,0,0,0,0},0,0,0,0,0,taml_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
328 static const itemTest t162[2] = {{{0,0,0,0,0,0},0,0,0,2,0,taml_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
330 /* Telugu */
331 static const WCHAR test17[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
332 static const itemTest t171[2] = {{{0,0,0,0,0,0},0,0,0,0,0,telu_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
333 static const itemTest t172[2] = {{{0,0,0,0,0,0},0,0,0,2,0,telu_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
335 /* Kannada */
336 static const WCHAR test18[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
337 static const itemTest t181[2] = {{{0,0,0,0,0,0},0,0,0,0,0,knda_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
338 static const itemTest t182[2] = {{{0,0,0,0,0,0},0,0,0,2,0,knda_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
340 /* Malayalam */
341 static const WCHAR test19[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
342 static const itemTest t191[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
343 static const itemTest t192[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mlym_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
345 /* Diacritical */
346 static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
347 static const itemTest t201[3] = {{{0,0,0,0,0,0},0,0,0,0,0x0,0,FALSE},{{0,0,0,0,0,0},1,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
348 static const itemTest t202[3] = {{{0,0,0,0,0,0},0,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},1,0,0,2,0,latn_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
350 static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
351 static const itemTest t211[2] = {{{0,0,0,0,0,0},0,1,1,1,0,syrc_tag,FALSE},{{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
352 static const itemTest t212[2] = {{{0,0,0,0,0,0},0,0,0,0,1,syrc_tag,FALSE},
353 {{0,0,0,0,0,0},5,0,0,0,0,-1,FALSE}};
355 /* Latin Punctuation */
356 static const WCHAR test22[] = {'#','$',',','!','\"','*',0};
357 static const itemTest t221[3] = {{{0,0,0,0,0,0},0,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
358 static const itemTest t222[3] = {{{0,0,0,0,0,0},0,1,1,1,0,latn_tag,FALSE},{{0,0,0,0,0,0},3,1,1,1,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
359 static const itemTest t223[2] = {{{0,0,0,0,0,0},0,1,1,1,0,latn_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
360 static const int b222[2] = {1,1};
361 static const int b223[2] = {2,2};
363 /* Number 2*/
364 static const WCHAR test23[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
365 static const itemTest t231[3] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
366 static const itemTest t232[3] = {{{0,0,0,0,0,0},0,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},3,0,1,2,0,0,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
368 /* Myanmar */
369 static const WCHAR test24[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
370 static const itemTest t241[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mymr_tag,FALSE},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
371 static const itemTest t242[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mymr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},12,0,0,0,0,-1,FALSE}};
373 /* Tai Le */
374 static const WCHAR test25[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
375 static const itemTest t251[2] = {{{0,0,0,0,0,0},0,0,0,0,0,tale_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
376 static const itemTest t252[2] = {{{0,0,0,0,0,0},0,0,0,2,0,tale_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
378 /* New Tai Lue */
379 static const WCHAR test26[] = {0x1992,0x19c4};
380 static const itemTest t261[2] = {{{0,0,0,0,0,0},0,0,0,0,0,talu_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
381 static const itemTest t262[2] = {{{0,0,0,0,0,0},0,0,0,2,0,talu_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
383 /* Khmer */
384 static const WCHAR test27[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
385 static const itemTest t271[2] = {{{0,0,0,0,0,0},0,0,0,0,0,khmr_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
386 static const itemTest t272[2] = {{{0,0,0,0,0,0},0,0,0,2,0,khmr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
388 /* CJK Han */
389 static const WCHAR test28[] = {0x8bed,0x7d20,0x6587,0x5b57};
390 static const itemTest t281[2] = {{{0,0,0,0,0,0},0,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
391 static const itemTest t282[2] = {{{0,0,0,0,0,0},0,0,0,2,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
393 /* Ideographic */
394 static const WCHAR test29[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
395 static const itemTest t291[3] = {{{0,0,0,0,0,0},0,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
396 static const itemTest t292[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hani_tag,FALSE},{{0,0,0,0,0,0},4,0,0,2,0,hani_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
398 /* Bopomofo */
399 static const WCHAR test30[] = {0x3113,0x3128,0x3127,0x3123,0x3108,0x3128,0x310f,0x3120};
400 static const itemTest t301[2] = {{{0,0,0,0,0,0},0,0,0,0,0,bopo_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
401 static const itemTest t302[2] = {{{0,0,0,0,0,0},0,0,0,2,0,bopo_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
403 /* Kana */
404 static const WCHAR test31[] = {0x3072,0x3089,0x304b,0x306a,0x30ab,0x30bf,0x30ab,0x30ca};
405 static const itemTest t311[2] = {{{0,0,0,0,0,0},0,0,0,0,0,kana_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
406 static const itemTest t312[2] = {{{0,0,0,0,0,0},0,0,0,2,0,kana_tag,FALSE},{{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
407 static const int b311[2] = {2,2};
408 static const int b312[2] = {2,2};
410 /* Hangul */
411 static const WCHAR test32[] = {0xd55c,0xad6d,0xc5b4};
412 static const itemTest t321[2] = {{{0,0,0,0,0,0},0,0,0,0,0,hang_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
413 static const itemTest t322[2] = {{{0,0,0,0,0,0},0,0,0,2,0,hang_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
415 /* Yi */
416 static const WCHAR test33[] = {0xa188,0xa320,0xa071,0xa0b7};
417 static const itemTest t331[2] = {{{0,0,0,0,0,0},0,0,0,0,0,yi_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
418 static const itemTest t332[2] = {{{0,0,0,0,0,0},0,0,0,2,0,yi_tag,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
420 /* Ethiopic */
421 static const WCHAR test34[] = {0x130d,0x12d5,0x12dd};
422 static const itemTest t341[2] = {{{0,0,0,0,0,0},0,0,0,0,0,ethi_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
423 static const itemTest t342[2] = {{{0,0,0,0,0,0},0,0,0,2,0,ethi_tag,FALSE},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
424 static const int b342[2] = {2,2};
426 /* Mongolian */
427 static const WCHAR test35[] = {0x182e,0x1823,0x1829,0x182d,0x1823,0x182f,0x0020,0x182a,0x1822,0x1834,0x1822,0x182d,0x180c};
428 static const itemTest t351[2] = {{{0,0,0,0,0,0},0,0,0,0,0,mong_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
429 static const int b351[2] = {2,2};
430 static const itemTest t352[2] = {{{0,0,0,0,0,0},0,0,0,2,0,mong_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
431 static const int b352[2] = {2,3};
432 static const itemTest t353[2] = {{{0,0,0,0,0,1},0,0,0,0,1,mong_tag,TRUE,{0,0,0,0,0}},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
434 /* Tifinagh */
435 static const WCHAR test36[] = {0x2d5c,0x2d49,0x2d3c,0x2d49,0x2d4f,0x2d30,0x2d56};
436 static const itemTest t361[2] = {{{0,0,0,0,0,0},0,0,0,0,0,tfng_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
437 static const itemTest t362[2] = {{{0,0,0,0,0,0},0,0,0,2,0,tfng_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
439 /* N'Ko */
440 static const WCHAR test37[] = {0x07d2,0x07de,0x07cf};
441 static const itemTest t371[2] = {{{0,0,0,0,0,0},0,1,1,1,0,nko_tag,TRUE,{-1,0,0,0,arab_tag,0}},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
442 static const itemTest t372[2] = {{{0,0,0,0,0,0},0,1,1,1,0,nko_tag,TRUE,{-1,0,0,2,arab_tag,0}},{{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
443 static const itemTest t373[2] = {{{0,0,0,0,0,0},0,0,0,0,1,nko_tag,TRUE,{-1,0,0,2,arab_tag,0}}, {{0,0,0,0,0,0},3,0,0,0,0,-1,FALSE}};
445 /* Vai */
446 static const WCHAR test38[] = {0xa559,0xa524};
447 static const itemTest t381[2] = {{{0,0,0,0,0,0},0,0,0,0,0,vai_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
448 static const itemTest t382[2] = {{{0,0,0,0,0,0},0,0,0,2,0,vai_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0,0},2,0,0,0,0,-1,FALSE}};
450 /* Cherokee */
451 static const WCHAR test39[] = {0x13e3,0x13b3,0x13a9,0x0020,0x13a6,0x13ec,0x13c2,0x13af,0x13cd,0x13d7};
452 static const itemTest t391[2] = {{{0,0,0,0,0,0},0,0,0,0,0,cher_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
453 static const itemTest t392[2] = {{{0,0,0,0,0,0},0,0,0,2,0,cher_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},10,0,0,0,0,-1,FALSE}};
455 /* Canadian Aboriginal Syllabics */
456 static const WCHAR test40[] = {0x1403,0x14c4,0x1483,0x144e,0x1450,0x1466};
457 static const itemTest t401[2] = {{{0,0,0,0,0,0},0,0,0,0,0,cans_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
458 static const itemTest t402[2] = {{{0,0,0,0,0,0},0,0,0,2,0,cans_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
460 /* Ogham */
461 static const WCHAR test41[] = {0x169b,0x1691,0x168c,0x1690,0x168b,0x169c};
462 static const itemTest t411[2] = {{{0,0,0,0,0,0},0,0,0,0,0,ogam_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
463 static const itemTest t412[4] = {{{0,0,0,0,0,0},0,1,1,1,0,ogam_tag,FALSE},{{0,0,0,0,0,0},1,0,0,2,0,ogam_tag,FALSE},{{0,0,0,0,0,0},5,1,1,1,0,ogam_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
464 static const int b412[2] = {1,1};
466 /* Runic */
467 static const WCHAR test42[] = {0x16a0,0x16a1,0x16a2,0x16a3,0x16a4,0x16a5};
468 static const itemTest t421[2] = {{{0,0,0,0,0,0},0,0,0,0,0,runr_tag,FALSE},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
469 static const itemTest t422[4] = {{{0,0,0,0,0,0},0,0,0,2,0,runr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
471 /* Braille */
472 static const WCHAR test43[] = {0x280f,0x2817,0x2811,0x280d,0x280a,0x2811,0x2817};
473 static const itemTest t431[2] = {{{0,0,0,0,0,0},0,0,0,0,0,brai_tag,FALSE},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
474 static const itemTest t432[4] = {{{0,0,0,0,0,0},0,0,0,2,0,brai_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
476 /* Private and Surrogates Area */
477 static const WCHAR test44[] = {0xe000, 0xe001, 0xd800, 0xd801};
478 static const itemTest t441[3] = {{{0,0,0,0,0,0},0,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},2,0,0,0,0,0,FALSE},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
479 static const itemTest t442[4] = {{{0,0,0,0,0,0},0,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},2,0,0,2,0,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0,0},4,0,0,0,0,-1,FALSE}};
481 /* Deseret */
482 static const WCHAR test45[] = {0xd801,0xdc19,0xd801,0xdc32,0xd801,0xdc4c,0xd801,0xdc3c,0xd801,0xdc32,0xd801,0xdc4b,0xd801,0xdc2f,0xd801,0xdc4c,0xd801,0xdc3b,0xd801,0xdc32,0xd801,0xdc4a,0xd801,0xdc28};
483 static const itemTest t451[2] = {{{0,0,0,0,0,0},0,0,0,0,0,dsrt_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},24,0,0,0,0,-1,FALSE}};
484 static const itemTest t452[2] = {{{0,0,0,0,0,0},0,0,0,2,0,dsrt_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},24,0,0,0,0,-1,FALSE}};
486 /* Osmanya */
487 static const WCHAR test46[] = {0xd801,0xdc8b,0xd801,0xdc98,0xd801,0xdc88,0xd801,0xdc91,0xd801,0xdc9b,0xd801,0xdc92,0xd801,0xdc95,0xd801,0xdc80};
488 static const itemTest t461[2] = {{{0,0,0,0,0,0},0,0,0,0,0,osma_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
489 static const itemTest t462[2] = {{{0,0,0,0,0,0},0,0,0,2,0,osma_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},16,0,0,0,0,-1,FALSE}};
491 /* Mathematical Alphanumeric Symbols */
492 static const WCHAR test47[] = {0xd835,0xdc00,0xd835,0xdc35,0xd835,0xdc6a,0xd835,0xdc9f,0xd835,0xdcd4,0xd835,0xdd09,0xd835,0xdd3e,0xd835,0xdd73,0xd835,0xdda8,0xd835,0xdddd,0xd835,0xde12,0xd835,0xde47,0xd835,0xde7c};
493 static const itemTest t471[2] = {{{0,0,0,0,0,0},0,0,0,0,0,math_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0,0},26,0,0,0,0,-1,FALSE}};
494 static const itemTest t472[2] = {{{0,0,0,0,0,0},0,0,0,2,0,math_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0,0},26,0,0,0,0,-1,FALSE}};
496 /* Mathematical and Numeric combinations */
497 /* These have a leading hebrew character to force complicated itemization */
498 static const WCHAR test48[] = {0x05e9,' ','1','2','3','.'};
499 static const itemTest t481[4] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
500 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,0,0,FALSE},
501 {{0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
502 static const itemTest t482[4] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
503 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
504 {{0,0,0,0,0,0},5,0,0,0,1,0,FALSE},
505 {{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
507 static const WCHAR test49[] = {0x05e9,' ','1','2','.','1','2'};
508 static const itemTest t491[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
509 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
510 static const itemTest t492[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
511 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
512 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
514 static const WCHAR test50[] = {0x05e9,' ','.','1','2','3'};
515 static const itemTest t501[4] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
516 {{0,0,0,0,0},2,1,1,1,0,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,0,FALSE},
517 {{0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
518 static const itemTest t502[4] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
519 {{0,0,0,0,0,0},2,0,0,0,1,0,FALSE},
520 {{0,0,0,0,0,0},3,0,1,0,1,0,FALSE},
521 {{0,0,0,0,0,0},6,0,0,0,0,-1,FALSE}};
523 static const WCHAR test51[] = {0x05e9,' ','a','b','.','1','2'};
524 static const itemTest t511[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
525 {{0,0,0,0,0},1,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,0,FALSE},
526 {{0,0,0,0,0},5,0,0,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
527 static const itemTest t512[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
528 {{0,0,0,0,0,0},2,0,0,0,1,latn_tag,FALSE},
529 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
530 {{0,0,0,0,0,0},5,0,0,0,1,0,FALSE},
531 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
533 static const WCHAR test52[] = {0x05e9,' ','1','2','.','a','b'};
534 static const itemTest t521[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
535 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,0,FALSE},
536 {{0,0,0,0,0},5,0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
537 static const itemTest t522[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
538 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
539 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
540 {{0,0,0,0,0,0},5,0,0,0,1,latn_tag,FALSE},
541 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
543 static const WCHAR test53[] = {0x05e9,' ','1','2','.','.','1','2'};
544 static const itemTest t531[5] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
545 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},4,1,1,1,0,0,FALSE},
546 {{0,0,0,0,0},6,0,1,2,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
547 static const itemTest t532[5] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
548 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
549 {{0,0,0,0,0,0},4,0,0,0,1,0,FALSE},
550 {{0,0,0,0,0,0},6,0,1,0,1,0,FALSE},
551 {{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
553 static const WCHAR test54[] = {0x05e9,' ','1','2','+','1','2'};
554 static const itemTest t541[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
555 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
556 static const itemTest t542[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
557 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
558 {{0,0,0,0,0,0},7,0,0,0,0,-1,FALSE}};
559 static const WCHAR test55[] = {0x05e9,' ','1','2','+','+','1','2'};
560 static const itemTest t551[3] = {{{0,0,0,0,0,0},0,1,1,1,0,hebr_tag,FALSE},
561 {{0,0,0,0,0},2,0,1,2,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
562 static const itemTest t552[3] = {{{0,0,0,0,0,0},0,0,0,0,1,hebr_tag,FALSE},
563 {{0,0,0,0,0,0},2,0,1,0,1,0,FALSE},
564 {{0,0,0,0,0,0},8,0,0,0,0,-1,FALSE}};
566 SCRIPT_ITEM items[15];
567 SCRIPT_CONTROL Control;
568 SCRIPT_STATE State;
569 HRESULT hr;
570 HMODULE usp10;
571 int nItems;
573 usp10 = LoadLibraryA("usp10.dll");
574 ok (usp10 != 0,"Unable to LoadLibrary on usp10.dll\n");
575 pScriptItemizeOpenType = (void*)GetProcAddress(usp10, "ScriptItemizeOpenType");
576 pScriptShapeOpenType = (void*)GetProcAddress(usp10, "ScriptShapeOpenType");
577 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
579 memset(&Control, 0, sizeof(Control));
580 memset(&State, 0, sizeof(State));
582 hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
583 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
585 hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
586 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
588 hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
589 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
591 hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
592 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
594 test_items_ok(test1,4,NULL,NULL,1,t11,FALSE,0);
595 test_items_ok(test1b,4,NULL,NULL,1,t1b1,FALSE,0);
596 test_items_ok(test1c,6,NULL,NULL,1,t1c1,FALSE,0);
597 test_items_ok(test2,16,NULL,NULL,6,t21,FALSE,0);
598 test_items_ok(test2b,11,NULL,NULL,4,t2b1,FALSE,0);
599 test_items_ok(test2c,11,NULL,NULL,4,t2c1,FALSE,0);
600 test_items_ok(test2d,11,NULL,NULL,4,t2d1,FALSE,0);
601 test_items_ok(test3,41,NULL,NULL,1,t31,FALSE,0);
602 test_items_ok(test4,12,NULL,NULL,5,t41,FALSE,0);
603 test_items_ok(test5,38,NULL,NULL,1,t51,FALSE,0);
604 test_items_ok(test6,5,NULL,NULL,2,t61,FALSE,0);
605 test_items_ok(test7,29,NULL,NULL,3,t71,FALSE,0);
606 test_items_ok(test8,4,NULL,NULL,1,t81,FALSE,0);
607 test_items_ok(test9,5,NULL,NULL,2,t91,FALSE,0);
608 test_items_ok(test10,4,NULL,NULL,1,t101,FALSE,0);
609 test_items_ok(test11,8,NULL,NULL,1,t111,FALSE,0);
610 test_items_ok(test12,5,NULL,NULL,1,t121,FALSE,0);
611 test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
612 test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
613 test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
614 test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
615 test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
616 test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
617 test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
618 test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
619 test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
620 test_items_ok(test22,6,NULL,NULL,2,t221,FALSE,0);
621 test_items_ok(test23,6,NULL,NULL,2,t231,FALSE,0);
622 test_items_ok(test24,12,NULL,NULL,1,t241,FALSE,0);
623 test_items_ok(test25,10,NULL,NULL,1,t251,FALSE,0);
624 test_items_ok(test26,2,NULL,NULL,1,t261,FALSE,0);
625 test_items_ok(test27,8,NULL,NULL,1,t271,FALSE,0);
626 test_items_ok(test28,4,NULL,NULL,1,t281,FALSE,0);
627 test_items_ok(test29,10,NULL,NULL,2,t291,FALSE,0);
628 test_items_ok(test30,8,NULL,NULL,1,t301,FALSE,0);
629 test_items_ok(test31,8,NULL,NULL,1,t311,FALSE,b311);
630 test_items_ok(test32,3,NULL,NULL,1,t321,FALSE,0);
631 test_items_ok(test33,4,NULL,NULL,1,t331,FALSE,0);
632 test_items_ok(test34,3,NULL,NULL,1,t341,FALSE,0);
633 test_items_ok(test35,13,NULL,NULL,1,t351,FALSE,b351);
634 test_items_ok(test36,7,NULL,NULL,1,t361,FALSE,0);
635 test_items_ok(test37,3,NULL,NULL,1,t371,FALSE,0);
636 test_items_ok(test38,2,NULL,NULL,1,t381,FALSE,0);
637 test_items_ok(test39,10,NULL,NULL,1,t391,FALSE,0);
638 test_items_ok(test40,6,NULL,NULL,1,t401,FALSE,0);
639 test_items_ok(test41,6,NULL,NULL,1,t411,FALSE,0);
640 test_items_ok(test42,6,NULL,NULL,1,t421,FALSE,0);
641 test_items_ok(test43,7,NULL,NULL,1,t431,FALSE,0);
642 test_items_ok(test44,4,NULL,NULL,2,t441,FALSE,0);
643 test_items_ok(test45,24,NULL,NULL,1,t451,FALSE,0);
644 test_items_ok(test46,16,NULL,NULL,1,t461,FALSE,0);
645 test_items_ok(test47,26,NULL,NULL,1,t471,FALSE,0);
647 State.uBidiLevel = 0;
648 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
649 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
650 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
651 test_items_ok(test2,16,&Control,&State,4,t22,FALSE,0);
652 test_items_ok(test2b,11,&Control,&State,4,t2b1,FALSE,0);
653 test_items_ok(test2c,11,&Control,&State,5,t2c2,FALSE,0);
654 test_items_ok(test2d,11,&Control,&State,5,t2d2,FALSE,0);
655 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
656 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
657 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
658 test_items_ok(test6,5,&Control,&State,2,t61,FALSE,0);
659 test_items_ok(test7,29,&Control,&State,3,t72,FALSE,0);
660 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
661 test_items_ok(test9,5,&Control,&State,2,t91,FALSE,0);
662 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
663 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
664 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
665 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
666 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
667 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
668 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
669 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
670 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
671 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
672 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
673 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
674 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
675 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
676 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
677 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
678 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
679 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
680 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
681 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
682 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
683 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
684 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
685 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
686 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
687 test_items_ok(test35,13,&Control,&State,1,t351,FALSE,b351);
688 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
689 test_items_ok(test37,3,&Control,&State,1,t371,FALSE,0);
690 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
691 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
692 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
693 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
694 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
695 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
696 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
697 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
698 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
699 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
700 test_items_ok(test48,6,&Control,&State,3,t481,FALSE,0);
701 test_items_ok(test49,7,&Control,&State,2,t491,FALSE,0);
702 test_items_ok(test50,6,&Control,&State,3,t501,FALSE,0);
703 test_items_ok(test51,7,&Control,&State,4,t511,FALSE,0);
704 test_items_ok(test52,7,&Control,&State,4,t521,FALSE,0);
705 test_items_ok(test53,8,&Control,&State,4,t531,FALSE,0);
706 test_items_ok(test54,7,&Control,&State,2,t541,FALSE,0);
707 test_items_ok(test55,8,&Control,&State,2,t551,FALSE,0);
709 State.uBidiLevel = 1;
710 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
711 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
712 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
713 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
714 test_items_ok(test2b,11,&Control,&State,4,t2b2,FALSE,0);
715 test_items_ok(test2c,11,&Control,&State,4,t2c3,FALSE,0);
716 test_items_ok(test2d,11,&Control,&State,4,t2d3,FALSE,0);
717 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
718 test_items_ok(test4,12,&Control,&State,4,t42,FALSE,0);
719 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
720 test_items_ok(test6,5,&Control,&State,2,t62,FALSE,0);
721 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
722 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
723 test_items_ok(test9,5,&Control,&State,2,t92,FALSE,0);
724 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
725 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
726 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
727 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
728 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
729 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
730 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
731 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
732 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
733 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
734 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
735 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
736 test_items_ok(test22,6,&Control,&State,2,t222,FALSE,b222);
737 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
738 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
739 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
740 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
741 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
742 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
743 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
744 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
745 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
746 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
747 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
748 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
749 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
750 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
751 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
752 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
753 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
754 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
755 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
756 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
757 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
758 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
759 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
760 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
761 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
763 State.uBidiLevel = 1;
764 Control.fMergeNeutralItems = TRUE;
765 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
766 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
767 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
768 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
769 test_items_ok(test2b,11,&Control,&State,2,t2b3,FALSE,b2);
770 test_items_ok(test2c,11,&Control,&State,2,t2c4,FALSE,b2);
771 test_items_ok(test2d,11,&Control,&State,2,t2d4,FALSE,b2);
772 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
773 test_items_ok(test4,12,&Control,&State,3,t43,FALSE,b43);
774 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
775 test_items_ok(test6,5,&Control,&State,1,t63,FALSE,b63);
776 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
777 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
778 test_items_ok(test9,5,&Control,&State,1,t93,FALSE,b93);
779 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
780 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
781 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
782 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
783 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
784 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
785 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
786 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
787 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
788 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
789 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
790 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
791 test_items_ok(test22,6,&Control,&State,1,t223,FALSE,b223);
792 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
793 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
794 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
795 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
796 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
797 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
798 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
799 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
800 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
801 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
802 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
803 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
804 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
805 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
806 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
807 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
808 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
809 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
810 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
811 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
812 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
813 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
814 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
815 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
816 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
818 State.uBidiLevel = 0;
819 Control.fMergeNeutralItems = FALSE;
820 State.fOverrideDirection = 1;
821 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
822 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
823 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
824 test_items_ok(test2,16,&Control,&State,4,t24,FALSE,0);
825 test_items_ok(test2b,11,&Control,&State,4,t2b4,FALSE,0);
826 test_items_ok(test2c,11,&Control,&State,4,t2c5,FALSE,0);
827 test_items_ok(test2d,11,&Control,&State,4,t2d5,FALSE,0);
828 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
829 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
830 test_items_ok(test5,38,&Control,&State,1,t52,FALSE,0);
831 test_items_ok(test6,5,&Control,&State,2,t64,FALSE,0);
832 test_items_ok(test7,29,&Control,&State,3,t74,FALSE,0);
833 test_items_ok(test8,4,&Control,&State,1,t82,FALSE,0);
834 test_items_ok(test9,5,&Control,&State,2,t94,FALSE,0);
835 test_items_ok(test10,4,&Control,&State,1,t102,FALSE,0);
836 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
837 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
838 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
839 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
840 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
841 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
842 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
843 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
844 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
845 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
846 test_items_ok(test21,5,&Control,&State,1,t212,FALSE,0);
847 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
848 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
849 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
850 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
851 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
852 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
853 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
854 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
855 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
856 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
857 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
858 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
859 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
860 test_items_ok(test35,13,&Control,&State,1,t353,FALSE,b351);
861 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
862 test_items_ok(test37,3,&Control,&State,1,t373,FALSE,0);
863 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
864 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
865 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
866 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
867 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
868 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
869 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
870 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
871 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
872 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
873 test_items_ok(test48,6,&Control,&State,3,t482,FALSE,0);
874 test_items_ok(test49,7,&Control,&State,2,t492,FALSE,0);
875 test_items_ok(test50,6,&Control,&State,3,t502,FALSE,0);
876 test_items_ok(test51,7,&Control,&State,4,t512,FALSE,0);
877 test_items_ok(test52,7,&Control,&State,4,t522,FALSE,0);
878 test_items_ok(test53,8,&Control,&State,4,t532,FALSE,0);
879 test_items_ok(test54,7,&Control,&State,2,t542,FALSE,0);
880 test_items_ok(test55,8,&Control,&State,2,t552,FALSE,0);
883 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
884 DWORD cchString, SCRIPT_CONTROL *Control,
885 SCRIPT_STATE *State, DWORD item, DWORD nGlyphs,
886 const shapeTest_char* charItems,
887 const shapeTest_glyph* glyphItems)
889 HRESULT hr;
890 int x, outnItems=0, outnGlyphs=0;
891 SCRIPT_ITEM outpItems[15];
892 SCRIPT_CACHE sc = NULL;
893 WORD *glyphs;
894 WORD *logclust;
895 int maxGlyphs = cchString * 1.5;
896 SCRIPT_GLYPHPROP *glyphProp;
897 SCRIPT_CHARPROP *charProp;
898 ULONG tags[15];
900 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
901 if (hr == USP_E_SCRIPT_NOT_IN_FONT)
903 if (valid > 0)
904 winetest_win_skip("Select font does not support script\n");
905 else
906 winetest_trace("Select font does not support script\n");
907 return;
909 if (valid > 0)
910 winetest_ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
911 else if (hr != S_OK)
912 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr);
914 if (outnItems <= item)
916 if (valid > 0)
917 winetest_win_skip("Did not get enough items\n");
918 else
919 winetest_trace("Did not get enough items\n");
920 return;
923 logclust = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * cchString);
924 memset(logclust,'a',sizeof(WORD) * cchString);
925 charProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP) * cchString);
926 memset(charProp,'a',sizeof(SCRIPT_CHARPROP) * cchString);
927 glyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * maxGlyphs);
928 memset(glyphs,'a',sizeof(WORD) * cchString);
929 glyphProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP) * maxGlyphs);
930 memset(glyphProp,'a',sizeof(SCRIPT_GLYPHPROP) * cchString);
932 hr = pScriptShapeOpenType(hdc, &sc, &outpItems[item].a, tags[item], 0x00000000, NULL, NULL, 0, string, cchString, maxGlyphs, logclust, charProp, glyphs, glyphProp, &outnGlyphs);
933 if (valid > 0)
934 winetest_ok(hr == S_OK, "ScriptShapeOpenType failed (%x)\n",hr);
935 else if (hr != S_OK)
936 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr);
937 if (FAILED(hr))
938 goto cleanup;
940 for (x = 0; x < cchString; x++)
942 if (valid > 0)
943 winetest_ok(logclust[x] == charItems[x].wLogClust, "%i: invalid LogClust(%i)\n",x,logclust[x]);
944 else if (logclust[x] != charItems[x].wLogClust)
945 winetest_trace("%i: invalid LogClust(%i)\n",x,logclust[x]);
946 if (valid > 0)
947 winetest_ok(charProp[x].fCanGlyphAlone == charItems[x].CharProp.fCanGlyphAlone, "%i: invalid fCanGlyphAlone\n",x);
948 else if (charProp[x].fCanGlyphAlone != charItems[x].CharProp.fCanGlyphAlone)
949 winetest_trace("%i: invalid fCanGlyphAlone\n",x);
952 if (valid > 0)
953 winetest_ok(nGlyphs == outnGlyphs, "got incorrect number of glyphs (%i)\n",outnGlyphs);
954 else if (nGlyphs != outnGlyphs)
955 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs);
956 for (x = 0; x < outnGlyphs; x++)
958 if (glyphItems[x].Glyph)
960 if (valid > 0)
961 winetest_ok(glyphs[x]!=0, "%i: Glyph not present when it should be\n",x);
962 else if (glyphs[x]==0)
963 winetest_trace("%i: Glyph not present when it should be\n",x);
965 else
967 if (valid > 0)
968 winetest_ok(glyphs[x]==0, "%i: Glyph present when it should not be\n",x);
969 else if (glyphs[x]!=0)
970 winetest_trace("%i: Glyph present when it should not be\n",x);
972 if (valid > 0)
973 winetest_ok(glyphProp[x].sva.uJustification == glyphItems[x].GlyphProp.sva.uJustification, "%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
974 else if (glyphProp[x].sva.uJustification != glyphItems[x].GlyphProp.sva.uJustification)
975 winetest_trace("%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
976 if (valid > 0)
977 winetest_ok(glyphProp[x].sva.fClusterStart == glyphItems[x].GlyphProp.sva.fClusterStart, "%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
978 else if (glyphProp[x].sva.fClusterStart != glyphItems[x].GlyphProp.sva.fClusterStart)
979 winetest_trace("%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
980 if (valid > 0)
981 winetest_ok(glyphProp[x].sva.fDiacritic == glyphItems[x].GlyphProp.sva.fDiacritic, "%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
982 else if (glyphProp[x].sva.fDiacritic != glyphItems[x].GlyphProp.sva.fDiacritic)
983 winetest_trace("%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
984 if (valid > 0)
985 winetest_ok(glyphProp[x].sva.fZeroWidth == glyphItems[x].GlyphProp.sva.fZeroWidth, "%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
986 else if (glyphProp[x].sva.fZeroWidth != glyphItems[x].GlyphProp.sva.fZeroWidth)
987 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
990 cleanup:
991 HeapFree(GetProcessHeap(),0,logclust);
992 HeapFree(GetProcessHeap(),0,charProp);
993 HeapFree(GetProcessHeap(),0,glyphs);
994 HeapFree(GetProcessHeap(),0,glyphProp);
995 ScriptFreeCache(&sc);
998 #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)
1000 #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)
1002 typedef struct tagRangeP {
1003 BYTE range;
1004 LOGFONTA lf;
1005 } fontEnumParam;
1007 static int CALLBACK enumFontProc( const LOGFONTA *lpelfe, const TEXTMETRICA *lpntme, DWORD FontType, LPARAM lParam )
1009 NEWTEXTMETRICEXA *ntme = (NEWTEXTMETRICEXA*)lpntme;
1010 fontEnumParam *rp = (fontEnumParam*) lParam;
1011 int idx = 0;
1012 DWORD i;
1013 DWORD mask = 0;
1015 if (FontType != TRUETYPE_FONTTYPE)
1016 return 1;
1018 i = rp->range;
1019 while (i >= sizeof(DWORD)*8)
1021 idx++;
1022 i -= (sizeof(DWORD)*8);
1024 if (idx > 3)
1025 return 0;
1027 mask = 1 << i;
1029 if (ntme->ntmFontSig.fsUsb[idx] & mask)
1031 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONTA));
1032 return 0;
1034 return 1;
1037 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
1039 int rc = 0;
1040 fontEnumParam lParam;
1042 lParam.range = range;
1043 memset(&lParam.lf,0,sizeof(LOGFONTA));
1044 *hfont = NULL;
1046 if (recommended)
1048 lstrcpyA(lParam.lf.lfFaceName, recommended);
1049 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
1051 *hfont = CreateFontIndirectA(&lParam.lf);
1052 if (*hfont)
1054 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
1055 rc = 1;
1060 if (!*hfont)
1062 memset(&lParam.lf,0,sizeof(LOGFONTA));
1063 lParam.lf.lfCharSet = DEFAULT_CHARSET;
1065 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
1067 *hfont = CreateFontIndirectA(&lParam.lf);
1068 if (*hfont)
1069 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
1073 if (*hfont)
1075 WORD glyph = 0;
1077 *origFont = SelectObject(hdc,*hfont);
1078 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
1080 winetest_trace(" Font fails to contain required glyphs\n");
1081 SelectObject(hdc,*origFont);
1082 DeleteObject(*hfont);
1083 *hfont=NULL;
1084 rc = 0;
1086 else if (!rc)
1087 rc = -1;
1089 else
1090 winetest_trace("Failed to find usable font\n");
1092 return rc;
1095 #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)
1097 static void test_ScriptShapeOpenType(HDC hdc)
1099 HRESULT hr;
1100 SCRIPT_CACHE sc = NULL;
1101 WORD glyphs[4], logclust[4];
1102 SCRIPT_GLYPHPROP glyphProp[4];
1103 SCRIPT_ITEM items[2];
1104 ULONG tags[2];
1105 SCRIPT_CONTROL Control;
1106 SCRIPT_STATE State;
1107 int nb, outnItems;
1108 HFONT hfont, hfont_orig;
1109 int test_valid;
1110 shapeTest_glyph glyph_test[4];
1112 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1113 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
1114 static const shapeTest_glyph t1_g[] = {
1115 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1116 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1117 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1118 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1120 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1121 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
1122 static const shapeTest_glyph t2_g[] = {
1123 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1124 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1125 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1126 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1128 /* Hebrew */
1129 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
1130 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
1131 static const shapeTest_glyph hebrew_g[] = {
1132 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1133 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1134 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1135 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
1137 /* Arabic */
1138 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
1139 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
1140 static const shapeTest_glyph arabic_g[] = {
1141 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1142 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
1143 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
1145 /* Thai */
1146 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
1147 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}}};
1148 static const shapeTest_glyph thai_g[] = {
1149 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1150 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1151 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1152 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1153 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1154 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1155 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1156 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1157 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1158 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
1160 /* Syriac */
1161 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
1162 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
1163 static const shapeTest_glyph syriac_g[] = {
1164 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1165 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1166 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1167 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1168 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1169 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1171 /* Thaana */
1172 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
1173 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}}};
1174 static const shapeTest_glyph thaana_g[] = {
1175 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1176 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1177 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1178 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1179 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1180 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1181 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1182 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1183 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1184 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1185 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1186 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1187 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1189 /* Phags-pa */
1190 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
1191 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}}};
1192 static const shapeTest_glyph phagspa_g[] = {
1193 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1194 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1195 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1196 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1197 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1198 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
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_CHARACTER,1,0,0,0,0},0}},
1202 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1203 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1205 /* Lao */
1206 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
1207 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}}};
1208 static const shapeTest_glyph lao_g[] = {
1209 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1210 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1211 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1212 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1213 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1214 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1215 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1216 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1217 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1219 /* Tibetan */
1220 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
1221 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}}};
1222 static const shapeTest_glyph tibetan_g[] = {
1223 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1224 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1225 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1226 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
1227 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1228 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1229 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1230 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1231 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1232 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1233 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1234 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1235 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1236 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1237 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1238 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1239 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1241 /* Devanagari */
1242 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
1243 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}}};
1244 static const shapeTest_glyph devanagari_g[] = {
1245 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1246 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1247 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1248 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1249 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1250 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1251 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1252 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1254 /* Bengali */
1255 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
1256 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
1257 static const shapeTest_glyph bengali_g[] = {
1258 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1259 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1260 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1261 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1262 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1264 /* Gurmukhi */
1265 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
1266 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}}};
1267 static const shapeTest_glyph gurmukhi_g[] = {
1268 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1269 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1270 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1271 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1272 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1273 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1274 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1276 /* Gujarati */
1277 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
1278 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}}};
1279 static const shapeTest_glyph gujarati_g[] = {
1280 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1281 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1282 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1283 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1284 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1285 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1286 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1288 /* Oriya */
1289 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
1290 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1291 static const shapeTest_glyph oriya_g[] = {
1292 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1293 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1294 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1295 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1297 /* Tamil */
1298 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1299 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1300 static const shapeTest_glyph tamil_g[] = {
1301 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1302 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1303 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1304 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1306 /* Telugu */
1307 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1308 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1309 static const shapeTest_glyph telugu_g[] = {
1310 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1311 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1312 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1313 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1314 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1315 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1317 /* Malayalam */
1318 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1319 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1320 static const shapeTest_glyph malayalam_g[] = {
1321 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1322 {1,{{SCRIPT_JUSTIFY_NONE,1,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}},
1325 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1326 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1328 /* Kannada */
1329 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1330 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1331 static const shapeTest_glyph kannada_g[] = {
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 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
1340 win_skip("ScriptShapeOpenType not available on this platform\n");
1341 return;
1344 memset(&Control, 0 , sizeof(Control));
1345 memset(&State, 0 , sizeof(State));
1347 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
1348 ok(hr == S_OK, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
1349 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1351 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
1352 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1354 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
1355 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1357 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1358 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
1360 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1361 ok( hr == E_INVALIDARG,
1362 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1363 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
1364 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1366 ScriptFreeCache(&sc);
1368 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
1370 /* newer Tahoma has zerowidth space glyphs for 0x202b and 0x202c */
1371 memcpy(glyph_test, t2_g, sizeof(glyph_test));
1372 GetGlyphIndicesW(hdc, test2, 4, glyphs, 0);
1373 if (glyphs[0] != 0)
1374 glyph_test[0].Glyph = 1;
1375 if (glyphs[3] != 0)
1376 glyph_test[3].Glyph = 1;
1378 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, glyph_test);
1380 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
1381 if (hfont != NULL)
1383 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
1384 SelectObject(hdc, hfont_orig);
1385 DeleteObject(hfont);
1388 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
1389 if (hfont != NULL)
1391 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
1392 SelectObject(hdc, hfont_orig);
1393 DeleteObject(hfont);
1396 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
1397 if (hfont != NULL)
1399 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
1400 SelectObject(hdc, hfont_orig);
1401 DeleteObject(hfont);
1404 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
1405 if (hfont != NULL)
1407 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
1408 SelectObject(hdc, hfont_orig);
1409 DeleteObject(hfont);
1412 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
1413 if (hfont != NULL)
1415 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
1416 SelectObject(hdc, hfont_orig);
1417 DeleteObject(hfont);
1420 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
1421 if (hfont != NULL)
1423 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
1424 SelectObject(hdc, hfont_orig);
1425 DeleteObject(hfont);
1428 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
1429 if (hfont != NULL)
1431 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
1432 SelectObject(hdc, hfont_orig);
1433 DeleteObject(hfont);
1436 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
1437 if (hfont != NULL)
1439 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
1440 SelectObject(hdc, hfont_orig);
1441 DeleteObject(hfont);
1444 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1445 if (hfont != NULL)
1447 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1448 SelectObject(hdc, hfont_orig);
1449 DeleteObject(hfont);
1452 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1453 if (hfont != NULL)
1455 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1456 SelectObject(hdc, hfont_orig);
1457 DeleteObject(hfont);
1460 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1461 if (hfont != NULL)
1463 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1464 SelectObject(hdc, hfont_orig);
1465 DeleteObject(hfont);
1468 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1469 if (hfont != NULL)
1471 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1472 SelectObject(hdc, hfont_orig);
1473 DeleteObject(hfont);
1476 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1477 if (hfont != NULL)
1479 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1480 SelectObject(hdc, hfont_orig);
1481 DeleteObject(hfont);
1484 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1485 if (hfont != NULL)
1487 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1488 SelectObject(hdc, hfont_orig);
1489 DeleteObject(hfont);
1492 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1493 if (hfont != NULL)
1495 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1496 SelectObject(hdc, hfont_orig);
1497 DeleteObject(hfont);
1500 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1501 if (hfont != NULL)
1503 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1504 SelectObject(hdc, hfont_orig);
1505 DeleteObject(hfont);
1508 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1509 if (hfont != NULL)
1511 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1512 SelectObject(hdc, hfont_orig);
1513 DeleteObject(hfont);
1517 static void test_ScriptShape(HDC hdc)
1519 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1520 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1521 HRESULT hr;
1522 SCRIPT_CACHE sc = NULL;
1523 WORD glyphs[4], glyphs2[4], logclust[4], glyphs3[4];
1524 SCRIPT_VISATTR attrs[4];
1525 SCRIPT_ITEM items[2];
1526 int nb, i, j;
1528 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1529 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1530 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1532 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1533 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1535 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1536 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1538 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1539 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1541 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1542 ok(broken(hr == S_OK) ||
1543 hr == E_INVALIDARG || /* Vista, W2K8 */
1544 hr == E_FAIL, /* WIN7 */
1545 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1546 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1548 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1549 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1550 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1553 memset(glyphs,-1,sizeof(glyphs));
1554 memset(logclust,-1,sizeof(logclust));
1555 memset(attrs,-1,sizeof(attrs));
1556 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1557 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1558 ok(nb == 4, "Wrong number of items\n");
1559 ok(logclust[0] == 0, "clusters out of order\n");
1560 ok(logclust[1] == 1, "clusters out of order\n");
1561 ok(logclust[2] == 2, "clusters out of order\n");
1562 ok(logclust[3] == 3, "clusters out of order\n");
1563 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1564 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1565 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1566 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1567 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1568 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1569 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1570 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1571 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1572 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1573 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1574 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1575 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1576 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1577 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1578 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1580 ScriptFreeCache(&sc);
1581 sc = NULL;
1583 memset(glyphs2,-1,sizeof(glyphs2));
1584 memset(glyphs3,-1,sizeof(glyphs3));
1585 memset(logclust,-1,sizeof(logclust));
1586 memset(attrs,-1,sizeof(attrs));
1588 GetGlyphIndicesW(hdc, test2, 4, glyphs3, 0);
1590 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1591 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1592 ok(nb == 4, "Wrong number of items\n");
1593 ok(glyphs2[0] == glyphs3[0], "Incorrect glyph for 0x202B\n");
1594 ok(glyphs2[3] == glyphs3[3], "Incorrect glyph for 0x202C\n");
1595 ok(logclust[0] == 0, "clusters out of order\n");
1596 ok(logclust[1] == 1, "clusters out of order\n");
1597 ok(logclust[2] == 2, "clusters out of order\n");
1598 ok(logclust[3] == 3, "clusters out of order\n");
1599 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1600 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1601 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1602 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1603 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1604 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1605 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1606 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1607 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1608 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1609 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1610 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1611 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1612 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1613 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1614 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1616 /* modify LTR to RTL */
1617 items[0].a.fRTL = 1;
1618 memset(glyphs2,-1,sizeof(glyphs2));
1619 memset(logclust,-1,sizeof(logclust));
1620 memset(attrs,-1,sizeof(attrs));
1621 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1622 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1623 ok(nb == 4, "Wrong number of items\n");
1624 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1625 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1626 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1627 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1628 ok(logclust[0] == 3, "clusters out of order\n");
1629 ok(logclust[1] == 2, "clusters out of order\n");
1630 ok(logclust[2] == 1, "clusters out of order\n");
1631 ok(logclust[3] == 0, "clusters out of order\n");
1632 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1633 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1634 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1635 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1636 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1637 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1638 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1639 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1640 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1641 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1642 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1643 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1644 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1645 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1646 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1647 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1649 ScriptFreeCache(&sc);
1651 /* some control characters are shown as blank */
1652 for (i = 0; i < 2; i++)
1654 static const WCHAR space[] = {' ', 0};
1655 static const WCHAR blanks[] = {'\t', '\r', '\n', 0x001C, 0x001D, 0x001E, 0x001F,0};
1656 HFONT font, oldfont = NULL;
1657 LOGFONTA lf;
1659 font = GetCurrentObject(hdc, OBJ_FONT);
1660 GetObjectA(font, sizeof(lf), &lf);
1661 if (i == 1) {
1662 lstrcpyA(lf.lfFaceName, "MS Sans Serif");
1663 font = CreateFontIndirectA(&lf);
1664 oldfont = SelectObject(hdc, font);
1667 hr = ScriptItemize(space, 1, 2, NULL, NULL, items, NULL);
1668 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1670 hr = ScriptShape(hdc, &sc, space, 1, 1, &items[0].a, glyphs, logclust, attrs, &nb);
1671 ok(hr == S_OK, "%s: expected S_OK, got %08x\n", lf.lfFaceName, hr);
1672 ok(nb == 1, "%s: expected 1, got %d\n", lf.lfFaceName, nb);
1674 for (j = 0; blanks[j]; j++)
1676 hr = ScriptItemize(&blanks[j], 1, 2, NULL, NULL, items, NULL);
1677 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1679 hr = ScriptShape(hdc, &sc, &blanks[j], 1, 1, &items[0].a, glyphs2, logclust, attrs, &nb);
1680 ok(hr == S_OK, "%s: [%02x] expected S_OK, got %08x\n", lf.lfFaceName, blanks[j], hr);
1681 ok(nb == 1, "%s: [%02x] expected 1, got %d\n", lf.lfFaceName, blanks[j], nb);
1683 ok(glyphs[0] == glyphs2[0] ||
1684 broken(glyphs2[0] == blanks[j] && (blanks[j] < 0x10)),
1685 "%s: [%02x] expected %04x, got %04x\n", lf.lfFaceName, blanks[j], glyphs[0], glyphs2[0]);
1687 if (oldfont)
1688 DeleteObject(SelectObject(hdc, oldfont));
1689 ScriptFreeCache(&sc);
1693 static void test_ScriptPlace(HDC hdc)
1695 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1696 BOOL ret;
1697 HRESULT hr;
1698 SCRIPT_CACHE sc = NULL;
1699 WORD glyphs[4], logclust[4];
1700 SCRIPT_VISATTR attrs[4];
1701 SCRIPT_ITEM items[2];
1702 int nb, widths[4];
1703 GOFFSET offset[4];
1704 ABC abc[4];
1706 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1707 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
1708 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1710 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1711 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1712 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1714 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1715 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1717 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1718 ok(broken(hr == E_PENDING) ||
1719 hr == E_INVALIDARG || /* Vista, W2K8 */
1720 hr == E_FAIL, /* WIN7 */
1721 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1723 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1724 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1726 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1727 ok(broken(hr == E_PENDING) ||
1728 hr == E_INVALIDARG || /* Vista, W2K8 */
1729 hr == E_FAIL, /* WIN7 */
1730 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1732 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1733 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1734 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1736 if (widths[0] != 0)
1738 int old_width = widths[0];
1739 attrs[0].fZeroWidth = 1;
1741 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1742 ok(hr == S_OK, "ScriptPlace should return S_OK not %08x\n", hr);
1743 ok(widths[0] == 0, "got width %d\n", widths[0]);
1744 widths[0] = old_width;
1746 else
1747 skip("Glyph already has zero-width - skipping fZeroWidth test\n");
1749 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1750 ok(ret, "ExtTextOutW should return TRUE\n");
1752 ScriptFreeCache(&sc);
1755 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1757 HRESULT hr;
1758 int iMaxProps;
1759 const SCRIPT_PROPERTIES **ppSp;
1761 int cInChars;
1762 int cMaxItems;
1763 SCRIPT_ITEM pItem[255];
1764 int pcItems;
1765 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1766 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1767 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1768 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1769 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1770 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1772 SCRIPT_CACHE psc;
1773 int cChars;
1774 int cMaxGlyphs;
1775 unsigned short pwOutGlyphs1[256];
1776 unsigned short pwOutGlyphs2[256];
1777 unsigned short pwLogClust[256];
1778 SCRIPT_VISATTR psva[256];
1779 int pcGlyphs;
1780 int piAdvance[256];
1781 GOFFSET pGoffset[256];
1782 ABC pABC[256];
1783 int cnt;
1785 /* Start testing usp10 functions */
1786 /* This test determines that the pointer returned by ScriptGetProperties is valid
1787 * by checking a known value in the table */
1788 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1789 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1790 trace("number of script properties %d\n", iMaxProps);
1791 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1792 if (iMaxProps > 0)
1793 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1794 /* ptrs work */
1796 /* This is a valid test that will cause parsing to take place */
1797 cInChars = 5;
1798 cMaxItems = 255;
1799 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1800 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1801 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1802 * returned. */
1803 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1804 if (pcItems > 0)
1805 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1806 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1807 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1809 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1810 * ie. ScriptItemize has succeeded and that pItem has been set */
1811 cInChars = 5;
1812 if (hr == S_OK) {
1813 psc = NULL; /* must be null on first call */
1814 cChars = cInChars;
1815 cMaxGlyphs = cInChars;
1816 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1817 cMaxGlyphs, &pItem[0].a,
1818 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1819 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1820 cMaxGlyphs = 4;
1821 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1822 cMaxGlyphs, &pItem[0].a,
1823 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1824 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1825 "(%d) but not E_OUTOFMEMORY\n",
1826 cChars, cMaxGlyphs);
1827 cMaxGlyphs = 256;
1828 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1829 cMaxGlyphs, &pItem[0].a,
1830 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1831 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1832 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1833 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1834 if (hr ==0) {
1835 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1836 pGoffset, pABC);
1837 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1838 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1839 pGoffset, pABC);
1840 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1841 for (cnt=0; cnt < pcGlyphs; cnt++)
1842 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1845 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1846 * takes place if fNoGlyphIndex is set. */
1848 cInChars = 5;
1849 cMaxItems = 255;
1850 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1851 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1852 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1853 * returned. */
1854 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1855 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1856 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1857 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1858 if (hr == S_OK) {
1859 cChars = cInChars;
1860 cMaxGlyphs = 256;
1861 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1862 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1863 cMaxGlyphs, &pItem[0].a,
1864 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1865 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1866 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
1867 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1868 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1869 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1870 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1871 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1872 if (hr == S_OK) {
1873 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1874 pGoffset, pABC);
1875 ok (hr == S_OK, "ScriptPlace should return S_OK not (%08x)\n", hr);
1878 ScriptFreeCache( &psc);
1879 ok (!psc, "psc is not null after ScriptFreeCache\n");
1883 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1884 cInChars = (sizeof(TestItem3)/2)-1;
1885 cMaxItems = 255;
1886 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1887 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1888 if (hr == S_OK)
1890 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1891 if (pcItems > 2)
1893 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1894 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1895 pItem[0].iCharPos, pItem[1].iCharPos);
1896 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1897 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1898 pItem[1].iCharPos, pItem[2].iCharPos);
1899 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1900 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1901 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1905 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1906 cInChars = (sizeof(TestItem4)/2)-1;
1907 cMaxItems = 255;
1908 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1909 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1910 if (hr == S_OK)
1912 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1913 if (pcItems > 4)
1915 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1916 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1917 pItem[0].iCharPos, pItem[1].iCharPos);
1918 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1919 pItem[0].a.s.uBidiLevel);
1920 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1921 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1922 pItem[1].iCharPos, pItem[2].iCharPos);
1923 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1924 pItem[1].a.s.uBidiLevel);
1925 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1926 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1927 pItem[2].iCharPos, pItem[3].iCharPos);
1928 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1929 pItem[2].a.s.uBidiLevel);
1930 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1931 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1932 pItem[3].iCharPos, pItem[4].iCharPos);
1933 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1934 pItem[3].a.s.uBidiLevel);
1935 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1936 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1937 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1942 * This test is for when the first unicode character requires bidi support
1944 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1945 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1946 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
1947 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1948 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1949 pItem[0].a.s.uBidiLevel);
1951 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1952 * the pointer to the last char works. Note that windows often needs a greater number of *
1953 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1954 cInChars = (sizeof(TestItem6)/2)-1;
1955 cMaxItems = 4;
1956 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1957 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1961 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1963 HRESULT hr;
1964 SCRIPT_CACHE psc = NULL;
1965 int cInChars;
1966 int cChars;
1967 unsigned short pwOutGlyphs2[256];
1968 unsigned short pwOutGlyphs3[256];
1969 DWORD dwFlags;
1970 int cnt;
1972 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1973 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1974 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1975 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1977 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1978 dwFlags = 0;
1979 cInChars = cChars = 5;
1980 /* Some sanity checks for ScriptGetCMap */
1982 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1983 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
1984 "expected E_INVALIDARG, got %08x\n", hr);
1986 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1987 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1988 "expected E_INVALIDARG, got %08x\n", hr);
1990 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1991 psc = NULL;
1992 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1993 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1994 "got %08x\n", hr);
1995 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1997 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1998 psc = NULL;
1999 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
2000 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
2001 "got %08x\n", hr);
2002 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
2003 ScriptFreeCache( &psc);
2005 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2006 psc = NULL;
2007 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
2008 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
2009 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2010 /* Check to see if the results are the same as those returned by ScriptShape */
2011 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
2012 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2013 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2014 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
2015 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
2016 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
2018 ScriptFreeCache( &psc);
2019 ok (!psc, "psc is not null after ScriptFreeCache\n");
2021 /* ScriptGetCMap returns whatever font defines, no special treatment for control chars */
2022 cInChars = cChars = 4;
2023 GetGlyphIndicesW(hdc, TestItem2, cInChars, pwOutGlyphs2, 0);
2025 hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
2026 if (pwOutGlyphs3[0] == 0 || pwOutGlyphs3[3] == 0)
2027 ok(hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
2028 else
2029 ok(hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2031 ok(psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2032 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "expected glyph %d, got %d\n", pwOutGlyphs2[0], pwOutGlyphs3[0]);
2033 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "expected glyph %d, got %d\n", pwOutGlyphs2[3], pwOutGlyphs3[3]);
2035 cInChars = cChars = 9;
2036 hr = ScriptGetCMap(hdc, &psc, TestItem3b, cInChars, dwFlags, pwOutGlyphs2);
2037 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2038 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2040 cInChars = cChars = 9;
2041 dwFlags = SGCM_RTL;
2042 hr = ScriptGetCMap(hdc, &psc, TestItem3, cInChars, dwFlags, pwOutGlyphs3);
2043 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
2044 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2045 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "glyph incorrectly altered\n");
2046 ok(pwOutGlyphs3[1] == pwOutGlyphs2[1], "glyph incorrectly altered\n");
2047 ok(pwOutGlyphs3[2] == pwOutGlyphs2[2], "glyph incorrectly altered\n");
2048 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "glyph incorrectly altered\n");
2049 ok(pwOutGlyphs3[4] == pwOutGlyphs2[4], "glyph not mirrored correctly\n");
2050 ok(pwOutGlyphs3[5] == pwOutGlyphs2[5], "glyph not mirrored correctly\n");
2051 ok(pwOutGlyphs3[6] == pwOutGlyphs2[6], "glyph not mirrored correctly\n");
2052 ok(pwOutGlyphs3[7] == pwOutGlyphs2[7], "glyph not mirrored correctly\n");
2053 ok(pwOutGlyphs3[8] == pwOutGlyphs2[8], "glyph not mirrored correctly\n");
2055 ScriptFreeCache( &psc);
2056 ok (!psc, "psc is not null after ScriptFreeCache\n");
2059 #define MAX_ENUM_FONTS 4096
2061 struct enum_font_data
2063 int total;
2064 ENUMLOGFONTA elf[MAX_ENUM_FONTS];
2067 static INT CALLBACK enum_bitmap_font_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
2069 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
2071 if (type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE)) return 1;
2073 if (efnd->total < MAX_ENUM_FONTS)
2075 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
2077 else
2078 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
2080 return 1;
2083 static INT CALLBACK enum_truetype_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
2085 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
2087 if (!(type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE))) return 1;
2089 if (efnd->total < MAX_ENUM_FONTS)
2091 efnd->elf[efnd->total++] = *(ENUMLOGFONTA*)lf;
2093 else
2094 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
2096 return 1;
2099 static void test_ScriptGetFontProperties(HDC hdc)
2101 HRESULT hr;
2102 SCRIPT_CACHE psc,old_psc;
2103 SCRIPT_FONTPROPERTIES sfp;
2104 HFONT font, oldfont;
2105 LOGFONTA lf;
2106 struct enum_font_data efnd;
2107 TEXTMETRICA tmA;
2108 WORD gi[3];
2109 WCHAR str[3];
2110 DWORD i, ret;
2111 WORD system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
2112 static const WCHAR invalids[] = {0x0020, 0x200B, 0xF71B};
2113 /* U+0020: numeric space
2114 U+200B: zero width space
2115 U+F71B: unknown, found by black box testing */
2116 BOOL is_arial, is_times_new_roman, is_arabic = (system_lang_id == LANG_ARABIC);
2118 /* Some sanity checks for ScriptGetFontProperties */
2120 hr = ScriptGetFontProperties(NULL,NULL,NULL);
2121 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
2123 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
2124 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
2126 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2127 psc = NULL;
2128 hr = ScriptGetFontProperties(NULL,&psc,NULL);
2129 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
2130 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2132 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2133 psc = NULL;
2134 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
2135 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
2136 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2138 hr = ScriptGetFontProperties(hdc,NULL,NULL);
2139 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
2141 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
2142 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
2144 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2145 psc = NULL;
2146 hr = ScriptGetFontProperties(hdc,&psc,NULL);
2147 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
2148 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2150 /* Pass an invalid sfp */
2151 psc = NULL;
2152 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES) - 1;
2153 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
2154 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr);
2155 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
2156 ScriptFreeCache(&psc);
2157 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2159 /* Give it the correct cBytes, we don't care about what's coming back */
2160 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2161 psc = NULL;
2162 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
2163 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
2164 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
2166 /* Save the psc pointer */
2167 old_psc = psc;
2168 /* Now a NULL hdc again */
2169 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
2170 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
2171 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
2172 ScriptFreeCache(&psc);
2173 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2175 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
2176 if (!pGetGlyphIndicesW)
2178 win_skip("Skip on WINNT4\n");
2179 return;
2181 memset(&lf, 0, sizeof(lf));
2182 lf.lfCharSet = DEFAULT_CHARSET;
2183 efnd.total = 0;
2184 EnumFontFamiliesA(hdc, NULL, enum_bitmap_font_proc, (LPARAM)&efnd);
2186 for (i = 0; i < efnd.total; i++)
2188 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2190 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2191 continue;
2193 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2194 font = CreateFontIndirectA(&lf);
2195 oldfont = SelectObject(hdc, font);
2197 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2198 psc = NULL;
2199 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2200 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2201 if (winetest_interactive)
2203 trace("bitmap font %s\n", lf.lfFaceName);
2204 trace("wgBlank %04x\n", sfp.wgBlank);
2205 trace("wgDefault %04x\n", sfp.wgDefault);
2206 trace("wgInvalid %04x\n", sfp.wgInvalid);
2207 trace("wgKashida %04x\n", sfp.wgKashida);
2208 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2211 ret = GetTextMetricsA(hdc, &tmA);
2212 ok(ret != 0, "GetTextMetricsA failed!\n");
2214 ret = pGetGlyphIndicesW(hdc, invalids, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2215 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2217 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]);
2219 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);
2221 ok(sfp.wgInvalid == sfp.wgBlank || broken(is_arabic), "bitmap font %s wgInvalid %02x wgBlank %02x\n", lf.lfFaceName, sfp.wgInvalid, sfp.wgBlank);
2223 ok(sfp.wgKashida == 0xFFFF || broken(is_arabic), "bitmap font %s wgKashida %02x\n", lf.lfFaceName, sfp.wgKashida);
2225 ScriptFreeCache(&psc);
2227 SelectObject(hdc, oldfont);
2228 DeleteObject(font);
2231 efnd.total = 0;
2232 EnumFontFamiliesA(hdc, NULL, enum_truetype_proc, (LPARAM)&efnd);
2234 for (i = 0; i < efnd.total; i++)
2236 if (strlen((char *)efnd.elf[i].elfFullName) >= LF_FACESIZE)
2238 trace("Font name to long to test: %s\n",(char *)efnd.elf[i].elfFullName);
2239 continue;
2241 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
2242 font = CreateFontIndirectA(&lf);
2243 oldfont = SelectObject(hdc, font);
2245 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
2246 psc = NULL;
2247 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
2248 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
2249 if (winetest_interactive)
2251 trace("truetype font %s\n", lf.lfFaceName);
2252 trace("wgBlank %04x\n", sfp.wgBlank);
2253 trace("wgDefault %04x\n", sfp.wgDefault);
2254 trace("wgInvalid %04x\n", sfp.wgInvalid);
2255 trace("wgKashida %04x\n", sfp.wgKashida);
2256 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
2259 str[0] = 0x0020; /* U+0020: numeric space */
2260 ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
2261 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2262 ok(sfp.wgBlank == gi[0], "truetype font %s wgBlank %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgBlank, gi[0]);
2264 ok(sfp.wgDefault == 0 || broken(is_arabic), "truetype font %s wgDefault %04x\n", lf.lfFaceName, sfp.wgDefault);
2266 ret = pGetGlyphIndicesW(hdc, invalids, 3, gi, GGI_MARK_NONEXISTING_GLYPHS);
2267 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2268 if (gi[2] != 0xFFFF) /* index of default non exist char */
2269 ok(sfp.wgInvalid == gi[2], "truetype font %s wgInvalid %04x gi[2] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[2]);
2270 else if (gi[1] != 0xFFFF)
2271 ok(sfp.wgInvalid == gi[1], "truetype font %s wgInvalid %04x gi[1] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[1]);
2272 else if (gi[0] != 0xFFFF)
2273 ok(sfp.wgInvalid == gi[0], "truetype font %s wgInvalid %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[0]);
2274 else
2275 ok(sfp.wgInvalid == 0, "truetype font %s wgInvalid %04x expect 0\n", lf.lfFaceName, sfp.wgInvalid);
2277 str[0] = 0x0640; /* U+0640: kashida */
2278 ret = pGetGlyphIndicesW(hdc, str, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2279 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2280 is_arial = !lstrcmpA(lf.lfFaceName, "Arial");
2281 is_times_new_roman= !lstrcmpA(lf.lfFaceName, "Times New Roman");
2282 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]);
2284 ScriptFreeCache(&psc);
2286 SelectObject(hdc, oldfont);
2287 DeleteObject(font);
2291 static void test_ScriptTextOut(HDC hdc)
2293 HRESULT hr;
2295 int cInChars;
2296 int cMaxItems;
2297 SCRIPT_ITEM pItem[255];
2298 int pcItems;
2299 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2301 SCRIPT_CACHE psc;
2302 int cChars;
2303 int cMaxGlyphs;
2304 unsigned short pwOutGlyphs1[256];
2305 WORD pwLogClust[256];
2306 SCRIPT_VISATTR psva[256];
2307 int pcGlyphs;
2308 int piAdvance[256];
2309 GOFFSET pGoffset[256];
2310 ABC pABC[256];
2311 RECT rect;
2312 int piX;
2313 int iCP = 1;
2314 BOOL fTrailing = FALSE;
2315 SCRIPT_LOGATTR *psla;
2316 SCRIPT_LOGATTR sla[256];
2318 /* This is a valid test that will cause parsing to take place */
2319 cInChars = 5;
2320 cMaxItems = 255;
2321 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2322 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2323 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2324 * returned. */
2325 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2326 if (pcItems > 0)
2327 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2328 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2329 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2331 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2332 * ie. ScriptItemize has succeeded and that pItem has been set */
2333 cInChars = 5;
2334 if (hr == S_OK) {
2335 psc = NULL; /* must be null on first call */
2336 cChars = cInChars;
2337 cMaxGlyphs = 256;
2338 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2339 cMaxGlyphs, &pItem[0].a,
2340 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2341 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2342 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2343 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2344 if (hr == S_OK) {
2345 /* Note hdc is needed as glyph info is not yet in psc */
2346 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2347 pGoffset, pABC);
2348 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2349 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
2350 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2352 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
2353 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
2355 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2356 piAdvance, NULL, pGoffset);
2357 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
2358 "expected E_INVALIDARG, got %08x\n", hr);
2360 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2361 psc = NULL;
2362 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
2363 NULL, NULL, NULL);
2364 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
2365 "got %08x\n", hr);
2366 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2368 /* hdc is required for this one rather than the usual optional */
2369 psc = NULL;
2370 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2371 piAdvance, NULL, pGoffset);
2372 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
2373 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2375 /* Set that it returns 0 status */
2376 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2377 piAdvance, NULL, pGoffset);
2378 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2380 /* Test Rect Rgn is acceptable */
2381 rect.top = 10;
2382 rect.bottom = 20;
2383 rect.left = 10;
2384 rect.right = 40;
2385 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2386 piAdvance, NULL, pGoffset);
2387 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2389 iCP = 1;
2390 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
2391 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
2392 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
2394 psla = (SCRIPT_LOGATTR *)&sla;
2395 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
2396 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
2398 /* Clean up and go */
2399 ScriptFreeCache(&psc);
2400 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2405 static void test_ScriptTextOut2(HDC hdc)
2407 /* Intent is to validate that the HDC passed into ScriptTextOut is
2408 * used instead of the (possibly) invalid cached one
2410 HRESULT hr;
2412 HDC hdc1, hdc2;
2413 int cInChars;
2414 int cMaxItems;
2415 SCRIPT_ITEM pItem[255];
2416 int pcItems;
2417 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2419 SCRIPT_CACHE psc;
2420 int cChars;
2421 int cMaxGlyphs;
2422 unsigned short pwOutGlyphs1[256];
2423 WORD pwLogClust[256];
2424 SCRIPT_VISATTR psva[256];
2425 int pcGlyphs;
2426 int piAdvance[256];
2427 GOFFSET pGoffset[256];
2428 ABC pABC[256];
2430 /* Create an extra DC that will be used until the ScriptTextOut */
2431 hdc1 = CreateCompatibleDC(hdc);
2432 ok (hdc1 != 0, "CreateCompatibleDC failed to create a DC\n");
2433 hdc2 = CreateCompatibleDC(hdc);
2434 ok (hdc2 != 0, "CreateCompatibleDC failed to create a DC\n");
2436 /* This is a valid test that will cause parsing to take place */
2437 cInChars = 5;
2438 cMaxItems = 255;
2439 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2440 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2441 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2442 * returned. */
2443 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2444 if (pcItems > 0)
2445 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2446 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2447 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2449 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2450 * ie. ScriptItemize has succeeded and that pItem has been set */
2451 cInChars = 5;
2452 if (hr == S_OK) {
2453 psc = NULL; /* must be null on first call */
2454 cChars = cInChars;
2455 cMaxGlyphs = 256;
2456 hr = ScriptShape(hdc2, &psc, TestItem1, cChars,
2457 cMaxGlyphs, &pItem[0].a,
2458 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2459 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2460 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2461 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2462 if (hr == S_OK) {
2463 BOOL ret;
2465 /* Note hdc is needed as glyph info is not yet in psc */
2466 hr = ScriptPlace(hdc2, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2467 pGoffset, pABC);
2468 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2470 /* key part!!! cached dc is being deleted */
2471 ret = DeleteDC(hdc2);
2472 ok(ret, "DeleteDC should return 1 not %d\n", ret);
2474 /* At this point the cached hdc (hdc2) has been destroyed,
2475 * however, we are passing in a *real* hdc (the original hdc).
2476 * The text should be written to that DC
2478 hr = ScriptTextOut(hdc1, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2479 piAdvance, NULL, pGoffset);
2480 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2481 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2483 DeleteDC(hdc1);
2485 /* Clean up and go */
2486 ScriptFreeCache(&psc);
2487 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2492 static void test_ScriptTextOut3(HDC hdc)
2494 HRESULT hr;
2496 int cInChars;
2497 int cMaxItems;
2498 SCRIPT_ITEM pItem[255];
2499 int pcItems;
2500 WCHAR TestItem1[] = {' ','\r', 0};
2502 SCRIPT_CACHE psc;
2503 int cChars;
2504 int cMaxGlyphs;
2505 unsigned short pwOutGlyphs1[256];
2506 WORD pwLogClust[256];
2507 SCRIPT_VISATTR psva[256];
2508 int pcGlyphs;
2509 int piAdvance[256];
2510 GOFFSET pGoffset[256];
2511 ABC pABC[256];
2512 RECT rect;
2514 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
2515 cInChars = 2;
2516 cMaxItems = 255;
2517 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2518 ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr);
2519 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2520 * returned. */
2521 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2522 if (pcItems > 0)
2523 ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
2524 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2525 pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
2527 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2528 * ie. ScriptItemize has succeeded and that pItem has been set */
2529 cInChars = 2;
2530 if (hr == S_OK) {
2531 psc = NULL; /* must be null on first call */
2532 cChars = cInChars;
2533 cMaxGlyphs = 256;
2534 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2535 cMaxGlyphs, &pItem[0].a,
2536 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2537 ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
2538 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2539 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2540 if (hr ==0) {
2541 /* Note hdc is needed as glyph info is not yet in psc */
2542 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2543 pGoffset, pABC);
2544 ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
2546 /* Test Rect Rgn is acceptable */
2547 rect.top = 10;
2548 rect.bottom = 20;
2549 rect.left = 10;
2550 rect.right = 40;
2551 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2552 piAdvance, NULL, pGoffset);
2553 ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
2555 /* Clean up and go */
2556 ScriptFreeCache(&psc);
2557 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2561 #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)
2563 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2565 int iX, iCP;
2566 int icChars, icGlyphs;
2567 int piCP, piX;
2568 HRESULT hr;
2569 SCRIPT_VISATTR psva[10];
2570 int piTrailing;
2571 BOOL fTrailing;
2572 int direction;
2574 memset(psva,0,sizeof(psva));
2575 direction = (psa->fRTL)?-1:+1;
2577 for(iCP = 0; iCP < cChars; iCP++)
2579 iX = offsets[iCP];
2580 icChars = cChars;
2581 icGlyphs = cGlyphs;
2582 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2583 winetest_ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2584 winetest_ok(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2585 winetest_ok(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2588 for(iCP = 0; iCP < cChars; iCP++)
2590 iX = offsets[iCP]+direction;
2591 icChars = cChars;
2592 icGlyphs = cGlyphs;
2593 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2594 winetest_ok(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2595 winetest_ok(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2596 winetest_ok(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2599 for(iCP = 0; iCP < cChars; iCP++)
2601 iX = offsets[iCP+1]-direction;
2602 icChars = cChars;
2603 icGlyphs = cGlyphs;
2604 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2605 winetest_ok(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2606 winetest_ok(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2607 winetest_ok(piTrailing == 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2610 for(iCP = 0; iCP <= cChars+1; iCP++)
2612 fTrailing = FALSE;
2613 icChars = cChars;
2614 icGlyphs = cGlyphs;
2615 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2616 winetest_ok(hr == S_OK, "ScriptCPtoX: should return S_OK not %08x\n", hr);
2617 winetest_ok(piX == offsets[iCP],
2618 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP], piX);
2621 for(iCP = 0; iCP <= cChars+1; iCP++)
2623 fTrailing = TRUE;
2624 icChars = cChars;
2625 icGlyphs = cGlyphs;
2626 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2627 winetest_ok(hr == S_OK, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr);
2628 winetest_ok(piX == offsets[iCP+1],
2629 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP+1], piX);
2633 #define test_caret_item_ScriptXtoCP(a,b,c,d,e,f) _test_caret_item_ScriptXtoCP(__LINE__,a,b,c,d,e,f)
2635 static void _test_caret_item_ScriptXtoCP(int line, SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2637 int iX, iCP, i;
2638 int icChars, icGlyphs;
2639 int piCP;
2640 int clusterSize;
2641 HRESULT hr;
2642 SCRIPT_VISATTR psva[10];
2643 int piTrailing;
2644 int direction;
2646 memset(psva,0,sizeof(psva));
2647 direction = (psa->fRTL)?-1:+1;
2649 for(iX = -1, i = iCP = 0; i < cChars; i++)
2651 if (offsets[i] != iX)
2653 iX = offsets[i];
2654 iCP = i;
2656 icChars = cChars;
2657 icGlyphs = cGlyphs;
2658 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2659 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2660 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2661 ok_(__FILE__,line)(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2664 for(iX = -2, i = 0; i < cChars; i++)
2666 if (offsets[i]+direction != iX)
2668 iX = offsets[i] + direction;
2669 iCP = i;
2671 icChars = cChars;
2672 icGlyphs = cGlyphs;
2673 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2674 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2675 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2676 ok_(__FILE__,line)(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2679 for(clusterSize = 0, iCP = 0, iX = -2, i = 0; i < cChars; i++)
2681 clusterSize++;
2682 if (offsets[i] != offsets[i+1])
2684 iX = offsets[i+1]-direction;
2685 icChars = cChars;
2686 icGlyphs = cGlyphs;
2687 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2688 ok_(__FILE__,line)(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2689 ok_(__FILE__,line)(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2690 ok_(__FILE__,line)(piTrailing == clusterSize, "ScriptXtoCP trailing: iX=%d should return piTrailing=%d not %d\n", iX, clusterSize, piTrailing);
2691 iCP = i+1;
2692 clusterSize = 0;
2697 static void test_ScriptXtoX(void)
2698 /****************************************************************************************
2699 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2700 ****************************************************************************************/
2702 WORD pwLogClust[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2703 WORD pwLogClust_RTL[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2704 WORD pwLogClust_2[7] = {4, 3, 3, 2, 1, 0 ,0};
2705 WORD pwLogClust_3[17] = {0, 1, 1, 1, 1, 4, 5, 6, 6, 8, 8, 8, 8, 11, 11, 13, 13};
2706 WORD pwLogClust_3_RTL[17] = {13, 13, 11, 11, 8, 8, 8, 8, 6, 6, 5, 4, 1, 1, 1, 1, 0};
2707 int piAdvance[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2708 int piAdvance_2[5] = {39, 26, 19, 17, 11};
2709 int piAdvance_3[15] = {6, 6, 0, 0, 10, 5, 10, 0, 12, 0, 0, 9, 0, 10, 0};
2710 static const int offsets[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2711 static const int offsets_RTL[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2712 static const int offsets_2[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2714 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};
2715 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};
2717 SCRIPT_VISATTR psva[15];
2718 SCRIPT_ANALYSIS sa;
2719 SCRIPT_ITEM items[2];
2720 int iX, i;
2721 int piCP;
2722 int piTrailing;
2723 HRESULT hr;
2724 static const WCHAR hebrW[] = { 0x5be, 0};
2725 static const WCHAR thaiW[] = { 0xe2a, 0};
2726 const SCRIPT_PROPERTIES **ppScriptProperties;
2728 memset(&sa, 0 , sizeof(SCRIPT_ANALYSIS));
2729 memset(psva, 0, sizeof(psva));
2731 sa.fRTL = FALSE;
2732 hr = ScriptXtoCP(-1, 10, 10, pwLogClust, psva, piAdvance, &sa, &piCP, &piTrailing);
2733 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2734 if (piTrailing)
2735 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2736 else /* win2k3 */
2737 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2739 for (iX = 0; iX <= 7; iX++)
2741 WORD clust = 0;
2742 INT advance = 16;
2743 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2744 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing);
2746 for (iX = 8; iX < 16; iX++)
2748 WORD clust = 0;
2749 INT advance = 16;
2750 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2751 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing);
2754 sa.fRTL = TRUE;
2755 hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2756 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2757 if (piTrailing)
2758 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2759 else /* win2k3 */
2760 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2762 iX = 1954;
2763 hr = ScriptXtoCP(1954, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2764 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2765 ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP);
2766 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2768 for (iX = 1; iX <= 8; iX++)
2770 WORD clust = 0;
2771 INT advance = 16;
2772 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2773 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing);
2775 for (iX = 9; iX < 16; iX++)
2777 WORD clust = 0;
2778 INT advance = 16;
2779 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2780 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing);
2783 sa.fRTL = FALSE;
2784 test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance);
2785 sa.fRTL = TRUE;
2786 test_item_ScriptXtoX(&sa, 10, 10, offsets_RTL, pwLogClust_RTL, piAdvance);
2787 test_item_ScriptXtoX(&sa, 7, 5, offsets_2, pwLogClust_2, piAdvance_2);
2789 /* Get thai eScript, This will do LTR and fNeedsCaretInfo */
2790 hr = ScriptItemize(thaiW, 1, 2, NULL, NULL, items, &i);
2791 ok(hr == S_OK, "got %08x\n", hr);
2792 ok(i == 1, "got %d\n", i);
2793 sa = items[0].a;
2795 test_caret_item_ScriptXtoCP(&sa, 17, 15, offsets_3, pwLogClust_3, piAdvance_3);
2797 /* Get hebrew eScript, This will do RTL and fNeedsCaretInfo */
2798 hr = ScriptItemize(hebrW, 1, 2, NULL, NULL, items, &i);
2799 ok(hr == S_OK, "got %08x\n", hr);
2800 ok(i == 1, "got %d\n", i);
2801 sa = items[0].a;
2803 /* Note: This behavior CHANGED in uniscribe versions...
2804 * so we only want to test if fNeedsCaretInfo is set */
2805 hr = ScriptGetProperties(&ppScriptProperties, &i);
2806 if (ppScriptProperties[sa.eScript]->fNeedsCaretInfo)
2808 test_caret_item_ScriptXtoCP(&sa, 17, 15, offsets_3_RTL, pwLogClust_3_RTL, piAdvance_3);
2809 hr = ScriptXtoCP(0, 17, 15, pwLogClust_3_RTL, psva, piAdvance_3, &sa, &piCP, &piTrailing);
2810 ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2811 ok(piCP == 16, "ScriptXtoCP: iX=0 should return piCP=16 not %d\n", piCP);
2812 ok(piTrailing == 1, "ScriptXtoCP: iX=0 should return piTrailing=1 not %d\n", piTrailing);
2814 else
2815 win_skip("Uniscribe version too old to test Hebrew clusters\n");
2818 static void test_ScriptString(HDC hdc)
2820 /*******************************************************************************************
2822 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2823 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2824 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2825 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2829 HRESULT hr;
2830 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2831 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
2832 int Glyphs = len * 2 + 16;
2833 int Charset;
2834 DWORD Flags = SSA_GLYPHS;
2835 int ReqWidth = 100;
2836 const int Dx[5] = {10, 10, 10, 10, 10};
2837 const BYTE InClass = 0;
2838 SCRIPT_STRING_ANALYSIS ssa = NULL;
2840 int X = 10;
2841 int Y = 100;
2842 UINT Options = 0;
2843 const RECT rc = {0, 50, 100, 100};
2844 int MinSel = 0;
2845 int MaxSel = 0;
2846 BOOL Disabled = FALSE;
2847 const int *clip_len;
2848 int i;
2849 UINT *order;
2852 Charset = -1; /* this flag indicates unicode input */
2853 /* Test without hdc to get E_PENDING */
2854 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
2855 ReqWidth, NULL, NULL, Dx, NULL,
2856 &InClass, &ssa);
2857 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
2859 /* Test that 0 length string returns E_INVALIDARG */
2860 hr = ScriptStringAnalyse( hdc, teststr, 0, Glyphs, Charset, Flags,
2861 ReqWidth, NULL, NULL, Dx, NULL,
2862 &InClass, &ssa);
2863 ok(hr == E_INVALIDARG, "ScriptStringAnalyse should return E_INVALIDARG not %08x\n", hr);
2865 /* test with hdc, this should be a valid test */
2866 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2867 ReqWidth, NULL, NULL, Dx, NULL,
2868 &InClass, &ssa);
2869 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2870 ScriptStringFree(&ssa);
2872 /* test makes sure that a call with a valid pssa still works */
2873 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2874 ReqWidth, NULL, NULL, Dx, NULL,
2875 &InClass, &ssa);
2876 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2877 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
2879 if (hr == S_OK)
2881 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
2882 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
2885 clip_len = ScriptString_pcOutChars(ssa);
2886 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
2888 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
2889 hr = ScriptStringGetOrder(ssa, order);
2890 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
2892 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
2893 HeapFree(GetProcessHeap(), 0, order);
2895 hr = ScriptStringFree(&ssa);
2896 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2899 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
2901 /*****************************************************************************************
2903 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2904 * nature of the fonts between Windows and Wine, the test is implemented by generating
2905 * values using one one function then checking the output of the second. In this way
2906 * the validity of the functions is established using Windows as a base and confirming
2907 * similar behaviour in wine.
2910 HRESULT hr;
2911 static const WCHAR teststr1[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2912 static const BOOL rtl[] = {1, 0, 1, 0, 1, 0, 1, 0};
2913 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
2914 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
2915 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
2916 int Charset = -1; /* unicode */
2917 DWORD Flags = SSA_GLYPHS;
2918 int ReqWidth = 100;
2919 const BYTE InClass = 0;
2920 SCRIPT_STRING_ANALYSIS ssa = NULL;
2922 int Ch; /* Character position in string */
2923 int iTrailing;
2924 int Cp; /* Character position in string */
2925 int X;
2926 int trail,lead;
2927 BOOL fTrailing;
2929 /* Test with hdc, this should be a valid test
2930 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2931 * following character positions to X and X to character position functions.
2934 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2935 ReqWidth, NULL, NULL, NULL, NULL,
2936 &InClass, &ssa);
2937 ok(hr == S_OK ||
2938 hr == E_INVALIDARG, /* NT */
2939 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
2941 if (hr == S_OK)
2943 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
2946 * Loop to generate character positions to provide starting positions for the
2947 * ScriptStringCPtoX and ScriptStringXtoCP functions
2949 for (Cp = 0; Cp < String_len; Cp++)
2951 /* The fTrailing flag is used to indicate whether the X being returned is at
2952 * the beginning or the end of the character. What happens here is that if
2953 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2954 * returns the beginning of the next character and iTrailing is FALSE. So for this
2955 * loop iTrailing will be FALSE in both cases.
2957 hr = ScriptStringCPtoX(ssa, Cp, TRUE, &trail);
2958 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2959 hr = ScriptStringCPtoX(ssa, Cp, FALSE, &lead);
2960 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2961 if (rtl[Cp])
2962 ok(lead > trail, "Leading values should be after trailing for rtl characters(%i)\n",Cp);
2963 else
2964 ok(lead < trail, "Trailing values should be after leading for ltr characters(%i)\n",Cp);
2966 /* move by 1 pixel so that we are not between 2 characters. That could result in being the lead of a rtl and
2967 at the same time the trail of an ltr */
2969 /* inside the leading edge */
2970 X = lead;
2971 if (rtl[Cp]) X--; else X++;
2972 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2973 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2974 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2975 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2976 iTrailing, X);
2978 /* inside the trailing edge */
2979 X = trail;
2980 if (rtl[Cp]) X++; else X--;
2981 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2982 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2983 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2984 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2985 iTrailing, X);
2987 /* outside the "trailing" edge */
2988 if (Cp < String_len-1)
2990 if (rtl[Cp]) X = lead; else X = trail;
2991 X++;
2992 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2993 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2994 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, trail);
2995 if (rtl[Cp+1])
2996 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2997 iTrailing, X);
2998 else
2999 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
3000 iTrailing, X);
3003 /* outside the "leading" edge */
3004 if (Cp != 0)
3006 if (rtl[Cp]) X = trail; else X = lead;
3007 X--;
3008 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3009 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3010 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, trail);
3011 if (Cp != 0 && rtl[Cp-1])
3012 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
3013 iTrailing, X);
3014 else
3015 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
3016 iTrailing, X);
3020 /* Check beyond the leading boundary of the whole string */
3021 if (rtl[0])
3023 /* having a leading rtl character seems to confuse usp */
3024 /* this looks to be a windows bug we should emulate */
3025 hr = ScriptStringCPtoX(ssa, 0, TRUE, &X);
3026 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3027 X--;
3028 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3029 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3030 ok(Ch == 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch);
3031 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
3032 iTrailing);
3034 else
3036 hr = ScriptStringCPtoX(ssa, 0, FALSE, &X);
3037 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3038 X--;
3039 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
3040 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
3041 ok(Ch == -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch);
3042 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
3043 iTrailing);
3046 /* Check beyond the end boundary of the whole string */
3047 if (rtl[String_len-1])
3049 hr = ScriptStringCPtoX(ssa, String_len-1, FALSE, &X);
3050 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
3052 else
3054 hr = ScriptStringCPtoX(ssa, String_len-1, TRUE, &X);
3055 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
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(Ch == String_len, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len, Ch);
3061 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
3062 iTrailing);
3065 * Cleanup the SSA for the next round of tests
3067 hr = ScriptStringFree(&ssa);
3068 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
3071 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
3072 * generate an SSA for the subsequent tests.
3074 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
3075 ReqWidth, NULL, NULL, NULL, NULL,
3076 &InClass, &ssa);
3077 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
3080 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
3081 * string length, return E_INVALIDARG. This also invalidates the ssa so a
3082 * ScriptStringFree should also fail.
3084 fTrailing = FALSE;
3085 Cp = String_len + 1;
3086 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
3087 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
3089 ScriptStringFree(&ssa);
3093 static void test_ScriptCacheGetHeight(HDC hdc)
3095 HRESULT hr;
3096 SCRIPT_CACHE sc = NULL;
3097 LONG height;
3099 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
3100 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3102 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
3103 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3105 hr = ScriptCacheGetHeight(NULL, &sc, &height);
3106 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
3108 height = 0;
3110 hr = ScriptCacheGetHeight(hdc, &sc, &height);
3111 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3112 ok(height > 0, "expected height > 0\n");
3114 ScriptFreeCache(&sc);
3117 static void test_ScriptGetGlyphABCWidth(HDC hdc)
3119 HRESULT hr;
3120 SCRIPT_CACHE sc = NULL;
3121 ABC abc;
3123 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
3124 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3126 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
3127 ok(broken(hr == E_PENDING) ||
3128 hr == E_INVALIDARG, /* WIN7 */
3129 "expected E_INVALIDARG, got 0x%08x\n", hr);
3131 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', &abc);
3132 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
3134 if (0) { /* crashes on WinXP */
3135 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
3136 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3139 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
3140 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3142 ScriptFreeCache(&sc);
3145 static void test_ScriptLayout(void)
3147 HRESULT hr;
3148 static const BYTE levels[][10] =
3150 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
3151 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
3152 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
3153 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
3155 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
3156 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
3157 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
3158 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
3159 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
3161 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
3162 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
3164 { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
3165 { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 },
3166 { 2, 2, 2, 4, 4, 4, 1, 1, 0, 0 },
3167 { 1, 2, 3, 0, 3, 2, 1, 0, 0, 0 }
3169 static const int expect_l2v[][10] =
3171 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3172 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3173 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3174 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3176 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
3177 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
3178 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
3179 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3180 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
3182 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3183 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
3185 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
3186 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
3187 { 2, 3, 4, 5, 6, 7, 1, 0, 8, 9},
3188 { 2, 0, 1, 3, 5, 6, 4, 7, 8, 9}
3190 static const int expect_v2l[][10] =
3192 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3193 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3194 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
3195 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
3197 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
3198 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
3199 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
3200 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3201 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
3203 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
3204 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
3206 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
3207 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
3208 { 7, 6, 0, 1, 2, 3, 4, 5, 8, 9},
3209 { 1, 2, 0, 3, 6, 4, 5, 7, 8, 9}
3212 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
3214 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
3215 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3217 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
3218 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
3220 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
3222 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
3223 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
3225 for (j = 0; j < sizeof(levels[i]); j++)
3227 ok(expect_v2l[i][j] == vistolog[j],
3228 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
3229 i, j, levels[i][j], j, vistolog[j] );
3232 for (j = 0; j < sizeof(levels[i]); j++)
3234 ok(expect_l2v[i][j] == logtovis[j],
3235 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
3236 i, j, levels[i][j], j, logtovis[j] );
3241 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
3243 HRESULT hr;
3244 SCRIPT_DIGITSUBSTITUTE sds;
3245 SCRIPT_CONTROL sc;
3246 SCRIPT_STATE ss;
3247 LCID lcid_old;
3249 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
3251 memset(&sds, 0, sizeof(sds));
3252 memset(&sc, 0, sizeof(sc));
3253 memset(&ss, 0, sizeof(ss));
3255 lcid_old = GetThreadLocale();
3256 if (!SetThreadLocale(lcid)) return TRUE;
3258 hr = ScriptRecordDigitSubstitution(lcid, &sds);
3259 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
3261 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
3262 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
3264 SetThreadLocale(lcid_old);
3265 return TRUE;
3268 static void test_digit_substitution(void)
3270 BOOL ret;
3271 unsigned int i;
3272 static const LGRPID groups[] =
3274 LGRPID_WESTERN_EUROPE,
3275 LGRPID_CENTRAL_EUROPE,
3276 LGRPID_BALTIC,
3277 LGRPID_GREEK,
3278 LGRPID_CYRILLIC,
3279 LGRPID_TURKISH,
3280 LGRPID_JAPANESE,
3281 LGRPID_KOREAN,
3282 LGRPID_TRADITIONAL_CHINESE,
3283 LGRPID_SIMPLIFIED_CHINESE,
3284 LGRPID_THAI,
3285 LGRPID_HEBREW,
3286 LGRPID_ARABIC,
3287 LGRPID_VIETNAMESE,
3288 LGRPID_INDIC,
3289 LGRPID_GEORGIAN,
3290 LGRPID_ARMENIAN
3292 HMODULE hKernel32;
3293 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROCA,LGRPID,DWORD,LONG_PTR);
3295 hKernel32 = GetModuleHandleA("kernel32.dll");
3296 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
3298 if (!pEnumLanguageGroupLocalesA)
3300 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
3301 return;
3304 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
3306 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
3307 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
3309 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
3310 break;
3313 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
3317 static void test_ScriptGetProperties(void)
3319 const SCRIPT_PROPERTIES **props;
3320 HRESULT hr;
3321 int num;
3323 hr = ScriptGetProperties(NULL, NULL);
3324 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
3326 hr = ScriptGetProperties(NULL, &num);
3327 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3329 hr = ScriptGetProperties(&props, NULL);
3330 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3332 hr = ScriptGetProperties(&props, &num);
3333 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
3336 static void test_ScriptBreak(void)
3338 static const WCHAR test[] = {' ','\r','\n',0};
3339 SCRIPT_ITEM items[4];
3340 SCRIPT_LOGATTR la;
3341 HRESULT hr;
3343 hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL);
3344 ok(hr == S_OK, "ScriptItemize should return S_OK not %08x\n", hr);
3347 * This Test crashes pre Vista.
3349 hr = ScriptBreak(test, 1, &items[0].a, NULL);
3350 ok(hr == E_INVALIDARG, "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3353 hr = ScriptBreak(test, 0, &items[0].a, &la);
3354 ok(hr == E_FAIL || broken(hr == S_OK), "ScriptBreak should return E_FAIL not %08x\n", hr);
3356 hr = ScriptBreak(test, -1, &items[0].a, &la);
3357 ok(hr == E_INVALIDARG || broken(hr == S_OK), "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
3359 memset(&la, 0, sizeof(la));
3360 hr = ScriptBreak(test, 1, &items[0].a, &la);
3361 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3363 ok(!la.fSoftBreak, "fSoftBreak set\n");
3364 ok(la.fWhiteSpace, "fWhiteSpace not set\n");
3365 ok(la.fCharStop, "fCharStop not set\n");
3366 ok(!la.fWordStop, "fWordStop set\n");
3367 ok(!la.fInvalid, "fInvalid set\n");
3368 ok(!la.fReserved, "fReserved set\n");
3370 memset(&la, 0, sizeof(la));
3371 hr = ScriptBreak(test + 1, 1, &items[1].a, &la);
3372 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3374 ok(!la.fSoftBreak, "fSoftBreak set\n");
3375 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3376 ok(la.fCharStop, "fCharStop not set\n");
3377 ok(!la.fWordStop, "fWordStop set\n");
3378 ok(!la.fInvalid, "fInvalid set\n");
3379 ok(!la.fReserved, "fReserved set\n");
3381 memset(&la, 0, sizeof(la));
3382 hr = ScriptBreak(test + 2, 1, &items[2].a, &la);
3383 ok(hr == S_OK, "ScriptBreak should return S_OK not %08x\n", hr);
3385 ok(!la.fSoftBreak, "fSoftBreak set\n");
3386 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3387 ok(la.fCharStop, "fCharStop not set\n");
3388 ok(!la.fWordStop, "fWordStop set\n");
3389 ok(!la.fInvalid, "fInvalid set\n");
3390 ok(!la.fReserved, "fReserved set\n");
3393 static void test_newlines(void)
3395 static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
3396 static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
3397 static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
3398 static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
3399 static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
3400 SCRIPT_ITEM items[5];
3401 HRESULT hr;
3402 int count;
3404 count = 0;
3405 hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
3406 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3407 ok(count == 3, "got %d expected 3\n", count);
3409 count = 0;
3410 hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
3411 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3412 ok(count == 3, "got %d expected 3\n", count);
3414 count = 0;
3415 hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
3416 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3417 ok(count == 4, "got %d expected 4\n", count);
3419 count = 0;
3420 hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
3421 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3422 ok(count == 4, "got %d expected 4\n", count);
3424 count = 0;
3425 hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
3426 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3427 ok(count == 4, "got %d expected 4\n", count);
3430 static void test_ScriptGetFontFunctions(HDC hdc)
3432 HRESULT hr;
3433 pScriptGetFontScriptTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontScriptTags");
3434 pScriptGetFontLanguageTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontLanguageTags");
3435 pScriptGetFontFeatureTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontFeatureTags");
3436 if (!pScriptGetFontScriptTags || !pScriptGetFontLanguageTags || !pScriptGetFontFeatureTags)
3438 win_skip("ScriptGetFontScriptTags,ScriptGetFontLanguageTags or ScriptGetFontFeatureTags not available on this platform\n");
3440 else
3442 SCRIPT_CACHE sc = NULL;
3443 OPENTYPE_TAG tags[5];
3444 int count = 0;
3445 int outnItems=0;
3446 SCRIPT_ITEM outpItems[15];
3447 SCRIPT_CONTROL Control;
3448 SCRIPT_STATE State;
3449 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
3451 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, NULL);
3452 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3453 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3454 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, &count);
3455 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3456 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3457 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, NULL);
3458 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3459 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3460 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, tags, &count);
3461 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3462 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3463 hr = pScriptGetFontScriptTags(NULL, &sc, NULL, 5, tags, &count);
3464 ok(hr == E_PENDING,"Incorrect return code\n");
3465 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3466 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, &count);
3467 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3468 if (hr == S_OK)
3469 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3470 else if (hr == E_OUTOFMEMORY)
3471 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3472 ok(sc != NULL, "ScriptCache should be initialized\n");
3474 ScriptFreeCache(&sc);
3475 sc = NULL;
3477 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, NULL);
3478 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3479 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3480 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, &count);
3481 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3482 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3483 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, NULL);
3484 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3485 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3486 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, tags, &count);
3487 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3488 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3489 hr = pScriptGetFontLanguageTags(NULL, &sc, NULL, latn_tag, 5, tags, &count);
3490 ok(hr == E_PENDING,"Incorrect return code\n");
3491 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3492 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, &count);
3493 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3494 if (hr == S_OK)
3495 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3496 else if (hr == E_OUTOFMEMORY)
3497 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3499 ScriptFreeCache(&sc);
3500 sc = NULL;
3502 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, NULL);
3503 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3504 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3505 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, &count);
3506 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3507 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3508 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, NULL);
3509 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3510 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3511 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, tags, &count);
3512 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3513 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3514 hr = pScriptGetFontFeatureTags(NULL, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3515 ok(hr == E_PENDING,"Incorrect return code\n");
3516 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3517 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3518 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3519 if (hr == S_OK)
3520 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3521 else if (hr == E_OUTOFMEMORY)
3522 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3524 memset(&Control, 0, sizeof(Control));
3525 memset(&State, 0, sizeof(State));
3527 hr = ScriptItemize(test_phagspa, 10, 15, &Control, &State, outpItems, &outnItems);
3528 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3529 memset(tags,0,sizeof(tags));
3530 hr = pScriptGetFontScriptTags(hdc, &sc, &outpItems[0].a, 5, tags, &count);
3531 ok( hr == USP_E_SCRIPT_NOT_IN_FONT || broken(hr == S_OK), "wrong return code\n");
3533 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, dsrt_tag, 5, tags, &count);
3534 ok( hr == S_OK, "wrong return code\n");
3535 hr = pScriptGetFontLanguageTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 5, tags, &count);
3536 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3538 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, dsrt_tag, 0x0, 5, tags, &count);
3539 ok( hr == S_OK, "wrong return code\n");
3540 hr = pScriptGetFontFeatureTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 0x0, 5, tags, &count);
3541 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3543 ScriptFreeCache(&sc);
3547 START_TEST(usp10)
3549 HWND hwnd;
3550 HDC hdc;
3551 LOGFONTA lf;
3552 HFONT hfont;
3554 unsigned short pwOutGlyphs[256];
3556 /* We need a valid HDC to drive a lot of Script functions which requires the following *
3557 * to set up for the tests. */
3558 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
3559 0, 0, 0, NULL);
3560 assert(hwnd != 0);
3561 ShowWindow(hwnd, SW_SHOW);
3562 UpdateWindow(hwnd);
3564 hdc = GetDC(hwnd); /* We now have a hdc */
3565 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
3567 memset(&lf, 0, sizeof(LOGFONTA));
3568 lstrcpyA(lf.lfFaceName, "Tahoma");
3569 lf.lfHeight = 10;
3570 lf.lfWeight = 3;
3571 lf.lfWidth = 10;
3573 hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
3574 ok(hfont != NULL, "SelectObject failed: %p\n", hfont);
3576 test_ScriptItemize();
3577 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
3578 test_ScriptGetCMap(hdc, pwOutGlyphs);
3579 test_ScriptCacheGetHeight(hdc);
3580 test_ScriptGetGlyphABCWidth(hdc);
3581 test_ScriptShape(hdc);
3582 test_ScriptShapeOpenType(hdc);
3583 test_ScriptPlace(hdc);
3585 test_ScriptGetFontProperties(hdc);
3586 test_ScriptTextOut(hdc);
3587 test_ScriptTextOut2(hdc);
3588 test_ScriptTextOut3(hdc);
3589 test_ScriptXtoX();
3590 test_ScriptString(hdc);
3591 test_ScriptStringXtoCP_CPtoX(hdc);
3593 test_ScriptLayout();
3594 test_digit_substitution();
3595 test_ScriptGetProperties();
3596 test_ScriptBreak();
3597 test_newlines();
3599 test_ScriptGetFontFunctions(hdc);
3601 ReleaseDC(hwnd, hdc);
3602 DestroyWindow(hwnd);