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
23 * Uniscribe allows for processing of complex scripts such as joining
24 * and filtering characters and bi-directional text with custom line breaks.
30 #include <wine/test.h>
34 typedef struct _itemTest
{
43 typedef struct _shapeTest_char
{
45 SCRIPT_CHARPROP CharProp
;
48 typedef struct _shapeTest_glyph
{
50 SCRIPT_GLYPHPROP GlyphProp
;
53 /* Uniscribe 1.6 calls */
54 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
);
56 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
);
58 static DWORD (WINAPI
*pGetGlyphIndicesW
)(HDC hdc
, LPCWSTR lpstr
, INT count
, LPWORD pgi
, DWORD flags
);
60 static inline void _test_items_ok(LPCWSTR string
, DWORD cchString
,
61 SCRIPT_CONTROL
*Control
, SCRIPT_STATE
*State
,
62 DWORD nItems
, const itemTest
* items
, BOOL nItemsToDo
,
67 SCRIPT_ITEM outpItems
[15];
68 ULONG tags
[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
70 if (pScriptItemizeOpenType
)
71 hr
= pScriptItemizeOpenType(string
, cchString
, 15, Control
, State
, outpItems
, tags
, &outnItems
);
73 hr
= ScriptItemize(string
, cchString
, 15, Control
, State
, outpItems
, &outnItems
);
75 winetest_ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
76 if (nItemsBroken
&& broken(nItemsBroken
== outnItems
))
78 winetest_win_skip("This test broken on this platform\n");
82 todo_wine
winetest_ok(outnItems
== nItems
, "Wrong number of items\n");
84 winetest_ok(outnItems
== nItems
, "Wrong number of items\n");
85 for (x
= 0; x
<= outnItems
; x
++)
87 if (items
[x
].todo_flag
[0])
88 todo_wine
winetest_ok(outpItems
[x
].iCharPos
== items
[x
].iCharPos
, "%i:Wrong CharPos\n",x
);
90 winetest_ok(outpItems
[x
].iCharPos
== items
[x
].iCharPos
, "%i:Wrong CharPos (%i)\n",x
,outpItems
[x
].iCharPos
);
92 if (items
[x
].todo_flag
[1])
93 todo_wine
winetest_ok(outpItems
[x
].a
.fRTL
== items
[x
].fRTL
, "%i:Wrong fRTL\n",x
);
95 winetest_ok(outpItems
[x
].a
.fRTL
== items
[x
].fRTL
, "%i:Wrong fRTL(%i)\n",x
,outpItems
[x
].a
.fRTL
);
96 if (items
[x
].todo_flag
[2])
97 todo_wine
winetest_ok(outpItems
[x
].a
.fLayoutRTL
== items
[x
].fLayoutRTL
, "%i:Wrong fLayoutRTL\n",x
);
99 winetest_ok(outpItems
[x
].a
.fLayoutRTL
== items
[x
].fLayoutRTL
, "%i:Wrong fLayoutRTL(%i)\n",x
,outpItems
[x
].a
.fLayoutRTL
);
100 if (items
[x
].todo_flag
[3])
101 todo_wine
winetest_ok(outpItems
[x
].a
.s
.uBidiLevel
== items
[x
].uBidiLevel
, "%i:Wrong BidiLevel\n",x
);
103 winetest_ok(outpItems
[x
].a
.s
.uBidiLevel
== items
[x
].uBidiLevel
, "%i:Wrong BidiLevel(%i)\n",x
,outpItems
[x
].a
.s
.uBidiLevel
);
105 winetest_ok(outpItems
[x
].a
.eScript
!= SCRIPT_UNDEFINED
, "%i: Undefined script\n",x
);
106 if (pScriptItemizeOpenType
)
108 if (items
[x
].todo_flag
[4])
109 todo_wine
winetest_ok(tags
[x
] == items
[x
].scriptTag
,"%i:Incorrect Script Tag %x != %x\n",x
,tags
[x
],items
[x
].scriptTag
);
111 winetest_ok(tags
[x
] == items
[x
].scriptTag
,"%i:Incorrect Script Tag %x != %x\n",x
,tags
[x
],items
[x
].scriptTag
);
116 #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)
118 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
119 ( ( (ULONG)_x4 << 24 ) | \
120 ( (ULONG)_x3 << 16 ) | \
121 ( (ULONG)_x2 << 8 ) | \
124 #define latn_tag MS_MAKE_TAG('l','a','t','n')
125 #define arab_tag MS_MAKE_TAG('a','r','a','b')
126 #define thai_tag MS_MAKE_TAG('t','h','a','i')
127 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
128 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
129 #define deva_tag MS_MAKE_TAG('d','e','v','a')
130 #define beng_tag MS_MAKE_TAG('b','e','n','g')
131 #define guru_tag MS_MAKE_TAG('g','u','r','u')
132 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
134 static void test_ScriptItemize( void )
136 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
137 static const itemTest t11
[2] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},4,0,0,0,-1}};
138 static const itemTest t12
[2] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},4,0,0,0,-1}};
140 static const WCHAR test1b
[] = {' ', ' ', ' ', ' ',0};
141 static const itemTest t1b1
[2] = {{{0,0,0,0,0},0,0,0,0,0},{{0,0,0,0,0},4,0,0,0,-1}};
142 static const itemTest t1b2
[2] = {{{0,0,0,0,0},0,1,1,1,0},{{0,0,0,0,0},4,0,0,0,-1}};
145 static const WCHAR test2
[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
146 static const itemTest t21
[7] = {{{0,0,0,0,0},0,0,0,0,0},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,0},{{0,0,0,0,0},6,1,1,1,arab_tag
},{{0,0,0,0,0},13,0,0,0,0},{{0,0,0,0,0},15,0,0,0,0},{{0,0,0,0,0},16,0,0,0,-1}};
147 static const itemTest t22
[5] = {{{0,0,0,1,0},0,0,0,2,0},{{0,0,0,0,0},6,1,1,1,arab_tag
},{{0,0,1,0,0},13,0,1,2,0},{{0,0,0,0,0},15,0,0,0,0},{{0,0,0,0,0},16,0,0,0,-1}};
148 static const itemTest t23
[5] = {{{0,0,1,0,0},0,0,1,2,0},{{0,0,0,0,0},6,1,1,1,arab_tag
},{{0,0,1,0,0},13,0,1,2,0},{{0,0,0,0,0},15,1,1,1,0},{{0,0,0,0,0},16,0,0,0,-1}};
150 static const WCHAR test2b
[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
151 static const itemTest t2b1
[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,latn_tag
},{{0,0,0,0,0},8,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
152 static const itemTest t2b2
[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},3,0,0,2,0},{{0,0,0,0,0},4,0,0,2,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
153 static const itemTest t2b3
[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
156 static const WCHAR test2c
[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
157 static const itemTest t2c1
[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag
},{{0,0,0,0,0},4,0,0,0,latn_tag
},{{0,0,0,0,0},7,0,0,0,0},{{0,0,0,0,0},8,0,0,0,latn_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
158 static const itemTest t2c2
[6] = {{{0,0,0,0,1},0,0,0,0,0},{{0,0,0,0,0},1,1,1,1,arab_tag
},{{0,0,0,0,0},4,0,0,0,latn_tag
},{{0,0,0,0,0},7,0,0,0,0},{{0,0,0,0,0},8,0,0,0,latn_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
159 static const itemTest t2c3
[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag
},{{0,0,0,0,0},4,0,0,2,latn_tag
},{{0,0,0,0,0},7,0,0,2,0},{{0,0,0,0,0},8,0,0,2,latn_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
160 static const itemTest t2c4
[3] = {{{0,0,0,0,0},0,1,1,1,arab_tag
},{{0,0,0,0,0},4,0,0,2,latn_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
163 static const WCHAR test2d
[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
164 static const itemTest t2d1
[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
165 static const itemTest t2d2
[6] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},10,0,0,0,0},{{0,0,0,0,0},11,0,0,0,-1}};
166 static const itemTest t2d3
[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},3,0,0,2,0},{{0,0,0,0,0},4,0,0,2,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
167 static const itemTest t2d4
[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},7,1,1,1,arab_tag
},{{0,0,0,0,0},11,0,0,0,-1}};
170 static const WCHAR test3
[] =
171 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
172 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
173 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
174 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
176 static const itemTest t31
[2] = {{{0,0,0,0,0},0,0,0,0,thai_tag
},{{0,0,0,0,0},41,0,0,0,-1}};
177 static const itemTest t32
[2] = {{{0,0,0,0,0},0,0,0,2,thai_tag
},{{0,0,0,0,0},41,0,0,0,-1}};
179 static const WCHAR test4
[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
181 static const itemTest t41
[6] = {{{0,0,0,0,0},0,0,0,0,0},{{0,0,0,0,0},3,0,0,0,0},{{0,0,0,0,0},4,0,0,0,0},{{0,0,0,0,0},7,0,0,0,latn_tag
},{{0,0,0,0,0},10,0,0,0,0},{{0,0,0,0,0},12,0,0,0,-1}};
182 static const itemTest t42
[5] = {{{0,0,1,0,0},0,0,1,2,0},{{0,0,0,0,1},6,1,1,1,0},{{0,0,0,0,0},7,0,0,2,latn_tag
},{{0,0,0,0,0},10,0,0,2,0},{{0,0,0,0,0},12,0,0,0,-1}};
183 static const itemTest t43
[4] = {{{0,0,1,0,0},0,0,1,2,0},{{0,0,0,0,1},6,1,1,1,0},{{0,0,0,0,0},7,0,0,2,latn_tag
},{{0,0,0,0,0},12,0,0,0,-1}};
186 static const WCHAR test5
[] =
187 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
188 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
189 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
190 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
191 static const itemTest t51
[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag
},{{0,0,0,0,0},38,0,0,0,-1}};
194 static const WCHAR test6
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
195 static const itemTest t61
[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
},{{0,0,0,0,0},4,0,0,0,0},{{0,0,0,0,0},5,0,0,0,-1}};
196 static const itemTest t62
[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
},{{0,0,0,0,0},4,1,1,1,0},{{0,0,0,0,0},5,0,0,0,-1}};
197 static const itemTest t63
[2] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
},{{0,0,0,0,0},5,0,0,0,-1}};
198 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};
199 static const itemTest t71
[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},9,1,1,1,hebr_tag
},{{0,0,0,0,0},19,0,0,0,latn_tag
},{{0,0,0,0,0},29,0,0,0,-1}};
200 static const itemTest t72
[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag
},{{0,0,0,0,0},9,1,1,1,hebr_tag
},{{0,0,0,0,0},18,0,0,0,latn_tag
},{{0,0,0,0,0},29,0,0,0,-1}};
201 static const itemTest t73
[4] = {{{0,0,0,0,0},0,0,0,2,latn_tag
},{{0,0,0,0,0},8,1,1,1,hebr_tag
},{{0,0,0,0,0},19,0,0,2,latn_tag
},{{0,0,0,0,0},29,0,0,0,-1}};
202 static const WCHAR test8
[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
203 static const itemTest t81
[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag
},{{0,0,0,0,0},4,0,0,0,-1}};
205 /* Syriac (Like Arabic )*/
206 static const WCHAR test9
[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
207 static const itemTest t91
[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
},{{0,0,0,0,0},4,0,0,0,0},{{0,0,0,0,0},5,0,0,0,-1}};
208 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},{{0,0,0,0,0},5,0,0,0,-1}};
209 static const itemTest t93
[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
},{{0,0,0,0,0},5,0,0,0,-1}};
211 static const WCHAR test10
[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
212 static const itemTest t101
[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
},{{0,0,0,0,0},4,0,0,0,-1}};
215 static const WCHAR test11
[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
216 static const itemTest t111
[2] = {{{0,0,0,0,0},0,0,0,0,deva_tag
},{{0,0,0,0,0},8,0,0,0,-1}};
217 static const itemTest t112
[2] = {{{0,0,0,0,0},0,0,0,2,deva_tag
},{{0,0,0,0,0},8,0,0,0,-1}};
220 static const WCHAR test12
[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
221 static const itemTest t121
[2] = {{{0,0,0,0,0},0,0,0,0,beng_tag
},{{0,0,0,0,0},5,0,0,0,-1}};
222 static const itemTest t122
[2] = {{{0,0,0,0,0},0,0,0,2,beng_tag
},{{0,0,0,0,0},5,0,0,0,-1}};
225 static const WCHAR test13
[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
226 static const itemTest t131
[2] = {{{0,0,0,0,0},0,0,0,0,guru_tag
},{{0,0,0,0,0},7,0,0,0,-1}};
227 static const itemTest t132
[2] = {{{0,0,0,0,0},0,0,0,2,guru_tag
},{{0,0,0,0,0},7,0,0,0,-1}};
230 static const WCHAR test14
[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
231 static const itemTest t141
[2] = {{{0,0,0,0,0},0,0,0,0,gujr_tag
},{{0,0,0,0,0},7,0,0,0,-1}};
232 static const itemTest t142
[2] = {{{0,0,0,0,0},0,0,0,2,gujr_tag
},{{0,0,0,0,0},7,0,0,0,-1}};
236 SCRIPT_ITEM items
[15];
237 SCRIPT_CONTROL Control
;
243 usp10
= LoadLibraryA("usp10.dll");
244 ok (usp10
!= 0,"Unable to LoadLibrary on usp10.dll\n");
245 pScriptItemizeOpenType
= (void*)GetProcAddress(usp10
, "ScriptItemizeOpenType");
246 pScriptShapeOpenType
= (void*)GetProcAddress(usp10
, "ScriptShapeOpenType");
247 pGetGlyphIndicesW
= (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
249 memset(&Control
, 0, sizeof(Control
));
250 memset(&State
, 0, sizeof(State
));
252 hr
= ScriptItemize(NULL
, 4, 10, &Control
, &State
, items
, NULL
);
253 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
255 hr
= ScriptItemize(test1
, 4, 10, &Control
, &State
, NULL
, NULL
);
256 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
258 hr
= ScriptItemize(test1
, 4, 1, &Control
, &State
, items
, NULL
);
259 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
261 hr
= ScriptItemize(test1
, 0, 10, NULL
, NULL
, items
, &nItems
);
262 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
264 test_items_ok(test1
,4,NULL
,NULL
,1,t11
,FALSE
,0);
265 test_items_ok(test1b
,4,NULL
,NULL
,1,t1b1
,FALSE
,0);
266 test_items_ok(test2
,16,NULL
,NULL
,6,t21
,FALSE
,0);
267 test_items_ok(test2b
,11,NULL
,NULL
,4,t2b1
,FALSE
,0);
268 test_items_ok(test2c
,11,NULL
,NULL
,4,t2c1
,FALSE
,0);
269 test_items_ok(test2d
,11,NULL
,NULL
,4,t2d1
,FALSE
,0);
270 test_items_ok(test3
,41,NULL
,NULL
,1,t31
,FALSE
,0);
271 test_items_ok(test4
,12,NULL
,NULL
,5,t41
,FALSE
,0);
272 test_items_ok(test5
,38,NULL
,NULL
,1,t51
,FALSE
,0);
273 test_items_ok(test6
,5,NULL
,NULL
,2,t61
,FALSE
,0);
274 test_items_ok(test7
,29,NULL
,NULL
,3,t71
,FALSE
,0);
275 test_items_ok(test8
,4,NULL
,NULL
,1,t81
,FALSE
,0);
276 test_items_ok(test9
,5,NULL
,NULL
,2,t91
,FALSE
,0);
277 test_items_ok(test10
,4,NULL
,NULL
,1,t101
,FALSE
,0);
278 test_items_ok(test11
,8,NULL
,NULL
,1,t111
,FALSE
,0);
279 test_items_ok(test12
,5,NULL
,NULL
,1,t121
,FALSE
,0);
280 test_items_ok(test13
,7,NULL
,NULL
,1,t131
,FALSE
,0);
281 test_items_ok(test14
,7,NULL
,NULL
,1,t141
,FALSE
,0);
283 State
.uBidiLevel
= 0;
284 test_items_ok(test1
,4,&Control
,&State
,1,t11
,FALSE
,0);
285 test_items_ok(test1b
,4,&Control
,&State
,1,t1b1
,FALSE
,0);
286 test_items_ok(test2
,16,&Control
,&State
,4,t22
,FALSE
,0);
287 test_items_ok(test2b
,11,&Control
,&State
,4,t2b1
,FALSE
,0);
288 test_items_ok(test2c
,11,&Control
,&State
,5,t2c2
,FALSE
,0);
289 test_items_ok(test2d
,11,&Control
,&State
,5,t2d2
,FALSE
,0);
290 test_items_ok(test3
,41,&Control
,&State
,1,t31
,FALSE
,0);
291 test_items_ok(test4
,12,&Control
,&State
,5,t41
,FALSE
,0);
292 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
293 test_items_ok(test6
,5,&Control
,&State
,2,t61
,FALSE
,0);
294 test_items_ok(test7
,29,&Control
,&State
,3,t72
,FALSE
,0);
295 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
296 test_items_ok(test9
,5,&Control
,&State
,2,t91
,FALSE
,0);
297 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
298 test_items_ok(test11
,8,&Control
,&State
,1,t111
,FALSE
,0);
299 test_items_ok(test12
,5,&Control
,&State
,1,t121
,FALSE
,0);
300 test_items_ok(test13
,7,&Control
,&State
,1,t131
,FALSE
,0);
301 test_items_ok(test14
,7,&Control
,&State
,1,t141
,FALSE
,0);
303 State
.uBidiLevel
= 1;
304 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
305 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
306 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
307 test_items_ok(test2b
,11,&Control
,&State
,4,t2b2
,FALSE
,0);
308 test_items_ok(test2c
,11,&Control
,&State
,4,t2c3
,FALSE
,0);
309 test_items_ok(test2d
,11,&Control
,&State
,4,t2d3
,FALSE
,0);
310 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
311 test_items_ok(test4
,12,&Control
,&State
,4,t42
,FALSE
,0);
312 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
313 test_items_ok(test6
,5,&Control
,&State
,2,t62
,FALSE
,0);
314 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
315 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
316 test_items_ok(test9
,5,&Control
,&State
,2,t92
,FALSE
,0);
317 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
318 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
319 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
320 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
321 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
323 State
.uBidiLevel
= 1;
324 Control
.fMergeNeutralItems
= TRUE
;
325 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
326 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
327 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
328 test_items_ok(test2b
,11,&Control
,&State
,2,t2b3
,FALSE
,4);
329 test_items_ok(test2c
,11,&Control
,&State
,2,t2c4
,FALSE
,4);
330 test_items_ok(test2d
,11,&Control
,&State
,2,t2d4
,FALSE
,4);
331 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
332 test_items_ok(test4
,12,&Control
,&State
,3,t43
,FALSE
,4);
333 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
334 test_items_ok(test6
,5,&Control
,&State
,1,t63
,FALSE
,2);
335 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
336 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
337 test_items_ok(test9
,5,&Control
,&State
,1,t93
,FALSE
,2);
338 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
339 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
340 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
341 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
342 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
345 static inline void _test_shape_ok(int valid
, HDC hdc
, LPCWSTR string
,
346 DWORD cchString
, SCRIPT_CONTROL
*Control
,
347 SCRIPT_STATE
*State
, DWORD item
, DWORD nGlyphs
,
348 const shapeTest_char
* charItems
,
349 const shapeTest_glyph
* glyphItems
)
352 int x
, outnItems
=0, outnGlyphs
=0;
353 SCRIPT_ITEM outpItems
[15];
354 SCRIPT_CACHE sc
= NULL
;
357 int maxGlyphs
= cchString
* 1.5;
358 SCRIPT_GLYPHPROP
*glyphProp
;
359 SCRIPT_CHARPROP
*charProp
;
362 hr
= pScriptItemizeOpenType(string
, cchString
, 15, Control
, State
, outpItems
, tags
, &outnItems
);
363 if (hr
== USP_E_SCRIPT_NOT_IN_FONT
)
366 winetest_win_skip("Select font does not support script\n");
368 winetest_trace("Select font does not support script\n");
372 winetest_ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
374 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
377 if (outnItems
<= item
)
380 winetest_win_skip("Did not get enough items\n");
382 winetest_trace("Did not get enough items\n");
386 logclust
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * cchString
);
387 memset(logclust
,'a',sizeof(WORD
) * cchString
);
388 charProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP
) * cchString
);
389 memset(charProp
,'a',sizeof(SCRIPT_CHARPROP
) * cchString
);
390 glyphs
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * maxGlyphs
);
391 memset(glyphs
,'a',sizeof(WORD
) * cchString
);
392 glyphProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP
) * maxGlyphs
);
393 memset(glyphProp
,'a',sizeof(SCRIPT_GLYPHPROP
) * cchString
);
395 hr
= pScriptShapeOpenType(hdc
, &sc
, &outpItems
[item
].a
, tags
[item
], 0x00000000, NULL
, NULL
, 0, string
, cchString
, maxGlyphs
, logclust
, charProp
, glyphs
, glyphProp
, &outnGlyphs
);
397 winetest_ok(hr
== S_OK
, "ScriptShapeOpenType failed (%x)\n",hr
);
399 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr
);
403 for (x
= 0; x
< cchString
; x
++)
406 winetest_ok(logclust
[x
] == charItems
[x
].wLogClust
, "%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
407 else if (logclust
[x
] != charItems
[x
].wLogClust
)
408 winetest_trace("%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
410 winetest_ok(charProp
[x
].fCanGlyphAlone
== charItems
[x
].CharProp
.fCanGlyphAlone
, "%i: invalid fCanGlyphAlone\n",x
);
411 else if (charProp
[x
].fCanGlyphAlone
!= charItems
[x
].CharProp
.fCanGlyphAlone
)
412 winetest_trace("%i: invalid fCanGlyphAlone\n",x
);
416 winetest_ok(nGlyphs
== outnGlyphs
, "got incorrect number of glyphs (%i)\n",outnGlyphs
);
417 else if (nGlyphs
!= outnGlyphs
)
418 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs
);
419 for (x
= 0; x
< outnGlyphs
; x
++)
421 if (glyphItems
[x
].Glyph
)
424 winetest_ok(glyphs
[x
]!=0, "%i: Glyph not present when it should be\n",x
);
425 else if (glyphs
[x
]==0)
426 winetest_trace("%i: Glyph not present when it should be\n",x
);
431 winetest_ok(glyphs
[x
]==0, "%i: Glyph present when it should not be\n",x
);
432 else if (glyphs
[x
]!=0)
433 winetest_trace("%i: Glyph present when it should not be\n",x
);
436 winetest_ok(glyphProp
[x
].sva
.uJustification
== glyphItems
[x
].GlyphProp
.sva
.uJustification
, "%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
437 else if (glyphProp
[x
].sva
.uJustification
!= glyphItems
[x
].GlyphProp
.sva
.uJustification
)
438 winetest_trace("%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
440 winetest_ok(glyphProp
[x
].sva
.fClusterStart
== glyphItems
[x
].GlyphProp
.sva
.fClusterStart
, "%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
441 else if (glyphProp
[x
].sva
.fClusterStart
!= glyphItems
[x
].GlyphProp
.sva
.fClusterStart
)
442 winetest_trace("%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
444 winetest_ok(glyphProp
[x
].sva
.fDiacritic
== glyphItems
[x
].GlyphProp
.sva
.fDiacritic
, "%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
445 else if (glyphProp
[x
].sva
.fDiacritic
!= glyphItems
[x
].GlyphProp
.sva
.fDiacritic
)
446 winetest_trace("%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
448 winetest_ok(glyphProp
[x
].sva
.fZeroWidth
== glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
, "%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
449 else if (glyphProp
[x
].sva
.fZeroWidth
!= glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
)
450 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
453 HeapFree(GetProcessHeap(),0,logclust
);
454 HeapFree(GetProcessHeap(),0,charProp
);
455 HeapFree(GetProcessHeap(),0,glyphs
);
456 HeapFree(GetProcessHeap(),0,glyphProp
);
457 ScriptFreeCache(&sc
);
460 #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)
462 #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)
464 typedef struct tagRangeP
{
469 static int CALLBACK
enumFontProc( const LOGFONT
*lpelfe
, const TEXTMETRIC
*lpntme
,
470 DWORD FontType
, LPARAM lParam
)
472 NEWTEXTMETRICEX
*ntme
= (NEWTEXTMETRICEX
*)lpntme
;
473 fontEnumParam
*rp
= (fontEnumParam
*) lParam
;
478 if (FontType
!= TRUETYPE_FONTTYPE
)
482 while (i
> sizeof(DWORD
)*8)
485 i
-= (sizeof(DWORD
)*8);
492 if (ntme
->ntmFontSig
.fsUsb
[idx
] & mask
)
494 memcpy(&(rp
->lf
),lpelfe
,sizeof(LOGFONT
));
500 static int _find_font_for_range(HDC hdc
, const CHAR
*recommended
, BYTE range
, const WCHAR check
, HFONT
*hfont
, HFONT
*origFont
)
503 fontEnumParam lParam
;
505 lParam
.range
= range
;
506 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
511 lstrcpyA(lParam
.lf
.lfFaceName
, recommended
);
512 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0))
514 *hfont
= CreateFontIndirectA(&lParam
.lf
);
517 winetest_trace("using font %s\n",lParam
.lf
.lfFaceName
);
525 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
526 lParam
.lf
.lfCharSet
= DEFAULT_CHARSET
;
528 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0) && lParam
.lf
.lfFaceName
[0])
530 *hfont
= CreateFontIndirectA(&lParam
.lf
);
532 winetest_trace("trying font %s: failures will only be warnings\n",lParam
.lf
.lfFaceName
);
540 *origFont
= SelectObject(hdc
,*hfont
);
541 if (pGetGlyphIndicesW
&& (pGetGlyphIndicesW(hdc
, &check
, 1, &glyph
, 0) == GDI_ERROR
|| glyph
==0))
543 winetest_trace(" Font fails to contain required glyphs\n");
544 SelectObject(hdc
,*origFont
);
545 DeleteObject(*hfont
);
553 winetest_trace("Failed to find usable font\n");
558 #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)
560 static void test_ScriptShapeOpenType(HDC hdc
)
563 SCRIPT_CACHE sc
= NULL
;
564 WORD glyphs
[4], logclust
[4];
565 SCRIPT_GLYPHPROP glyphProp
[4];
566 SCRIPT_ITEM items
[2];
568 SCRIPT_CONTROL Control
;
571 HFONT hfont
, hfont_orig
;
574 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
575 static const shapeTest_char t1_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
576 static const shapeTest_glyph t1_g
[] = {
577 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
578 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
579 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
580 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
582 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
583 static const shapeTest_char t2_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
584 static const shapeTest_glyph t2_g
[] = {
585 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
586 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
587 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
588 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
591 static const WCHAR test_hebrew
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
592 static const shapeTest_char hebrew_c
[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
593 static const shapeTest_glyph hebrew_g
[] = {
594 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
595 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
596 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
597 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
600 static const WCHAR test_arabic
[] = {0x0633,0x0644,0x0627,0x0645,0};
601 static const shapeTest_char arabic_c
[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
602 static const shapeTest_glyph arabic_g
[] = {
603 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
604 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL
,1,0,0,0,0},0}},
605 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN
,1,0,0,0,0},0}} };
608 static const WCHAR test_thai
[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
609 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}}};
610 static const shapeTest_glyph thai_g
[] = {
611 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
612 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
613 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
614 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
615 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
616 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
617 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
618 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
619 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
620 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}}};
623 static const WCHAR test_syriac
[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
624 static const shapeTest_char syriac_c
[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
625 static const shapeTest_glyph syriac_g
[] = {
626 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
627 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
628 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
629 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
630 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
631 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
634 static const WCHAR test_thaana
[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
635 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}}};
636 static const shapeTest_glyph thaana_g
[] = {
637 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
638 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
639 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
640 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
641 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
642 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
643 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
644 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
645 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
646 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
647 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
648 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
649 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
652 static const WCHAR test_phagspa
[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
653 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}}};
654 static const shapeTest_glyph phagspa_g
[] = {
655 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
656 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
657 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
658 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
659 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
660 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
661 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
662 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
663 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
664 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
665 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
668 static const WCHAR test_lao
[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
669 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}}};
670 static const shapeTest_glyph lao_g
[] = {
671 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
672 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
673 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
674 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
675 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
676 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
677 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
678 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
679 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
682 static const WCHAR test_tibetan
[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
683 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}}};
684 static const shapeTest_glyph tibetan_g
[] = {
685 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
686 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
687 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
688 {1,{{SCRIPT_JUSTIFY_BLANK
,1,0,0,0,0},0}},
689 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
690 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
691 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
692 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
693 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
694 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
695 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
696 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
697 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
698 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
699 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
700 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
701 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
703 if (!pScriptItemizeOpenType
|| !pScriptShapeOpenType
)
705 win_skip("ScriptShapeOpenType not available on this platform\n");
709 memset(&Control
, 0 , sizeof(Control
));
710 memset(&State
, 0 , sizeof(State
));
712 hr
= pScriptItemizeOpenType(test1
, 4, 2, &Control
, &State
, items
, tags
, &outnItems
);
713 ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
714 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
716 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, NULL
, &nb
);
717 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
719 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, NULL
);
720 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
722 hr
= pScriptShapeOpenType(NULL
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
723 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr
);
725 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
726 ok( hr
== E_INVALIDARG
,
727 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
728 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, logclust
, NULL
, glyphs
, glyphProp
, &nb
);
729 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
731 ScriptFreeCache(&sc
);
733 test_shape_ok(hdc
, test1
, 4, &Control
, &State
, 0, 4, t1_c
, t1_g
);
734 test_shape_ok(hdc
, test2
, 4, &Control
, &State
, 1, 4, t2_c
, t2_g
);
736 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 11, test_hebrew
[0], &hfont
, &hfont_orig
);
739 test_shape_ok_valid(test_valid
, hdc
, test_hebrew
, 4, &Control
, &State
, 0, 4, hebrew_c
, hebrew_g
);
740 SelectObject(hdc
, hfont_orig
);
744 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 13, test_arabic
[0], &hfont
, &hfont_orig
);
747 test_shape_ok_valid(test_valid
, hdc
, test_arabic
, 4, &Control
, &State
, 0, 3, arabic_c
, arabic_g
);
748 SelectObject(hdc
, hfont_orig
);
752 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 24, test_thai
[0], &hfont
, &hfont_orig
);
755 test_shape_ok_valid(test_valid
, hdc
, test_thai
, 10, &Control
, &State
, 0, 10, thai_c
, thai_g
);
756 SelectObject(hdc
, hfont_orig
);
760 test_valid
= find_font_for_range(hdc
, "Estrangelo Edessa", 71, test_syriac
[0], &hfont
, &hfont_orig
);
763 test_shape_ok_valid(test_valid
, hdc
, test_syriac
, 6, &Control
, &State
, 0, 6, syriac_c
, syriac_g
);
764 SelectObject(hdc
, hfont_orig
);
768 test_valid
= find_font_for_range(hdc
, "MV Boli", 72, test_thaana
[0], &hfont
, &hfont_orig
);
771 test_shape_ok_valid(test_valid
, hdc
, test_thaana
, 13, &Control
, &State
, 0, 13, thaana_c
, thaana_g
);
772 SelectObject(hdc
, hfont_orig
);
776 test_valid
= find_font_for_range(hdc
, "Microsoft PhagsPa", 53, test_phagspa
[0], &hfont
, &hfont_orig
);
779 test_shape_ok_valid(test_valid
, hdc
, test_phagspa
, 11, &Control
, &State
, 0, 11, phagspa_c
, phagspa_g
);
780 SelectObject(hdc
, hfont_orig
);
784 test_valid
= find_font_for_range(hdc
, "DokChampa", 25, test_lao
[0], &hfont
, &hfont_orig
);
787 test_shape_ok_valid(test_valid
, hdc
, test_lao
, 9, &Control
, &State
, 0, 9, lao_c
, lao_g
);
788 SelectObject(hdc
, hfont_orig
);
792 test_valid
= find_font_for_range(hdc
, "Microsoft Himalaya", 70, test_tibetan
[0], &hfont
, &hfont_orig
);
795 test_shape_ok_valid(test_valid
, hdc
, test_tibetan
, 17, &Control
, &State
, 0, 17, tibetan_c
, tibetan_g
);
796 SelectObject(hdc
, hfont_orig
);
801 static void test_ScriptShape(HDC hdc
)
803 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
804 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
806 SCRIPT_CACHE sc
= NULL
;
807 WORD glyphs
[4], glyphs2
[4], logclust
[4];
808 SCRIPT_VISATTR attrs
[4];
809 SCRIPT_ITEM items
[2];
812 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
813 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
814 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
816 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, NULL
, &nb
);
817 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
819 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, NULL
);
820 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
822 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
823 ok(hr
== E_PENDING
, "ScriptShape should return E_PENDING not %08x\n", hr
);
825 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
826 ok(broken(hr
== S_OK
) ||
827 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
828 hr
== E_FAIL
, /* WIN7 */
829 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
830 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
832 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
833 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
834 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
837 memset(glyphs
,-1,sizeof(glyphs
));
838 memset(logclust
,-1,sizeof(logclust
));
839 memset(attrs
,-1,sizeof(attrs
));
840 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
841 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
842 ok(nb
== 4, "Wrong number of items\n");
843 ok(logclust
[0] == 0, "clusters out of order\n");
844 ok(logclust
[1] == 1, "clusters out of order\n");
845 ok(logclust
[2] == 2, "clusters out of order\n");
846 ok(logclust
[3] == 3, "clusters out of order\n");
847 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
848 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
849 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
850 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
851 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
852 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
853 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
854 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
855 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
856 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
857 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
858 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
859 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
860 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
861 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
862 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
864 ScriptFreeCache(&sc
);
867 memset(glyphs2
,-1,sizeof(glyphs2
));
868 memset(logclust
,-1,sizeof(logclust
));
869 memset(attrs
,-1,sizeof(attrs
));
870 hr
= ScriptShape(hdc
, &sc
, test2
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
871 ok(hr
== S_OK
, "ScriptShape should return S_OK not %08x\n", hr
);
872 ok(nb
== 4, "Wrong number of items\n");
873 ok(glyphs2
[0] == 0 || broken(glyphs2
[0] == 0x80), "Incorrect glyph for 0x202B\n");
874 ok(glyphs2
[3] == 0 || broken(glyphs2
[3] == 0x80), "Incorrect glyph for 0x202C\n");
875 ok(logclust
[0] == 0, "clusters out of order\n");
876 ok(logclust
[1] == 1, "clusters out of order\n");
877 ok(logclust
[2] == 2, "clusters out of order\n");
878 ok(logclust
[3] == 3, "clusters out of order\n");
879 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
880 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
881 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
882 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
883 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
884 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
885 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
886 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
887 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
888 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
889 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
890 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
891 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
892 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
893 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
894 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
896 /* modify LTR to RTL */
898 memset(glyphs2
,-1,sizeof(glyphs2
));
899 memset(logclust
,-1,sizeof(logclust
));
900 memset(attrs
,-1,sizeof(attrs
));
901 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
902 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
903 ok(nb
== 4, "Wrong number of items\n");
904 ok(glyphs2
[0] == glyphs
[3], "Glyphs not reordered properly\n");
905 ok(glyphs2
[1] == glyphs
[2], "Glyphs not reordered properly\n");
906 ok(glyphs2
[2] == glyphs
[1], "Glyphs not reordered properly\n");
907 ok(glyphs2
[3] == glyphs
[0], "Glyphs not reordered properly\n");
908 ok(logclust
[0] == 3, "clusters out of order\n");
909 ok(logclust
[1] == 2, "clusters out of order\n");
910 ok(logclust
[2] == 1, "clusters out of order\n");
911 ok(logclust
[3] == 0, "clusters out of order\n");
912 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
913 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
914 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
915 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
916 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
917 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
918 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
919 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
920 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
921 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
922 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
923 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
924 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
925 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
926 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
927 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
929 ScriptFreeCache(&sc
);
932 static void test_ScriptPlace(HDC hdc
)
934 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
937 SCRIPT_CACHE sc
= NULL
;
938 WORD glyphs
[4], logclust
[4];
939 SCRIPT_VISATTR attrs
[4];
940 SCRIPT_ITEM items
[2];
945 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
946 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
947 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
949 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
950 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
951 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
953 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, NULL
, &items
[0].a
, widths
, NULL
, NULL
);
954 ok(hr
== E_INVALIDARG
, "ScriptPlace should return E_INVALIDARG not %08x\n", hr
);
956 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, NULL
);
957 ok(broken(hr
== E_PENDING
) ||
958 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
959 hr
== E_FAIL
, /* WIN7 */
960 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
962 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
963 ok(hr
== E_PENDING
, "ScriptPlace should return E_PENDING not %08x\n", hr
);
965 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, abc
);
966 ok(broken(hr
== E_PENDING
) ||
967 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
968 hr
== E_FAIL
, /* WIN7 */
969 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
971 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
972 ok(!hr
, "ScriptPlace should return S_OK not %08x\n", hr
);
973 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
975 ret
= ExtTextOutW(hdc
, 1, 1, 0, NULL
, glyphs
, 4, widths
);
976 ok(ret
, "ExtTextOutW should return TRUE\n");
978 ScriptFreeCache(&sc
);
981 static void test_ScriptItemIzeShapePlace(HDC hdc
, unsigned short pwOutGlyphs
[256])
985 const SCRIPT_PROPERTIES
**ppSp
;
989 SCRIPT_ITEM pItem
[255];
991 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
992 WCHAR TestItem2
[] = {'T', 'e', 's', 't', 'b', 0};
993 WCHAR TestItem3
[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
994 WCHAR TestItem4
[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
995 WCHAR TestItem5
[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
996 WCHAR TestItem6
[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1001 unsigned short pwOutGlyphs1
[256];
1002 unsigned short pwOutGlyphs2
[256];
1003 unsigned short pwLogClust
[256];
1004 SCRIPT_VISATTR psva
[256];
1007 GOFFSET pGoffset
[256];
1011 /* Start testing usp10 functions */
1012 /* This test determines that the pointer returned by ScriptGetProperties is valid
1013 * by checking a known value in the table */
1014 hr
= ScriptGetProperties(&ppSp
, &iMaxProps
);
1015 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
1016 trace("number of script properties %d\n", iMaxProps
);
1017 ok (iMaxProps
> 0, "Number of scripts returned should not be 0\n");
1019 ok( ppSp
[0]->langid
== 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1022 /* This is a valid test that will cause parsing to take place */
1025 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1026 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1027 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1029 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1031 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1032 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1033 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1035 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1036 * ie. ScriptItemize has succeeded and that pItem has been set */
1039 psc
= NULL
; /* must be null on first call */
1041 cMaxGlyphs
= cInChars
;
1042 hr
= ScriptShape(NULL
, &psc
, TestItem1
, cChars
,
1043 cMaxGlyphs
, &pItem
[0].a
,
1044 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1045 ok (hr
== E_PENDING
, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr
);
1047 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1048 cMaxGlyphs
, &pItem
[0].a
,
1049 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1050 ok (hr
== E_OUTOFMEMORY
, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1051 "(%d) but not E_OUTOFMEMORY\n",
1052 cChars
, cMaxGlyphs
);
1054 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1055 cMaxGlyphs
, &pItem
[0].a
,
1056 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1057 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1058 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1059 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1061 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1063 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1064 hr
= ScriptPlace(NULL
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1066 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1067 for (cnt
=0; cnt
< pcGlyphs
; cnt
++)
1068 pwOutGlyphs
[cnt
] = pwOutGlyphs1
[cnt
]; /* Send to next function */
1071 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1072 * takes place if fNoGlyphIndex is set. */
1076 hr
= ScriptItemize(TestItem2
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1077 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1078 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1080 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1081 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1082 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1083 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1087 pItem
[0].a
.fNoGlyphIndex
= 1; /* say no translate */
1088 hr
= ScriptShape(NULL
, &psc
, TestItem2
, cChars
,
1089 cMaxGlyphs
, &pItem
[0].a
,
1090 pwOutGlyphs2
, pwLogClust
, psva
, &pcGlyphs
);
1091 ok (hr
!= E_PENDING
, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr
);
1092 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1093 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1094 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1095 for (cnt
=0; cnt
< cChars
&& TestItem2
[cnt
] == pwOutGlyphs2
[cnt
]; cnt
++) {}
1096 ok (cnt
== cChars
, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1097 cnt
, TestItem2
[cnt
], pwOutGlyphs2
[cnt
]);
1099 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs2
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1101 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1104 ScriptFreeCache( &psc
);
1105 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1109 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1110 cInChars
= (sizeof(TestItem3
)/2)-1;
1112 hr
= ScriptItemize(TestItem3
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1113 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1116 ok (pcItems
== 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems
);
1119 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1120 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1121 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1122 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1123 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1124 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1125 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== cInChars
,
1126 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1127 pItem
[2].iCharPos
, pItem
[3].iCharPos
, cInChars
);
1131 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1132 cInChars
= (sizeof(TestItem4
)/2)-1;
1134 hr
= ScriptItemize(TestItem4
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1135 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1138 ok (pcItems
== 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems
);
1141 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1142 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1143 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1144 ok (pItem
[0].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1145 pItem
[0].a
.s
.uBidiLevel
);
1146 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1147 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1148 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1149 ok (pItem
[1].a
.s
.uBidiLevel
== 1, "Should have been bidi=1 not %d\n",
1150 pItem
[1].a
.s
.uBidiLevel
);
1151 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== 12,
1152 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1153 pItem
[2].iCharPos
, pItem
[3].iCharPos
);
1154 ok (pItem
[2].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1155 pItem
[2].a
.s
.uBidiLevel
);
1156 ok (pItem
[3].iCharPos
== 12 && pItem
[4].iCharPos
== 13,
1157 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1158 pItem
[3].iCharPos
, pItem
[4].iCharPos
);
1159 ok (pItem
[3].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1160 pItem
[3].a
.s
.uBidiLevel
);
1161 ok (pItem
[4].iCharPos
== 13 && pItem
[5].iCharPos
== cInChars
,
1162 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1163 pItem
[4].iCharPos
, pItem
[5].iCharPos
, cInChars
);
1168 * This test is for when the first unicode character requires bidi support
1170 cInChars
= (sizeof(TestItem5
)-1)/sizeof(WCHAR
);
1171 hr
= ScriptItemize(TestItem5
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1172 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1173 ok (pcItems
== 4, "There should have been 4 items, found %d\n", pcItems
);
1174 ok (pItem
[0].a
.s
.uBidiLevel
== 1, "The first character should have been bidi=1 not %d\n",
1175 pItem
[0].a
.s
.uBidiLevel
);
1177 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1178 * the pointer to the last char works. Note that windows often needs a greater number of *
1179 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1180 cInChars
= (sizeof(TestItem6
)/2)-1;
1182 hr
= ScriptItemize(TestItem6
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1183 ok (hr
== E_OUTOFMEMORY
, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr
);
1187 static void test_ScriptGetCMap(HDC hdc
, unsigned short pwOutGlyphs
[256])
1190 SCRIPT_CACHE psc
= NULL
;
1193 unsigned short pwOutGlyphs2
[256];
1194 unsigned short pwOutGlyphs3
[256];
1198 static const WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1199 static const WCHAR TestItem2
[] = {0x202B, 'i', 'n', 0x202C,0};
1200 static const WCHAR TestItem3
[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1201 static const WCHAR TestItem3b
[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1203 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1205 cInChars
= cChars
= 5;
1206 /* Some sanity checks for ScriptGetCMap */
1208 hr
= ScriptGetCMap(NULL
, NULL
, NULL
, 0, 0, NULL
);
1209 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL,0,0,NULL), "
1210 "expected E_INVALIDARG, got %08x\n", hr
);
1212 hr
= ScriptGetCMap(NULL
, NULL
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1213 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1214 "expected E_INVALIDARG, got %08x\n", hr
);
1216 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1218 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1219 ok( hr
== E_PENDING
, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1221 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1223 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1225 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1226 ok( hr
== S_OK
, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1228 ok( psc
!= NULL
, "ScritpGetCMap expected psc to be not NULL\n");
1229 ScriptFreeCache( &psc
);
1231 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1233 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1234 ok( hr
== E_PENDING
, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr
);
1235 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1236 /* Check to see if the results are the same as those returned by ScriptShape */
1237 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1238 ok (hr
== 0, "ScriptGetCMap should return 0 not (%08x)\n", hr
);
1239 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1240 for (cnt
=0; cnt
< cChars
&& pwOutGlyphs
[cnt
] == pwOutGlyphs3
[cnt
]; cnt
++) {}
1241 ok (cnt
== cInChars
, "Translation not correct. WCHAR %d - %04x != %04x\n",
1242 cnt
, pwOutGlyphs
[cnt
], pwOutGlyphs3
[cnt
]);
1244 ScriptFreeCache( &psc
);
1245 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1247 cInChars
= cChars
= 4;
1248 hr
= ScriptGetCMap(hdc
, &psc
, TestItem2
, cInChars
, dwFlags
, pwOutGlyphs3
);
1249 ok (hr
== S_FALSE
, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr
);
1250 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1251 ok(pwOutGlyphs3
[0] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1252 ok(pwOutGlyphs3
[3] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1255 cInChars
= cChars
= 9;
1256 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3b
, cInChars
, dwFlags
, pwOutGlyphs2
);
1257 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1258 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1260 cInChars
= cChars
= 9;
1262 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3
, cInChars
, dwFlags
, pwOutGlyphs3
);
1263 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1264 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1265 ok(pwOutGlyphs3
[0] == pwOutGlyphs2
[0], "glyph incorrectly altered\n");
1266 ok(pwOutGlyphs3
[1] == pwOutGlyphs2
[1], "glyph incorreclty altered\n");
1267 ok(pwOutGlyphs3
[2] == pwOutGlyphs2
[2], "glyph incorreclty altered\n");
1268 ok(pwOutGlyphs3
[3] == pwOutGlyphs2
[3], "glyph incorreclty altered\n");
1269 ok(pwOutGlyphs3
[4] == pwOutGlyphs2
[4], "glyph not mirrored correctly\n");
1270 ok(pwOutGlyphs3
[5] == pwOutGlyphs2
[5], "glyph not mirrored correctly\n");
1271 ok(pwOutGlyphs3
[6] == pwOutGlyphs2
[6], "glyph not mirrored correctly\n");
1272 ok(pwOutGlyphs3
[7] == pwOutGlyphs2
[7], "glyph not mirrored correctly\n");
1273 ok(pwOutGlyphs3
[8] == pwOutGlyphs2
[8], "glyph not mirrored correctly\n");
1275 ScriptFreeCache( &psc
);
1276 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1279 static void test_ScriptGetFontProperties(HDC hdc
)
1282 SCRIPT_CACHE psc
,old_psc
;
1283 SCRIPT_FONTPROPERTIES sfp
;
1285 /* Some sanity checks for ScriptGetFontProperties */
1287 hr
= ScriptGetFontProperties(NULL
,NULL
,NULL
);
1288 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1290 hr
= ScriptGetFontProperties(NULL
,NULL
,&sfp
);
1291 ok( hr
== E_INVALIDARG
, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1293 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1295 hr
= ScriptGetFontProperties(NULL
,&psc
,NULL
);
1296 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1297 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1299 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1301 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1302 ok( hr
== E_PENDING
, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr
);
1303 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1305 hr
= ScriptGetFontProperties(hdc
,NULL
,NULL
);
1306 ok( hr
== E_INVALIDARG
, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1308 hr
= ScriptGetFontProperties(hdc
,NULL
,&sfp
);
1309 ok( hr
== E_INVALIDARG
, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1311 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1313 hr
= ScriptGetFontProperties(hdc
,&psc
,NULL
);
1314 ok( hr
== E_INVALIDARG
, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1315 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1317 /* Pass an invalid sfp */
1319 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
) - 1;
1320 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1321 ok( hr
== E_INVALIDARG
, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr
);
1322 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1323 ScriptFreeCache(&psc
);
1324 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1326 /* Give it the correct cBytes, we don't care about what's coming back */
1327 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
);
1329 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1330 ok( hr
== S_OK
, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr
);
1331 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1333 /* Save the psc pointer */
1335 /* Now a NULL hdc again */
1336 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1337 ok( hr
== S_OK
, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr
);
1338 ok( psc
== old_psc
, "Expected psc not to be changed, was %p is now %p\n", old_psc
, psc
);
1339 ScriptFreeCache(&psc
);
1340 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1343 static void test_ScriptTextOut(HDC hdc
)
1349 SCRIPT_ITEM pItem
[255];
1351 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1356 unsigned short pwOutGlyphs1
[256];
1357 WORD pwLogClust
[256];
1358 SCRIPT_VISATTR psva
[256];
1361 GOFFSET pGoffset
[256];
1366 BOOL fTrailing
= FALSE
;
1367 SCRIPT_LOGATTR
*psla
;
1368 SCRIPT_LOGATTR sla
[256];
1370 /* This is a valid test that will cause parsing to take place */
1373 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1374 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1375 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1377 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1379 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1380 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1381 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1383 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1384 * ie. ScriptItemize has succeeded and that pItem has been set */
1387 psc
= NULL
; /* must be null on first call */
1390 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1391 cMaxGlyphs
, &pItem
[0].a
,
1392 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1393 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1394 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1395 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1397 /* Note hdc is needed as glyph info is not yet in psc */
1398 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1400 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1401 ScriptFreeCache(&psc
); /* Get rid of psc for next test set */
1402 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1404 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0, NULL
, NULL
, NULL
);
1405 ok (hr
== E_INVALIDARG
, "Should return 0 not (%08x)\n", hr
);
1407 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1408 piAdvance
, NULL
, pGoffset
);
1409 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1410 "expected E_INVALIDARG, got %08x\n", hr
);
1412 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1414 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0,
1416 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
1418 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1420 /* hdc is required for this one rather than the usual optional */
1422 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1423 piAdvance
, NULL
, pGoffset
);
1424 ok( hr
== E_INVALIDARG
, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr
);
1425 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1427 /* Set that it returns 0 status */
1428 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1429 piAdvance
, NULL
, pGoffset
);
1430 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1432 /* Test Rect Rgn is acceptable */
1437 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1438 piAdvance
, NULL
, pGoffset
);
1439 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1442 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, pcGlyphs
, (const WORD
*) &pwLogClust
,
1443 (const SCRIPT_VISATTR
*) &psva
, (const int *)&piAdvance
, &pItem
[0].a
, &piX
);
1444 ok(hr
== S_OK
, "ScriptCPtoX Stub should return S_OK not %08x\n", hr
);
1446 psla
= (SCRIPT_LOGATTR
*)&sla
;
1447 hr
= ScriptBreak(TestItem1
, cChars
, &pItem
[0].a
, psla
);
1448 ok(hr
== S_OK
, "ScriptBreak Stub should return S_OK not %08x\n", hr
);
1450 /* Clean up and go */
1451 ScriptFreeCache(&psc
);
1452 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1457 static void test_ScriptTextOut2(HDC hdc
)
1459 /* Intent is to validate that the HDC passed into ScriptTextOut is
1460 * used instead of the (possibly) invalid cached one
1467 SCRIPT_ITEM pItem
[255];
1469 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1474 unsigned short pwOutGlyphs1
[256];
1475 WORD pwLogClust
[256];
1476 SCRIPT_VISATTR psva
[256];
1479 GOFFSET pGoffset
[256];
1482 /* Create an extra DC that will be used until the ScriptTextOut */
1483 hdc1
= CreateCompatibleDC(hdc
);
1484 ok (hdc1
!= 0, "CreateCompatibleDC failed to create a DC\n");
1485 hdc2
= CreateCompatibleDC(hdc
);
1486 ok (hdc2
!= 0, "CreateCompatibleDC failed to create a DC\n");
1488 /* This is a valid test that will cause parsing to take place */
1491 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1492 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1493 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1495 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1497 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1498 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1499 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1501 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1502 * ie. ScriptItemize has succeeded and that pItem has been set */
1505 psc
= NULL
; /* must be null on first call */
1508 hr
= ScriptShape(hdc2
, &psc
, TestItem1
, cChars
,
1509 cMaxGlyphs
, &pItem
[0].a
,
1510 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1511 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1512 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1513 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1515 /* Note hdc is needed as glyph info is not yet in psc */
1516 hr
= ScriptPlace(hdc2
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1518 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1520 /* key part!!! cached dc is being deleted */
1521 hr
= DeleteDC(hdc2
);
1522 ok(hr
== 1, "DeleteDC should return 1 not %08x\n", hr
);
1524 /* At this point the cached hdc (hdc2) has been destroyed,
1525 * however, we are passing in a *real* hdc (the original hdc).
1526 * The text should be written to that DC
1528 hr
= ScriptTextOut(hdc1
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1529 piAdvance
, NULL
, pGoffset
);
1530 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1531 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1535 /* Clean up and go */
1536 ScriptFreeCache(&psc
);
1537 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1542 static void test_ScriptTextOut3(HDC hdc
)
1548 SCRIPT_ITEM pItem
[255];
1550 WCHAR TestItem1
[] = {' ','\r', 0};
1555 unsigned short pwOutGlyphs1
[256];
1556 WORD pwLogClust
[256];
1557 SCRIPT_VISATTR psva
[256];
1560 GOFFSET pGoffset
[256];
1564 /* This is to ensure that non exisiting glyphs are translated into a valid glyph number */
1567 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1568 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1569 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1571 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1573 ok (pItem
[0].iCharPos
== 0 && pItem
[2].iCharPos
== cInChars
,
1574 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1575 pItem
[0].iCharPos
, cInChars
, pItem
[2].iCharPos
);
1577 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1578 * ie. ScriptItemize has succeeded and that pItem has been set */
1581 psc
= NULL
; /* must be null on first call */
1584 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1585 cMaxGlyphs
, &pItem
[0].a
,
1586 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1587 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1588 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1589 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1591 /* Note hdc is needed as glyph info is not yet in psc */
1592 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1594 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1596 /* Test Rect Rgn is acceptable */
1601 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1602 piAdvance
, NULL
, pGoffset
);
1603 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1606 /* Clean up and go */
1607 ScriptFreeCache(&psc
);
1608 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1612 static void test_ScriptXtoX(void)
1613 /****************************************************************************************
1614 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
1615 ****************************************************************************************/
1617 static const WCHAR test
[] = {'t', 'e', 's', 't',0};
1618 SCRIPT_ITEM items
[2];
1622 WORD pwLogClust
[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
1623 WORD pwLogClust_RTL
[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
1624 SCRIPT_VISATTR psva
[10];
1625 int piAdvance
[10] = {200, 190, 210, 180, 170, 204, 189, 195, 212, 203};
1630 static const int offsets
[13] = {0, 66, 133, 200, 295, 390, 495, 600, 1051, 1502, 1953, 1953, 1953};
1631 static const int offsets_RTL
[13] = {780, 720, 660, 600, 495, 390, 295, 200, 133, 66, 0, 0, 0};
1633 hr
= ScriptItemize(test
, lstrlenW(test
), sizeof(items
)/sizeof(items
[0]), NULL
, NULL
, items
, NULL
);
1634 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
1639 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1640 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1642 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
1644 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
1646 for(iCP
= 0; iCP
< 10; iCP
++)
1648 iX
= offsets
[iCP
]+1;
1651 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1652 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1653 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1654 ok(piTrailing
== 0, "iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1657 for(iCP
= 0; iCP
< 10; iCP
++)
1659 iX
= offsets
[iCP
+1]-1;
1662 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1663 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1664 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1665 ok(piTrailing
== 1, "iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
1668 /* 0,1,2 are actually fractional offsets meaning that they will not be reporting the same iCP as comes in so don't test those */
1669 for(iCP
= 3; iCP
< 10; iCP
++)
1674 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1675 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1676 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1677 ok(piTrailing
== 0, "iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1680 items
[0].a
.fRTL
= TRUE
;
1685 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1686 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1688 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
1690 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
1695 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1696 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1697 ok(piCP
== -1, "iX=%d should return piCP=-1 not %d\n", iX
, piCP
);
1698 ok(piTrailing
== 1, "iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
1700 for(iCP
= 0; iCP
< 10; iCP
++)
1702 iX
= offsets_RTL
[iCP
]-1;
1705 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1706 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1707 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1708 ok(piTrailing
== 0, "iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1711 for(iCP
= 0; iCP
< 10; iCP
++)
1713 iX
= offsets_RTL
[iCP
+1]+1;
1716 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1717 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1718 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1719 ok(piTrailing
== 1, "iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
1722 for(iCP
= 0; iCP
< 10; iCP
++)
1724 iX
= offsets_RTL
[iCP
];
1727 hr
= ScriptXtoCP(iX
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piCP
, &piTrailing
);
1728 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
1729 ok(piCP
== iCP
, "iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1730 ok(piTrailing
== 0, "iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1733 items
[0].a
.fRTL
= FALSE
;
1735 for(iCP
= 0; iCP
<= 11; iCP
++)
1740 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piX
);
1741 ok(hr
== S_OK
, "ScriptCPtoX should return S_OK not %08x\n", hr
);
1742 ok(piX
== offsets
[iCP
],
1743 "iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
], piX
);
1746 for(iCP
= 0; iCP
<= 11; iCP
++)
1751 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, cGlyphs
, pwLogClust
, psva
, piAdvance
, &items
[0].a
, &piX
);
1752 ok(hr
== S_OK
, "ScriptCPtoX should return S_OK not %08x\n", hr
);
1753 ok(piX
== offsets
[iCP
+1],
1754 "iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
+1], piX
);
1757 items
[0].a
.fRTL
= TRUE
;
1759 for(iCP
= 0; iCP
<= 11; iCP
++)
1764 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piX
);
1765 ok(hr
== S_OK
, "ScriptCPtoX should return S_OK not %08x\n", hr
);
1766 ok(piX
== offsets_RTL
[iCP
],
1767 "iCP=%d should return piX=%d not %d\n", iCP
, offsets_RTL
[iCP
], piX
);
1770 for(iCP
= 0; iCP
<= 11; iCP
++)
1775 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, cGlyphs
, pwLogClust_RTL
, psva
, piAdvance
, &items
[0].a
, &piX
);
1776 ok(hr
== S_OK
, "ScriptCPtoX should return S_OK not %08x\n", hr
);
1777 ok(piX
== offsets_RTL
[iCP
+1],
1778 "iCP=%d should return piX=%d not %d\n", iCP
, offsets_RTL
[iCP
+1], piX
);
1782 static void test_ScriptString(HDC hdc
)
1784 /*******************************************************************************************
1786 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
1787 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
1788 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
1789 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
1794 WCHAR teststr
[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
1795 int len
= (sizeof(teststr
) / sizeof(WCHAR
)) - 1;
1796 int Glyphs
= len
* 2 + 16;
1798 DWORD Flags
= SSA_GLYPHS
;
1800 const int Dx
[5] = {10, 10, 10, 10, 10};
1801 const BYTE InClass
= 0;
1802 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
1807 const RECT rc
= {0, 50, 100, 100};
1810 BOOL Disabled
= FALSE
;
1811 const int *clip_len
;
1816 Charset
= -1; /* this flag indicates unicode input */
1817 /* Test without hdc to get E_PENDING */
1818 hr
= ScriptStringAnalyse( NULL
, teststr
, len
, Glyphs
, Charset
, Flags
,
1819 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
1821 ok(hr
== E_PENDING
, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr
);
1823 /* test with hdc, this should be a valid test */
1824 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
1825 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
1827 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
1828 ScriptStringFree(&ssa
);
1830 /* test makes sure that a call with a valid pssa still works */
1831 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
1832 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
1834 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
1835 ok(ssa
!= NULL
, "ScriptStringAnalyse pssa should not be NULL\n");
1839 hr
= ScriptStringOut(ssa
, X
, Y
, Options
, &rc
, MinSel
, MaxSel
, Disabled
);
1840 ok(hr
== S_OK
, "ScriptStringOut should return S_OK not %08x\n", hr
);
1843 clip_len
= ScriptString_pcOutChars(ssa
);
1844 ok(*clip_len
== len
, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len
, len
);
1846 order
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, *clip_len
* sizeof(UINT
));
1847 hr
= ScriptStringGetOrder(ssa
, order
);
1848 ok(hr
== S_OK
, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr
);
1850 for (i
= 0; i
< *clip_len
; i
++) ok(order
[i
] == i
, "%d: got %d expected %d\n", i
, order
[i
], i
);
1851 HeapFree(GetProcessHeap(), 0, order
);
1853 hr
= ScriptStringFree(&ssa
);
1854 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
1857 static void test_ScriptStringXtoCP_CPtoX(HDC hdc
)
1859 /*****************************************************************************************
1861 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
1862 * nature of the fonts between Windows and Wine, the test is implemented by generating
1863 * values using one one function then checking the output of the second. In this way
1864 * the validity of the functions is established using Windows as a base and confirming
1865 * similar behaviour in wine.
1869 static const WCHAR teststr1
[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
1870 static const BOOL rtl
[] = {1, 0, 1, 0, 1, 0, 1, 0};
1871 void *String
= (WCHAR
*) &teststr1
; /* ScriptStringAnalysis needs void */
1872 int String_len
= (sizeof(teststr1
)/sizeof(WCHAR
))-1;
1873 int Glyphs
= String_len
* 2 + 16; /* size of buffer as recommended */
1874 int Charset
= -1; /* unicode */
1875 DWORD Flags
= SSA_GLYPHS
;
1877 const BYTE InClass
= 0;
1878 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
1880 int Ch
; /* Character position in string */
1882 int Cp
; /* Character position in string */
1887 /* Test with hdc, this should be a valid test
1888 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
1889 * following character positions to X and X to character position functions.
1892 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
1893 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
1896 hr
== E_INVALIDARG
, /* NT */
1897 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr
);
1901 ok(ssa
!= NULL
, "ScriptStringAnalyse ssa should not be NULL\n");
1904 * Loop to generate character positions to provide starting positions for the
1905 * ScriptStringCPtoX and ScriptStringXtoCP functions
1907 for (Cp
= 0; Cp
< String_len
; Cp
++)
1909 /* The fTrailing flag is used to indicate whether the X being returned is at
1910 * the beginning or the end of the character. What happens here is that if
1911 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
1912 * returns the beginning of the next character and iTrailing is FALSE. So for this
1913 * loop iTrailing will be FALSE in both cases.
1915 hr
= ScriptStringCPtoX(ssa
, Cp
, TRUE
, &trail
);
1916 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
1917 hr
= ScriptStringCPtoX(ssa
, Cp
, FALSE
, &lead
);
1918 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
1920 ok(lead
> trail
, "Leading values should be after trialing for rtl chracters(%i)\n",Cp
);
1922 ok(lead
< trail
, "Trailing values should be after leading for ltr chracters(%i)\n",Cp
);
1924 /* move by 1 pixel so that we are not inbetween 2 characters. That could result in being the lead of a rtl and
1925 at the same time the trail of an ltr */
1927 /* inside the leading edge */
1929 if (rtl
[Cp
]) X
--; else X
++;
1930 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1931 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1932 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
1933 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
1936 /* inside the trailing edge */
1938 if (rtl
[Cp
]) X
++; else X
--;
1939 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1940 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1941 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
1942 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
1945 /* outside the "trailing" edge */
1946 if (Cp
< String_len
-1)
1948 if (rtl
[Cp
]) X
= lead
; else X
= trail
;
1950 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1951 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1952 ok(Cp
+ 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
+ 1, Ch
, trail
);
1954 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
1957 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
1961 /* outside the "leading" edge */
1964 if (rtl
[Cp
]) X
= trail
; else X
= lead
;
1966 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1967 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1968 ok(Cp
- 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
- 1, Ch
, trail
);
1969 if (Cp
!= 0 && rtl
[Cp
-1])
1970 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
1973 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
1978 /* Check beyond the leading boundary of the whole string */
1981 /* having a leading rtl character seems to confuse usp */
1982 /* this looks to be a windows bug we should emulate */
1983 hr
= ScriptStringCPtoX(ssa
, 0, TRUE
, &X
);
1984 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
1986 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1987 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1988 ok(Ch
== 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch
);
1989 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
1994 hr
= ScriptStringCPtoX(ssa
, 0, FALSE
, &X
);
1995 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
1997 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
1998 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
1999 ok(Ch
== -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch
);
2000 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2004 /* Check beyond the end boundary of the whole string */
2005 if (rtl
[String_len
-1])
2007 hr
= ScriptStringCPtoX(ssa
, String_len
-1, FALSE
, &X
);
2008 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2012 hr
= ScriptStringCPtoX(ssa
, String_len
-1, TRUE
, &X
);
2013 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2016 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2017 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2018 ok(Ch
== String_len
, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len
, Ch
);
2019 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside traling edge\n",
2023 * Cleanup the SSA for the next round of tests
2025 hr
= ScriptStringFree(&ssa
);
2026 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
2029 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2030 * generate an SSA for the subsequent tests.
2032 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
2033 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
2035 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2038 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2039 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2040 * ScriptStringFree should also fail.
2043 Cp
= String_len
+ 1;
2044 hr
= ScriptStringCPtoX(ssa
, Cp
, fTrailing
, &X
);
2045 ok(hr
== E_INVALIDARG
, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr
);
2047 ScriptStringFree(&ssa
);
2051 static void test_ScriptCacheGetHeight(HDC hdc
)
2054 SCRIPT_CACHE sc
= NULL
;
2057 hr
= ScriptCacheGetHeight(NULL
, NULL
, NULL
);
2058 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2060 hr
= ScriptCacheGetHeight(NULL
, &sc
, NULL
);
2061 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2063 hr
= ScriptCacheGetHeight(NULL
, &sc
, &height
);
2064 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2068 hr
= ScriptCacheGetHeight(hdc
, &sc
, &height
);
2069 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2070 ok(height
> 0, "expected height > 0\n");
2072 ScriptFreeCache(&sc
);
2075 static void test_ScriptGetGlyphABCWidth(HDC hdc
)
2078 SCRIPT_CACHE sc
= NULL
;
2081 hr
= ScriptGetGlyphABCWidth(NULL
, NULL
, 'a', NULL
);
2082 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2084 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', NULL
);
2085 ok(broken(hr
== E_PENDING
) ||
2086 hr
== E_INVALIDARG
, /* WIN7 */
2087 "expected E_INVALIDARG, got 0x%08x\n", hr
);
2089 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', &abc
);
2090 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2092 if (0) { /* crashes on WinXP */
2093 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', NULL
);
2094 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2097 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', &abc
);
2098 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2100 ScriptFreeCache(&sc
);
2103 static void test_ScriptLayout(void)
2106 static const BYTE levels
[][10] =
2108 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2109 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2110 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2111 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2113 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2114 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2115 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2116 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2117 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2119 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2120 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2122 static const int expect_l2v
[][10] =
2124 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2125 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2126 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2127 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2129 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2130 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2131 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2132 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2133 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2135 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2136 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2138 static const int expect_v2l
[][10] =
2140 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2141 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2142 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2143 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2145 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2146 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2147 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2148 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2149 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2151 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2152 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2155 int i
, j
, vistolog
[sizeof(levels
[0])], logtovis
[sizeof(levels
[0])];
2157 hr
= ScriptLayout(sizeof(levels
[0]), NULL
, vistolog
, logtovis
);
2158 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2160 hr
= ScriptLayout(sizeof(levels
[0]), levels
[0], NULL
, NULL
);
2161 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2163 for (i
= 0; i
< sizeof(levels
)/sizeof(levels
[0]); i
++)
2165 hr
= ScriptLayout(sizeof(levels
[0]), levels
[i
], vistolog
, logtovis
);
2166 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2168 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2170 ok(expect_v2l
[i
][j
] == vistolog
[j
],
2171 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2172 i
, j
, levels
[i
][j
], j
, vistolog
[j
] );
2175 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2177 ok(expect_l2v
[i
][j
] == logtovis
[j
],
2178 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2179 i
, j
, levels
[i
][j
], j
, logtovis
[j
] );
2184 static BOOL CALLBACK
enum_proc(LGRPID group
, LCID lcid
, LPSTR locale
, LONG_PTR lparam
)
2187 SCRIPT_DIGITSUBSTITUTE sds
;
2192 if (!IsValidLocale(lcid
, LCID_INSTALLED
)) return TRUE
;
2194 memset(&sds
, 0, sizeof(sds
));
2195 memset(&sc
, 0, sizeof(sc
));
2196 memset(&ss
, 0, sizeof(ss
));
2198 lcid_old
= GetThreadLocale();
2199 if (!SetThreadLocale(lcid
)) return TRUE
;
2201 hr
= ScriptRecordDigitSubstitution(lcid
, &sds
);
2202 ok(hr
== S_OK
, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr
);
2204 hr
= ScriptApplyDigitSubstitution(&sds
, &sc
, &ss
);
2205 ok(hr
== S_OK
, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr
);
2207 SetThreadLocale(lcid_old
);
2211 static void test_digit_substitution(void)
2215 static const LGRPID groups
[] =
2217 LGRPID_WESTERN_EUROPE
,
2218 LGRPID_CENTRAL_EUROPE
,
2225 LGRPID_TRADITIONAL_CHINESE
,
2226 LGRPID_SIMPLIFIED_CHINESE
,
2236 static BOOL (WINAPI
* pEnumLanguageGroupLocalesA
)(LANGGROUPLOCALE_ENUMPROCA
,LGRPID
,DWORD
,LONG_PTR
);
2238 hKernel32
= GetModuleHandleA("kernel32.dll");
2239 pEnumLanguageGroupLocalesA
= (void*)GetProcAddress(hKernel32
, "EnumLanguageGroupLocalesA");
2241 if (!pEnumLanguageGroupLocalesA
)
2243 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
2247 for (i
= 0; i
< sizeof(groups
)/sizeof(groups
[0]); i
++)
2249 ret
= pEnumLanguageGroupLocalesA(enum_proc
, groups
[i
], 0, 0);
2250 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
2252 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
2256 ok(ret
, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
2260 static void test_ScriptGetProperties(void)
2262 const SCRIPT_PROPERTIES
**props
;
2266 hr
= ScriptGetProperties(NULL
, NULL
);
2267 ok(hr
== E_INVALIDARG
, "ScriptGetProperties succeeded\n");
2269 hr
= ScriptGetProperties(NULL
, &num
);
2270 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2272 hr
= ScriptGetProperties(&props
, NULL
);
2273 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2275 hr
= ScriptGetProperties(&props
, &num
);
2276 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2279 static void test_ScriptBreak(void)
2281 static const WCHAR test
[] = {' ','\r','\n',0};
2282 SCRIPT_ITEM items
[4];
2286 hr
= ScriptItemize(test
, 3, 4, NULL
, NULL
, items
, NULL
);
2287 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
2289 memset(&la
, 0, sizeof(la
));
2290 hr
= ScriptBreak(test
, 1, &items
[0].a
, &la
);
2291 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2293 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2294 ok(la
.fWhiteSpace
, "fWhiteSpace not set\n");
2295 ok(la
.fCharStop
, "fCharStop not set\n");
2296 ok(!la
.fWordStop
, "fWordStop set\n");
2297 ok(!la
.fInvalid
, "fInvalid set\n");
2298 ok(!la
.fReserved
, "fReserved set\n");
2300 memset(&la
, 0, sizeof(la
));
2301 hr
= ScriptBreak(test
+ 1, 1, &items
[1].a
, &la
);
2302 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2304 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2305 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2306 ok(la
.fCharStop
, "fCharStop not set\n");
2307 ok(!la
.fWordStop
, "fWordStop set\n");
2308 ok(!la
.fInvalid
, "fInvalid set\n");
2309 ok(!la
.fReserved
, "fReserved set\n");
2311 memset(&la
, 0, sizeof(la
));
2312 hr
= ScriptBreak(test
+ 2, 1, &items
[2].a
, &la
);
2313 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2315 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2316 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2317 ok(la
.fCharStop
, "fCharStop not set\n");
2318 ok(!la
.fWordStop
, "fWordStop set\n");
2319 ok(!la
.fInvalid
, "fInvalid set\n");
2320 ok(!la
.fReserved
, "fReserved set\n");
2323 static void test_newlines(void)
2325 static const WCHAR test1
[] = {'t','e','x','t','\r','t','e','x','t',0};
2326 static const WCHAR test2
[] = {'t','e','x','t','\n','t','e','x','t',0};
2327 static const WCHAR test3
[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
2328 static const WCHAR test4
[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
2329 static const WCHAR test5
[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
2330 SCRIPT_ITEM items
[5];
2335 hr
= ScriptItemize(test1
, lstrlenW(test1
), 5, NULL
, NULL
, items
, &count
);
2336 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2337 ok(count
== 3, "got %d expected 3\n", count
);
2340 hr
= ScriptItemize(test2
, lstrlenW(test2
), 5, NULL
, NULL
, items
, &count
);
2341 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2342 ok(count
== 3, "got %d expected 3\n", count
);
2345 hr
= ScriptItemize(test3
, lstrlenW(test3
), 5, NULL
, NULL
, items
, &count
);
2346 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2347 ok(count
== 4, "got %d expected 4\n", count
);
2350 hr
= ScriptItemize(test4
, lstrlenW(test4
), 5, NULL
, NULL
, items
, &count
);
2351 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2352 ok(count
== 4, "got %d expected 4\n", count
);
2355 hr
= ScriptItemize(test5
, lstrlenW(test5
), 5, NULL
, NULL
, items
, &count
);
2356 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2357 ok(count
== 4, "got %d expected 4\n", count
);
2367 unsigned short pwOutGlyphs
[256];
2369 /* We need a valid HDC to drive a lot of Script functions which requires the following *
2370 * to set up for the tests. */
2371 hwnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,
2374 ShowWindow(hwnd
, SW_SHOW
);
2377 hdc
= GetDC(hwnd
); /* We now have a hdc */
2378 ok( hdc
!= NULL
, "HDC failed to be created %p\n", hdc
);
2380 memset(&lf
, 0, sizeof(LOGFONTA
));
2381 lstrcpyA(lf
.lfFaceName
, "Tahoma");
2386 hfont
= SelectObject(hdc
, CreateFontIndirectA(&lf
));
2387 ok(hfont
!= NULL
, "SelectObject failed: %p\n", hfont
);
2389 test_ScriptItemize();
2390 test_ScriptItemIzeShapePlace(hdc
,pwOutGlyphs
);
2391 test_ScriptGetCMap(hdc
, pwOutGlyphs
);
2392 test_ScriptCacheGetHeight(hdc
);
2393 test_ScriptGetGlyphABCWidth(hdc
);
2394 test_ScriptShape(hdc
);
2395 test_ScriptShapeOpenType(hdc
);
2396 test_ScriptPlace(hdc
);
2398 test_ScriptGetFontProperties(hdc
);
2399 test_ScriptTextOut(hdc
);
2400 test_ScriptTextOut2(hdc
);
2401 test_ScriptTextOut3(hdc
);
2403 test_ScriptString(hdc
);
2404 test_ScriptStringXtoCP_CPtoX(hdc
);
2406 test_ScriptLayout();
2407 test_digit_substitution();
2408 test_ScriptGetProperties();
2412 ReleaseDC(hwnd
, hdc
);
2413 DestroyWindow(hwnd
);