Release 1.6-rc2.
[wine/testsucceed.git] / dlls / usp10 / tests / usp10.c
blob354bc234828d8950e555c8c2f4acdfe4f2284cb3
1 /*
2 * Tests for usp10 dll
4 * Copyright 2006 Jeff Latimer
5 * Copyright 2006 Hans Leidekker
6 * Copyright 2010 CodeWeavers, Aric Stewart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Notes:
23 * Uniscribe allows for processing of complex scripts such as joining
24 * and filtering characters and bi-directional text with custom line breaks.
27 #include <assert.h>
28 #include <stdio.h>
30 #include <wine/test.h>
31 #include <windows.h>
32 #include <usp10.h>
34 typedef struct _itemTest {
35 char todo_flag[5];
36 int iCharPos;
37 int fRTL;
38 int fLayoutRTL;
39 int uBidiLevel;
40 ULONG scriptTag;
41 BOOL isBroken;
42 int broken_value[5];
43 } itemTest;
45 typedef struct _shapeTest_char {
46 WORD wLogClust;
47 SCRIPT_CHARPROP CharProp;
48 } shapeTest_char;
50 typedef struct _shapeTest_glyph {
51 int Glyph;
52 SCRIPT_GLYPHPROP GlyphProp;
53 } shapeTest_glyph;
55 /* Uniscribe 1.6 calls */
56 static HRESULT (WINAPI *pScriptItemizeOpenType)( const WCHAR *pwcInChars, int cInChars, int cMaxItems, const SCRIPT_CONTROL *psControl, const SCRIPT_STATE *psState, SCRIPT_ITEM *pItems, ULONG *pScriptTags, int *pcItems);
58 static HRESULT (WINAPI *pScriptShapeOpenType)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, OPENTYPE_TAG tagLangSys, int *rcRangeChars, TEXTRANGE_PROPERTIES **rpRangeProperties, int cRanges, const WCHAR *pwcChars, int cChars, int cMaxGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProps, WORD *pwOutGlyphs, SCRIPT_GLYPHPROP *pOutGlyphProps, int *pcGlyphs);
60 static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
62 static HRESULT (WINAPI *pScriptGetFontScriptTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags);
63 static HRESULT (WINAPI *pScriptGetFontLanguageTags)( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, OPENTYPE_TAG tagScript, int cMaxTags, OPENTYPE_TAG *pLangSysTags, int *pcTags);
64 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);
66 static inline void _test_items_ok(LPCWSTR string, DWORD cchString,
67 SCRIPT_CONTROL *Control, SCRIPT_STATE *State,
68 DWORD nItems, const itemTest* items, BOOL nItemsToDo,
69 const INT nItemsBroken[2])
71 HRESULT hr;
72 int x, outnItems;
73 SCRIPT_ITEM outpItems[15];
74 ULONG tags[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
76 if (pScriptItemizeOpenType)
77 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
78 else
79 hr = ScriptItemize(string, cchString, 15, Control, State, outpItems, &outnItems);
81 winetest_ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
82 if (nItemsBroken && (broken(nItemsBroken[0] == outnItems) || broken(nItemsBroken[1] == outnItems)))
84 winetest_win_skip("This test broken on this platform\n");
85 return;
87 if (nItemsToDo)
88 todo_wine winetest_ok(outnItems == nItems, "Wrong number of items\n");
89 else
90 winetest_ok(outnItems == nItems, "Wrong number of items\n");
91 for (x = 0; x <= outnItems; x++)
93 if (items[x].isBroken && broken(outpItems[x].iCharPos == items[x].broken_value[0]))
94 winetest_win_skip("This test broken on this platform\n");
95 else if (items[x].todo_flag[0])
96 todo_wine winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos\n",x);
97 else
98 winetest_ok(outpItems[x].iCharPos == items[x].iCharPos, "%i:Wrong CharPos (%i)\n",x,outpItems[x].iCharPos);
100 if (items[x].isBroken && broken(outpItems[x].a.fRTL== items[x].broken_value[1]))
101 winetest_win_skip("This test broken on this platform\n");
102 else if (items[x].todo_flag[1])
103 todo_wine winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL\n",x);
104 else
105 winetest_ok(outpItems[x].a.fRTL == items[x].fRTL, "%i:Wrong fRTL(%i)\n",x,outpItems[x].a.fRTL);
107 if (items[x].isBroken && broken(outpItems[x].a.fLayoutRTL == items[x].broken_value[2]))
108 winetest_win_skip("This test broken on this platform\n");
109 else if (items[x].todo_flag[2])
110 todo_wine winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL\n",x);
111 else
112 winetest_ok(outpItems[x].a.fLayoutRTL == items[x].fLayoutRTL, "%i:Wrong fLayoutRTL(%i)\n",x,outpItems[x].a.fLayoutRTL);
114 if (items[x].isBroken && broken(outpItems[x].a.s.uBidiLevel == items[x].broken_value[3]))
115 winetest_win_skip("This test broken on this platform\n");
116 else if (items[x].todo_flag[3])
117 todo_wine winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel\n",x);
118 else
119 winetest_ok(outpItems[x].a.s.uBidiLevel == items[x].uBidiLevel, "%i:Wrong BidiLevel(%i)\n",x,outpItems[x].a.s.uBidiLevel);
120 if (x != outnItems)
121 winetest_ok(outpItems[x].a.eScript != SCRIPT_UNDEFINED, "%i: Undefined script\n",x);
122 if (pScriptItemizeOpenType)
124 if (items[x].isBroken && broken(tags[x] == items[x].broken_value[4]))
125 winetest_win_skip("This test broken on this platform\n");
126 else if (items[x].todo_flag[4])
127 todo_wine winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
128 else
129 winetest_ok(tags[x] == items[x].scriptTag,"%i:Incorrect Script Tag %x != %x\n",x,tags[x],items[x].scriptTag);
134 #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)
136 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
137 ( ( (ULONG)_x4 << 24 ) | \
138 ( (ULONG)_x3 << 16 ) | \
139 ( (ULONG)_x2 << 8 ) | \
140 (ULONG)_x1 )
142 #define latn_tag MS_MAKE_TAG('l','a','t','n')
143 #define arab_tag MS_MAKE_TAG('a','r','a','b')
144 #define thai_tag MS_MAKE_TAG('t','h','a','i')
145 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
146 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
147 #define deva_tag MS_MAKE_TAG('d','e','v','a')
148 #define beng_tag MS_MAKE_TAG('b','e','n','g')
149 #define guru_tag MS_MAKE_TAG('g','u','r','u')
150 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
151 #define orya_tag MS_MAKE_TAG('o','r','y','a')
152 #define taml_tag MS_MAKE_TAG('t','a','m','l')
153 #define telu_tag MS_MAKE_TAG('t','e','l','u')
154 #define knda_tag MS_MAKE_TAG('k','n','d','a')
155 #define mlym_tag MS_MAKE_TAG('m','l','y','m')
156 #define mymr_tag MS_MAKE_TAG('m','y','m','r')
157 #define tale_tag MS_MAKE_TAG('t','a','l','e')
158 #define talu_tag MS_MAKE_TAG('t','a','l','u')
159 #define khmr_tag MS_MAKE_TAG('k','h','m','r')
160 #define hani_tag MS_MAKE_TAG('h','a','n','i')
161 #define bopo_tag MS_MAKE_TAG('b','o','p','o')
162 #define kana_tag MS_MAKE_TAG('k','a','n','a')
163 #define hang_tag MS_MAKE_TAG('h','a','n','g')
164 #define yi_tag MS_MAKE_TAG('y','i',' ',' ')
165 #define ethi_tag MS_MAKE_TAG('e','t','h','i')
166 #define mong_tag MS_MAKE_TAG('m','o','n','g')
167 #define tfng_tag MS_MAKE_TAG('t','f','n','g')
168 #define nko_tag MS_MAKE_TAG('n','k','o',' ')
169 #define vai_tag MS_MAKE_TAG('v','a','i',' ')
170 #define cher_tag MS_MAKE_TAG('c','h','e','r')
171 #define cans_tag MS_MAKE_TAG('c','a','n','s')
172 #define ogam_tag MS_MAKE_TAG('o','g','a','m')
173 #define runr_tag MS_MAKE_TAG('r','u','n','r')
174 #define brai_tag MS_MAKE_TAG('b','r','a','i')
175 #define dsrt_tag MS_MAKE_TAG('d','s','r','t')
176 #define osma_tag MS_MAKE_TAG('o','s','m','a')
177 #define math_tag MS_MAKE_TAG('m','a','t','h')
179 static void test_ScriptItemize( void )
181 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
182 static const itemTest t11[2] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1}};
183 static const itemTest t12[2] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
185 static const WCHAR test1b[] = {' ', ' ', ' ', ' ',0};
186 static const itemTest t1b1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
187 static const itemTest t1b2[2] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
189 static const WCHAR test1c[] = {' ', ' ', ' ', '1', '2', ' ',0};
190 static const itemTest t1c1[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
191 static const itemTest t1c2[4] = {{{0,0,0,0,0},0,1,1,1,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},5,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
193 /* Arabic, English*/
194 static const WCHAR test2[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
195 static const itemTest t21[7] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,0,0,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
196 static const itemTest t22[5] = {{{0,0,0,0,0},0,0,0,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,0,0,0,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
197 static const itemTest t23[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},13,0,1,2,0,FALSE},{{0,0,0,0,0},15,1,1,1,0,FALSE},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
199 static const WCHAR test2b[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
200 static const itemTest t2b1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
201 static const itemTest t2b2[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
202 static const itemTest t2b3[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
203 static const int b2[2] = {4,4};
205 /* leading space */
206 static const WCHAR test2c[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
207 static const itemTest t2c1[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
208 static const itemTest t2c2[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},1,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,0,0,FALSE},{{0,0,0,0,0},8,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
209 static const itemTest t2c3[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,0,0,2,0,FALSE},{{0,0,0,0,0},8,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
210 static const itemTest t2c4[3] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
212 /* trailing space */
213 static const WCHAR test2d[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
214 static const itemTest t2d1[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
215 static const itemTest t2d2[6] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
216 static const itemTest t2d3[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,2,0,FALSE},{{0,0,0,0,0},4,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
217 static const itemTest t2d4[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},7,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},11,0,0,0,-1,FALSE}};
219 /* Thai */
220 static const WCHAR test3[] =
221 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
222 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
223 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
224 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
226 static const itemTest t31[2] = {{{0,0,0,0,0},0,0,0,0,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
227 static const itemTest t32[2] = {{{0,0,0,0,0},0,0,0,2,thai_tag,FALSE},{{0,0,0,0,0},41,0,0,0,-1,FALSE}};
229 static const WCHAR test4[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
231 static const itemTest t41[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},7,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,0,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
232 static const itemTest t42[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},10,0,0,2,0,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
233 static const itemTest t43[4] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},6,1,1,1,0,FALSE},{{0,0,0,0,0},7,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
234 static const int b43[2] = {4,4};
236 /* Arabic */
237 static const WCHAR test5[] =
238 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
239 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
240 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
241 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
242 static const itemTest t51[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},38,0,0,0,-1,FALSE}};
244 /* Hebrew */
245 static const WCHAR test6[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
246 static const itemTest t61[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
247 static const itemTest t62[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
248 static const itemTest t63[2] = {{{0,0,0,0,0},0,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
249 static const int b63[2] = {2,2};
250 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};
251 static const itemTest t71[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},19,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
252 static const itemTest t72[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},9,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},18,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
253 static const itemTest t73[4] = {{{0,0,0,0,0},0,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},8,1,1,1,hebr_tag,FALSE},{{0,0,0,0,0},19,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},29,0,0,0,-1,FALSE}};
254 static const WCHAR test8[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
255 static const itemTest t81[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
257 /* Syriac (Like Arabic )*/
258 static const WCHAR test9[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
259 static const itemTest t91[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
260 static const itemTest t92[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag},{{0,0,0,0,0},4,1,1,1,0,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
261 static const itemTest t93[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
262 static const int b93[2] = {2,2};
264 static const WCHAR test10[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
265 static const itemTest t101[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
267 /* Devanagari */
268 static const WCHAR test11[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
269 static const itemTest t111[2] = {{{0,0,0,0,0},0,0,0,0,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
270 static const itemTest t112[2] = {{{0,0,0,0,0},0,0,0,2,deva_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
272 /* Bengali */
273 static const WCHAR test12[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
274 static const itemTest t121[2] = {{{0,0,0,0,0},0,0,0,0,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
275 static const itemTest t122[2] = {{{0,0,0,0,0},0,0,0,2,beng_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
277 /* Gurmukhi */
278 static const WCHAR test13[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
279 static const itemTest t131[2] = {{{0,0,0,0,0},0,0,0,0,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
280 static const itemTest t132[2] = {{{0,0,0,0,0},0,0,0,2,guru_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
282 /* Gujarati */
283 static const WCHAR test14[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
284 static const itemTest t141[2] = {{{0,0,0,0,0},0,0,0,0,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
285 static const itemTest t142[2] = {{{0,0,0,0,0},0,0,0,2,gujr_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
287 /* Oriya */
288 static const WCHAR test15[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
289 static const itemTest t151[2] = {{{0,0,0,0,0},0,0,0,0,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
290 static const itemTest t152[2] = {{{0,0,0,0,0},0,0,0,2,orya_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
292 /* Tamil */
293 static const WCHAR test16[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
294 static const itemTest t161[2] = {{{0,0,0,0,0},0,0,0,0,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
295 static const itemTest t162[2] = {{{0,0,0,0,0},0,0,0,2,taml_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
297 /* Telugu */
298 static const WCHAR test17[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
299 static const itemTest t171[2] = {{{0,0,0,0,0},0,0,0,0,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
300 static const itemTest t172[2] = {{{0,0,0,0,0},0,0,0,2,telu_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
302 /* Kannada */
303 static const WCHAR test18[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
304 static const itemTest t181[2] = {{{0,0,0,0,0},0,0,0,0,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
305 static const itemTest t182[2] = {{{0,0,0,0,0},0,0,0,2,knda_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
307 /* Malayalam */
308 static const WCHAR test19[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
309 static const itemTest t191[2] = {{{0,0,0,0,0},0,0,0,0,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
310 static const itemTest t192[2] = {{{0,0,0,0,0},0,0,0,2,mlym_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
312 /* Diacritical */
313 static const WCHAR test20[] = {0x0309,'a','b','c','d',0};
314 static const itemTest t201[3] = {{{0,0,0,0,0},0,0,0,0,0x0,FALSE},{{0,0,0,0,0},1,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
315 static const itemTest t202[3] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},1,0,0,2,latn_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
317 static const WCHAR test21[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
318 static const itemTest t211[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag,FALSE},{{0,0,0,0,0},5,0,0,0,-1,FALSE}};
320 /* Latin Punctuation */
321 static const WCHAR test22[] = {'#','$',',','!','\"','*',0};
322 static const itemTest t221[3] = {{{0,0,0,0,0},0,0,0,0,latn_tag,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
323 static const itemTest t222[3] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},3,1,1,1,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
324 static const itemTest t223[2] = {{{0,0,0,0,0},0,1,1,1,latn_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
325 static const int b222[2] = {1,1};
326 static const int b223[2] = {2,2};
328 /* Number 2*/
329 static const WCHAR test23[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
330 static const itemTest t231[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},3,0,0,0,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
331 static const itemTest t232[3] = {{{0,0,0,0,0},0,0,1,2,0,FALSE},{{0,0,0,0,0},3,0,1,2,0,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
333 /* Myanmar */
334 static const WCHAR test24[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
335 static const itemTest t241[2] = {{{0,0,0,0,0},0,0,0,0,mymr_tag,FALSE},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
336 static const itemTest t242[2] = {{{0,0,0,0,0},0,0,0,2,mymr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},12,0,0,0,-1,FALSE}};
338 /* Tai Le */
339 static const WCHAR test25[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
340 static const itemTest t251[2] = {{{0,0,0,0,0},0,0,0,0,tale_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
341 static const itemTest t252[2] = {{{0,0,0,0,0},0,0,0,2,tale_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
343 /* New Tai Lue */
344 static const WCHAR test26[] = {0x1992,0x19c4};
345 static const itemTest t261[2] = {{{0,0,0,0,0},0,0,0,0,talu_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
346 static const itemTest t262[2] = {{{0,0,0,0,0},0,0,0,2,talu_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
348 /* Khmer */
349 static const WCHAR test27[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
350 static const itemTest t271[2] = {{{0,0,0,0,0},0,0,0,0,khmr_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
351 static const itemTest t272[2] = {{{0,0,0,0,0},0,0,0,2,khmr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
353 /* CJK Han */
354 static const WCHAR test28[] = {0x8bed,0x7d20,0x6587,0x5b57};
355 static const itemTest t281[2] = {{{0,0,0,0,0},0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
356 static const itemTest t282[2] = {{{0,0,0,0,0},0,0,0,2,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
358 /* Ideographic */
359 static const WCHAR test29[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
360 static const itemTest t291[3] = {{{0,0,0,0,0},0,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,0,hani_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
361 static const itemTest t292[3] = {{{0,0,0,0,0},0,1,1,1,hani_tag,FALSE},{{0,0,0,0,0},4,0,0,2,hani_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
363 /* Bopomofo */
364 static const WCHAR test30[] = {0x3113,0x3128,0x3127,0x3123,0x3108,0x3128,0x310f,0x3120};
365 static const itemTest t301[2] = {{{0,0,0,0,0},0,0,0,0,bopo_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
366 static const itemTest t302[2] = {{{0,0,0,0,0},0,0,0,2,bopo_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
368 /* Kana */
369 static const WCHAR test31[] = {0x3072,0x3089,0x304b,0x306a,0x30ab,0x30bf,0x30ab,0x30ca};
370 static const itemTest t311[2] = {{{0,0,0,0,0},0,0,0,0,kana_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
371 static const itemTest t312[2] = {{{0,0,0,0,0},0,0,0,2,kana_tag,FALSE},{{0,0,0,0,0},8,0,0,0,-1,FALSE}};
372 static const int b311[2] = {2,2};
373 static const int b312[2] = {2,2};
375 /* Hangul */
376 static const WCHAR test32[] = {0xd55c,0xad6d,0xc5b4};
377 static const itemTest t321[2] = {{{0,0,0,0,0},0,0,0,0,hang_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
378 static const itemTest t322[2] = {{{0,0,0,0,0},0,0,0,2,hang_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
380 /* Yi */
381 static const WCHAR test33[] = {0xa188,0xa320,0xa071,0xa0b7};
382 static const itemTest t331[2] = {{{0,0,0,0,0},0,0,0,0,yi_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
383 static const itemTest t332[2] = {{{0,0,0,0,0},0,0,0,2,yi_tag,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
385 /* Ethiopic */
386 static const WCHAR test34[] = {0x130d,0x12d5,0x12dd};
387 static const itemTest t341[2] = {{{0,0,0,0,0},0,0,0,0,ethi_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
388 static const itemTest t342[2] = {{{0,0,0,0,0},0,0,0,2,ethi_tag,FALSE},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
389 static const int b342[2] = {2,2};
391 /* Mongolian */
392 static const WCHAR test35[] = {0x182e,0x1823,0x1829,0x182d,0x1823,0x182f,0x0020,0x182a,0x1822,0x1834,0x1822,0x182d,0x180c};
393 static const itemTest t351[2] = {{{0,0,0,0,0},0,0,0,0,mong_tag,FALSE},{{0,0,0,0,0},13,0,0,0,-1,FALSE}};
394 static const itemTest t352[2] = {{{0,0,0,0,0},0,0,0,2,mong_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},13,0,0,0,-1,FALSE}};
395 static const int b351[2] = {2,2};
396 static const int b352[2] = {2,3};
398 /* Tifinagh */
399 static const WCHAR test36[] = {0x2d5c,0x2d49,0x2d3c,0x2d49,0x2d4f,0x2d30,0x2d56};
400 static const itemTest t361[2] = {{{0,0,0,0,0},0,0,0,0,tfng_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
401 static const itemTest t362[2] = {{{0,0,0,0,0},0,0,0,2,tfng_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
403 /* N'Ko */
404 static const WCHAR test37[] = {0x07d2,0x07de,0x07cf};
405 static const itemTest t371[2] = {{{0,0,0,0,0},0,1,1,1,nko_tag,TRUE,{-1,0,0,0,arab_tag}},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
406 static const itemTest t372[2] = {{{0,0,0,0,0},0,1,1,1,nko_tag,TRUE,{-1,0,0,2,arab_tag}},{{0,0,0,0,0},3,0,0,0,-1,FALSE}};
408 /* Vai */
409 static const WCHAR test38[] = {0xa559,0xa524};
410 static const itemTest t381[2] = {{{0,0,0,0,0},0,0,0,0,vai_tag,TRUE,{-1,-1,-1,-1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
411 static const itemTest t382[2] = {{{0,0,0,0,0},0,0,0,2,vai_tag,TRUE,{-1,1,1,1,latn_tag}},{{0,0,0,0,0},2,0,0,0,-1,FALSE}};
413 /* Cherokee */
414 static const WCHAR test39[] = {0x13e3,0x13b3,0x13a9,0x0020,0x13a6,0x13ec,0x13c2,0x13af,0x13cd,0x13d7};
415 static const itemTest t391[2] = {{{0,0,0,0,0},0,0,0,0,cher_tag,FALSE},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
416 static const itemTest t392[2] = {{{0,0,0,0,0},0,0,0,2,cher_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},10,0,0,0,-1,FALSE}};
418 /* Canadian Aboriginal Syllabics */
419 static const WCHAR test40[] = {0x1403,0x14c4,0x1483,0x144e,0x1450,0x1466};
420 static const itemTest t401[2] = {{{0,0,0,0,0},0,0,0,0,cans_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
421 static const itemTest t402[2] = {{{0,0,0,0,0},0,0,0,2,cans_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
423 /* Ogham */
424 static const WCHAR test41[] = {0x169b,0x1691,0x168c,0x1690,0x168b,0x169c};
425 static const itemTest t411[2] = {{{0,0,0,0,0},0,0,0,0,ogam_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
426 static const itemTest t412[4] = {{{0,0,0,0,0},0,1,1,1,ogam_tag,FALSE},{{0,0,0,0,0},1,0,0,2,ogam_tag,FALSE},{{0,0,0,0,0},5,1,1,1,ogam_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
427 static const int b412[2] = {1,1};
429 /* Runic */
430 static const WCHAR test42[] = {0x16a0,0x16a1,0x16a2,0x16a3,0x16a4,0x16a5};
431 static const itemTest t421[2] = {{{0,0,0,0,0},0,0,0,0,runr_tag,FALSE},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
432 static const itemTest t422[4] = {{{0,0,0,0,0},0,0,0,2,runr_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},6,0,0,0,-1,FALSE}};
434 /* Braille */
435 static const WCHAR test43[] = {0x280f,0x2817,0x2811,0x280d,0x280a,0x2811,0x2817};
436 static const itemTest t431[2] = {{{0,0,0,0,0},0,0,0,0,brai_tag,FALSE},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
437 static const itemTest t432[4] = {{{0,0,0,0,0},0,0,0,2,brai_tag,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},7,0,0,0,-1,FALSE}};
439 /* Private and Surrogates Area */
440 static const WCHAR test44[] = {0xe000, 0xe001, 0xd800, 0xd801};
441 static const itemTest t441[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE},{{0,0,0,0,0},2,0,0,0,0,FALSE},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
442 static const itemTest t442[4] = {{{0,0,0,0,0},0,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},2,0,0,2,0,TRUE,{-1,1,1,1,-1}},{{0,0,0,0,0},4,0,0,0,-1,FALSE}};
444 /* Deseret */
445 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};
446 static const itemTest t451[2] = {{{0,0,0,0,0},0,0,0,0,dsrt_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},24,0,0,0,-1,FALSE}};
447 static const itemTest t452[2] = {{{0,0,0,0,0},0,0,0,2,dsrt_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},24,0,0,0,-1,FALSE}};
449 /* Osmanya */
450 static const WCHAR test46[] = {0xd801,0xdc8b,0xd801,0xdc98,0xd801,0xdc88,0xd801,0xdc91,0xd801,0xdc9b,0xd801,0xdc92,0xd801,0xdc95,0xd801,0xdc80};
451 static const itemTest t461[2] = {{{0,0,0,0,0},0,0,0,0,osma_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
452 static const itemTest t462[2] = {{{0,0,0,0,0},0,0,0,2,osma_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},16,0,0,0,-1,FALSE}};
454 /* Mathematical Alphanumeric Symbols */
455 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};
456 static const itemTest t471[2] = {{{0,0,0,0,0},0,0,0,0,math_tag,TRUE,{-1,-1,-1,-1,0x0}},{{0,0,0,0,0},26,0,0,0,-1,FALSE}};
457 static const itemTest t472[2] = {{{0,0,0,0,0},0,0,0,2,math_tag,TRUE,{-1,1,1,1,0x0}},{{0,0,0,0,0},26,0,0,0,-1,FALSE}};
459 SCRIPT_ITEM items[15];
460 SCRIPT_CONTROL Control;
461 SCRIPT_STATE State;
462 HRESULT hr;
463 HMODULE usp10;
464 int nItems;
466 usp10 = LoadLibraryA("usp10.dll");
467 ok (usp10 != 0,"Unable to LoadLibrary on usp10.dll\n");
468 pScriptItemizeOpenType = (void*)GetProcAddress(usp10, "ScriptItemizeOpenType");
469 pScriptShapeOpenType = (void*)GetProcAddress(usp10, "ScriptShapeOpenType");
470 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
472 memset(&Control, 0, sizeof(Control));
473 memset(&State, 0, sizeof(State));
475 hr = ScriptItemize(NULL, 4, 10, &Control, &State, items, NULL);
476 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
478 hr = ScriptItemize(test1, 4, 10, &Control, &State, NULL, NULL);
479 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
481 hr = ScriptItemize(test1, 4, 1, &Control, &State, items, NULL);
482 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
484 hr = ScriptItemize(test1, 0, 10, NULL, NULL, items, &nItems);
485 ok (hr == E_INVALIDARG, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
487 test_items_ok(test1,4,NULL,NULL,1,t11,FALSE,0);
488 test_items_ok(test1b,4,NULL,NULL,1,t1b1,FALSE,0);
489 test_items_ok(test1c,6,NULL,NULL,1,t1c1,FALSE,0);
490 test_items_ok(test2,16,NULL,NULL,6,t21,FALSE,0);
491 test_items_ok(test2b,11,NULL,NULL,4,t2b1,FALSE,0);
492 test_items_ok(test2c,11,NULL,NULL,4,t2c1,FALSE,0);
493 test_items_ok(test2d,11,NULL,NULL,4,t2d1,FALSE,0);
494 test_items_ok(test3,41,NULL,NULL,1,t31,FALSE,0);
495 test_items_ok(test4,12,NULL,NULL,5,t41,FALSE,0);
496 test_items_ok(test5,38,NULL,NULL,1,t51,FALSE,0);
497 test_items_ok(test6,5,NULL,NULL,2,t61,FALSE,0);
498 test_items_ok(test7,29,NULL,NULL,3,t71,FALSE,0);
499 test_items_ok(test8,4,NULL,NULL,1,t81,FALSE,0);
500 test_items_ok(test9,5,NULL,NULL,2,t91,FALSE,0);
501 test_items_ok(test10,4,NULL,NULL,1,t101,FALSE,0);
502 test_items_ok(test11,8,NULL,NULL,1,t111,FALSE,0);
503 test_items_ok(test12,5,NULL,NULL,1,t121,FALSE,0);
504 test_items_ok(test13,7,NULL,NULL,1,t131,FALSE,0);
505 test_items_ok(test14,7,NULL,NULL,1,t141,FALSE,0);
506 test_items_ok(test15,5,NULL,NULL,1,t151,FALSE,0);
507 test_items_ok(test16,5,NULL,NULL,1,t161,FALSE,0);
508 test_items_ok(test17,6,NULL,NULL,1,t171,FALSE,0);
509 test_items_ok(test18,5,NULL,NULL,1,t181,FALSE,0);
510 test_items_ok(test19,6,NULL,NULL,1,t191,FALSE,0);
511 test_items_ok(test20,5,NULL,NULL,2,t201,FALSE,0);
512 test_items_ok(test21,5,NULL,NULL,1,t211,FALSE,0);
513 test_items_ok(test22,6,NULL,NULL,2,t221,FALSE,0);
514 test_items_ok(test23,6,NULL,NULL,2,t231,FALSE,0);
515 test_items_ok(test24,12,NULL,NULL,1,t241,FALSE,0);
516 test_items_ok(test25,10,NULL,NULL,1,t251,FALSE,0);
517 test_items_ok(test26,2,NULL,NULL,1,t261,FALSE,0);
518 test_items_ok(test27,8,NULL,NULL,1,t271,FALSE,0);
519 test_items_ok(test28,4,NULL,NULL,1,t281,FALSE,0);
520 test_items_ok(test29,10,NULL,NULL,2,t291,FALSE,0);
521 test_items_ok(test30,8,NULL,NULL,1,t301,FALSE,0);
522 test_items_ok(test31,8,NULL,NULL,1,t311,FALSE,b311);
523 test_items_ok(test32,3,NULL,NULL,1,t321,FALSE,0);
524 test_items_ok(test33,4,NULL,NULL,1,t331,FALSE,0);
525 test_items_ok(test34,3,NULL,NULL,1,t341,FALSE,0);
526 test_items_ok(test35,13,NULL,NULL,1,t351,FALSE,b351);
527 test_items_ok(test36,7,NULL,NULL,1,t361,FALSE,0);
528 test_items_ok(test37,3,NULL,NULL,1,t371,FALSE,0);
529 test_items_ok(test38,2,NULL,NULL,1,t381,FALSE,0);
530 test_items_ok(test39,10,NULL,NULL,1,t391,FALSE,0);
531 test_items_ok(test40,6,NULL,NULL,1,t401,FALSE,0);
532 test_items_ok(test41,6,NULL,NULL,1,t411,FALSE,0);
533 test_items_ok(test42,6,NULL,NULL,1,t421,FALSE,0);
534 test_items_ok(test43,7,NULL,NULL,1,t431,FALSE,0);
535 test_items_ok(test44,4,NULL,NULL,2,t441,FALSE,0);
536 test_items_ok(test45,24,NULL,NULL,1,t451,FALSE,0);
537 test_items_ok(test46,16,NULL,NULL,1,t461,FALSE,0);
538 test_items_ok(test47,26,NULL,NULL,1,t471,FALSE,0);
540 State.uBidiLevel = 0;
541 test_items_ok(test1,4,&Control,&State,1,t11,FALSE,0);
542 test_items_ok(test1b,4,&Control,&State,1,t1b1,FALSE,0);
543 test_items_ok(test1c,6,&Control,&State,1,t1c1,FALSE,0);
544 test_items_ok(test2,16,&Control,&State,4,t22,FALSE,0);
545 test_items_ok(test2b,11,&Control,&State,4,t2b1,FALSE,0);
546 test_items_ok(test2c,11,&Control,&State,5,t2c2,FALSE,0);
547 test_items_ok(test2d,11,&Control,&State,5,t2d2,FALSE,0);
548 test_items_ok(test3,41,&Control,&State,1,t31,FALSE,0);
549 test_items_ok(test4,12,&Control,&State,5,t41,FALSE,0);
550 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
551 test_items_ok(test6,5,&Control,&State,2,t61,FALSE,0);
552 test_items_ok(test7,29,&Control,&State,3,t72,FALSE,0);
553 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
554 test_items_ok(test9,5,&Control,&State,2,t91,FALSE,0);
555 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
556 test_items_ok(test11,8,&Control,&State,1,t111,FALSE,0);
557 test_items_ok(test12,5,&Control,&State,1,t121,FALSE,0);
558 test_items_ok(test13,7,&Control,&State,1,t131,FALSE,0);
559 test_items_ok(test14,7,&Control,&State,1,t141,FALSE,0);
560 test_items_ok(test15,5,&Control,&State,1,t151,FALSE,0);
561 test_items_ok(test16,5,&Control,&State,1,t161,FALSE,0);
562 test_items_ok(test17,6,&Control,&State,1,t171,FALSE,0);
563 test_items_ok(test18,5,&Control,&State,1,t181,FALSE,0);
564 test_items_ok(test19,6,&Control,&State,1,t191,FALSE,0);
565 test_items_ok(test20,5,&Control,&State,2,t201,FALSE,0);
566 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
567 test_items_ok(test22,6,&Control,&State,2,t221,FALSE,0);
568 test_items_ok(test23,6,&Control,&State,2,t231,FALSE,0);
569 test_items_ok(test24,12,&Control,&State,1,t241,FALSE,0);
570 test_items_ok(test25,10,&Control,&State,1,t251,FALSE,0);
571 test_items_ok(test26,2,&Control,&State,1,t261,FALSE,0);
572 test_items_ok(test27,8,&Control,&State,1,t271,FALSE,0);
573 test_items_ok(test28,4,&Control,&State,1,t281,FALSE,0);
574 test_items_ok(test29,10,&Control,&State,2,t291,FALSE,0);
575 test_items_ok(test30,8,&Control,&State,1,t301,FALSE,0);
576 test_items_ok(test31,8,&Control,&State,1,t311,FALSE,b311);
577 test_items_ok(test32,3,&Control,&State,1,t321,FALSE,0);
578 test_items_ok(test33,4,&Control,&State,1,t331,FALSE,0);
579 test_items_ok(test34,3,&Control,&State,1,t341,FALSE,0);
580 test_items_ok(test35,13,&Control,&State,1,t351,FALSE,b351);
581 test_items_ok(test36,7,&Control,&State,1,t361,FALSE,0);
582 test_items_ok(test37,3,&Control,&State,1,t371,FALSE,0);
583 test_items_ok(test38,2,&Control,&State,1,t381,FALSE,0);
584 test_items_ok(test39,10,&Control,&State,1,t391,FALSE,0);
585 test_items_ok(test40,6,&Control,&State,1,t401,FALSE,0);
586 test_items_ok(test41,6,&Control,&State,1,t411,FALSE,0);
587 test_items_ok(test42,6,&Control,&State,1,t421,FALSE,0);
588 test_items_ok(test43,7,&Control,&State,1,t431,FALSE,0);
589 test_items_ok(test44,4,&Control,&State,2,t441,FALSE,0);
590 test_items_ok(test45,24,&Control,&State,1,t451,FALSE,0);
591 test_items_ok(test46,16,&Control,&State,1,t461,FALSE,0);
592 test_items_ok(test47,26,&Control,&State,1,t471,FALSE,0);
594 State.uBidiLevel = 1;
595 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
596 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
597 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
598 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
599 test_items_ok(test2b,11,&Control,&State,4,t2b2,FALSE,0);
600 test_items_ok(test2c,11,&Control,&State,4,t2c3,FALSE,0);
601 test_items_ok(test2d,11,&Control,&State,4,t2d3,FALSE,0);
602 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
603 test_items_ok(test4,12,&Control,&State,4,t42,FALSE,0);
604 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
605 test_items_ok(test6,5,&Control,&State,2,t62,FALSE,0);
606 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
607 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
608 test_items_ok(test9,5,&Control,&State,2,t92,FALSE,0);
609 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
610 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
611 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
612 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
613 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
614 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
615 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
616 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
617 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
618 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
619 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
620 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
621 test_items_ok(test22,6,&Control,&State,2,t222,FALSE,b222);
622 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
623 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
624 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
625 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
626 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
627 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
628 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
629 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
630 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
631 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
632 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
633 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
634 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
635 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
636 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
637 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
638 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
639 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
640 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
641 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
642 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
643 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
644 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
645 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
646 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
648 State.uBidiLevel = 1;
649 Control.fMergeNeutralItems = TRUE;
650 test_items_ok(test1,4,&Control,&State,1,t12,FALSE,0);
651 test_items_ok(test1b,4,&Control,&State,1,t1b2,FALSE,0);
652 test_items_ok(test1c,6,&Control,&State,3,t1c2,FALSE,0);
653 test_items_ok(test2,16,&Control,&State,4,t23,FALSE,0);
654 test_items_ok(test2b,11,&Control,&State,2,t2b3,FALSE,b2);
655 test_items_ok(test2c,11,&Control,&State,2,t2c4,FALSE,b2);
656 test_items_ok(test2d,11,&Control,&State,2,t2d4,FALSE,b2);
657 test_items_ok(test3,41,&Control,&State,1,t32,FALSE,0);
658 test_items_ok(test4,12,&Control,&State,3,t43,FALSE,b43);
659 test_items_ok(test5,38,&Control,&State,1,t51,FALSE,0);
660 test_items_ok(test6,5,&Control,&State,1,t63,FALSE,b63);
661 test_items_ok(test7,29,&Control,&State,3,t73,FALSE,0);
662 test_items_ok(test8,4,&Control,&State,1,t81,FALSE,0);
663 test_items_ok(test9,5,&Control,&State,1,t93,FALSE,b93);
664 test_items_ok(test10,4,&Control,&State,1,t101,FALSE,0);
665 test_items_ok(test11,8,&Control,&State,1,t112,FALSE,0);
666 test_items_ok(test12,5,&Control,&State,1,t122,FALSE,0);
667 test_items_ok(test13,7,&Control,&State,1,t132,FALSE,0);
668 test_items_ok(test14,7,&Control,&State,1,t142,FALSE,0);
669 test_items_ok(test15,5,&Control,&State,1,t152,FALSE,0);
670 test_items_ok(test16,5,&Control,&State,1,t162,FALSE,0);
671 test_items_ok(test17,6,&Control,&State,1,t172,FALSE,0);
672 test_items_ok(test18,5,&Control,&State,1,t182,FALSE,0);
673 test_items_ok(test19,6,&Control,&State,1,t192,FALSE,0);
674 test_items_ok(test20,5,&Control,&State,2,t202,FALSE,0);
675 test_items_ok(test21,5,&Control,&State,1,t211,FALSE,0);
676 test_items_ok(test22,6,&Control,&State,1,t223,FALSE,b223);
677 test_items_ok(test23,6,&Control,&State,2,t232,FALSE,0);
678 test_items_ok(test24,12,&Control,&State,1,t242,FALSE,0);
679 test_items_ok(test25,10,&Control,&State,1,t252,FALSE,0);
680 test_items_ok(test26,2,&Control,&State,1,t262,FALSE,0);
681 test_items_ok(test27,8,&Control,&State,1,t272,FALSE,0);
682 test_items_ok(test28,4,&Control,&State,1,t282,FALSE,0);
683 test_items_ok(test29,10,&Control,&State,2,t292,FALSE,0);
684 test_items_ok(test30,8,&Control,&State,1,t302,FALSE,0);
685 test_items_ok(test31,8,&Control,&State,1,t312,FALSE,b312);
686 test_items_ok(test32,3,&Control,&State,1,t322,FALSE,0);
687 test_items_ok(test33,4,&Control,&State,1,t332,FALSE,0);
688 test_items_ok(test34,3,&Control,&State,1,t342,FALSE,b342);
689 test_items_ok(test35,13,&Control,&State,1,t352,FALSE,b352);
690 test_items_ok(test36,7,&Control,&State,1,t362,FALSE,0);
691 test_items_ok(test37,3,&Control,&State,1,t372,FALSE,0);
692 test_items_ok(test38,2,&Control,&State,1,t382,FALSE,0);
693 test_items_ok(test39,10,&Control,&State,1,t392,FALSE,0);
694 test_items_ok(test40,6,&Control,&State,1,t402,FALSE,0);
695 test_items_ok(test41,6,&Control,&State,3,t412,FALSE,b412);
696 test_items_ok(test42,6,&Control,&State,1,t422,FALSE,0);
697 test_items_ok(test43,7,&Control,&State,1,t432,FALSE,0);
698 test_items_ok(test44,4,&Control,&State,2,t442,FALSE,0);
699 test_items_ok(test45,24,&Control,&State,1,t452,FALSE,0);
700 test_items_ok(test46,16,&Control,&State,1,t462,FALSE,0);
701 test_items_ok(test47,26,&Control,&State,1,t472,FALSE,0);
704 static inline void _test_shape_ok(int valid, HDC hdc, LPCWSTR string,
705 DWORD cchString, SCRIPT_CONTROL *Control,
706 SCRIPT_STATE *State, DWORD item, DWORD nGlyphs,
707 const shapeTest_char* charItems,
708 const shapeTest_glyph* glyphItems)
710 HRESULT hr;
711 int x, outnItems=0, outnGlyphs=0;
712 SCRIPT_ITEM outpItems[15];
713 SCRIPT_CACHE sc = NULL;
714 WORD *glyphs;
715 WORD *logclust;
716 int maxGlyphs = cchString * 1.5;
717 SCRIPT_GLYPHPROP *glyphProp;
718 SCRIPT_CHARPROP *charProp;
719 ULONG tags[15];
721 hr = pScriptItemizeOpenType(string, cchString, 15, Control, State, outpItems, tags, &outnItems);
722 if (hr == USP_E_SCRIPT_NOT_IN_FONT)
724 if (valid > 0)
725 winetest_win_skip("Select font does not support script\n");
726 else
727 winetest_trace("Select font does not support script\n");
728 return;
730 if (valid > 0)
731 winetest_ok(!hr, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
732 else if (hr)
733 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr);
736 if (outnItems <= item)
738 if (valid > 0)
739 winetest_win_skip("Did not get enough items\n");
740 else
741 winetest_trace("Did not get enough items\n");
742 return;
745 logclust = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * cchString);
746 memset(logclust,'a',sizeof(WORD) * cchString);
747 charProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP) * cchString);
748 memset(charProp,'a',sizeof(SCRIPT_CHARPROP) * cchString);
749 glyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * maxGlyphs);
750 memset(glyphs,'a',sizeof(WORD) * cchString);
751 glyphProp = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP) * maxGlyphs);
752 memset(glyphProp,'a',sizeof(SCRIPT_GLYPHPROP) * cchString);
754 hr = pScriptShapeOpenType(hdc, &sc, &outpItems[item].a, tags[item], 0x00000000, NULL, NULL, 0, string, cchString, maxGlyphs, logclust, charProp, glyphs, glyphProp, &outnGlyphs);
755 if (valid > 0)
756 winetest_ok(hr == S_OK, "ScriptShapeOpenType failed (%x)\n",hr);
757 else if (hr != S_OK)
758 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr);
759 if (FAILED(hr))
760 return;
762 for (x = 0; x < cchString; x++)
764 if (valid > 0)
765 winetest_ok(logclust[x] == charItems[x].wLogClust, "%i: invalid LogClust(%i)\n",x,logclust[x]);
766 else if (logclust[x] != charItems[x].wLogClust)
767 winetest_trace("%i: invalid LogClust(%i)\n",x,logclust[x]);
768 if (valid > 0)
769 winetest_ok(charProp[x].fCanGlyphAlone == charItems[x].CharProp.fCanGlyphAlone, "%i: invalid fCanGlyphAlone\n",x);
770 else if (charProp[x].fCanGlyphAlone != charItems[x].CharProp.fCanGlyphAlone)
771 winetest_trace("%i: invalid fCanGlyphAlone\n",x);
774 if (valid > 0)
775 winetest_ok(nGlyphs == outnGlyphs, "got incorrect number of glyphs (%i)\n",outnGlyphs);
776 else if (nGlyphs != outnGlyphs)
777 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs);
778 for (x = 0; x < outnGlyphs; x++)
780 if (glyphItems[x].Glyph)
782 if (valid > 0)
783 winetest_ok(glyphs[x]!=0, "%i: Glyph not present when it should be\n",x);
784 else if (glyphs[x]==0)
785 winetest_trace("%i: Glyph not present when it should be\n",x);
787 else
789 if (valid > 0)
790 winetest_ok(glyphs[x]==0, "%i: Glyph present when it should not be\n",x);
791 else if (glyphs[x]!=0)
792 winetest_trace("%i: Glyph present when it should not be\n",x);
794 if (valid > 0)
795 winetest_ok(glyphProp[x].sva.uJustification == glyphItems[x].GlyphProp.sva.uJustification, "%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
796 else if (glyphProp[x].sva.uJustification != glyphItems[x].GlyphProp.sva.uJustification)
797 winetest_trace("%i: uJustification incorrect (%i)\n",x,glyphProp[x].sva.uJustification);
798 if (valid > 0)
799 winetest_ok(glyphProp[x].sva.fClusterStart == glyphItems[x].GlyphProp.sva.fClusterStart, "%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
800 else if (glyphProp[x].sva.fClusterStart != glyphItems[x].GlyphProp.sva.fClusterStart)
801 winetest_trace("%i: fClusterStart incorrect (%i)\n",x,glyphProp[x].sva.fClusterStart);
802 if (valid > 0)
803 winetest_ok(glyphProp[x].sva.fDiacritic == glyphItems[x].GlyphProp.sva.fDiacritic, "%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
804 else if (glyphProp[x].sva.fDiacritic != glyphItems[x].GlyphProp.sva.fDiacritic)
805 winetest_trace("%i: fDiacritic incorrect (%i)\n",x,glyphProp[x].sva.fDiacritic);
806 if (valid > 0)
807 winetest_ok(glyphProp[x].sva.fZeroWidth == glyphItems[x].GlyphProp.sva.fZeroWidth, "%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
808 else if (glyphProp[x].sva.fZeroWidth != glyphItems[x].GlyphProp.sva.fZeroWidth)
809 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x,glyphProp[x].sva.fZeroWidth);
812 HeapFree(GetProcessHeap(),0,logclust);
813 HeapFree(GetProcessHeap(),0,charProp);
814 HeapFree(GetProcessHeap(),0,glyphs);
815 HeapFree(GetProcessHeap(),0,glyphProp);
816 ScriptFreeCache(&sc);
819 #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)
821 #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)
823 typedef struct tagRangeP {
824 BYTE range;
825 LOGFONTA lf;
826 } fontEnumParam;
828 static int CALLBACK enumFontProc( const LOGFONT *lpelfe, const TEXTMETRIC *lpntme,
829 DWORD FontType, LPARAM lParam)
831 NEWTEXTMETRICEX *ntme = (NEWTEXTMETRICEX*)lpntme;
832 fontEnumParam *rp = (fontEnumParam*) lParam;
833 int idx = 0;
834 DWORD i;
835 DWORD mask = 0;
837 if (FontType != TRUETYPE_FONTTYPE)
838 return 1;
840 i = rp->range;
841 while (i > sizeof(DWORD)*8)
843 idx++;
844 i -= (sizeof(DWORD)*8);
846 if (idx > 3)
847 return 0;
849 mask = 1 << i;
851 if (ntme->ntmFontSig.fsUsb[idx] & mask)
853 memcpy(&(rp->lf),lpelfe,sizeof(LOGFONT));
854 return 0;
856 return 1;
859 static int _find_font_for_range(HDC hdc, const CHAR *recommended, BYTE range, const WCHAR check, HFONT *hfont, HFONT *origFont)
861 int rc = 0;
862 fontEnumParam lParam;
864 lParam.range = range;
865 memset(&lParam.lf,0,sizeof(LOGFONT));
866 *hfont = NULL;
868 if (recommended)
870 lstrcpyA(lParam.lf.lfFaceName, recommended);
871 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0))
873 *hfont = CreateFontIndirectA(&lParam.lf);
874 if (*hfont)
876 winetest_trace("using font %s\n",lParam.lf.lfFaceName);
877 rc = 1;
882 if (!*hfont)
884 memset(&lParam.lf,0,sizeof(LOGFONT));
885 lParam.lf.lfCharSet = DEFAULT_CHARSET;
887 if (!EnumFontFamiliesExA(hdc, &lParam.lf, enumFontProc, (LPARAM)&lParam, 0) && lParam.lf.lfFaceName[0])
889 *hfont = CreateFontIndirectA(&lParam.lf);
890 if (*hfont)
891 winetest_trace("trying font %s: failures will only be warnings\n",lParam.lf.lfFaceName);
895 if (*hfont)
897 WORD glyph = 0;
899 *origFont = SelectObject(hdc,*hfont);
900 if (pGetGlyphIndicesW && (pGetGlyphIndicesW(hdc, &check, 1, &glyph, 0) == GDI_ERROR || glyph ==0))
902 winetest_trace(" Font fails to contain required glyphs\n");
903 SelectObject(hdc,*origFont);
904 DeleteObject(*hfont);
905 *hfont=NULL;
906 rc = 0;
908 else if (!rc)
909 rc = -1;
911 else
912 winetest_trace("Failed to find usable font\n");
914 return rc;
917 #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)
919 static void test_ScriptShapeOpenType(HDC hdc)
921 HRESULT hr;
922 SCRIPT_CACHE sc = NULL;
923 WORD glyphs[4], logclust[4];
924 SCRIPT_GLYPHPROP glyphProp[4];
925 SCRIPT_ITEM items[2];
926 ULONG tags[2];
927 SCRIPT_CONTROL Control;
928 SCRIPT_STATE State;
929 int nb, outnItems;
930 HFONT hfont, hfont_orig;
931 int test_valid;
933 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
934 static const shapeTest_char t1_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
935 static const shapeTest_glyph t1_g[] = {
936 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
937 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
938 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
939 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
941 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
942 static const shapeTest_char t2_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
943 static const shapeTest_glyph t2_g[] = {
944 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
945 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
946 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
947 {0,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
949 /* Hebrew */
950 static const WCHAR test_hebrew[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
951 static const shapeTest_char hebrew_c[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
952 static const shapeTest_glyph hebrew_g[] = {
953 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
954 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
955 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
956 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}} };
958 /* Arabic */
959 static const WCHAR test_arabic[] = {0x0633,0x0644,0x0627,0x0645,0};
960 static const shapeTest_char arabic_c[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
961 static const shapeTest_glyph arabic_g[] = {
962 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
963 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL,1,0,0,0,0},0}},
964 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN,1,0,0,0,0},0}} };
966 /* Thai */
967 static const WCHAR test_thai[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
968 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}}};
969 static const shapeTest_glyph thai_g[] = {
970 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
971 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
972 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
973 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
974 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
975 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
976 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
977 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
978 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
979 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}}};
981 /* Syriac */
982 static const WCHAR test_syriac[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
983 static const shapeTest_char syriac_c[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
984 static const shapeTest_glyph syriac_g[] = {
985 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
986 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
987 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
988 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
989 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
990 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
992 /* Thaana */
993 static const WCHAR test_thaana[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
994 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}}};
995 static const shapeTest_glyph thaana_g[] = {
996 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
997 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
998 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
999 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1000 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1001 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1002 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1003 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1004 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1005 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1006 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1007 {1,{{SCRIPT_JUSTIFY_NONE,0,1,1,0,0},0}},
1008 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1010 /* Phags-pa */
1011 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
1012 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}}};
1013 static const shapeTest_glyph phagspa_g[] = {
1014 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1015 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1016 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1017 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1018 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1019 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1020 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1021 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1022 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1023 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1024 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1026 /* Lao */
1027 static const WCHAR test_lao[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
1028 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}}};
1029 static const shapeTest_glyph lao_g[] = {
1030 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1031 {1,{{SCRIPT_JUSTIFY_CHARACTER,0,1,1,0,0},0}},
1032 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1033 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1034 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1035 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1036 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1037 {1,{{SCRIPT_JUSTIFY_CHARACTER,1,0,0,0,0},0}},
1038 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1040 /* Tibetan */
1041 static const WCHAR test_tibetan[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
1042 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}}};
1043 static const shapeTest_glyph tibetan_g[] = {
1044 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1045 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1046 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1047 {1,{{SCRIPT_JUSTIFY_BLANK,1,0,0,0,0},0}},
1048 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1049 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1050 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1051 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1052 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1053 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1054 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1055 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1056 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1057 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1058 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1059 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1060 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1062 /* Devanagari */
1063 static const WCHAR test_devanagari[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
1064 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}}};
1065 static const shapeTest_glyph devanagari_g[] = {
1066 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1067 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1068 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1069 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1070 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1071 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1072 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1073 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1075 /* Bengali */
1076 static const WCHAR test_bengali[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
1077 static const shapeTest_char bengali_c[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
1078 static const shapeTest_glyph bengali_g[] = {
1079 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1080 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1081 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1082 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1083 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1085 /* Gurmukhi */
1086 static const WCHAR test_gurmukhi[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
1087 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}}};
1088 static const shapeTest_glyph gurmukhi_g[] = {
1089 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1090 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1091 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1092 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1093 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1094 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1095 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1097 /* Gujarati */
1098 static const WCHAR test_gujarati[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
1099 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}}};
1100 static const shapeTest_glyph gujarati_g[] = {
1101 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1102 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1103 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1104 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1105 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1106 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1107 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1109 /* Oriya */
1110 static const WCHAR test_oriya[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
1111 static const shapeTest_char oriya_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1112 static const shapeTest_glyph oriya_g[] = {
1113 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1114 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1115 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1116 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1118 /* Tamil */
1119 static const WCHAR test_tamil[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1120 static const shapeTest_char tamil_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1121 static const shapeTest_glyph tamil_g[] = {
1122 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1123 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1124 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1125 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}} };
1127 /* Telugu */
1128 static const WCHAR test_telugu[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1129 static const shapeTest_char telugu_c[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1130 static const shapeTest_glyph telugu_g[] = {
1131 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1132 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1133 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1134 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1135 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1136 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1138 /* Malayalam */
1139 static const WCHAR test_malayalam[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1140 static const shapeTest_char malayalam_c[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1141 static const shapeTest_glyph malayalam_g[] = {
1142 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1143 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1144 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1145 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1146 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1147 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1149 /* Kannada */
1150 static const WCHAR test_kannada[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1151 static const shapeTest_char kannada_c[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1152 static const shapeTest_glyph kannada_g[] = {
1153 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1154 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1155 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}},
1156 {1,{{SCRIPT_JUSTIFY_NONE,1,0,0,0,0},0}},
1157 {1,{{SCRIPT_JUSTIFY_NONE,0,0,0,0,0},0}} };
1159 if (!pScriptItemizeOpenType || !pScriptShapeOpenType)
1161 win_skip("ScriptShapeOpenType not available on this platform\n");
1162 return;
1165 memset(&Control, 0 , sizeof(Control));
1166 memset(&State, 0 , sizeof(State));
1168 hr = pScriptItemizeOpenType(test1, 4, 2, &Control, &State, items, tags, &outnItems);
1169 ok(!hr, "ScriptItemizeOpenType should return S_OK not %08x\n", hr);
1170 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1172 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, NULL, &nb);
1173 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1175 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, NULL);
1176 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1178 hr = pScriptShapeOpenType(NULL, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1179 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr);
1181 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, NULL, NULL, glyphs, glyphProp, &nb);
1182 ok( hr == E_INVALIDARG,
1183 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1184 hr = pScriptShapeOpenType(hdc, &sc, &items[0].a, tags[0], 0x00000000, NULL, NULL, 0, test1, 4, 4, logclust, NULL, glyphs, glyphProp, &nb);
1185 ok(hr == E_INVALIDARG, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr);
1187 ScriptFreeCache(&sc);
1189 test_shape_ok(hdc, test1, 4, &Control, &State, 0, 4, t1_c, t1_g);
1190 test_shape_ok(hdc, test2, 4, &Control, &State, 1, 4, t2_c, t2_g);
1192 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 11, test_hebrew[0], &hfont, &hfont_orig);
1193 if (hfont != NULL)
1195 test_shape_ok_valid(test_valid, hdc, test_hebrew, 4, &Control, &State, 0, 4, hebrew_c, hebrew_g);
1196 SelectObject(hdc, hfont_orig);
1197 DeleteObject(hfont);
1200 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 13, test_arabic[0], &hfont, &hfont_orig);
1201 if (hfont != NULL)
1203 test_shape_ok_valid(test_valid, hdc, test_arabic, 4, &Control, &State, 0, 3, arabic_c, arabic_g);
1204 SelectObject(hdc, hfont_orig);
1205 DeleteObject(hfont);
1208 test_valid = find_font_for_range(hdc, "Microsoft Sans Serif", 24, test_thai[0], &hfont, &hfont_orig);
1209 if (hfont != NULL)
1211 test_shape_ok_valid(test_valid, hdc, test_thai, 10, &Control, &State, 0, 10, thai_c, thai_g);
1212 SelectObject(hdc, hfont_orig);
1213 DeleteObject(hfont);
1216 test_valid = find_font_for_range(hdc, "Estrangelo Edessa", 71, test_syriac[0], &hfont, &hfont_orig);
1217 if (hfont != NULL)
1219 test_shape_ok_valid(test_valid, hdc, test_syriac, 6, &Control, &State, 0, 6, syriac_c, syriac_g);
1220 SelectObject(hdc, hfont_orig);
1221 DeleteObject(hfont);
1224 test_valid = find_font_for_range(hdc, "MV Boli", 72, test_thaana[0], &hfont, &hfont_orig);
1225 if (hfont != NULL)
1227 test_shape_ok_valid(test_valid, hdc, test_thaana, 13, &Control, &State, 0, 13, thaana_c, thaana_g);
1228 SelectObject(hdc, hfont_orig);
1229 DeleteObject(hfont);
1232 test_valid = find_font_for_range(hdc, "Microsoft PhagsPa", 53, test_phagspa[0], &hfont, &hfont_orig);
1233 if (hfont != NULL)
1235 test_shape_ok_valid(test_valid, hdc, test_phagspa, 11, &Control, &State, 0, 11, phagspa_c, phagspa_g);
1236 SelectObject(hdc, hfont_orig);
1237 DeleteObject(hfont);
1240 test_valid = find_font_for_range(hdc, "DokChampa", 25, test_lao[0], &hfont, &hfont_orig);
1241 if (hfont != NULL)
1243 test_shape_ok_valid(test_valid, hdc, test_lao, 9, &Control, &State, 0, 9, lao_c, lao_g);
1244 SelectObject(hdc, hfont_orig);
1245 DeleteObject(hfont);
1248 test_valid = find_font_for_range(hdc, "Microsoft Himalaya", 70, test_tibetan[0], &hfont, &hfont_orig);
1249 if (hfont != NULL)
1251 test_shape_ok_valid(test_valid, hdc, test_tibetan, 17, &Control, &State, 0, 17, tibetan_c, tibetan_g);
1252 SelectObject(hdc, hfont_orig);
1253 DeleteObject(hfont);
1256 test_valid = find_font_for_range(hdc, "Mangal", 15, test_devanagari[0], &hfont, &hfont_orig);
1257 if (hfont != NULL)
1259 test_shape_ok_valid(test_valid, hdc, test_devanagari, 8, &Control, &State, 0, 8, devanagari_c, devanagari_g);
1260 SelectObject(hdc, hfont_orig);
1261 DeleteObject(hfont);
1264 test_valid = find_font_for_range(hdc, "Vrinda", 16, test_bengali[0], &hfont, &hfont_orig);
1265 if (hfont != NULL)
1267 test_shape_ok_valid(test_valid, hdc, test_bengali, 5, &Control, &State, 0, 5, bengali_c, bengali_g);
1268 SelectObject(hdc, hfont_orig);
1269 DeleteObject(hfont);
1272 test_valid = find_font_for_range(hdc, "Raavi", 17, test_gurmukhi[0], &hfont, &hfont_orig);
1273 if (hfont != NULL)
1275 test_shape_ok_valid(test_valid, hdc, test_gurmukhi, 7, &Control, &State, 0, 7, gurmukhi_c, gurmukhi_g);
1276 SelectObject(hdc, hfont_orig);
1277 DeleteObject(hfont);
1280 test_valid = find_font_for_range(hdc, "Shruti", 18, test_gujarati[0], &hfont, &hfont_orig);
1281 if (hfont != NULL)
1283 test_shape_ok_valid(test_valid, hdc, test_gujarati, 7, &Control, &State, 0, 7, gujarati_c, gujarati_g);
1284 SelectObject(hdc, hfont_orig);
1285 DeleteObject(hfont);
1288 test_valid = find_font_for_range(hdc, "Kalinga", 19, test_oriya[0], &hfont, &hfont_orig);
1289 if (hfont != NULL)
1291 test_shape_ok_valid(test_valid, hdc, test_oriya, 5, &Control, &State, 0, 4, oriya_c, oriya_g);
1292 SelectObject(hdc, hfont_orig);
1293 DeleteObject(hfont);
1296 test_valid = find_font_for_range(hdc, "Latha", 20, test_tamil[0], &hfont, &hfont_orig);
1297 if (hfont != NULL)
1299 test_shape_ok_valid(test_valid, hdc, test_tamil, 5, &Control, &State, 0, 4, tamil_c, tamil_g);
1300 SelectObject(hdc, hfont_orig);
1301 DeleteObject(hfont);
1304 test_valid = find_font_for_range(hdc, "Gautami", 21, test_telugu[0], &hfont, &hfont_orig);
1305 if (hfont != NULL)
1307 test_shape_ok_valid(test_valid, hdc, test_telugu, 6, &Control, &State, 0, 6, telugu_c, telugu_g);
1308 SelectObject(hdc, hfont_orig);
1309 DeleteObject(hfont);
1312 test_valid = find_font_for_range(hdc, "Kartika", 23, test_malayalam[0], &hfont, &hfont_orig);
1313 if (hfont != NULL)
1315 test_shape_ok_valid(test_valid, hdc, test_malayalam, 6, &Control, &State, 0, 6, malayalam_c, malayalam_g);
1316 SelectObject(hdc, hfont_orig);
1317 DeleteObject(hfont);
1320 test_valid = find_font_for_range(hdc, "Tunga", 22, test_kannada[0], &hfont, &hfont_orig);
1321 if (hfont != NULL)
1323 test_shape_ok_valid(test_valid, hdc, test_kannada, 5, &Control, &State, 0, 4, kannada_c, kannada_g);
1324 SelectObject(hdc, hfont_orig);
1325 DeleteObject(hfont);
1329 static void test_ScriptShape(HDC hdc)
1331 static const WCHAR test1[] = {'w', 'i', 'n', 'e',0};
1332 static const WCHAR test2[] = {0x202B, 'i', 'n', 0x202C,0};
1333 HRESULT hr;
1334 SCRIPT_CACHE sc = NULL;
1335 WORD glyphs[4], glyphs2[4], logclust[4];
1336 SCRIPT_VISATTR attrs[4];
1337 SCRIPT_ITEM items[2];
1338 int nb;
1340 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1341 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
1342 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1344 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, NULL, &nb);
1345 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1347 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, NULL);
1348 ok(hr == E_INVALIDARG, "ScriptShape should return E_INVALIDARG not %08x\n", hr);
1350 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1351 ok(hr == E_PENDING, "ScriptShape should return E_PENDING not %08x\n", hr);
1353 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, NULL, attrs, &nb);
1354 ok(broken(hr == S_OK) ||
1355 hr == E_INVALIDARG || /* Vista, W2K8 */
1356 hr == E_FAIL, /* WIN7 */
1357 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1358 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1360 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1361 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1362 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1365 memset(glyphs,-1,sizeof(glyphs));
1366 memset(logclust,-1,sizeof(logclust));
1367 memset(attrs,-1,sizeof(attrs));
1368 hr = ScriptShape(NULL, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1369 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1370 ok(nb == 4, "Wrong number of items\n");
1371 ok(logclust[0] == 0, "clusters out of order\n");
1372 ok(logclust[1] == 1, "clusters out of order\n");
1373 ok(logclust[2] == 2, "clusters out of order\n");
1374 ok(logclust[3] == 3, "clusters out of order\n");
1375 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1376 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1377 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1378 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1379 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1380 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1381 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1382 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1383 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1384 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1385 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1386 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1387 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1388 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1389 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1390 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1392 ScriptFreeCache(&sc);
1393 sc = NULL;
1395 memset(glyphs2,-1,sizeof(glyphs2));
1396 memset(logclust,-1,sizeof(logclust));
1397 memset(attrs,-1,sizeof(attrs));
1398 hr = ScriptShape(hdc, &sc, test2, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1399 ok(hr == S_OK, "ScriptShape should return S_OK not %08x\n", hr);
1400 ok(nb == 4, "Wrong number of items\n");
1401 ok(glyphs2[0] == 0 || broken(glyphs2[0] == 0x80), "Incorrect glyph for 0x202B\n");
1402 ok(glyphs2[3] == 0 || broken(glyphs2[3] == 0x80), "Incorrect glyph for 0x202C\n");
1403 ok(logclust[0] == 0, "clusters out of order\n");
1404 ok(logclust[1] == 1, "clusters out of order\n");
1405 ok(logclust[2] == 2, "clusters out of order\n");
1406 ok(logclust[3] == 3, "clusters out of order\n");
1407 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1408 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1409 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1410 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1411 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1412 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1413 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1414 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1415 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1416 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1417 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1418 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1419 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1420 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1421 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1422 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1424 /* modify LTR to RTL */
1425 items[0].a.fRTL = 1;
1426 memset(glyphs2,-1,sizeof(glyphs2));
1427 memset(logclust,-1,sizeof(logclust));
1428 memset(attrs,-1,sizeof(attrs));
1429 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs2, logclust, attrs, &nb);
1430 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1431 ok(nb == 4, "Wrong number of items\n");
1432 ok(glyphs2[0] == glyphs[3], "Glyphs not reordered properly\n");
1433 ok(glyphs2[1] == glyphs[2], "Glyphs not reordered properly\n");
1434 ok(glyphs2[2] == glyphs[1], "Glyphs not reordered properly\n");
1435 ok(glyphs2[3] == glyphs[0], "Glyphs not reordered properly\n");
1436 ok(logclust[0] == 3, "clusters out of order\n");
1437 ok(logclust[1] == 2, "clusters out of order\n");
1438 ok(logclust[2] == 1, "clusters out of order\n");
1439 ok(logclust[3] == 0, "clusters out of order\n");
1440 ok(attrs[0].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1441 ok(attrs[1].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1442 ok(attrs[2].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1443 ok(attrs[3].uJustification == SCRIPT_JUSTIFY_CHARACTER, "uJustification incorrect\n");
1444 ok(attrs[0].fClusterStart == 1, "fClusterStart incorrect\n");
1445 ok(attrs[1].fClusterStart == 1, "fClusterStart incorrect\n");
1446 ok(attrs[2].fClusterStart == 1, "fClusterStart incorrect\n");
1447 ok(attrs[3].fClusterStart == 1, "fClusterStart incorrect\n");
1448 ok(attrs[0].fDiacritic == 0, "fDiacritic incorrect\n");
1449 ok(attrs[1].fDiacritic == 0, "fDiacritic incorrect\n");
1450 ok(attrs[2].fDiacritic == 0, "fDiacritic incorrect\n");
1451 ok(attrs[3].fDiacritic == 0, "fDiacritic incorrect\n");
1452 ok(attrs[0].fZeroWidth == 0, "fZeroWidth incorrect\n");
1453 ok(attrs[1].fZeroWidth == 0, "fZeroWidth incorrect\n");
1454 ok(attrs[2].fZeroWidth == 0, "fZeroWidth incorrect\n");
1455 ok(attrs[3].fZeroWidth == 0, "fZeroWidth incorrect\n");
1457 ScriptFreeCache(&sc);
1460 static void test_ScriptPlace(HDC hdc)
1462 static const WCHAR test1[] = {'t', 'e', 's', 't',0};
1463 BOOL ret;
1464 HRESULT hr;
1465 SCRIPT_CACHE sc = NULL;
1466 WORD glyphs[4], logclust[4];
1467 SCRIPT_VISATTR attrs[4];
1468 SCRIPT_ITEM items[2];
1469 int nb, widths[4];
1470 GOFFSET offset[4];
1471 ABC abc[4];
1473 hr = ScriptItemize(test1, 4, 2, NULL, NULL, items, NULL);
1474 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
1475 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1477 hr = ScriptShape(hdc, &sc, test1, 4, 4, &items[0].a, glyphs, logclust, attrs, &nb);
1478 ok(!hr, "ScriptShape should return S_OK not %08x\n", hr);
1479 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1481 hr = ScriptPlace(hdc, &sc, glyphs, 4, NULL, &items[0].a, widths, NULL, NULL);
1482 ok(hr == E_INVALIDARG, "ScriptPlace should return E_INVALIDARG not %08x\n", hr);
1484 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, NULL);
1485 ok(broken(hr == E_PENDING) ||
1486 hr == E_INVALIDARG || /* Vista, W2K8 */
1487 hr == E_FAIL, /* WIN7 */
1488 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1490 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1491 ok(hr == E_PENDING, "ScriptPlace should return E_PENDING not %08x\n", hr);
1493 hr = ScriptPlace(NULL, &sc, glyphs, 4, attrs, &items[0].a, widths, NULL, abc);
1494 ok(broken(hr == E_PENDING) ||
1495 hr == E_INVALIDARG || /* Vista, W2K8 */
1496 hr == E_FAIL, /* WIN7 */
1497 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr);
1499 hr = ScriptPlace(hdc, &sc, glyphs, 4, attrs, &items[0].a, widths, offset, NULL);
1500 ok(!hr, "ScriptPlace should return S_OK not %08x\n", hr);
1501 ok(items[0].a.fNoGlyphIndex == FALSE, "fNoGlyphIndex TRUE\n");
1503 ret = ExtTextOutW(hdc, 1, 1, 0, NULL, glyphs, 4, widths);
1504 ok(ret, "ExtTextOutW should return TRUE\n");
1506 ScriptFreeCache(&sc);
1509 static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256])
1511 HRESULT hr;
1512 int iMaxProps;
1513 const SCRIPT_PROPERTIES **ppSp;
1515 int cInChars;
1516 int cMaxItems;
1517 SCRIPT_ITEM pItem[255];
1518 int pcItems;
1519 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1520 WCHAR TestItem2[] = {'T', 'e', 's', 't', 'b', 0};
1521 WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1522 WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1523 WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1524 WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1526 SCRIPT_CACHE psc;
1527 int cChars;
1528 int cMaxGlyphs;
1529 unsigned short pwOutGlyphs1[256];
1530 unsigned short pwOutGlyphs2[256];
1531 unsigned short pwLogClust[256];
1532 SCRIPT_VISATTR psva[256];
1533 int pcGlyphs;
1534 int piAdvance[256];
1535 GOFFSET pGoffset[256];
1536 ABC pABC[256];
1537 int cnt;
1539 /* Start testing usp10 functions */
1540 /* This test determines that the pointer returned by ScriptGetProperties is valid
1541 * by checking a known value in the table */
1542 hr = ScriptGetProperties(&ppSp, &iMaxProps);
1543 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
1544 trace("number of script properties %d\n", iMaxProps);
1545 ok (iMaxProps > 0, "Number of scripts returned should not be 0\n");
1546 if (iMaxProps > 0)
1547 ok( ppSp[0]->langid == 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1548 /* ptrs work */
1550 /* This is a valid test that will cause parsing to take place */
1551 cInChars = 5;
1552 cMaxItems = 255;
1553 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1554 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1555 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1556 * returned. */
1557 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1558 if (pcItems > 0)
1559 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1560 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1561 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1563 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1564 * ie. ScriptItemize has succeeded and that pItem has been set */
1565 cInChars = 5;
1566 if (hr == 0) {
1567 psc = NULL; /* must be null on first call */
1568 cChars = cInChars;
1569 cMaxGlyphs = cInChars;
1570 hr = ScriptShape(NULL, &psc, TestItem1, cChars,
1571 cMaxGlyphs, &pItem[0].a,
1572 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1573 ok (hr == E_PENDING, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr);
1574 cMaxGlyphs = 4;
1575 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1576 cMaxGlyphs, &pItem[0].a,
1577 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1578 ok (hr == E_OUTOFMEMORY, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1579 "(%d) but not E_OUTOFMEMORY\n",
1580 cChars, cMaxGlyphs);
1581 cMaxGlyphs = 256;
1582 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
1583 cMaxGlyphs, &pItem[0].a,
1584 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
1585 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1586 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1587 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1588 if (hr ==0) {
1589 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1590 pGoffset, pABC);
1591 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1592 hr = ScriptPlace(NULL, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
1593 pGoffset, pABC);
1594 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1595 for (cnt=0; cnt < pcGlyphs; cnt++)
1596 pwOutGlyphs[cnt] = pwOutGlyphs1[cnt]; /* Send to next function */
1599 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1600 * takes place if fNoGlyphIndex is set. */
1602 cInChars = 5;
1603 cMaxItems = 255;
1604 hr = ScriptItemize(TestItem2, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1605 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1606 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1607 * returned. */
1608 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
1609 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1610 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
1611 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1612 if (hr == 0) {
1613 cChars = cInChars;
1614 cMaxGlyphs = 256;
1615 pItem[0].a.fNoGlyphIndex = 1; /* say no translate */
1616 hr = ScriptShape(NULL, &psc, TestItem2, cChars,
1617 cMaxGlyphs, &pItem[0].a,
1618 pwOutGlyphs2, pwLogClust, psva, &pcGlyphs);
1619 ok (hr != E_PENDING, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr);
1620 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
1621 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1622 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
1623 for (cnt=0; cnt < cChars && TestItem2[cnt] == pwOutGlyphs2[cnt]; cnt++) {}
1624 ok (cnt == cChars, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1625 cnt, TestItem2[cnt], pwOutGlyphs2[cnt]);
1626 if (hr ==0) {
1627 hr = ScriptPlace(hdc, &psc, pwOutGlyphs2, pcGlyphs, psva, &pItem[0].a, piAdvance,
1628 pGoffset, pABC);
1629 ok (hr == 0, "ScriptPlace should return 0 not (%08x)\n", hr);
1632 ScriptFreeCache( &psc);
1633 ok (!psc, "psc is not null after ScriptFreeCache\n");
1637 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1638 cInChars = (sizeof(TestItem3)/2)-1;
1639 cMaxItems = 255;
1640 hr = ScriptItemize(TestItem3, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1641 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1642 if (hr == 0)
1644 ok (pcItems == 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems);
1645 if (pcItems > 2)
1647 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1648 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1649 pItem[0].iCharPos, pItem[1].iCharPos);
1650 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1651 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1652 pItem[1].iCharPos, pItem[2].iCharPos);
1653 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == cInChars,
1654 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1655 pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
1659 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1660 cInChars = (sizeof(TestItem4)/2)-1;
1661 cMaxItems = 255;
1662 hr = ScriptItemize(TestItem4, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1663 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1664 if (hr == 0)
1666 ok (pcItems == 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems);
1667 if (pcItems > 4)
1669 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
1670 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1671 pItem[0].iCharPos, pItem[1].iCharPos);
1672 ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1673 pItem[0].a.s.uBidiLevel);
1674 ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
1675 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1676 pItem[1].iCharPos, pItem[2].iCharPos);
1677 ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
1678 pItem[1].a.s.uBidiLevel);
1679 ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
1680 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1681 pItem[2].iCharPos, pItem[3].iCharPos);
1682 ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1683 pItem[2].a.s.uBidiLevel);
1684 ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
1685 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1686 pItem[3].iCharPos, pItem[4].iCharPos);
1687 ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
1688 pItem[3].a.s.uBidiLevel);
1689 ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
1690 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1691 pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
1696 * This test is for when the first unicode character requires bidi support
1698 cInChars = (sizeof(TestItem5)-1)/sizeof(WCHAR);
1699 hr = ScriptItemize(TestItem5, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1700 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
1701 ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
1702 ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
1703 pItem[0].a.s.uBidiLevel);
1705 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1706 * the pointer to the last char works. Note that windows often needs a greater number of *
1707 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1708 cInChars = (sizeof(TestItem6)/2)-1;
1709 cMaxItems = 4;
1710 hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
1711 ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
1715 static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
1717 HRESULT hr;
1718 SCRIPT_CACHE psc = NULL;
1719 int cInChars;
1720 int cChars;
1721 unsigned short pwOutGlyphs2[256];
1722 unsigned short pwOutGlyphs3[256];
1723 DWORD dwFlags;
1724 int cnt;
1726 static const WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
1727 static const WCHAR TestItem2[] = {0x202B, 'i', 'n', 0x202C,0};
1728 static const WCHAR TestItem3[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1729 static const WCHAR TestItem3b[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1731 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1732 dwFlags = 0;
1733 cInChars = cChars = 5;
1734 /* Some sanity checks for ScriptGetCMap */
1736 hr = ScriptGetCMap(NULL, NULL, NULL, 0, 0, NULL);
1737 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL,0,0,NULL), "
1738 "expected E_INVALIDARG, got %08x\n", hr);
1740 hr = ScriptGetCMap(NULL, NULL, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1741 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1742 "expected E_INVALIDARG, got %08x\n", hr);
1744 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1745 psc = NULL;
1746 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1747 ok( hr == E_PENDING, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1748 "got %08x\n", hr);
1749 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1751 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1752 psc = NULL;
1753 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, 0, pwOutGlyphs3);
1754 ok( hr == S_OK, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1755 "got %08x\n", hr);
1756 ok( psc != NULL, "ScritpGetCMap expected psc to be not NULL\n");
1757 ScriptFreeCache( &psc);
1759 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1760 psc = NULL;
1761 hr = ScriptGetCMap(NULL, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1762 ok( hr == E_PENDING, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr);
1763 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1764 /* Check to see if the results are the same as those returned by ScriptShape */
1765 hr = ScriptGetCMap(hdc, &psc, TestItem1, cInChars, dwFlags, pwOutGlyphs3);
1766 ok (hr == 0, "ScriptGetCMap should return 0 not (%08x)\n", hr);
1767 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1768 for (cnt=0; cnt < cChars && pwOutGlyphs[cnt] == pwOutGlyphs3[cnt]; cnt++) {}
1769 ok (cnt == cInChars, "Translation not correct. WCHAR %d - %04x != %04x\n",
1770 cnt, pwOutGlyphs[cnt], pwOutGlyphs3[cnt]);
1772 ScriptFreeCache( &psc);
1773 ok (!psc, "psc is not null after ScriptFreeCache\n");
1775 cInChars = cChars = 4;
1776 hr = ScriptGetCMap(hdc, &psc, TestItem2, cInChars, dwFlags, pwOutGlyphs3);
1777 ok (hr == S_FALSE, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr);
1778 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1779 ok(pwOutGlyphs3[0] == 0 || broken(pwOutGlyphs3[0] == 0x80), "Glyph 0 should be default glyph\n");
1780 ok(pwOutGlyphs3[3] == 0 || broken(pwOutGlyphs3[0] == 0x80), "Glyph 0 should be default glyph\n");
1783 cInChars = cChars = 9;
1784 hr = ScriptGetCMap(hdc, &psc, TestItem3b, cInChars, dwFlags, pwOutGlyphs2);
1785 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1786 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1788 cInChars = cChars = 9;
1789 dwFlags = SGCM_RTL;
1790 hr = ScriptGetCMap(hdc, &psc, TestItem3, cInChars, dwFlags, pwOutGlyphs3);
1791 ok (hr == S_OK, "ScriptGetCMap should return S_OK not (%08x)\n", hr);
1792 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1793 ok(pwOutGlyphs3[0] == pwOutGlyphs2[0], "glyph incorrectly altered\n");
1794 ok(pwOutGlyphs3[1] == pwOutGlyphs2[1], "glyph incorrectly altered\n");
1795 ok(pwOutGlyphs3[2] == pwOutGlyphs2[2], "glyph incorrectly altered\n");
1796 ok(pwOutGlyphs3[3] == pwOutGlyphs2[3], "glyph incorrectly altered\n");
1797 ok(pwOutGlyphs3[4] == pwOutGlyphs2[4], "glyph not mirrored correctly\n");
1798 ok(pwOutGlyphs3[5] == pwOutGlyphs2[5], "glyph not mirrored correctly\n");
1799 ok(pwOutGlyphs3[6] == pwOutGlyphs2[6], "glyph not mirrored correctly\n");
1800 ok(pwOutGlyphs3[7] == pwOutGlyphs2[7], "glyph not mirrored correctly\n");
1801 ok(pwOutGlyphs3[8] == pwOutGlyphs2[8], "glyph not mirrored correctly\n");
1803 ScriptFreeCache( &psc);
1804 ok (!psc, "psc is not null after ScriptFreeCache\n");
1807 #define MAX_ENUM_FONTS 4096
1809 struct enum_font_data
1811 int total;
1812 ENUMLOGFONT elf[MAX_ENUM_FONTS];
1815 static INT CALLBACK enum_bitmap_font_proc(const LOGFONT *lf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
1817 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
1819 if (type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE)) return 1;
1821 if (efnd->total < MAX_ENUM_FONTS)
1823 efnd->elf[efnd->total++] = *(ENUMLOGFONT*)lf;
1825 else
1826 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
1828 return 1;
1831 static INT CALLBACK enum_truetype_proc(const LOGFONT *lf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
1833 struct enum_font_data *efnd = (struct enum_font_data *)lParam;
1835 if (!(type & (TRUETYPE_FONTTYPE | DEVICE_FONTTYPE))) return 1;
1837 if (efnd->total < MAX_ENUM_FONTS)
1839 efnd->elf[efnd->total++] = *(ENUMLOGFONT*)lf;
1841 else
1842 trace("enum tests invalid; you have more than %d fonts\n", MAX_ENUM_FONTS);
1844 return 1;
1847 static void test_ScriptGetFontProperties(HDC hdc)
1849 HRESULT hr;
1850 SCRIPT_CACHE psc,old_psc;
1851 SCRIPT_FONTPROPERTIES sfp;
1852 HFONT font, oldfont;
1853 LOGFONT lf;
1854 struct enum_font_data efnd;
1855 TEXTMETRICA tmA;
1856 WORD gi[3];
1857 WCHAR str[3];
1858 DWORD i, ret;
1859 WORD system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
1860 static const WCHAR invalids[] = {0x0020, 0x200B, 0xF71B};
1861 /* U+0020: numeric space
1862 U+200B: zero width space
1863 U+F71B: unknown, found by black box testing */
1864 BOOL is_terminal, is_arial, is_times_new_roman, is_arabic = (system_lang_id == LANG_ARABIC);
1866 /* Some sanity checks for ScriptGetFontProperties */
1868 hr = ScriptGetFontProperties(NULL,NULL,NULL);
1869 ok( hr == E_INVALIDARG, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1871 hr = ScriptGetFontProperties(NULL,NULL,&sfp);
1872 ok( hr == E_INVALIDARG, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1874 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1875 psc = NULL;
1876 hr = ScriptGetFontProperties(NULL,&psc,NULL);
1877 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1878 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1880 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1881 psc = NULL;
1882 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1883 ok( hr == E_PENDING, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr);
1884 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1886 hr = ScriptGetFontProperties(hdc,NULL,NULL);
1887 ok( hr == E_INVALIDARG, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr);
1889 hr = ScriptGetFontProperties(hdc,NULL,&sfp);
1890 ok( hr == E_INVALIDARG, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr);
1892 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1893 psc = NULL;
1894 hr = ScriptGetFontProperties(hdc,&psc,NULL);
1895 ok( hr == E_INVALIDARG, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr);
1896 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1898 /* Pass an invalid sfp */
1899 psc = NULL;
1900 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES) - 1;
1901 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1902 ok( hr == E_INVALIDARG, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr);
1903 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1904 ScriptFreeCache(&psc);
1905 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1907 /* Give it the correct cBytes, we don't care about what's coming back */
1908 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
1909 psc = NULL;
1910 hr = ScriptGetFontProperties(hdc,&psc,&sfp);
1911 ok( hr == S_OK, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr);
1912 ok( psc != NULL, "Expected a pointer in psc, got NULL\n");
1914 /* Save the psc pointer */
1915 old_psc = psc;
1916 /* Now a NULL hdc again */
1917 hr = ScriptGetFontProperties(NULL,&psc,&sfp);
1918 ok( hr == S_OK, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr);
1919 ok( psc == old_psc, "Expected psc not to be changed, was %p is now %p\n", old_psc, psc);
1920 ScriptFreeCache(&psc);
1921 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
1923 pGetGlyphIndicesW = (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
1924 if (!pGetGlyphIndicesW)
1926 win_skip("Skip on WINNT4\n");
1927 return;
1929 memset(&lf, 0, sizeof(lf));
1930 lf.lfCharSet = DEFAULT_CHARSET;
1931 efnd.total = 0;
1932 EnumFontFamiliesA(hdc, NULL, enum_bitmap_font_proc, (LPARAM)&efnd);
1934 for (i = 0; i < efnd.total; i++)
1936 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
1937 font = CreateFontIndirect(&lf);
1938 oldfont = SelectObject(hdc, font);
1940 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
1941 psc = NULL;
1942 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
1943 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
1944 if (winetest_interactive)
1946 trace("bitmap font %s\n", lf.lfFaceName);
1947 trace("wgBlank %04x\n", sfp.wgBlank);
1948 trace("wgDefault %04x\n", sfp.wgDefault);
1949 trace("wgInvalid %04x\n", sfp.wgInvalid);
1950 trace("wgKashida %04x\n", sfp.wgKashida);
1951 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
1954 ret = GetTextMetricsA(hdc, &tmA);
1955 ok(ret != 0, "GetTextMetricsA failed!\n");
1957 is_terminal = !(lstrcmpA(lf.lfFaceName, "Terminal") && lstrcmpA(lf.lfFaceName, "@Terminal"));
1958 ok(sfp.wgBlank == tmA.tmBreakChar || broken(is_terminal) || broken(is_arabic), "bitmap font %s wgBlank %04x tmBreakChar %04x\n", lf.lfFaceName, sfp.wgBlank, tmA.tmBreakChar);
1960 ok(sfp.wgDefault == tmA.tmDefaultChar || broken(is_arabic), "bitmap font %s wgDefault %04x, tmDefaultChar %04x\n", lf.lfFaceName, sfp.wgDefault, tmA.tmDefaultChar);
1962 ok(sfp.wgInvalid == sfp.wgBlank || broken(is_arabic), "bitmap font %s wgInvalid %02x wgBlank %02x\n", lf.lfFaceName, sfp.wgInvalid, sfp.wgBlank);
1964 ok(sfp.wgKashida == 0xFFFF || broken(is_arabic), "bitmap font %s wgKashida %02x\n", lf.lfFaceName, sfp.wgKashida);
1966 ScriptFreeCache(&psc);
1968 SelectObject(hdc, oldfont);
1969 DeleteObject(font);
1972 efnd.total = 0;
1973 EnumFontFamiliesA(hdc, NULL, enum_truetype_proc, (LPARAM)&efnd);
1975 for (i = 0; i < efnd.total; i++)
1977 lstrcpyA(lf.lfFaceName, (char *)efnd.elf[i].elfFullName);
1978 font = CreateFontIndirect(&lf);
1979 oldfont = SelectObject(hdc, font);
1981 sfp.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
1982 psc = NULL;
1983 hr = ScriptGetFontProperties(hdc, &psc, &sfp);
1984 ok(hr == S_OK, "ScriptGetFontProperties expected S_OK, got %08x\n", hr);
1985 if (winetest_interactive)
1987 trace("truetype font %s\n", lf.lfFaceName);
1988 trace("wgBlank %04x\n", sfp.wgBlank);
1989 trace("wgDefault %04x\n", sfp.wgDefault);
1990 trace("wgInvalid %04x\n", sfp.wgInvalid);
1991 trace("wgKashida %04x\n", sfp.wgKashida);
1992 trace("iKashidaWidth %d\n", sfp.iKashidaWidth);
1995 str[0] = 0x0020; /* U+0020: numeric space */
1996 ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
1997 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
1998 ok(sfp.wgBlank == gi[0], "truetype font %s wgBlank %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgBlank, gi[0]);
2000 ok(sfp.wgDefault == 0 || broken(is_arabic), "truetype font %s wgDefault %04x\n", lf.lfFaceName, sfp.wgDefault);
2002 ret = pGetGlyphIndicesW(hdc, invalids, 3, gi, GGI_MARK_NONEXISTING_GLYPHS);
2003 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2004 if (gi[2] != 0xFFFF) /* index of default non exist char */
2005 ok(sfp.wgInvalid == gi[2], "truetype font %s wgInvalid %04x gi[2] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[2]);
2006 else if (gi[1] != 0xFFFF)
2007 ok(sfp.wgInvalid == gi[1], "truetype font %s wgInvalid %04x gi[1] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[1]);
2008 else if (gi[0] != 0xFFFF)
2009 ok(sfp.wgInvalid == gi[0], "truetype font %s wgInvalid %04x gi[0] %04x\n", lf.lfFaceName, sfp.wgInvalid, gi[0]);
2010 else
2011 ok(sfp.wgInvalid == 0, "truetype font %s wgInvalid %04x expect 0\n", lf.lfFaceName, sfp.wgInvalid);
2013 str[0] = 0x0640; /* U+0640: kashida */
2014 ret = pGetGlyphIndicesW(hdc, str, 1, gi, GGI_MARK_NONEXISTING_GLYPHS);
2015 ok(ret != GDI_ERROR, "GetGlyphIndicesW failed!\n");
2016 is_arial = !lstrcmpA(lf.lfFaceName, "Arial");
2017 is_times_new_roman= !lstrcmpA(lf.lfFaceName, "Times New Roman");
2018 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]);
2020 ScriptFreeCache(&psc);
2022 SelectObject(hdc, oldfont);
2023 DeleteObject(font);
2027 static void test_ScriptTextOut(HDC hdc)
2029 HRESULT hr;
2031 int cInChars;
2032 int cMaxItems;
2033 SCRIPT_ITEM pItem[255];
2034 int pcItems;
2035 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2037 SCRIPT_CACHE psc;
2038 int cChars;
2039 int cMaxGlyphs;
2040 unsigned short pwOutGlyphs1[256];
2041 WORD pwLogClust[256];
2042 SCRIPT_VISATTR psva[256];
2043 int pcGlyphs;
2044 int piAdvance[256];
2045 GOFFSET pGoffset[256];
2046 ABC pABC[256];
2047 RECT rect;
2048 int piX;
2049 int iCP = 1;
2050 BOOL fTrailing = FALSE;
2051 SCRIPT_LOGATTR *psla;
2052 SCRIPT_LOGATTR sla[256];
2054 /* This is a valid test that will cause parsing to take place */
2055 cInChars = 5;
2056 cMaxItems = 255;
2057 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2058 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
2059 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2060 * returned. */
2061 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2062 if (pcItems > 0)
2063 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2064 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2065 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2067 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2068 * ie. ScriptItemize has succeeded and that pItem has been set */
2069 cInChars = 5;
2070 if (hr == 0) {
2071 psc = NULL; /* must be null on first call */
2072 cChars = cInChars;
2073 cMaxGlyphs = 256;
2074 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2075 cMaxGlyphs, &pItem[0].a,
2076 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2077 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
2078 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2079 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2080 if (hr ==0) {
2081 /* Note hdc is needed as glyph info is not yet in psc */
2082 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2083 pGoffset, pABC);
2084 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
2085 ScriptFreeCache(&psc); /* Get rid of psc for next test set */
2086 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2088 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
2089 ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr);
2091 hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2092 piAdvance, NULL, pGoffset);
2093 ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
2094 "expected E_INVALIDARG, got %08x\n", hr);
2096 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
2097 psc = NULL;
2098 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
2099 NULL, NULL, NULL);
2100 ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
2101 "got %08x\n", hr);
2102 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2104 /* hdc is required for this one rather than the usual optional */
2105 psc = NULL;
2106 hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2107 piAdvance, NULL, pGoffset);
2108 ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
2109 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2111 /* Set that it returns 0 status */
2112 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2113 piAdvance, NULL, pGoffset);
2114 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
2116 /* Test Rect Rgn is acceptable */
2117 rect.top = 10;
2118 rect.bottom = 20;
2119 rect.left = 10;
2120 rect.right = 40;
2121 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2122 piAdvance, NULL, pGoffset);
2123 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
2125 iCP = 1;
2126 hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust,
2127 (const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX);
2128 ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr);
2130 psla = (SCRIPT_LOGATTR *)&sla;
2131 hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla);
2132 ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
2134 /* Clean up and go */
2135 ScriptFreeCache(&psc);
2136 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2141 static void test_ScriptTextOut2(HDC hdc)
2143 /* Intent is to validate that the HDC passed into ScriptTextOut is
2144 * used instead of the (possibly) invalid cached one
2146 HRESULT hr;
2148 HDC hdc1, hdc2;
2149 int cInChars;
2150 int cMaxItems;
2151 SCRIPT_ITEM pItem[255];
2152 int pcItems;
2153 WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 0};
2155 SCRIPT_CACHE psc;
2156 int cChars;
2157 int cMaxGlyphs;
2158 unsigned short pwOutGlyphs1[256];
2159 WORD pwLogClust[256];
2160 SCRIPT_VISATTR psva[256];
2161 int pcGlyphs;
2162 int piAdvance[256];
2163 GOFFSET pGoffset[256];
2164 ABC pABC[256];
2166 /* Create an extra DC that will be used until the ScriptTextOut */
2167 hdc1 = CreateCompatibleDC(hdc);
2168 ok (hdc1 != 0, "CreateCompatibleDC failed to create a DC\n");
2169 hdc2 = CreateCompatibleDC(hdc);
2170 ok (hdc2 != 0, "CreateCompatibleDC failed to create a DC\n");
2172 /* This is a valid test that will cause parsing to take place */
2173 cInChars = 5;
2174 cMaxItems = 255;
2175 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2176 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
2177 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2178 * returned. */
2179 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2180 if (pcItems > 0)
2181 ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars,
2182 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2183 pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
2185 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2186 * ie. ScriptItemize has succeeded and that pItem has been set */
2187 cInChars = 5;
2188 if (hr == 0) {
2189 psc = NULL; /* must be null on first call */
2190 cChars = cInChars;
2191 cMaxGlyphs = 256;
2192 hr = ScriptShape(hdc2, &psc, TestItem1, cChars,
2193 cMaxGlyphs, &pItem[0].a,
2194 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2195 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
2196 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2197 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2198 if (hr ==0) {
2199 /* Note hdc is needed as glyph info is not yet in psc */
2200 hr = ScriptPlace(hdc2, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2201 pGoffset, pABC);
2202 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
2204 /* key part!!! cached dc is being deleted */
2205 hr = DeleteDC(hdc2);
2206 ok(hr == 1, "DeleteDC should return 1 not %08x\n", hr);
2208 /* At this point the cached hdc (hdc2) has been destroyed,
2209 * however, we are passing in a *real* hdc (the original hdc).
2210 * The text should be written to that DC
2212 hr = ScriptTextOut(hdc1, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2213 piAdvance, NULL, pGoffset);
2214 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
2215 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2217 DeleteDC(hdc1);
2219 /* Clean up and go */
2220 ScriptFreeCache(&psc);
2221 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2226 static void test_ScriptTextOut3(HDC hdc)
2228 HRESULT hr;
2230 int cInChars;
2231 int cMaxItems;
2232 SCRIPT_ITEM pItem[255];
2233 int pcItems;
2234 WCHAR TestItem1[] = {' ','\r', 0};
2236 SCRIPT_CACHE psc;
2237 int cChars;
2238 int cMaxGlyphs;
2239 unsigned short pwOutGlyphs1[256];
2240 WORD pwLogClust[256];
2241 SCRIPT_VISATTR psva[256];
2242 int pcGlyphs;
2243 int piAdvance[256];
2244 GOFFSET pGoffset[256];
2245 ABC pABC[256];
2246 RECT rect;
2248 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
2249 cInChars = 2;
2250 cMaxItems = 255;
2251 hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
2252 ok (hr == 0, "ScriptItemize should return 0, returned %08x\n", hr);
2253 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
2254 * returned. */
2255 ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
2256 if (pcItems > 0)
2257 ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars,
2258 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
2259 pItem[0].iCharPos, cInChars, pItem[2].iCharPos);
2261 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
2262 * ie. ScriptItemize has succeeded and that pItem has been set */
2263 cInChars = 2;
2264 if (hr == 0) {
2265 psc = NULL; /* must be null on first call */
2266 cChars = cInChars;
2267 cMaxGlyphs = 256;
2268 hr = ScriptShape(hdc, &psc, TestItem1, cChars,
2269 cMaxGlyphs, &pItem[0].a,
2270 pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
2271 ok (hr == 0, "ScriptShape should return 0 not (%08x)\n", hr);
2272 ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2273 ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
2274 if (hr ==0) {
2275 /* Note hdc is needed as glyph info is not yet in psc */
2276 hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
2277 pGoffset, pABC);
2278 ok (hr == 0, "Should return 0 not (%08x)\n", hr);
2280 /* Test Rect Rgn is acceptable */
2281 rect.top = 10;
2282 rect.bottom = 20;
2283 rect.left = 10;
2284 rect.right = 40;
2285 hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs,
2286 piAdvance, NULL, pGoffset);
2287 ok (hr == 0, "ScriptTextOut should return 0 not (%08x)\n", hr);
2290 /* Clean up and go */
2291 ScriptFreeCache(&psc);
2292 ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
2296 #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)
2298 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS *psa, int cChars, int cGlyphs, const int* offsets, const WORD *pwLogClust, const int* piAdvance )
2300 int iX, iCP;
2301 int icChars, icGlyphs;
2302 int piCP, piX;
2303 HRESULT hr;
2304 SCRIPT_VISATTR psva[10];
2305 int piTrailing;
2306 BOOL fTrailing;
2307 int direction;
2309 memset(psva,0,sizeof(psva));
2310 direction = (psa->fRTL)?-1:+1;
2312 for(iCP = 0; iCP < cChars; iCP++)
2314 iX = offsets[iCP];
2315 icChars = cChars;
2316 icGlyphs = cGlyphs;
2317 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2318 winetest_ok(hr == S_OK, "ScriptXtoCP: should return S_OK not %08x\n", hr);
2319 winetest_ok(piCP == iCP, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2320 winetest_ok(piTrailing == 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2323 for(iCP = 0; iCP < cChars; iCP++)
2325 iX = offsets[iCP]+direction;
2326 icChars = cChars;
2327 icGlyphs = cGlyphs;
2328 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2329 winetest_ok(hr == S_OK, "ScriptXtoCP leading: should return S_OK not %08x\n", hr);
2330 winetest_ok(piCP == iCP, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2331 winetest_ok(piTrailing == 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX, piTrailing);
2334 for(iCP = 0; iCP < cChars; iCP++)
2336 iX = offsets[iCP+1]-direction;
2337 icChars = cChars;
2338 icGlyphs = cGlyphs;
2339 hr = ScriptXtoCP(iX, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piCP, &piTrailing);
2340 winetest_ok(hr == S_OK, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr);
2341 winetest_ok(piCP == iCP, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX, iCP, piCP);
2342 winetest_ok(piTrailing == 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2345 for(iCP = 0; iCP <= cChars+1; iCP++)
2347 fTrailing = FALSE;
2348 icChars = cChars;
2349 icGlyphs = cGlyphs;
2350 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2351 winetest_ok(hr == S_OK, "ScriptCPtoX: should return S_OK not %08x\n", hr);
2352 winetest_ok(piX == offsets[iCP],
2353 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP], piX);
2356 for(iCP = 0; iCP <= cChars+1; iCP++)
2358 fTrailing = TRUE;
2359 icChars = cChars;
2360 icGlyphs = cGlyphs;
2361 hr = ScriptCPtoX(iCP, fTrailing, icChars, icGlyphs, pwLogClust, psva, piAdvance, psa, &piX);
2362 winetest_ok(hr == S_OK, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr);
2363 winetest_ok(piX == offsets[iCP+1],
2364 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP, offsets[iCP+1], piX);
2368 static void test_ScriptXtoX(void)
2369 /****************************************************************************************
2370 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2371 ****************************************************************************************/
2373 WORD pwLogClust[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2374 WORD pwLogClust_RTL[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2375 WORD pwLogClust_2[7] = {4, 3, 3, 2, 1, 0 ,0};
2376 int piAdvance[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2377 int piAdvance_2[5] = {39, 26, 19, 17, 11};
2378 static const int offsets[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2379 static const int offsets_RTL[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2380 static const int offsets_2[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2381 SCRIPT_VISATTR psva[10];
2382 SCRIPT_ANALYSIS sa;
2383 int iX;
2384 int piCP;
2385 int piTrailing;
2386 HRESULT hr;
2388 memset(&sa, 0 , sizeof(SCRIPT_ANALYSIS));
2389 memset(psva, 0, sizeof(psva));
2391 sa.fRTL = FALSE;
2392 hr = ScriptXtoCP(-1, 10, 10, pwLogClust, psva, piAdvance, &sa, &piCP, &piTrailing);
2393 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2394 if (piTrailing)
2395 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2396 else /* win2k3 */
2397 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2399 for (iX = 0; iX <= 7; iX++)
2401 WORD clust = 0;
2402 INT advance = 16;
2403 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2404 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX, piCP,piTrailing);
2406 for (iX = 8; iX < 16; iX++)
2408 WORD clust = 0;
2409 INT advance = 16;
2410 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2411 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX, piCP,piTrailing);
2414 sa.fRTL = TRUE;
2415 hr = ScriptXtoCP(-1, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2416 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2417 if (piTrailing)
2418 ok(piCP == -1, "Negative iX should return piCP=-1 not %d\n", piCP);
2419 else /* win2k3 */
2420 ok(piCP == 10, "Negative iX should return piCP=10 not %d\n", piCP);
2422 iX = 1954;
2423 hr = ScriptXtoCP(1954, 10, 10, pwLogClust_RTL, psva, piAdvance, &sa, &piCP, &piTrailing);
2424 ok(hr == S_OK, "ScriptXtoCP should return S_OK not %08x\n", hr);
2425 ok(piCP == -1, "iX=%d should return piCP=-1 not %d\n", iX, piCP);
2426 ok(piTrailing == 1, "iX=%d should return piTrailing=1 not %d\n", iX, piTrailing);
2428 for (iX = 1; iX <= 8; iX++)
2430 WORD clust = 0;
2431 INT advance = 16;
2432 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2433 ok(piCP==0 && piTrailing==1,"%i should return 0(%i) and 1(%i)\n",iX,piCP,piTrailing);
2435 for (iX = 9; iX < 16; iX++)
2437 WORD clust = 0;
2438 INT advance = 16;
2439 hr = ScriptXtoCP(iX, 1, 1, &clust, psva, &advance, &sa, &piCP, &piTrailing);
2440 ok(piCP==0 && piTrailing==0,"%i should return 0(%i) and 0(%i)\n",iX,piCP,piTrailing);
2443 sa.fRTL = FALSE;
2444 test_item_ScriptXtoX(&sa, 10, 10, offsets, pwLogClust, piAdvance);
2445 sa.fRTL = TRUE;
2446 test_item_ScriptXtoX(&sa, 10, 10, offsets_RTL, pwLogClust_RTL, piAdvance);
2447 test_item_ScriptXtoX(&sa, 7, 5, offsets_2, pwLogClust_2, piAdvance_2);
2450 static void test_ScriptString(HDC hdc)
2452 /*******************************************************************************************
2454 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2455 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2456 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2457 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2461 HRESULT hr;
2462 WCHAR teststr[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2463 int len = (sizeof(teststr) / sizeof(WCHAR)) - 1;
2464 int Glyphs = len * 2 + 16;
2465 int Charset;
2466 DWORD Flags = SSA_GLYPHS;
2467 int ReqWidth = 100;
2468 const int Dx[5] = {10, 10, 10, 10, 10};
2469 const BYTE InClass = 0;
2470 SCRIPT_STRING_ANALYSIS ssa = NULL;
2472 int X = 10;
2473 int Y = 100;
2474 UINT Options = 0;
2475 const RECT rc = {0, 50, 100, 100};
2476 int MinSel = 0;
2477 int MaxSel = 0;
2478 BOOL Disabled = FALSE;
2479 const int *clip_len;
2480 int i;
2481 UINT *order;
2484 Charset = -1; /* this flag indicates unicode input */
2485 /* Test without hdc to get E_PENDING */
2486 hr = ScriptStringAnalyse( NULL, teststr, len, Glyphs, Charset, Flags,
2487 ReqWidth, NULL, NULL, Dx, NULL,
2488 &InClass, &ssa);
2489 ok(hr == E_PENDING, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr);
2491 /* test with hdc, this should be a valid test */
2492 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2493 ReqWidth, NULL, NULL, Dx, NULL,
2494 &InClass, &ssa);
2495 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2496 ScriptStringFree(&ssa);
2498 /* test makes sure that a call with a valid pssa still works */
2499 hr = ScriptStringAnalyse( hdc, teststr, len, Glyphs, Charset, Flags,
2500 ReqWidth, NULL, NULL, Dx, NULL,
2501 &InClass, &ssa);
2502 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2503 ok(ssa != NULL, "ScriptStringAnalyse pssa should not be NULL\n");
2505 if (hr == S_OK)
2507 hr = ScriptStringOut(ssa, X, Y, Options, &rc, MinSel, MaxSel, Disabled);
2508 ok(hr == S_OK, "ScriptStringOut should return S_OK not %08x\n", hr);
2511 clip_len = ScriptString_pcOutChars(ssa);
2512 ok(*clip_len == len, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len, len);
2514 order = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *clip_len * sizeof(UINT));
2515 hr = ScriptStringGetOrder(ssa, order);
2516 ok(hr == S_OK, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr);
2518 for (i = 0; i < *clip_len; i++) ok(order[i] == i, "%d: got %d expected %d\n", i, order[i], i);
2519 HeapFree(GetProcessHeap(), 0, order);
2521 hr = ScriptStringFree(&ssa);
2522 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2525 static void test_ScriptStringXtoCP_CPtoX(HDC hdc)
2527 /*****************************************************************************************
2529 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2530 * nature of the fonts between Windows and Wine, the test is implemented by generating
2531 * values using one one function then checking the output of the second. In this way
2532 * the validity of the functions is established using Windows as a base and confirming
2533 * similar behaviour in wine.
2536 HRESULT hr;
2537 static const WCHAR teststr1[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2538 static const BOOL rtl[] = {1, 0, 1, 0, 1, 0, 1, 0};
2539 void *String = (WCHAR *) &teststr1; /* ScriptStringAnalysis needs void */
2540 int String_len = (sizeof(teststr1)/sizeof(WCHAR))-1;
2541 int Glyphs = String_len * 2 + 16; /* size of buffer as recommended */
2542 int Charset = -1; /* unicode */
2543 DWORD Flags = SSA_GLYPHS;
2544 int ReqWidth = 100;
2545 const BYTE InClass = 0;
2546 SCRIPT_STRING_ANALYSIS ssa = NULL;
2548 int Ch; /* Character position in string */
2549 int iTrailing;
2550 int Cp; /* Character position in string */
2551 int X;
2552 int trail,lead;
2553 BOOL fTrailing;
2555 /* Test with hdc, this should be a valid test
2556 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2557 * following character positions to X and X to character position functions.
2560 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2561 ReqWidth, NULL, NULL, NULL, NULL,
2562 &InClass, &ssa);
2563 ok(hr == S_OK ||
2564 hr == E_INVALIDARG, /* NT */
2565 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr);
2567 if (hr == S_OK)
2569 ok(ssa != NULL, "ScriptStringAnalyse ssa should not be NULL\n");
2572 * Loop to generate character positions to provide starting positions for the
2573 * ScriptStringCPtoX and ScriptStringXtoCP functions
2575 for (Cp = 0; Cp < String_len; Cp++)
2577 /* The fTrailing flag is used to indicate whether the X being returned is at
2578 * the beginning or the end of the character. What happens here is that if
2579 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2580 * returns the beginning of the next character and iTrailing is FALSE. So for this
2581 * loop iTrailing will be FALSE in both cases.
2583 hr = ScriptStringCPtoX(ssa, Cp, TRUE, &trail);
2584 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2585 hr = ScriptStringCPtoX(ssa, Cp, FALSE, &lead);
2586 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2587 if (rtl[Cp])
2588 ok(lead > trail, "Leading values should be after trailing for rtl characters(%i)\n",Cp);
2589 else
2590 ok(lead < trail, "Trailing values should be after leading for ltr characters(%i)\n",Cp);
2592 /* move by 1 pixel so that we are not between 2 characters. That could result in being the lead of a rtl and
2593 at the same time the trail of an ltr */
2595 /* inside the leading edge */
2596 X = lead;
2597 if (rtl[Cp]) X--; else X++;
2598 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2599 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2600 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2601 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2602 iTrailing, X);
2604 /* inside the trailing edge */
2605 X = trail;
2606 if (rtl[Cp]) X++; else X--;
2607 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2608 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2609 ok(Cp == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp, Ch, trail);
2610 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2611 iTrailing, X);
2613 /* outside the "trailing" edge */
2614 if (Cp < String_len-1)
2616 if (rtl[Cp]) X = lead; else X = trail;
2617 X++;
2618 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2619 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2620 ok(Cp + 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp + 1, Ch, trail);
2621 if (rtl[Cp+1])
2622 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2623 iTrailing, X);
2624 else
2625 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2626 iTrailing, X);
2629 /* outside the "leading" edge */
2630 if (Cp != 0)
2632 if (rtl[Cp]) X = trail; else X = lead;
2633 X--;
2634 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2635 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2636 ok(Cp - 1 == Ch, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp - 1, Ch, trail);
2637 if (Cp != 0 && rtl[Cp-1])
2638 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2639 iTrailing, X);
2640 else
2641 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2642 iTrailing, X);
2646 /* Check beyond the leading boundary of the whole string */
2647 if (rtl[0])
2649 /* having a leading rtl character seems to confuse usp */
2650 /* this looks to be a windows bug we should emulate */
2651 hr = ScriptStringCPtoX(ssa, 0, TRUE, &X);
2652 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2653 X--;
2654 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2655 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2656 ok(Ch == 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch);
2657 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
2658 iTrailing);
2660 else
2662 hr = ScriptStringCPtoX(ssa, 0, FALSE, &X);
2663 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2664 X--;
2665 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2666 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2667 ok(Ch == -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch);
2668 ok(iTrailing == TRUE, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2669 iTrailing);
2672 /* Check beyond the end boundary of the whole string */
2673 if (rtl[String_len-1])
2675 hr = ScriptStringCPtoX(ssa, String_len-1, FALSE, &X);
2676 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2678 else
2680 hr = ScriptStringCPtoX(ssa, String_len-1, TRUE, &X);
2681 ok(hr == S_OK, "ScriptStringCPtoX should return S_OK not %08x\n", hr);
2683 X++;
2684 hr = ScriptStringXtoCP(ssa, X, &Ch, &iTrailing);
2685 ok(hr == S_OK, "ScriptStringXtoCP should return S_OK not %08x\n", hr);
2686 ok(Ch == String_len, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len, Ch);
2687 ok(iTrailing == FALSE, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
2688 iTrailing);
2691 * Cleanup the SSA for the next round of tests
2693 hr = ScriptStringFree(&ssa);
2694 ok(hr == S_OK, "ScriptStringFree should return S_OK not %08x\n", hr);
2697 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2698 * generate an SSA for the subsequent tests.
2700 hr = ScriptStringAnalyse( hdc, String, String_len, Glyphs, Charset, Flags,
2701 ReqWidth, NULL, NULL, NULL, NULL,
2702 &InClass, &ssa);
2703 ok(hr == S_OK, "ScriptStringAnalyse should return S_OK not %08x\n", hr);
2706 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2707 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2708 * ScriptStringFree should also fail.
2710 fTrailing = FALSE;
2711 Cp = String_len + 1;
2712 hr = ScriptStringCPtoX(ssa, Cp, fTrailing, &X);
2713 ok(hr == E_INVALIDARG, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr);
2715 ScriptStringFree(&ssa);
2719 static void test_ScriptCacheGetHeight(HDC hdc)
2721 HRESULT hr;
2722 SCRIPT_CACHE sc = NULL;
2723 LONG height;
2725 hr = ScriptCacheGetHeight(NULL, NULL, NULL);
2726 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2728 hr = ScriptCacheGetHeight(NULL, &sc, NULL);
2729 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2731 hr = ScriptCacheGetHeight(NULL, &sc, &height);
2732 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2734 height = 0;
2736 hr = ScriptCacheGetHeight(hdc, &sc, &height);
2737 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2738 ok(height > 0, "expected height > 0\n");
2740 ScriptFreeCache(&sc);
2743 static void test_ScriptGetGlyphABCWidth(HDC hdc)
2745 HRESULT hr;
2746 SCRIPT_CACHE sc = NULL;
2747 ABC abc;
2749 hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
2750 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2752 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
2753 ok(broken(hr == E_PENDING) ||
2754 hr == E_INVALIDARG, /* WIN7 */
2755 "expected E_INVALIDARG, got 0x%08x\n", hr);
2757 hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', &abc);
2758 ok(hr == E_PENDING, "expected E_PENDING, got 0x%08x\n", hr);
2760 if (0) { /* crashes on WinXP */
2761 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
2762 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2765 hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
2766 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2768 ScriptFreeCache(&sc);
2771 static void test_ScriptLayout(void)
2773 HRESULT hr;
2774 static const BYTE levels[][10] =
2776 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2777 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2778 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2779 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2781 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2782 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2783 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2784 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2785 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2787 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2788 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2790 { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 },
2791 { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 },
2792 { 2, 2, 2, 4, 4, 4, 1, 1, 0, 0 },
2793 { 1, 2, 3, 0, 3, 2, 1, 0, 0, 0 }
2795 static const int expect_l2v[][10] =
2797 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2798 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2799 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2800 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2802 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2803 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2804 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2805 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2806 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2808 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2809 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2811 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
2812 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
2813 { 2, 3, 4, 5, 6, 7, 1, 0, 8, 9},
2814 { 2, 0, 1, 3, 5, 6, 4, 7, 8, 9}
2816 static const int expect_v2l[][10] =
2818 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2819 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2820 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2821 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2823 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2824 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2825 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2826 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2827 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2829 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2830 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2832 { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9},
2833 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
2834 { 7, 6, 0, 1, 2, 3, 4, 5, 8, 9},
2835 { 1, 2, 0, 3, 6, 4, 5, 7, 8, 9}
2838 int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];
2840 hr = ScriptLayout(sizeof(levels[0]), NULL, vistolog, logtovis);
2841 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2843 hr = ScriptLayout(sizeof(levels[0]), levels[0], NULL, NULL);
2844 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
2846 for (i = 0; i < sizeof(levels)/sizeof(levels[0]); i++)
2848 hr = ScriptLayout(sizeof(levels[0]), levels[i], vistolog, logtovis);
2849 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
2851 for (j = 0; j < sizeof(levels[i]); j++)
2853 ok(expect_v2l[i][j] == vistolog[j],
2854 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2855 i, j, levels[i][j], j, vistolog[j] );
2858 for (j = 0; j < sizeof(levels[i]); j++)
2860 ok(expect_l2v[i][j] == logtovis[j],
2861 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2862 i, j, levels[i][j], j, logtovis[j] );
2867 static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR lparam)
2869 HRESULT hr;
2870 SCRIPT_DIGITSUBSTITUTE sds;
2871 SCRIPT_CONTROL sc;
2872 SCRIPT_STATE ss;
2873 LCID lcid_old;
2875 if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
2877 memset(&sds, 0, sizeof(sds));
2878 memset(&sc, 0, sizeof(sc));
2879 memset(&ss, 0, sizeof(ss));
2881 lcid_old = GetThreadLocale();
2882 if (!SetThreadLocale(lcid)) return TRUE;
2884 hr = ScriptRecordDigitSubstitution(lcid, &sds);
2885 ok(hr == S_OK, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr);
2887 hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);
2888 ok(hr == S_OK, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr);
2890 SetThreadLocale(lcid_old);
2891 return TRUE;
2894 static void test_digit_substitution(void)
2896 BOOL ret;
2897 unsigned int i;
2898 static const LGRPID groups[] =
2900 LGRPID_WESTERN_EUROPE,
2901 LGRPID_CENTRAL_EUROPE,
2902 LGRPID_BALTIC,
2903 LGRPID_GREEK,
2904 LGRPID_CYRILLIC,
2905 LGRPID_TURKISH,
2906 LGRPID_JAPANESE,
2907 LGRPID_KOREAN,
2908 LGRPID_TRADITIONAL_CHINESE,
2909 LGRPID_SIMPLIFIED_CHINESE,
2910 LGRPID_THAI,
2911 LGRPID_HEBREW,
2912 LGRPID_ARABIC,
2913 LGRPID_VIETNAMESE,
2914 LGRPID_INDIC,
2915 LGRPID_GEORGIAN,
2916 LGRPID_ARMENIAN
2918 HMODULE hKernel32;
2919 static BOOL (WINAPI * pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROCA,LGRPID,DWORD,LONG_PTR);
2921 hKernel32 = GetModuleHandleA("kernel32.dll");
2922 pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
2924 if (!pEnumLanguageGroupLocalesA)
2926 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
2927 return;
2930 for (i = 0; i < sizeof(groups)/sizeof(groups[0]); i++)
2932 ret = pEnumLanguageGroupLocalesA(enum_proc, groups[i], 0, 0);
2933 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
2935 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
2936 break;
2939 ok(ret, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
2943 static void test_ScriptGetProperties(void)
2945 const SCRIPT_PROPERTIES **props;
2946 HRESULT hr;
2947 int num;
2949 hr = ScriptGetProperties(NULL, NULL);
2950 ok(hr == E_INVALIDARG, "ScriptGetProperties succeeded\n");
2952 hr = ScriptGetProperties(NULL, &num);
2953 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2955 hr = ScriptGetProperties(&props, NULL);
2956 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2958 hr = ScriptGetProperties(&props, &num);
2959 ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr);
2962 static void test_ScriptBreak(void)
2964 static const WCHAR test[] = {' ','\r','\n',0};
2965 SCRIPT_ITEM items[4];
2966 SCRIPT_LOGATTR la;
2967 HRESULT hr;
2969 hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL);
2970 ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr);
2973 * This Test crashes pre Vista.
2975 hr = ScriptBreak(test, 1, &items[0].a, NULL);
2976 ok(hr == E_INVALIDARG, "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
2979 hr = ScriptBreak(test, 0, &items[0].a, &la);
2980 ok(hr == E_FAIL || broken(hr == S_OK), "ScriptBreak should return E_FAIL not %08x\n", hr);
2982 hr = ScriptBreak(test, -1, &items[0].a, &la);
2983 ok(hr == E_INVALIDARG || broken(hr == S_OK), "ScriptBreak should return E_INVALIDARG not %08x\n", hr);
2985 memset(&la, 0, sizeof(la));
2986 hr = ScriptBreak(test, 1, &items[0].a, &la);
2987 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
2989 ok(!la.fSoftBreak, "fSoftBreak set\n");
2990 ok(la.fWhiteSpace, "fWhiteSpace not set\n");
2991 ok(la.fCharStop, "fCharStop not set\n");
2992 ok(!la.fWordStop, "fWordStop set\n");
2993 ok(!la.fInvalid, "fInvalid set\n");
2994 ok(!la.fReserved, "fReserved set\n");
2996 memset(&la, 0, sizeof(la));
2997 hr = ScriptBreak(test + 1, 1, &items[1].a, &la);
2998 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
3000 ok(!la.fSoftBreak, "fSoftBreak set\n");
3001 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3002 ok(la.fCharStop, "fCharStop not set\n");
3003 ok(!la.fWordStop, "fWordStop set\n");
3004 ok(!la.fInvalid, "fInvalid set\n");
3005 ok(!la.fReserved, "fReserved set\n");
3007 memset(&la, 0, sizeof(la));
3008 hr = ScriptBreak(test + 2, 1, &items[2].a, &la);
3009 ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr);
3011 ok(!la.fSoftBreak, "fSoftBreak set\n");
3012 ok(!la.fWhiteSpace, "fWhiteSpace set\n");
3013 ok(la.fCharStop, "fCharStop not set\n");
3014 ok(!la.fWordStop, "fWordStop set\n");
3015 ok(!la.fInvalid, "fInvalid set\n");
3016 ok(!la.fReserved, "fReserved set\n");
3019 static void test_newlines(void)
3021 static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
3022 static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
3023 static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
3024 static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
3025 static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
3026 SCRIPT_ITEM items[5];
3027 HRESULT hr;
3028 int count;
3030 count = 0;
3031 hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
3032 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3033 ok(count == 3, "got %d expected 3\n", count);
3035 count = 0;
3036 hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
3037 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3038 ok(count == 3, "got %d expected 3\n", count);
3040 count = 0;
3041 hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
3042 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3043 ok(count == 4, "got %d expected 4\n", count);
3045 count = 0;
3046 hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
3047 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3048 ok(count == 4, "got %d expected 4\n", count);
3050 count = 0;
3051 hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
3052 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3053 ok(count == 4, "got %d expected 4\n", count);
3056 static void test_ScriptGetFontFunctions(HDC hdc)
3058 HRESULT hr;
3059 pScriptGetFontScriptTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontScriptTags");
3060 pScriptGetFontLanguageTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontLanguageTags");
3061 pScriptGetFontFeatureTags = (void*)GetProcAddress(GetModuleHandleA("usp10.dll"), "ScriptGetFontFeatureTags");
3062 if (!pScriptGetFontScriptTags || !pScriptGetFontLanguageTags || !pScriptGetFontFeatureTags)
3064 win_skip("ScriptGetFontScriptTags,ScriptGetFontLanguageTags or ScriptGetFontFeatureTags not available on this platform\n");
3066 else
3068 SCRIPT_CACHE sc = NULL;
3069 OPENTYPE_TAG tags[5];
3070 int count = 0;
3071 int outnItems=0;
3072 SCRIPT_ITEM outpItems[15];
3073 SCRIPT_CONTROL Control;
3074 SCRIPT_STATE State;
3075 static const WCHAR test_phagspa[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
3077 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, NULL);
3078 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3079 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3080 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, NULL, &count);
3081 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3082 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3083 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, NULL);
3084 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3085 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3086 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 0, tags, &count);
3087 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3088 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3089 hr = pScriptGetFontScriptTags(NULL, &sc, NULL, 5, tags, &count);
3090 ok(hr == E_PENDING,"Incorrect return code\n");
3091 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3092 hr = pScriptGetFontScriptTags(hdc, &sc, NULL, 5, tags, &count);
3093 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3094 if (hr == S_OK)
3095 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3096 else if (hr == E_OUTOFMEMORY)
3097 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3098 ok(sc != NULL, "ScriptCache should be initialized\n");
3100 ScriptFreeCache(&sc);
3101 sc = NULL;
3103 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, NULL);
3104 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3105 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3106 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, NULL, &count);
3107 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3108 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3109 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, NULL);
3110 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3111 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3112 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 0, tags, &count);
3113 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3114 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3115 hr = pScriptGetFontLanguageTags(NULL, &sc, NULL, latn_tag, 5, tags, &count);
3116 ok(hr == E_PENDING,"Incorrect return code\n");
3117 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3118 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, latn_tag, 5, tags, &count);
3119 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3120 if (hr == S_OK)
3121 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3122 else if (hr == E_OUTOFMEMORY)
3123 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3125 ScriptFreeCache(&sc);
3126 sc = NULL;
3128 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, NULL);
3129 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3130 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3131 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, NULL, &count);
3132 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3133 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3134 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, NULL);
3135 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3136 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3137 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 0, tags, &count);
3138 ok(hr == E_INVALIDARG,"Incorrect return code\n");
3139 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3140 hr = pScriptGetFontFeatureTags(NULL, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3141 ok(hr == E_PENDING,"Incorrect return code\n");
3142 ok(sc == NULL, "ScriptCache should remain uninitialized\n");
3143 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, latn_tag, 0x0, 5, tags, &count);
3144 ok((hr == S_OK || hr == E_OUTOFMEMORY),"Incorrect return code\n");
3145 if (hr == S_OK)
3146 ok(count <= 5, "Count should be less or equal to 5 with S_OK return\n");
3147 else if (hr == E_OUTOFMEMORY)
3148 ok(count == 0, "Count should be 0 with E_OUTOFMEMORY return\n");
3150 memset(&Control, 0, sizeof(Control));
3151 memset(&State, 0, sizeof(State));
3153 hr = ScriptItemize(test_phagspa, 10, 15, &Control, &State, outpItems, &outnItems);
3154 ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
3155 memset(tags,0,sizeof(tags));
3156 hr = pScriptGetFontScriptTags(hdc, &sc, &outpItems[0].a, 5, tags, &count);
3157 ok( hr == USP_E_SCRIPT_NOT_IN_FONT || broken(hr == S_OK), "wrong return code\n");
3159 hr = pScriptGetFontLanguageTags(hdc, &sc, NULL, dsrt_tag, 5, tags, &count);
3160 ok( hr == S_OK, "wrong return code\n");
3161 hr = pScriptGetFontLanguageTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 5, tags, &count);
3162 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3164 hr = pScriptGetFontFeatureTags(hdc, &sc, NULL, dsrt_tag, 0x0, 5, tags, &count);
3165 ok( hr == S_OK, "wrong return code\n");
3166 hr = pScriptGetFontFeatureTags(hdc, &sc, &outpItems[0].a, dsrt_tag, 0x0, 5, tags, &count);
3167 ok( hr == E_INVALIDARG || broken(hr == S_OK), "wrong return code\n");
3169 ScriptFreeCache(&sc);
3173 START_TEST(usp10)
3175 HWND hwnd;
3176 HDC hdc;
3177 LOGFONTA lf;
3178 HFONT hfont;
3180 unsigned short pwOutGlyphs[256];
3182 /* We need a valid HDC to drive a lot of Script functions which requires the following *
3183 * to set up for the tests. */
3184 hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
3185 0, 0, 0, NULL);
3186 assert(hwnd != 0);
3187 ShowWindow(hwnd, SW_SHOW);
3188 UpdateWindow(hwnd);
3190 hdc = GetDC(hwnd); /* We now have a hdc */
3191 ok( hdc != NULL, "HDC failed to be created %p\n", hdc);
3193 memset(&lf, 0, sizeof(LOGFONTA));
3194 lstrcpyA(lf.lfFaceName, "Tahoma");
3195 lf.lfHeight = 10;
3196 lf.lfWeight = 3;
3197 lf.lfWidth = 10;
3199 hfont = SelectObject(hdc, CreateFontIndirectA(&lf));
3200 ok(hfont != NULL, "SelectObject failed: %p\n", hfont);
3202 test_ScriptItemize();
3203 test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
3204 test_ScriptGetCMap(hdc, pwOutGlyphs);
3205 test_ScriptCacheGetHeight(hdc);
3206 test_ScriptGetGlyphABCWidth(hdc);
3207 test_ScriptShape(hdc);
3208 test_ScriptShapeOpenType(hdc);
3209 test_ScriptPlace(hdc);
3211 test_ScriptGetFontProperties(hdc);
3212 test_ScriptTextOut(hdc);
3213 test_ScriptTextOut2(hdc);
3214 test_ScriptTextOut3(hdc);
3215 test_ScriptXtoX();
3216 test_ScriptString(hdc);
3217 test_ScriptStringXtoCP_CPtoX(hdc);
3219 test_ScriptLayout();
3220 test_digit_substitution();
3221 test_ScriptGetProperties();
3222 test_ScriptBreak();
3223 test_newlines();
3225 test_ScriptGetFontFunctions(hdc);
3227 ReleaseDC(hwnd, hdc);
3228 DestroyWindow(hwnd);