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
{
45 typedef struct _shapeTest_char
{
47 SCRIPT_CHARPROP CharProp
;
50 typedef struct _shapeTest_glyph
{
52 SCRIPT_GLYPHPROP GlyphProp
;
55 /* Uniscribe 1.6 calls */
56 static HRESULT (WINAPI
*pScriptItemizeOpenType
)( const WCHAR
*pwcInChars
, int cInChars
, int cMaxItems
, const SCRIPT_CONTROL
*psControl
, const SCRIPT_STATE
*psState
, SCRIPT_ITEM
*pItems
, ULONG
*pScriptTags
, int *pcItems
);
58 static HRESULT (WINAPI
*pScriptShapeOpenType
)( HDC hdc
, SCRIPT_CACHE
*psc
, SCRIPT_ANALYSIS
*psa
, OPENTYPE_TAG tagScript
, OPENTYPE_TAG tagLangSys
, int *rcRangeChars
, TEXTRANGE_PROPERTIES
**rpRangeProperties
, int cRanges
, const WCHAR
*pwcChars
, int cChars
, int cMaxGlyphs
, WORD
*pwLogClust
, SCRIPT_CHARPROP
*pCharProps
, WORD
*pwOutGlyphs
, SCRIPT_GLYPHPROP
*pOutGlyphProps
, int *pcGlyphs
);
60 static DWORD (WINAPI
*pGetGlyphIndicesW
)(HDC hdc
, LPCWSTR lpstr
, INT count
, LPWORD pgi
, DWORD flags
);
62 static inline void _test_items_ok(LPCWSTR string
, DWORD cchString
,
63 SCRIPT_CONTROL
*Control
, SCRIPT_STATE
*State
,
64 DWORD nItems
, const itemTest
* items
, BOOL nItemsToDo
,
65 const INT nItemsBroken
[2])
69 SCRIPT_ITEM outpItems
[15];
70 ULONG tags
[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
72 if (pScriptItemizeOpenType
)
73 hr
= pScriptItemizeOpenType(string
, cchString
, 15, Control
, State
, outpItems
, tags
, &outnItems
);
75 hr
= ScriptItemize(string
, cchString
, 15, Control
, State
, outpItems
, &outnItems
);
77 winetest_ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
78 if (nItemsBroken
&& (broken(nItemsBroken
[0] == outnItems
) || broken(nItemsBroken
[1] == outnItems
)))
80 winetest_win_skip("This test broken on this platform\n");
84 todo_wine
winetest_ok(outnItems
== nItems
, "Wrong number of items\n");
86 winetest_ok(outnItems
== nItems
, "Wrong number of items\n");
87 for (x
= 0; x
<= outnItems
; x
++)
89 if (items
[x
].isBroken
&& broken(outpItems
[x
].iCharPos
== items
[x
].broken_value
[0]))
90 winetest_win_skip("This test broken on this platform\n");
91 else if (items
[x
].todo_flag
[0])
92 todo_wine
winetest_ok(outpItems
[x
].iCharPos
== items
[x
].iCharPos
, "%i:Wrong CharPos\n",x
);
94 winetest_ok(outpItems
[x
].iCharPos
== items
[x
].iCharPos
, "%i:Wrong CharPos (%i)\n",x
,outpItems
[x
].iCharPos
);
96 if (items
[x
].isBroken
&& broken(outpItems
[x
].a
.fRTL
== items
[x
].broken_value
[1]))
97 winetest_win_skip("This test broken on this platform\n");
98 else if (items
[x
].todo_flag
[1])
99 todo_wine
winetest_ok(outpItems
[x
].a
.fRTL
== items
[x
].fRTL
, "%i:Wrong fRTL\n",x
);
101 winetest_ok(outpItems
[x
].a
.fRTL
== items
[x
].fRTL
, "%i:Wrong fRTL(%i)\n",x
,outpItems
[x
].a
.fRTL
);
103 if (items
[x
].isBroken
&& broken(outpItems
[x
].a
.fLayoutRTL
== items
[x
].broken_value
[2]))
104 winetest_win_skip("This test broken on this platform\n");
105 else if (items
[x
].todo_flag
[2])
106 todo_wine
winetest_ok(outpItems
[x
].a
.fLayoutRTL
== items
[x
].fLayoutRTL
, "%i:Wrong fLayoutRTL\n",x
);
108 winetest_ok(outpItems
[x
].a
.fLayoutRTL
== items
[x
].fLayoutRTL
, "%i:Wrong fLayoutRTL(%i)\n",x
,outpItems
[x
].a
.fLayoutRTL
);
110 if (items
[x
].isBroken
&& broken(outpItems
[x
].a
.s
.uBidiLevel
== items
[x
].broken_value
[3]))
111 winetest_win_skip("This test broken on this platform\n");
112 else if (items
[x
].todo_flag
[3])
113 todo_wine
winetest_ok(outpItems
[x
].a
.s
.uBidiLevel
== items
[x
].uBidiLevel
, "%i:Wrong BidiLevel\n",x
);
115 winetest_ok(outpItems
[x
].a
.s
.uBidiLevel
== items
[x
].uBidiLevel
, "%i:Wrong BidiLevel(%i)\n",x
,outpItems
[x
].a
.s
.uBidiLevel
);
117 winetest_ok(outpItems
[x
].a
.eScript
!= SCRIPT_UNDEFINED
, "%i: Undefined script\n",x
);
118 if (pScriptItemizeOpenType
)
120 if (items
[x
].isBroken
&& broken(tags
[x
] == items
[x
].broken_value
[4]))
121 winetest_win_skip("This test broken on this platform\n");
122 else if (items
[x
].todo_flag
[4])
123 todo_wine
winetest_ok(tags
[x
] == items
[x
].scriptTag
,"%i:Incorrect Script Tag %x != %x\n",x
,tags
[x
],items
[x
].scriptTag
);
125 winetest_ok(tags
[x
] == items
[x
].scriptTag
,"%i:Incorrect Script Tag %x != %x\n",x
,tags
[x
],items
[x
].scriptTag
);
130 #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)
132 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
133 ( ( (ULONG)_x4 << 24 ) | \
134 ( (ULONG)_x3 << 16 ) | \
135 ( (ULONG)_x2 << 8 ) | \
138 #define latn_tag MS_MAKE_TAG('l','a','t','n')
139 #define arab_tag MS_MAKE_TAG('a','r','a','b')
140 #define thai_tag MS_MAKE_TAG('t','h','a','i')
141 #define hebr_tag MS_MAKE_TAG('h','e','b','r')
142 #define syrc_tag MS_MAKE_TAG('s','y','r','c')
143 #define deva_tag MS_MAKE_TAG('d','e','v','a')
144 #define beng_tag MS_MAKE_TAG('b','e','n','g')
145 #define guru_tag MS_MAKE_TAG('g','u','r','u')
146 #define gujr_tag MS_MAKE_TAG('g','u','j','r')
147 #define orya_tag MS_MAKE_TAG('o','r','y','a')
148 #define taml_tag MS_MAKE_TAG('t','a','m','l')
149 #define telu_tag MS_MAKE_TAG('t','e','l','u')
150 #define knda_tag MS_MAKE_TAG('k','n','d','a')
151 #define mlym_tag MS_MAKE_TAG('m','l','y','m')
152 #define mymr_tag MS_MAKE_TAG('m','y','m','r')
153 #define tale_tag MS_MAKE_TAG('t','a','l','e')
154 #define talu_tag MS_MAKE_TAG('t','a','l','u')
155 #define khmr_tag MS_MAKE_TAG('k','h','m','r')
156 #define hani_tag MS_MAKE_TAG('h','a','n','i')
157 #define bopo_tag MS_MAKE_TAG('b','o','p','o')
158 #define kana_tag MS_MAKE_TAG('k','a','n','a')
159 #define hang_tag MS_MAKE_TAG('h','a','n','g')
160 #define yi_tag MS_MAKE_TAG('y','i',' ',' ')
161 #define ethi_tag MS_MAKE_TAG('e','t','h','i')
162 #define mong_tag MS_MAKE_TAG('m','o','n','g')
163 #define tfng_tag MS_MAKE_TAG('t','f','n','g')
165 static void test_ScriptItemize( void )
167 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
168 static const itemTest t11
[2] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1}};
169 static const itemTest t12
[2] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
171 static const WCHAR test1b
[] = {' ', ' ', ' ', ' ',0};
172 static const itemTest t1b1
[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
173 static const itemTest t1b2
[2] = {{{0,0,0,0,0},0,1,1,1,0,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
175 static const WCHAR test1c
[] = {' ', ' ', ' ', '1', '2', ' ',0};
176 static const itemTest t1c1
[2] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
177 static const itemTest t1c2
[4] = {{{0,0,0,0,0},0,1,1,1,0,FALSE
},{{0,0,0,0,0},3,0,1,2,0,FALSE
},{{0,0,0,0,0},5,1,1,1,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
180 static const WCHAR test2
[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
181 static const itemTest t21
[7] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,0,FALSE
},{{0,0,0,0,0},6,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},13,0,0,0,0,FALSE
},{{0,0,0,0,0},15,0,0,0,0,FALSE
},{{0,0,0,0,0},16,0,0,0,-1,FALSE
}};
182 static const itemTest t22
[5] = {{{0,0,0,0,0},0,0,0,2,0,FALSE
},{{0,0,0,0,0},6,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},13,0,1,2,0,FALSE
},{{0,0,0,0,0},15,0,0,0,0,FALSE
},{{0,0,0,0,0},16,0,0,0,-1,FALSE
}};
183 static const itemTest t23
[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE
},{{0,0,0,0,0},6,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},13,0,1,2,0,FALSE
},{{0,0,0,0,0},15,1,1,1,0,FALSE
},{{0,0,0,0,0},16,0,0,0,-1,FALSE
}};
185 static const WCHAR test2b
[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
186 static const itemTest t2b1
[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},8,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
187 static const itemTest t2b2
[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,2,0,FALSE
},{{0,0,0,0,0},4,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
188 static const itemTest t2b3
[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
189 static const int b2
[2] = {4,4};
192 static const WCHAR test2c
[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
193 static const itemTest t2c1
[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,0,FALSE
},{{0,0,0,0,0},8,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
194 static const itemTest t2c2
[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},1,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,0,FALSE
},{{0,0,0,0,0},8,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
195 static const itemTest t2c3
[5] = {{{0,0,0,0,0},0,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},4,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},7,0,0,2,0,FALSE
},{{0,0,0,0,0},8,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
196 static const itemTest t2c4
[3] = {{{0,0,0,0,0},0,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},4,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
199 static const WCHAR test2d
[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
200 static const itemTest t2d1
[5] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
201 static const itemTest t2d2
[6] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},10,0,0,0,0,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
202 static const itemTest t2d3
[5] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,2,0,FALSE
},{{0,0,0,0,0},4,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
203 static const itemTest t2d4
[3] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},7,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},11,0,0,0,-1,FALSE
}};
206 static const WCHAR test3
[] =
207 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
208 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
209 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
210 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
212 static const itemTest t31
[2] = {{{0,0,0,0,0},0,0,0,0,thai_tag
,FALSE
},{{0,0,0,0,0},41,0,0,0,-1,FALSE
}};
213 static const itemTest t32
[2] = {{{0,0,0,0,0},0,0,0,2,thai_tag
,FALSE
},{{0,0,0,0,0},41,0,0,0,-1,FALSE
}};
215 static const WCHAR test4
[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
217 static const itemTest t41
[6] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},4,0,0,0,0,FALSE
},{{0,0,0,0,0},7,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},10,0,0,0,0,FALSE
},{{0,0,0,0,0},12,0,0,0,-1,FALSE
}};
218 static const itemTest t42
[5] = {{{0,0,0,0,0},0,0,1,2,0,FALSE
},{{0,0,0,0,0},6,1,1,1,0,FALSE
},{{0,0,0,0,0},7,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},10,0,0,2,0,FALSE
},{{0,0,0,0,0},12,0,0,0,-1,FALSE
}};
219 static const itemTest t43
[4] = {{{0,0,0,0,0},0,0,1,2,0,FALSE
},{{0,0,0,0,0},6,1,1,1,0,FALSE
},{{0,0,0,0,0},7,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},12,0,0,0,-1,FALSE
}};
220 static const int b43
[2] = {4,4};
223 static const WCHAR test5
[] =
224 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
225 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
226 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
227 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
228 static const itemTest t51
[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},38,0,0,0,-1,FALSE
}};
231 static const WCHAR test6
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
232 static const itemTest t61
[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,0,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
233 static const itemTest t62
[3] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},4,1,1,1,0,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
234 static const itemTest t63
[2] = {{{0,0,0,0,0},0,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
235 static const int b63
[2] = {2,2};
236 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};
237 static const itemTest t71
[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},9,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},19,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},29,0,0,0,-1,FALSE
}};
238 static const itemTest t72
[4] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},9,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},18,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},29,0,0,0,-1,FALSE
}};
239 static const itemTest t73
[4] = {{{0,0,0,0,0},0,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},8,1,1,1,hebr_tag
,FALSE
},{{0,0,0,0,0},19,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},29,0,0,0,-1,FALSE
}};
240 static const WCHAR test8
[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
241 static const itemTest t81
[2] = {{{0,0,0,0,0},0,1,1,1,arab_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
243 /* Syriac (Like Arabic )*/
244 static const WCHAR test9
[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
245 static const itemTest t91
[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,0,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
246 static const itemTest t92
[3] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
},{{0,0,0,0,0},4,1,1,1,0,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
247 static const itemTest t93
[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
248 static const int b93
[2] = {2,2};
250 static const WCHAR test10
[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
251 static const itemTest t101
[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
254 static const WCHAR test11
[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
255 static const itemTest t111
[2] = {{{0,0,0,0,0},0,0,0,0,deva_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
256 static const itemTest t112
[2] = {{{0,0,0,0,0},0,0,0,2,deva_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
259 static const WCHAR test12
[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
260 static const itemTest t121
[2] = {{{0,0,0,0,0},0,0,0,0,beng_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
261 static const itemTest t122
[2] = {{{0,0,0,0,0},0,0,0,2,beng_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
264 static const WCHAR test13
[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
265 static const itemTest t131
[2] = {{{0,0,0,0,0},0,0,0,0,guru_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
266 static const itemTest t132
[2] = {{{0,0,0,0,0},0,0,0,2,guru_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
269 static const WCHAR test14
[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
270 static const itemTest t141
[2] = {{{0,0,0,0,0},0,0,0,0,gujr_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
271 static const itemTest t142
[2] = {{{0,0,0,0,0},0,0,0,2,gujr_tag
,FALSE
},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
274 static const WCHAR test15
[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
275 static const itemTest t151
[2] = {{{0,0,0,0,0},0,0,0,0,orya_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
276 static const itemTest t152
[2] = {{{0,0,0,0,0},0,0,0,2,orya_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
279 static const WCHAR test16
[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
280 static const itemTest t161
[2] = {{{0,0,0,0,0},0,0,0,0,taml_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
281 static const itemTest t162
[2] = {{{0,0,0,0,0},0,0,0,2,taml_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
284 static const WCHAR test17
[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
285 static const itemTest t171
[2] = {{{0,0,0,0,0},0,0,0,0,telu_tag
,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
286 static const itemTest t172
[2] = {{{0,0,0,0,0},0,0,0,2,telu_tag
,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
289 static const WCHAR test18
[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
290 static const itemTest t181
[2] = {{{0,0,0,0,0},0,0,0,0,knda_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
291 static const itemTest t182
[2] = {{{0,0,0,0,0},0,0,0,2,knda_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
294 static const WCHAR test19
[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
295 static const itemTest t191
[2] = {{{0,0,0,0,0},0,0,0,0,mlym_tag
,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
296 static const itemTest t192
[2] = {{{0,0,0,0,0},0,0,0,2,mlym_tag
,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
299 static const WCHAR test20
[] = {0x0309,'a','b','c','d',0};
300 static const itemTest t201
[3] = {{{0,0,0,0,0},0,0,0,0,0x0,FALSE
},{{0,0,0,0,0},1,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
301 static const itemTest t202
[3] = {{{0,0,0,0,0},0,0,0,2,0,TRUE
,{-1,1,1,1,-1}},{{0,0,0,0,0},1,0,0,2,latn_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
303 static const WCHAR test21
[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
304 static const itemTest t211
[2] = {{{0,0,0,0,0},0,1,1,1,syrc_tag
,FALSE
},{{0,0,0,0,0},5,0,0,0,-1,FALSE
}};
306 /* Latin Punctuation */
307 static const WCHAR test22
[] = {'#','$',',','!','\"','*',0};
308 static const itemTest t221
[3] = {{{0,0,0,0,0},0,0,0,0,latn_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
309 static const itemTest t222
[3] = {{{0,0,0,0,0},0,1,1,1,latn_tag
,FALSE
},{{0,0,0,0,0},3,1,1,1,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
310 static const itemTest t223
[2] = {{{0,0,0,0,0},0,1,1,1,latn_tag
,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
311 static const int b222
[2] = {1,1};
312 static const int b223
[2] = {2,2};
315 static const WCHAR test23
[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
316 static const itemTest t231
[3] = {{{0,0,0,0,0},0,0,0,0,0,FALSE
},{{0,0,0,0,0},3,0,0,0,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
317 static const itemTest t232
[3] = {{{0,0,0,0,0},0,0,1,2,0,FALSE
},{{0,0,0,0,0},3,0,1,2,0,FALSE
},{{0,0,0,0,0},6,0,0,0,-1,FALSE
}};
320 static const WCHAR test24
[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
321 static const itemTest t241
[2] = {{{0,0,0,0,0},0,0,0,0,mymr_tag
,FALSE
},{{0,0,0,0,0},12,0,0,0,-1,FALSE
}};
322 static const itemTest t242
[2] = {{{0,0,0,0,0},0,0,0,2,mymr_tag
,TRUE
,{-1,1,1,1,-1}},{{0,0,0,0,0},12,0,0,0,-1,FALSE
}};
325 static const WCHAR test25
[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
326 static const itemTest t251
[2] = {{{0,0,0,0,0},0,0,0,0,tale_tag
,TRUE
,{-1,-1,-1,-1,latn_tag
}},{{0,0,0,0,0},10,0,0,0,-1,FALSE
}};
327 static const itemTest t252
[2] = {{{0,0,0,0,0},0,0,0,2,tale_tag
,TRUE
,{-1,1,1,1,latn_tag
}},{{0,0,0,0,0},10,0,0,0,-1,FALSE
}};
330 static const WCHAR test26
[] = {0x1992,0x19c4};
331 static const itemTest t261
[2] = {{{0,0,0,0,0},0,0,0,0,talu_tag
,TRUE
,{-1,-1,-1,-1,latn_tag
}},{{0,0,0,0,0},2,0,0,0,-1,FALSE
}};
332 static const itemTest t262
[2] = {{{0,0,0,0,0},0,0,0,2,talu_tag
,TRUE
,{-1,1,1,1,latn_tag
}},{{0,0,0,0,0},2,0,0,0,-1,FALSE
}};
335 static const WCHAR test27
[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
336 static const itemTest t271
[2] = {{{0,0,0,0,0},0,0,0,0,khmr_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
337 static const itemTest t272
[2] = {{{0,0,0,0,0},0,0,0,2,khmr_tag
,TRUE
,{-1,1,1,1,-1}},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
340 static const WCHAR test28
[] = {0x8bed,0x7d20,0x6587,0x5b57};
341 static const itemTest t281
[2] = {{{0,0,0,0,0},0,0,0,0,hani_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
342 static const itemTest t282
[2] = {{{0,0,0,0,0},0,0,0,2,hani_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
345 static const WCHAR test29
[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
346 static const itemTest t291
[3] = {{{0,0,0,0,0},0,0,0,0,hani_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,hani_tag
,FALSE
},{{0,0,0,0,0},10,0,0,0,-1,FALSE
}};
347 static const itemTest t292
[3] = {{{0,0,0,0,0},0,1,1,1,hani_tag
,FALSE
},{{0,0,0,0,0},4,0,0,2,hani_tag
,FALSE
},{{0,0,0,0,0},10,0,0,0,-1,FALSE
}};
350 static const WCHAR test30
[] = {0x3113,0x3128,0x3127,0x3123,0x3108,0x3128,0x310f,0x3120};
351 static const itemTest t301
[2] = {{{0,0,0,0,0},0,0,0,0,bopo_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
352 static const itemTest t302
[2] = {{{0,0,0,0,0},0,0,0,2,bopo_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
355 static const WCHAR test31
[] = {0x3072,0x3089,0x304b,0x306a,0x30ab,0x30bf,0x30ab,0x30ca};
356 static const itemTest t311
[2] = {{{0,0,0,0,0},0,0,0,0,kana_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
357 static const itemTest t312
[2] = {{{0,0,0,0,0},0,0,0,2,kana_tag
,FALSE
},{{0,0,0,0,0},8,0,0,0,-1,FALSE
}};
358 static const int b311
[2] = {2,2};
359 static const int b312
[2] = {2,2};
362 static const WCHAR test32
[] = {0xd55c,0xad6d,0xc5b4};
363 static const itemTest t321
[2] = {{{0,0,0,0,0},0,0,0,0,hang_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,-1,FALSE
}};
364 static const itemTest t322
[2] = {{{0,0,0,0,0},0,0,0,2,hang_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,-1,FALSE
}};
367 static const WCHAR test33
[] = {0xa188,0xa320,0xa071,0xa0b7};
368 static const itemTest t331
[2] = {{{0,0,0,0,0},0,0,0,0,yi_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
369 static const itemTest t332
[2] = {{{0,0,0,0,0},0,0,0,2,yi_tag
,FALSE
},{{0,0,0,0,0},4,0,0,0,-1,FALSE
}};
372 static const WCHAR test34
[] = {0x130d,0x12d5,0x12dd};
373 static const itemTest t341
[2] = {{{0,0,0,0,0},0,0,0,0,ethi_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,-1,FALSE
}};
374 static const itemTest t342
[2] = {{{0,0,0,0,0},0,0,0,2,ethi_tag
,FALSE
},{{0,0,0,0,0},3,0,0,0,-1,FALSE
}};
375 static const int b342
[2] = {2,2};
378 static const WCHAR test35
[] = {0x182e,0x1823,0x1829,0x182d,0x1823,0x182f,0x0020,0x182a,0x1822,0x1834,0x1822,0x182d,0x180c};
379 static const itemTest t351
[2] = {{{0,0,0,0,0},0,0,0,0,mong_tag
,FALSE
},{{0,0,0,0,0},13,0,0,0,-1,FALSE
}};
380 static const itemTest t352
[2] = {{{0,0,0,0,0},0,0,0,2,mong_tag
,TRUE
,{-1,1,1,1,-1}},{{0,0,0,0,0},13,0,0,0,-1,FALSE
}};
381 static const int b351
[2] = {2,2};
382 static const int b352
[2] = {2,3};
385 static const WCHAR test36
[] = {0x2d5c,0x2d49,0x2d3c,0x2d49,0x2d4f,0x2d30,0x2d56};
386 static const itemTest t361
[2] = {{{0,0,0,0,0},0,0,0,0,tfng_tag
,TRUE
,{-1,-1,-1,-1,latn_tag
}},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
387 static const itemTest t362
[2] = {{{0,0,0,0,0},0,0,0,2,tfng_tag
,TRUE
,{-1,1,1,1,latn_tag
}},{{0,0,0,0,0},7,0,0,0,-1,FALSE
}};
389 SCRIPT_ITEM items
[15];
390 SCRIPT_CONTROL Control
;
396 usp10
= LoadLibraryA("usp10.dll");
397 ok (usp10
!= 0,"Unable to LoadLibrary on usp10.dll\n");
398 pScriptItemizeOpenType
= (void*)GetProcAddress(usp10
, "ScriptItemizeOpenType");
399 pScriptShapeOpenType
= (void*)GetProcAddress(usp10
, "ScriptShapeOpenType");
400 pGetGlyphIndicesW
= (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
402 memset(&Control
, 0, sizeof(Control
));
403 memset(&State
, 0, sizeof(State
));
405 hr
= ScriptItemize(NULL
, 4, 10, &Control
, &State
, items
, NULL
);
406 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
408 hr
= ScriptItemize(test1
, 4, 10, &Control
, &State
, NULL
, NULL
);
409 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
411 hr
= ScriptItemize(test1
, 4, 1, &Control
, &State
, items
, NULL
);
412 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
414 hr
= ScriptItemize(test1
, 0, 10, NULL
, NULL
, items
, &nItems
);
415 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
417 test_items_ok(test1
,4,NULL
,NULL
,1,t11
,FALSE
,0);
418 test_items_ok(test1b
,4,NULL
,NULL
,1,t1b1
,FALSE
,0);
419 test_items_ok(test1c
,6,NULL
,NULL
,1,t1c1
,FALSE
,0);
420 test_items_ok(test2
,16,NULL
,NULL
,6,t21
,FALSE
,0);
421 test_items_ok(test2b
,11,NULL
,NULL
,4,t2b1
,FALSE
,0);
422 test_items_ok(test2c
,11,NULL
,NULL
,4,t2c1
,FALSE
,0);
423 test_items_ok(test2d
,11,NULL
,NULL
,4,t2d1
,FALSE
,0);
424 test_items_ok(test3
,41,NULL
,NULL
,1,t31
,FALSE
,0);
425 test_items_ok(test4
,12,NULL
,NULL
,5,t41
,FALSE
,0);
426 test_items_ok(test5
,38,NULL
,NULL
,1,t51
,FALSE
,0);
427 test_items_ok(test6
,5,NULL
,NULL
,2,t61
,FALSE
,0);
428 test_items_ok(test7
,29,NULL
,NULL
,3,t71
,FALSE
,0);
429 test_items_ok(test8
,4,NULL
,NULL
,1,t81
,FALSE
,0);
430 test_items_ok(test9
,5,NULL
,NULL
,2,t91
,FALSE
,0);
431 test_items_ok(test10
,4,NULL
,NULL
,1,t101
,FALSE
,0);
432 test_items_ok(test11
,8,NULL
,NULL
,1,t111
,FALSE
,0);
433 test_items_ok(test12
,5,NULL
,NULL
,1,t121
,FALSE
,0);
434 test_items_ok(test13
,7,NULL
,NULL
,1,t131
,FALSE
,0);
435 test_items_ok(test14
,7,NULL
,NULL
,1,t141
,FALSE
,0);
436 test_items_ok(test15
,5,NULL
,NULL
,1,t151
,FALSE
,0);
437 test_items_ok(test16
,5,NULL
,NULL
,1,t161
,FALSE
,0);
438 test_items_ok(test17
,6,NULL
,NULL
,1,t171
,FALSE
,0);
439 test_items_ok(test18
,5,NULL
,NULL
,1,t181
,FALSE
,0);
440 test_items_ok(test19
,6,NULL
,NULL
,1,t191
,FALSE
,0);
441 test_items_ok(test20
,5,NULL
,NULL
,2,t201
,FALSE
,0);
442 test_items_ok(test21
,5,NULL
,NULL
,1,t211
,FALSE
,0);
443 test_items_ok(test22
,6,NULL
,NULL
,2,t221
,FALSE
,0);
444 test_items_ok(test23
,6,NULL
,NULL
,2,t231
,FALSE
,0);
445 test_items_ok(test24
,12,NULL
,NULL
,1,t241
,FALSE
,0);
446 test_items_ok(test25
,10,NULL
,NULL
,1,t251
,FALSE
,0);
447 test_items_ok(test26
,2,NULL
,NULL
,1,t261
,FALSE
,0);
448 test_items_ok(test27
,8,NULL
,NULL
,1,t271
,FALSE
,0);
449 test_items_ok(test28
,4,NULL
,NULL
,1,t281
,FALSE
,0);
450 test_items_ok(test29
,10,NULL
,NULL
,2,t291
,FALSE
,0);
451 test_items_ok(test30
,8,NULL
,NULL
,1,t301
,FALSE
,0);
452 test_items_ok(test31
,8,NULL
,NULL
,1,t311
,FALSE
,b311
);
453 test_items_ok(test32
,3,NULL
,NULL
,1,t321
,FALSE
,0);
454 test_items_ok(test33
,4,NULL
,NULL
,1,t331
,FALSE
,0);
455 test_items_ok(test34
,3,NULL
,NULL
,1,t341
,FALSE
,0);
456 test_items_ok(test35
,13,NULL
,NULL
,1,t351
,FALSE
,b351
);
457 test_items_ok(test36
,7,NULL
,NULL
,1,t361
,FALSE
,0);
459 State
.uBidiLevel
= 0;
460 test_items_ok(test1
,4,&Control
,&State
,1,t11
,FALSE
,0);
461 test_items_ok(test1b
,4,&Control
,&State
,1,t1b1
,FALSE
,0);
462 test_items_ok(test1c
,6,&Control
,&State
,1,t1c1
,FALSE
,0);
463 test_items_ok(test2
,16,&Control
,&State
,4,t22
,FALSE
,0);
464 test_items_ok(test2b
,11,&Control
,&State
,4,t2b1
,FALSE
,0);
465 test_items_ok(test2c
,11,&Control
,&State
,5,t2c2
,FALSE
,0);
466 test_items_ok(test2d
,11,&Control
,&State
,5,t2d2
,FALSE
,0);
467 test_items_ok(test3
,41,&Control
,&State
,1,t31
,FALSE
,0);
468 test_items_ok(test4
,12,&Control
,&State
,5,t41
,FALSE
,0);
469 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
470 test_items_ok(test6
,5,&Control
,&State
,2,t61
,FALSE
,0);
471 test_items_ok(test7
,29,&Control
,&State
,3,t72
,FALSE
,0);
472 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
473 test_items_ok(test9
,5,&Control
,&State
,2,t91
,FALSE
,0);
474 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
475 test_items_ok(test11
,8,&Control
,&State
,1,t111
,FALSE
,0);
476 test_items_ok(test12
,5,&Control
,&State
,1,t121
,FALSE
,0);
477 test_items_ok(test13
,7,&Control
,&State
,1,t131
,FALSE
,0);
478 test_items_ok(test14
,7,&Control
,&State
,1,t141
,FALSE
,0);
479 test_items_ok(test15
,5,&Control
,&State
,1,t151
,FALSE
,0);
480 test_items_ok(test16
,5,&Control
,&State
,1,t161
,FALSE
,0);
481 test_items_ok(test17
,6,&Control
,&State
,1,t171
,FALSE
,0);
482 test_items_ok(test18
,5,&Control
,&State
,1,t181
,FALSE
,0);
483 test_items_ok(test19
,6,&Control
,&State
,1,t191
,FALSE
,0);
484 test_items_ok(test20
,5,&Control
,&State
,2,t201
,FALSE
,0);
485 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
486 test_items_ok(test22
,6,&Control
,&State
,2,t221
,FALSE
,0);
487 test_items_ok(test23
,6,&Control
,&State
,2,t231
,FALSE
,0);
488 test_items_ok(test24
,12,&Control
,&State
,1,t241
,FALSE
,0);
489 test_items_ok(test25
,10,&Control
,&State
,1,t251
,FALSE
,0);
490 test_items_ok(test26
,2,&Control
,&State
,1,t261
,FALSE
,0);
491 test_items_ok(test27
,8,&Control
,&State
,1,t271
,FALSE
,0);
492 test_items_ok(test28
,4,&Control
,&State
,1,t281
,FALSE
,0);
493 test_items_ok(test29
,10,&Control
,&State
,2,t291
,FALSE
,0);
494 test_items_ok(test30
,8,&Control
,&State
,1,t301
,FALSE
,0);
495 test_items_ok(test31
,8,&Control
,&State
,1,t311
,FALSE
,b311
);
496 test_items_ok(test32
,3,&Control
,&State
,1,t321
,FALSE
,0);
497 test_items_ok(test33
,4,&Control
,&State
,1,t331
,FALSE
,0);
498 test_items_ok(test34
,3,&Control
,&State
,1,t341
,FALSE
,0);
499 test_items_ok(test35
,13,&Control
,&State
,1,t351
,FALSE
,b351
);
500 test_items_ok(test36
,7,&Control
,&State
,1,t361
,FALSE
,0);
502 State
.uBidiLevel
= 1;
503 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
504 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
505 test_items_ok(test1c
,6,&Control
,&State
,3,t1c2
,FALSE
,0);
506 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
507 test_items_ok(test2b
,11,&Control
,&State
,4,t2b2
,FALSE
,0);
508 test_items_ok(test2c
,11,&Control
,&State
,4,t2c3
,FALSE
,0);
509 test_items_ok(test2d
,11,&Control
,&State
,4,t2d3
,FALSE
,0);
510 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
511 test_items_ok(test4
,12,&Control
,&State
,4,t42
,FALSE
,0);
512 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
513 test_items_ok(test6
,5,&Control
,&State
,2,t62
,FALSE
,0);
514 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
515 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
516 test_items_ok(test9
,5,&Control
,&State
,2,t92
,FALSE
,0);
517 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
518 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
519 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
520 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
521 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
522 test_items_ok(test15
,5,&Control
,&State
,1,t152
,FALSE
,0);
523 test_items_ok(test16
,5,&Control
,&State
,1,t162
,FALSE
,0);
524 test_items_ok(test17
,6,&Control
,&State
,1,t172
,FALSE
,0);
525 test_items_ok(test18
,5,&Control
,&State
,1,t182
,FALSE
,0);
526 test_items_ok(test19
,6,&Control
,&State
,1,t192
,FALSE
,0);
527 test_items_ok(test20
,5,&Control
,&State
,2,t202
,FALSE
,0);
528 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
529 test_items_ok(test22
,6,&Control
,&State
,2,t222
,FALSE
,b222
);
530 test_items_ok(test23
,6,&Control
,&State
,2,t232
,FALSE
,0);
531 test_items_ok(test24
,12,&Control
,&State
,1,t242
,FALSE
,0);
532 test_items_ok(test25
,10,&Control
,&State
,1,t252
,FALSE
,0);
533 test_items_ok(test26
,2,&Control
,&State
,1,t262
,FALSE
,0);
534 test_items_ok(test27
,8,&Control
,&State
,1,t272
,FALSE
,0);
535 test_items_ok(test28
,4,&Control
,&State
,1,t282
,FALSE
,0);
536 test_items_ok(test29
,10,&Control
,&State
,2,t292
,FALSE
,0);
537 test_items_ok(test30
,8,&Control
,&State
,1,t302
,FALSE
,0);
538 test_items_ok(test31
,8,&Control
,&State
,1,t312
,FALSE
,b312
);
539 test_items_ok(test32
,3,&Control
,&State
,1,t322
,FALSE
,0);
540 test_items_ok(test33
,4,&Control
,&State
,1,t332
,FALSE
,0);
541 test_items_ok(test34
,3,&Control
,&State
,1,t342
,FALSE
,b342
);
542 test_items_ok(test35
,13,&Control
,&State
,1,t352
,FALSE
,b352
);
543 test_items_ok(test36
,7,&Control
,&State
,1,t362
,FALSE
,0);
545 State
.uBidiLevel
= 1;
546 Control
.fMergeNeutralItems
= TRUE
;
547 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
548 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
549 test_items_ok(test1c
,6,&Control
,&State
,3,t1c2
,FALSE
,0);
550 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
551 test_items_ok(test2b
,11,&Control
,&State
,2,t2b3
,FALSE
,b2
);
552 test_items_ok(test2c
,11,&Control
,&State
,2,t2c4
,FALSE
,b2
);
553 test_items_ok(test2d
,11,&Control
,&State
,2,t2d4
,FALSE
,b2
);
554 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
555 test_items_ok(test4
,12,&Control
,&State
,3,t43
,FALSE
,b43
);
556 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
557 test_items_ok(test6
,5,&Control
,&State
,1,t63
,FALSE
,b63
);
558 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
559 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
560 test_items_ok(test9
,5,&Control
,&State
,1,t93
,FALSE
,b93
);
561 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
562 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
563 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
564 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
565 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
566 test_items_ok(test15
,5,&Control
,&State
,1,t152
,FALSE
,0);
567 test_items_ok(test16
,5,&Control
,&State
,1,t162
,FALSE
,0);
568 test_items_ok(test17
,6,&Control
,&State
,1,t172
,FALSE
,0);
569 test_items_ok(test18
,5,&Control
,&State
,1,t182
,FALSE
,0);
570 test_items_ok(test19
,6,&Control
,&State
,1,t192
,FALSE
,0);
571 test_items_ok(test20
,5,&Control
,&State
,2,t202
,FALSE
,0);
572 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
573 test_items_ok(test22
,6,&Control
,&State
,1,t223
,FALSE
,b223
);
574 test_items_ok(test23
,6,&Control
,&State
,2,t232
,FALSE
,0);
575 test_items_ok(test24
,12,&Control
,&State
,1,t242
,FALSE
,0);
576 test_items_ok(test25
,10,&Control
,&State
,1,t252
,FALSE
,0);
577 test_items_ok(test26
,2,&Control
,&State
,1,t262
,FALSE
,0);
578 test_items_ok(test27
,8,&Control
,&State
,1,t272
,FALSE
,0);
579 test_items_ok(test28
,4,&Control
,&State
,1,t282
,FALSE
,0);
580 test_items_ok(test29
,10,&Control
,&State
,2,t292
,FALSE
,0);
581 test_items_ok(test30
,8,&Control
,&State
,1,t302
,FALSE
,0);
582 test_items_ok(test31
,8,&Control
,&State
,1,t312
,FALSE
,b312
);
583 test_items_ok(test32
,3,&Control
,&State
,1,t322
,FALSE
,0);
584 test_items_ok(test33
,4,&Control
,&State
,1,t332
,FALSE
,0);
585 test_items_ok(test34
,3,&Control
,&State
,1,t342
,FALSE
,b342
);
586 test_items_ok(test35
,13,&Control
,&State
,1,t352
,FALSE
,b352
);
587 test_items_ok(test36
,7,&Control
,&State
,1,t362
,FALSE
,0);
590 static inline void _test_shape_ok(int valid
, HDC hdc
, LPCWSTR string
,
591 DWORD cchString
, SCRIPT_CONTROL
*Control
,
592 SCRIPT_STATE
*State
, DWORD item
, DWORD nGlyphs
,
593 const shapeTest_char
* charItems
,
594 const shapeTest_glyph
* glyphItems
)
597 int x
, outnItems
=0, outnGlyphs
=0;
598 SCRIPT_ITEM outpItems
[15];
599 SCRIPT_CACHE sc
= NULL
;
602 int maxGlyphs
= cchString
* 1.5;
603 SCRIPT_GLYPHPROP
*glyphProp
;
604 SCRIPT_CHARPROP
*charProp
;
607 hr
= pScriptItemizeOpenType(string
, cchString
, 15, Control
, State
, outpItems
, tags
, &outnItems
);
608 if (hr
== USP_E_SCRIPT_NOT_IN_FONT
)
611 winetest_win_skip("Select font does not support script\n");
613 winetest_trace("Select font does not support script\n");
617 winetest_ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
619 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
622 if (outnItems
<= item
)
625 winetest_win_skip("Did not get enough items\n");
627 winetest_trace("Did not get enough items\n");
631 logclust
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * cchString
);
632 memset(logclust
,'a',sizeof(WORD
) * cchString
);
633 charProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP
) * cchString
);
634 memset(charProp
,'a',sizeof(SCRIPT_CHARPROP
) * cchString
);
635 glyphs
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * maxGlyphs
);
636 memset(glyphs
,'a',sizeof(WORD
) * cchString
);
637 glyphProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP
) * maxGlyphs
);
638 memset(glyphProp
,'a',sizeof(SCRIPT_GLYPHPROP
) * cchString
);
640 hr
= pScriptShapeOpenType(hdc
, &sc
, &outpItems
[item
].a
, tags
[item
], 0x00000000, NULL
, NULL
, 0, string
, cchString
, maxGlyphs
, logclust
, charProp
, glyphs
, glyphProp
, &outnGlyphs
);
642 winetest_ok(hr
== S_OK
, "ScriptShapeOpenType failed (%x)\n",hr
);
644 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr
);
648 for (x
= 0; x
< cchString
; x
++)
651 winetest_ok(logclust
[x
] == charItems
[x
].wLogClust
, "%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
652 else if (logclust
[x
] != charItems
[x
].wLogClust
)
653 winetest_trace("%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
655 winetest_ok(charProp
[x
].fCanGlyphAlone
== charItems
[x
].CharProp
.fCanGlyphAlone
, "%i: invalid fCanGlyphAlone\n",x
);
656 else if (charProp
[x
].fCanGlyphAlone
!= charItems
[x
].CharProp
.fCanGlyphAlone
)
657 winetest_trace("%i: invalid fCanGlyphAlone\n",x
);
661 winetest_ok(nGlyphs
== outnGlyphs
, "got incorrect number of glyphs (%i)\n",outnGlyphs
);
662 else if (nGlyphs
!= outnGlyphs
)
663 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs
);
664 for (x
= 0; x
< outnGlyphs
; x
++)
666 if (glyphItems
[x
].Glyph
)
669 winetest_ok(glyphs
[x
]!=0, "%i: Glyph not present when it should be\n",x
);
670 else if (glyphs
[x
]==0)
671 winetest_trace("%i: Glyph not present when it should be\n",x
);
676 winetest_ok(glyphs
[x
]==0, "%i: Glyph present when it should not be\n",x
);
677 else if (glyphs
[x
]!=0)
678 winetest_trace("%i: Glyph present when it should not be\n",x
);
681 winetest_ok(glyphProp
[x
].sva
.uJustification
== glyphItems
[x
].GlyphProp
.sva
.uJustification
, "%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
682 else if (glyphProp
[x
].sva
.uJustification
!= glyphItems
[x
].GlyphProp
.sva
.uJustification
)
683 winetest_trace("%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
685 winetest_ok(glyphProp
[x
].sva
.fClusterStart
== glyphItems
[x
].GlyphProp
.sva
.fClusterStart
, "%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
686 else if (glyphProp
[x
].sva
.fClusterStart
!= glyphItems
[x
].GlyphProp
.sva
.fClusterStart
)
687 winetest_trace("%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
689 winetest_ok(glyphProp
[x
].sva
.fDiacritic
== glyphItems
[x
].GlyphProp
.sva
.fDiacritic
, "%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
690 else if (glyphProp
[x
].sva
.fDiacritic
!= glyphItems
[x
].GlyphProp
.sva
.fDiacritic
)
691 winetest_trace("%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
693 winetest_ok(glyphProp
[x
].sva
.fZeroWidth
== glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
, "%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
694 else if (glyphProp
[x
].sva
.fZeroWidth
!= glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
)
695 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
698 HeapFree(GetProcessHeap(),0,logclust
);
699 HeapFree(GetProcessHeap(),0,charProp
);
700 HeapFree(GetProcessHeap(),0,glyphs
);
701 HeapFree(GetProcessHeap(),0,glyphProp
);
702 ScriptFreeCache(&sc
);
705 #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)
707 #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)
709 typedef struct tagRangeP
{
714 static int CALLBACK
enumFontProc( const LOGFONT
*lpelfe
, const TEXTMETRIC
*lpntme
,
715 DWORD FontType
, LPARAM lParam
)
717 NEWTEXTMETRICEX
*ntme
= (NEWTEXTMETRICEX
*)lpntme
;
718 fontEnumParam
*rp
= (fontEnumParam
*) lParam
;
723 if (FontType
!= TRUETYPE_FONTTYPE
)
727 while (i
> sizeof(DWORD
)*8)
730 i
-= (sizeof(DWORD
)*8);
737 if (ntme
->ntmFontSig
.fsUsb
[idx
] & mask
)
739 memcpy(&(rp
->lf
),lpelfe
,sizeof(LOGFONT
));
745 static int _find_font_for_range(HDC hdc
, const CHAR
*recommended
, BYTE range
, const WCHAR check
, HFONT
*hfont
, HFONT
*origFont
)
748 fontEnumParam lParam
;
750 lParam
.range
= range
;
751 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
756 lstrcpyA(lParam
.lf
.lfFaceName
, recommended
);
757 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0))
759 *hfont
= CreateFontIndirectA(&lParam
.lf
);
762 winetest_trace("using font %s\n",lParam
.lf
.lfFaceName
);
770 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
771 lParam
.lf
.lfCharSet
= DEFAULT_CHARSET
;
773 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0) && lParam
.lf
.lfFaceName
[0])
775 *hfont
= CreateFontIndirectA(&lParam
.lf
);
777 winetest_trace("trying font %s: failures will only be warnings\n",lParam
.lf
.lfFaceName
);
785 *origFont
= SelectObject(hdc
,*hfont
);
786 if (pGetGlyphIndicesW
&& (pGetGlyphIndicesW(hdc
, &check
, 1, &glyph
, 0) == GDI_ERROR
|| glyph
==0))
788 winetest_trace(" Font fails to contain required glyphs\n");
789 SelectObject(hdc
,*origFont
);
790 DeleteObject(*hfont
);
798 winetest_trace("Failed to find usable font\n");
803 #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)
805 static void test_ScriptShapeOpenType(HDC hdc
)
808 SCRIPT_CACHE sc
= NULL
;
809 WORD glyphs
[4], logclust
[4];
810 SCRIPT_GLYPHPROP glyphProp
[4];
811 SCRIPT_ITEM items
[2];
813 SCRIPT_CONTROL Control
;
816 HFONT hfont
, hfont_orig
;
819 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
820 static const shapeTest_char t1_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
821 static const shapeTest_glyph t1_g
[] = {
822 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
823 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
824 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
825 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
827 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
828 static const shapeTest_char t2_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
829 static const shapeTest_glyph t2_g
[] = {
830 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
831 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
832 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
833 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
836 static const WCHAR test_hebrew
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
837 static const shapeTest_char hebrew_c
[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
838 static const shapeTest_glyph hebrew_g
[] = {
839 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
840 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
841 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
842 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
845 static const WCHAR test_arabic
[] = {0x0633,0x0644,0x0627,0x0645,0};
846 static const shapeTest_char arabic_c
[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
847 static const shapeTest_glyph arabic_g
[] = {
848 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
849 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL
,1,0,0,0,0},0}},
850 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN
,1,0,0,0,0},0}} };
853 static const WCHAR test_thai
[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
854 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}}};
855 static const shapeTest_glyph thai_g
[] = {
856 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
857 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
858 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
859 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
860 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
861 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
862 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
863 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
864 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
865 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}}};
868 static const WCHAR test_syriac
[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
869 static const shapeTest_char syriac_c
[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
870 static const shapeTest_glyph syriac_g
[] = {
871 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
872 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
873 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
874 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
875 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
876 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
879 static const WCHAR test_thaana
[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
880 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}}};
881 static const shapeTest_glyph thaana_g
[] = {
882 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
883 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
884 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
885 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
886 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
887 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
888 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
889 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
890 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
891 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
892 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
893 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
894 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
897 static const WCHAR test_phagspa
[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
898 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}}};
899 static const shapeTest_glyph phagspa_g
[] = {
900 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
901 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
902 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
903 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
904 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
905 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
906 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
907 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
908 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
909 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
910 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
913 static const WCHAR test_lao
[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
914 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}}};
915 static const shapeTest_glyph lao_g
[] = {
916 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
917 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
918 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
919 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
920 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
921 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
922 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
923 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
924 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
927 static const WCHAR test_tibetan
[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
928 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}}};
929 static const shapeTest_glyph tibetan_g
[] = {
930 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
931 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
932 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
933 {1,{{SCRIPT_JUSTIFY_BLANK
,1,0,0,0,0},0}},
934 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
935 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
936 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
937 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
938 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
939 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
940 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
941 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
942 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
943 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
944 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
945 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
946 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
949 static const WCHAR test_devanagari
[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
950 static const shapeTest_char devanagari_c
[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{6,{0,0}},{6,{0,0}}};
951 static const shapeTest_glyph devanagari_g
[] = {
952 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
953 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
954 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
955 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
956 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
957 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
958 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
959 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
962 static const WCHAR test_bengali
[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
963 static const shapeTest_char bengali_c
[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
964 static const shapeTest_glyph bengali_g
[] = {
965 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
966 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
967 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
968 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
969 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
972 static const WCHAR test_gurmukhi
[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
973 static const shapeTest_char gurmukhi_c
[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{5,{0,0}}};
974 static const shapeTest_glyph gurmukhi_g
[] = {
975 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
976 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
977 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
978 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
979 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
980 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
981 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
984 static const WCHAR test_gujarati
[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
985 static const shapeTest_char gujarati_c
[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{3,{0,0}},{3,{0,0}},{5,{0,0}},{5,{0,0}}};
986 static const shapeTest_glyph gujarati_g
[] = {
987 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
988 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
989 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
990 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
991 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
992 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
993 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
996 static const WCHAR test_oriya
[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
997 static const shapeTest_char oriya_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
998 static const shapeTest_glyph oriya_g
[] = {
999 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1000 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1001 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1002 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
1005 static const WCHAR test_tamil
[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
1006 static const shapeTest_char tamil_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
1007 static const shapeTest_glyph tamil_g
[] = {
1008 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1009 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1010 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1011 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
1014 static const WCHAR test_telugu
[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
1015 static const shapeTest_char telugu_c
[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1016 static const shapeTest_glyph telugu_g
[] = {
1017 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1018 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1019 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1020 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1021 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1022 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
1025 static const WCHAR test_malayalam
[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
1026 static const shapeTest_char malayalam_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
1027 static const shapeTest_glyph malayalam_g
[] = {
1028 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1029 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1030 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1031 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1032 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1033 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
1036 static const WCHAR test_kannada
[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
1037 static const shapeTest_char kannada_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
1038 static const shapeTest_glyph kannada_g
[] = {
1039 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1040 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1041 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
1042 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
1043 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
1045 if (!pScriptItemizeOpenType
|| !pScriptShapeOpenType
)
1047 win_skip("ScriptShapeOpenType not available on this platform\n");
1051 memset(&Control
, 0 , sizeof(Control
));
1052 memset(&State
, 0 , sizeof(State
));
1054 hr
= pScriptItemizeOpenType(test1
, 4, 2, &Control
, &State
, items
, tags
, &outnItems
);
1055 ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
1056 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1058 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, NULL
, &nb
);
1059 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
1061 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, NULL
);
1062 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
1064 hr
= pScriptShapeOpenType(NULL
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
1065 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr
);
1067 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
1068 ok( hr
== E_INVALIDARG
,
1069 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1070 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, logclust
, NULL
, glyphs
, glyphProp
, &nb
);
1071 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
1073 ScriptFreeCache(&sc
);
1075 test_shape_ok(hdc
, test1
, 4, &Control
, &State
, 0, 4, t1_c
, t1_g
);
1076 test_shape_ok(hdc
, test2
, 4, &Control
, &State
, 1, 4, t2_c
, t2_g
);
1078 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 11, test_hebrew
[0], &hfont
, &hfont_orig
);
1081 test_shape_ok_valid(test_valid
, hdc
, test_hebrew
, 4, &Control
, &State
, 0, 4, hebrew_c
, hebrew_g
);
1082 SelectObject(hdc
, hfont_orig
);
1083 DeleteObject(hfont
);
1086 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 13, test_arabic
[0], &hfont
, &hfont_orig
);
1089 test_shape_ok_valid(test_valid
, hdc
, test_arabic
, 4, &Control
, &State
, 0, 3, arabic_c
, arabic_g
);
1090 SelectObject(hdc
, hfont_orig
);
1091 DeleteObject(hfont
);
1094 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 24, test_thai
[0], &hfont
, &hfont_orig
);
1097 test_shape_ok_valid(test_valid
, hdc
, test_thai
, 10, &Control
, &State
, 0, 10, thai_c
, thai_g
);
1098 SelectObject(hdc
, hfont_orig
);
1099 DeleteObject(hfont
);
1102 test_valid
= find_font_for_range(hdc
, "Estrangelo Edessa", 71, test_syriac
[0], &hfont
, &hfont_orig
);
1105 test_shape_ok_valid(test_valid
, hdc
, test_syriac
, 6, &Control
, &State
, 0, 6, syriac_c
, syriac_g
);
1106 SelectObject(hdc
, hfont_orig
);
1107 DeleteObject(hfont
);
1110 test_valid
= find_font_for_range(hdc
, "MV Boli", 72, test_thaana
[0], &hfont
, &hfont_orig
);
1113 test_shape_ok_valid(test_valid
, hdc
, test_thaana
, 13, &Control
, &State
, 0, 13, thaana_c
, thaana_g
);
1114 SelectObject(hdc
, hfont_orig
);
1115 DeleteObject(hfont
);
1118 test_valid
= find_font_for_range(hdc
, "Microsoft PhagsPa", 53, test_phagspa
[0], &hfont
, &hfont_orig
);
1121 test_shape_ok_valid(test_valid
, hdc
, test_phagspa
, 11, &Control
, &State
, 0, 11, phagspa_c
, phagspa_g
);
1122 SelectObject(hdc
, hfont_orig
);
1123 DeleteObject(hfont
);
1126 test_valid
= find_font_for_range(hdc
, "DokChampa", 25, test_lao
[0], &hfont
, &hfont_orig
);
1129 test_shape_ok_valid(test_valid
, hdc
, test_lao
, 9, &Control
, &State
, 0, 9, lao_c
, lao_g
);
1130 SelectObject(hdc
, hfont_orig
);
1131 DeleteObject(hfont
);
1134 test_valid
= find_font_for_range(hdc
, "Microsoft Himalaya", 70, test_tibetan
[0], &hfont
, &hfont_orig
);
1137 test_shape_ok_valid(test_valid
, hdc
, test_tibetan
, 17, &Control
, &State
, 0, 17, tibetan_c
, tibetan_g
);
1138 SelectObject(hdc
, hfont_orig
);
1139 DeleteObject(hfont
);
1142 test_valid
= find_font_for_range(hdc
, "Mangal", 15, test_devanagari
[0], &hfont
, &hfont_orig
);
1145 test_shape_ok_valid(test_valid
, hdc
, test_devanagari
, 8, &Control
, &State
, 0, 8, devanagari_c
, devanagari_g
);
1146 SelectObject(hdc
, hfont_orig
);
1147 DeleteObject(hfont
);
1150 test_valid
= find_font_for_range(hdc
, "Vrinda", 16, test_bengali
[0], &hfont
, &hfont_orig
);
1153 test_shape_ok_valid(test_valid
, hdc
, test_bengali
, 5, &Control
, &State
, 0, 5, bengali_c
, bengali_g
);
1154 SelectObject(hdc
, hfont_orig
);
1155 DeleteObject(hfont
);
1158 test_valid
= find_font_for_range(hdc
, "Raavi", 17, test_gurmukhi
[0], &hfont
, &hfont_orig
);
1161 test_shape_ok_valid(test_valid
, hdc
, test_gurmukhi
, 7, &Control
, &State
, 0, 7, gurmukhi_c
, gurmukhi_g
);
1162 SelectObject(hdc
, hfont_orig
);
1163 DeleteObject(hfont
);
1166 test_valid
= find_font_for_range(hdc
, "Shruti", 18, test_gujarati
[0], &hfont
, &hfont_orig
);
1169 test_shape_ok_valid(test_valid
, hdc
, test_gujarati
, 7, &Control
, &State
, 0, 7, gujarati_c
, gujarati_g
);
1170 SelectObject(hdc
, hfont_orig
);
1171 DeleteObject(hfont
);
1174 test_valid
= find_font_for_range(hdc
, "Kalinga", 19, test_oriya
[0], &hfont
, &hfont_orig
);
1177 test_shape_ok_valid(test_valid
, hdc
, test_oriya
, 5, &Control
, &State
, 0, 4, oriya_c
, oriya_g
);
1178 SelectObject(hdc
, hfont_orig
);
1179 DeleteObject(hfont
);
1182 test_valid
= find_font_for_range(hdc
, "Latha", 20, test_tamil
[0], &hfont
, &hfont_orig
);
1185 test_shape_ok_valid(test_valid
, hdc
, test_tamil
, 5, &Control
, &State
, 0, 4, tamil_c
, tamil_g
);
1186 SelectObject(hdc
, hfont_orig
);
1187 DeleteObject(hfont
);
1190 test_valid
= find_font_for_range(hdc
, "Gautami", 21, test_telugu
[0], &hfont
, &hfont_orig
);
1193 test_shape_ok_valid(test_valid
, hdc
, test_telugu
, 6, &Control
, &State
, 0, 6, telugu_c
, telugu_g
);
1194 SelectObject(hdc
, hfont_orig
);
1195 DeleteObject(hfont
);
1198 test_valid
= find_font_for_range(hdc
, "Kartika", 23, test_malayalam
[0], &hfont
, &hfont_orig
);
1201 test_shape_ok_valid(test_valid
, hdc
, test_malayalam
, 6, &Control
, &State
, 0, 6, malayalam_c
, malayalam_g
);
1202 SelectObject(hdc
, hfont_orig
);
1203 DeleteObject(hfont
);
1206 test_valid
= find_font_for_range(hdc
, "Tunga", 22, test_kannada
[0], &hfont
, &hfont_orig
);
1209 test_shape_ok_valid(test_valid
, hdc
, test_kannada
, 5, &Control
, &State
, 0, 4, kannada_c
, kannada_g
);
1210 SelectObject(hdc
, hfont_orig
);
1211 DeleteObject(hfont
);
1215 static void test_ScriptShape(HDC hdc
)
1217 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
1218 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
1220 SCRIPT_CACHE sc
= NULL
;
1221 WORD glyphs
[4], glyphs2
[4], logclust
[4];
1222 SCRIPT_VISATTR attrs
[4];
1223 SCRIPT_ITEM items
[2];
1226 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
1227 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
1228 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1230 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, NULL
, &nb
);
1231 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
1233 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, NULL
);
1234 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
1236 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
1237 ok(hr
== E_PENDING
, "ScriptShape should return E_PENDING not %08x\n", hr
);
1239 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
1240 ok(broken(hr
== S_OK
) ||
1241 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1242 hr
== E_FAIL
, /* WIN7 */
1243 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1244 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1246 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1247 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1248 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1251 memset(glyphs
,-1,sizeof(glyphs
));
1252 memset(logclust
,-1,sizeof(logclust
));
1253 memset(attrs
,-1,sizeof(attrs
));
1254 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1255 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1256 ok(nb
== 4, "Wrong number of items\n");
1257 ok(logclust
[0] == 0, "clusters out of order\n");
1258 ok(logclust
[1] == 1, "clusters out of order\n");
1259 ok(logclust
[2] == 2, "clusters out of order\n");
1260 ok(logclust
[3] == 3, "clusters out of order\n");
1261 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1262 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1263 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1264 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1265 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1266 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1267 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1268 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1269 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1270 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1271 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1272 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1273 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1274 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1275 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1276 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1278 ScriptFreeCache(&sc
);
1281 memset(glyphs2
,-1,sizeof(glyphs2
));
1282 memset(logclust
,-1,sizeof(logclust
));
1283 memset(attrs
,-1,sizeof(attrs
));
1284 hr
= ScriptShape(hdc
, &sc
, test2
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
1285 ok(hr
== S_OK
, "ScriptShape should return S_OK not %08x\n", hr
);
1286 ok(nb
== 4, "Wrong number of items\n");
1287 ok(glyphs2
[0] == 0 || broken(glyphs2
[0] == 0x80), "Incorrect glyph for 0x202B\n");
1288 ok(glyphs2
[3] == 0 || broken(glyphs2
[3] == 0x80), "Incorrect glyph for 0x202C\n");
1289 ok(logclust
[0] == 0, "clusters out of order\n");
1290 ok(logclust
[1] == 1, "clusters out of order\n");
1291 ok(logclust
[2] == 2, "clusters out of order\n");
1292 ok(logclust
[3] == 3, "clusters out of order\n");
1293 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1294 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1295 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1296 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1297 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1298 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1299 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1300 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1301 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1302 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1303 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1304 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1305 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1306 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1307 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1308 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1310 /* modify LTR to RTL */
1311 items
[0].a
.fRTL
= 1;
1312 memset(glyphs2
,-1,sizeof(glyphs2
));
1313 memset(logclust
,-1,sizeof(logclust
));
1314 memset(attrs
,-1,sizeof(attrs
));
1315 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
1316 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1317 ok(nb
== 4, "Wrong number of items\n");
1318 ok(glyphs2
[0] == glyphs
[3], "Glyphs not reordered properly\n");
1319 ok(glyphs2
[1] == glyphs
[2], "Glyphs not reordered properly\n");
1320 ok(glyphs2
[2] == glyphs
[1], "Glyphs not reordered properly\n");
1321 ok(glyphs2
[3] == glyphs
[0], "Glyphs not reordered properly\n");
1322 ok(logclust
[0] == 3, "clusters out of order\n");
1323 ok(logclust
[1] == 2, "clusters out of order\n");
1324 ok(logclust
[2] == 1, "clusters out of order\n");
1325 ok(logclust
[3] == 0, "clusters out of order\n");
1326 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1327 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1328 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1329 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1330 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1331 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1332 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1333 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1334 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1335 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1336 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1337 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1338 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1339 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1340 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1341 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1343 ScriptFreeCache(&sc
);
1346 static void test_ScriptPlace(HDC hdc
)
1348 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
1351 SCRIPT_CACHE sc
= NULL
;
1352 WORD glyphs
[4], logclust
[4];
1353 SCRIPT_VISATTR attrs
[4];
1354 SCRIPT_ITEM items
[2];
1359 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
1360 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
1361 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1363 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1364 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1365 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1367 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, NULL
, &items
[0].a
, widths
, NULL
, NULL
);
1368 ok(hr
== E_INVALIDARG
, "ScriptPlace should return E_INVALIDARG not %08x\n", hr
);
1370 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, NULL
);
1371 ok(broken(hr
== E_PENDING
) ||
1372 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1373 hr
== E_FAIL
, /* WIN7 */
1374 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1376 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
1377 ok(hr
== E_PENDING
, "ScriptPlace should return E_PENDING not %08x\n", hr
);
1379 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, abc
);
1380 ok(broken(hr
== E_PENDING
) ||
1381 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1382 hr
== E_FAIL
, /* WIN7 */
1383 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1385 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
1386 ok(!hr
, "ScriptPlace should return S_OK not %08x\n", hr
);
1387 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1389 ret
= ExtTextOutW(hdc
, 1, 1, 0, NULL
, glyphs
, 4, widths
);
1390 ok(ret
, "ExtTextOutW should return TRUE\n");
1392 ScriptFreeCache(&sc
);
1395 static void test_ScriptItemIzeShapePlace(HDC hdc
, unsigned short pwOutGlyphs
[256])
1399 const SCRIPT_PROPERTIES
**ppSp
;
1403 SCRIPT_ITEM pItem
[255];
1405 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1406 WCHAR TestItem2
[] = {'T', 'e', 's', 't', 'b', 0};
1407 WCHAR TestItem3
[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1408 WCHAR TestItem4
[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1409 WCHAR TestItem5
[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1410 WCHAR TestItem6
[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1415 unsigned short pwOutGlyphs1
[256];
1416 unsigned short pwOutGlyphs2
[256];
1417 unsigned short pwLogClust
[256];
1418 SCRIPT_VISATTR psva
[256];
1421 GOFFSET pGoffset
[256];
1425 /* Start testing usp10 functions */
1426 /* This test determines that the pointer returned by ScriptGetProperties is valid
1427 * by checking a known value in the table */
1428 hr
= ScriptGetProperties(&ppSp
, &iMaxProps
);
1429 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
1430 trace("number of script properties %d\n", iMaxProps
);
1431 ok (iMaxProps
> 0, "Number of scripts returned should not be 0\n");
1433 ok( ppSp
[0]->langid
== 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1436 /* This is a valid test that will cause parsing to take place */
1439 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1440 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1441 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1443 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1445 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1446 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1447 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1449 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1450 * ie. ScriptItemize has succeeded and that pItem has been set */
1453 psc
= NULL
; /* must be null on first call */
1455 cMaxGlyphs
= cInChars
;
1456 hr
= ScriptShape(NULL
, &psc
, TestItem1
, cChars
,
1457 cMaxGlyphs
, &pItem
[0].a
,
1458 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1459 ok (hr
== E_PENDING
, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr
);
1461 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1462 cMaxGlyphs
, &pItem
[0].a
,
1463 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1464 ok (hr
== E_OUTOFMEMORY
, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1465 "(%d) but not E_OUTOFMEMORY\n",
1466 cChars
, cMaxGlyphs
);
1468 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1469 cMaxGlyphs
, &pItem
[0].a
,
1470 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1471 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1472 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1473 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1475 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1477 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1478 hr
= ScriptPlace(NULL
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1480 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1481 for (cnt
=0; cnt
< pcGlyphs
; cnt
++)
1482 pwOutGlyphs
[cnt
] = pwOutGlyphs1
[cnt
]; /* Send to next function */
1485 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1486 * takes place if fNoGlyphIndex is set. */
1490 hr
= ScriptItemize(TestItem2
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1491 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1492 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1494 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1495 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1496 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1497 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1501 pItem
[0].a
.fNoGlyphIndex
= 1; /* say no translate */
1502 hr
= ScriptShape(NULL
, &psc
, TestItem2
, cChars
,
1503 cMaxGlyphs
, &pItem
[0].a
,
1504 pwOutGlyphs2
, pwLogClust
, psva
, &pcGlyphs
);
1505 ok (hr
!= E_PENDING
, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr
);
1506 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1507 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1508 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1509 for (cnt
=0; cnt
< cChars
&& TestItem2
[cnt
] == pwOutGlyphs2
[cnt
]; cnt
++) {}
1510 ok (cnt
== cChars
, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1511 cnt
, TestItem2
[cnt
], pwOutGlyphs2
[cnt
]);
1513 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs2
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1515 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1518 ScriptFreeCache( &psc
);
1519 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1523 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1524 cInChars
= (sizeof(TestItem3
)/2)-1;
1526 hr
= ScriptItemize(TestItem3
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1527 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1530 ok (pcItems
== 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems
);
1533 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1534 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1535 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1536 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1537 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1538 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1539 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== cInChars
,
1540 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1541 pItem
[2].iCharPos
, pItem
[3].iCharPos
, cInChars
);
1545 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1546 cInChars
= (sizeof(TestItem4
)/2)-1;
1548 hr
= ScriptItemize(TestItem4
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1549 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1552 ok (pcItems
== 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems
);
1555 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1556 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1557 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1558 ok (pItem
[0].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1559 pItem
[0].a
.s
.uBidiLevel
);
1560 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1561 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1562 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1563 ok (pItem
[1].a
.s
.uBidiLevel
== 1, "Should have been bidi=1 not %d\n",
1564 pItem
[1].a
.s
.uBidiLevel
);
1565 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== 12,
1566 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1567 pItem
[2].iCharPos
, pItem
[3].iCharPos
);
1568 ok (pItem
[2].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1569 pItem
[2].a
.s
.uBidiLevel
);
1570 ok (pItem
[3].iCharPos
== 12 && pItem
[4].iCharPos
== 13,
1571 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1572 pItem
[3].iCharPos
, pItem
[4].iCharPos
);
1573 ok (pItem
[3].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1574 pItem
[3].a
.s
.uBidiLevel
);
1575 ok (pItem
[4].iCharPos
== 13 && pItem
[5].iCharPos
== cInChars
,
1576 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1577 pItem
[4].iCharPos
, pItem
[5].iCharPos
, cInChars
);
1582 * This test is for when the first unicode character requires bidi support
1584 cInChars
= (sizeof(TestItem5
)-1)/sizeof(WCHAR
);
1585 hr
= ScriptItemize(TestItem5
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1586 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1587 ok (pcItems
== 4, "There should have been 4 items, found %d\n", pcItems
);
1588 ok (pItem
[0].a
.s
.uBidiLevel
== 1, "The first character should have been bidi=1 not %d\n",
1589 pItem
[0].a
.s
.uBidiLevel
);
1591 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1592 * the pointer to the last char works. Note that windows often needs a greater number of *
1593 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1594 cInChars
= (sizeof(TestItem6
)/2)-1;
1596 hr
= ScriptItemize(TestItem6
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1597 ok (hr
== E_OUTOFMEMORY
, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr
);
1601 static void test_ScriptGetCMap(HDC hdc
, unsigned short pwOutGlyphs
[256])
1604 SCRIPT_CACHE psc
= NULL
;
1607 unsigned short pwOutGlyphs2
[256];
1608 unsigned short pwOutGlyphs3
[256];
1612 static const WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1613 static const WCHAR TestItem2
[] = {0x202B, 'i', 'n', 0x202C,0};
1614 static const WCHAR TestItem3
[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1615 static const WCHAR TestItem3b
[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1617 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1619 cInChars
= cChars
= 5;
1620 /* Some sanity checks for ScriptGetCMap */
1622 hr
= ScriptGetCMap(NULL
, NULL
, NULL
, 0, 0, NULL
);
1623 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL,0,0,NULL), "
1624 "expected E_INVALIDARG, got %08x\n", hr
);
1626 hr
= ScriptGetCMap(NULL
, NULL
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1627 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1628 "expected E_INVALIDARG, got %08x\n", hr
);
1630 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1632 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1633 ok( hr
== E_PENDING
, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1635 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1637 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1639 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1640 ok( hr
== S_OK
, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1642 ok( psc
!= NULL
, "ScritpGetCMap expected psc to be not NULL\n");
1643 ScriptFreeCache( &psc
);
1645 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1647 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1648 ok( hr
== E_PENDING
, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr
);
1649 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1650 /* Check to see if the results are the same as those returned by ScriptShape */
1651 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1652 ok (hr
== 0, "ScriptGetCMap should return 0 not (%08x)\n", hr
);
1653 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1654 for (cnt
=0; cnt
< cChars
&& pwOutGlyphs
[cnt
] == pwOutGlyphs3
[cnt
]; cnt
++) {}
1655 ok (cnt
== cInChars
, "Translation not correct. WCHAR %d - %04x != %04x\n",
1656 cnt
, pwOutGlyphs
[cnt
], pwOutGlyphs3
[cnt
]);
1658 ScriptFreeCache( &psc
);
1659 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1661 cInChars
= cChars
= 4;
1662 hr
= ScriptGetCMap(hdc
, &psc
, TestItem2
, cInChars
, dwFlags
, pwOutGlyphs3
);
1663 ok (hr
== S_FALSE
, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr
);
1664 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1665 ok(pwOutGlyphs3
[0] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1666 ok(pwOutGlyphs3
[3] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1669 cInChars
= cChars
= 9;
1670 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3b
, cInChars
, dwFlags
, pwOutGlyphs2
);
1671 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1672 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1674 cInChars
= cChars
= 9;
1676 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3
, cInChars
, dwFlags
, pwOutGlyphs3
);
1677 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1678 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1679 ok(pwOutGlyphs3
[0] == pwOutGlyphs2
[0], "glyph incorrectly altered\n");
1680 ok(pwOutGlyphs3
[1] == pwOutGlyphs2
[1], "glyph incorreclty altered\n");
1681 ok(pwOutGlyphs3
[2] == pwOutGlyphs2
[2], "glyph incorreclty altered\n");
1682 ok(pwOutGlyphs3
[3] == pwOutGlyphs2
[3], "glyph incorreclty altered\n");
1683 ok(pwOutGlyphs3
[4] == pwOutGlyphs2
[4], "glyph not mirrored correctly\n");
1684 ok(pwOutGlyphs3
[5] == pwOutGlyphs2
[5], "glyph not mirrored correctly\n");
1685 ok(pwOutGlyphs3
[6] == pwOutGlyphs2
[6], "glyph not mirrored correctly\n");
1686 ok(pwOutGlyphs3
[7] == pwOutGlyphs2
[7], "glyph not mirrored correctly\n");
1687 ok(pwOutGlyphs3
[8] == pwOutGlyphs2
[8], "glyph not mirrored correctly\n");
1689 ScriptFreeCache( &psc
);
1690 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1693 static void test_ScriptGetFontProperties(HDC hdc
)
1696 SCRIPT_CACHE psc
,old_psc
;
1697 SCRIPT_FONTPROPERTIES sfp
;
1699 /* Some sanity checks for ScriptGetFontProperties */
1701 hr
= ScriptGetFontProperties(NULL
,NULL
,NULL
);
1702 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1704 hr
= ScriptGetFontProperties(NULL
,NULL
,&sfp
);
1705 ok( hr
== E_INVALIDARG
, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1707 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1709 hr
= ScriptGetFontProperties(NULL
,&psc
,NULL
);
1710 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1711 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1713 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1715 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1716 ok( hr
== E_PENDING
, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr
);
1717 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1719 hr
= ScriptGetFontProperties(hdc
,NULL
,NULL
);
1720 ok( hr
== E_INVALIDARG
, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1722 hr
= ScriptGetFontProperties(hdc
,NULL
,&sfp
);
1723 ok( hr
== E_INVALIDARG
, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1725 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1727 hr
= ScriptGetFontProperties(hdc
,&psc
,NULL
);
1728 ok( hr
== E_INVALIDARG
, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1729 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1731 /* Pass an invalid sfp */
1733 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
) - 1;
1734 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1735 ok( hr
== E_INVALIDARG
, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr
);
1736 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1737 ScriptFreeCache(&psc
);
1738 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1740 /* Give it the correct cBytes, we don't care about what's coming back */
1741 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
);
1743 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1744 ok( hr
== S_OK
, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr
);
1745 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1747 /* Save the psc pointer */
1749 /* Now a NULL hdc again */
1750 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1751 ok( hr
== S_OK
, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr
);
1752 ok( psc
== old_psc
, "Expected psc not to be changed, was %p is now %p\n", old_psc
, psc
);
1753 ScriptFreeCache(&psc
);
1754 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1757 static void test_ScriptTextOut(HDC hdc
)
1763 SCRIPT_ITEM pItem
[255];
1765 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1770 unsigned short pwOutGlyphs1
[256];
1771 WORD pwLogClust
[256];
1772 SCRIPT_VISATTR psva
[256];
1775 GOFFSET pGoffset
[256];
1780 BOOL fTrailing
= FALSE
;
1781 SCRIPT_LOGATTR
*psla
;
1782 SCRIPT_LOGATTR sla
[256];
1784 /* This is a valid test that will cause parsing to take place */
1787 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1788 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1789 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1791 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1793 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1794 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1795 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1797 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1798 * ie. ScriptItemize has succeeded and that pItem has been set */
1801 psc
= NULL
; /* must be null on first call */
1804 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1805 cMaxGlyphs
, &pItem
[0].a
,
1806 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1807 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1808 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1809 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1811 /* Note hdc is needed as glyph info is not yet in psc */
1812 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1814 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1815 ScriptFreeCache(&psc
); /* Get rid of psc for next test set */
1816 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1818 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0, NULL
, NULL
, NULL
);
1819 ok (hr
== E_INVALIDARG
, "Should return 0 not (%08x)\n", hr
);
1821 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1822 piAdvance
, NULL
, pGoffset
);
1823 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1824 "expected E_INVALIDARG, got %08x\n", hr
);
1826 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1828 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0,
1830 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
1832 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1834 /* hdc is required for this one rather than the usual optional */
1836 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1837 piAdvance
, NULL
, pGoffset
);
1838 ok( hr
== E_INVALIDARG
, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr
);
1839 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1841 /* Set that it returns 0 status */
1842 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1843 piAdvance
, NULL
, pGoffset
);
1844 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1846 /* Test Rect Rgn is acceptable */
1851 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1852 piAdvance
, NULL
, pGoffset
);
1853 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1856 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, pcGlyphs
, (const WORD
*) &pwLogClust
,
1857 (const SCRIPT_VISATTR
*) &psva
, (const int *)&piAdvance
, &pItem
[0].a
, &piX
);
1858 ok(hr
== S_OK
, "ScriptCPtoX Stub should return S_OK not %08x\n", hr
);
1860 psla
= (SCRIPT_LOGATTR
*)&sla
;
1861 hr
= ScriptBreak(TestItem1
, cChars
, &pItem
[0].a
, psla
);
1862 ok(hr
== S_OK
, "ScriptBreak Stub should return S_OK not %08x\n", hr
);
1864 /* Clean up and go */
1865 ScriptFreeCache(&psc
);
1866 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1871 static void test_ScriptTextOut2(HDC hdc
)
1873 /* Intent is to validate that the HDC passed into ScriptTextOut is
1874 * used instead of the (possibly) invalid cached one
1881 SCRIPT_ITEM pItem
[255];
1883 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1888 unsigned short pwOutGlyphs1
[256];
1889 WORD pwLogClust
[256];
1890 SCRIPT_VISATTR psva
[256];
1893 GOFFSET pGoffset
[256];
1896 /* Create an extra DC that will be used until the ScriptTextOut */
1897 hdc1
= CreateCompatibleDC(hdc
);
1898 ok (hdc1
!= 0, "CreateCompatibleDC failed to create a DC\n");
1899 hdc2
= CreateCompatibleDC(hdc
);
1900 ok (hdc2
!= 0, "CreateCompatibleDC failed to create a DC\n");
1902 /* This is a valid test that will cause parsing to take place */
1905 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1906 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1907 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1909 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1911 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1912 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1913 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1915 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1916 * ie. ScriptItemize has succeeded and that pItem has been set */
1919 psc
= NULL
; /* must be null on first call */
1922 hr
= ScriptShape(hdc2
, &psc
, TestItem1
, cChars
,
1923 cMaxGlyphs
, &pItem
[0].a
,
1924 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1925 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1926 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1927 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1929 /* Note hdc is needed as glyph info is not yet in psc */
1930 hr
= ScriptPlace(hdc2
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1932 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1934 /* key part!!! cached dc is being deleted */
1935 hr
= DeleteDC(hdc2
);
1936 ok(hr
== 1, "DeleteDC should return 1 not %08x\n", hr
);
1938 /* At this point the cached hdc (hdc2) has been destroyed,
1939 * however, we are passing in a *real* hdc (the original hdc).
1940 * The text should be written to that DC
1942 hr
= ScriptTextOut(hdc1
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1943 piAdvance
, NULL
, pGoffset
);
1944 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1945 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1949 /* Clean up and go */
1950 ScriptFreeCache(&psc
);
1951 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1956 static void test_ScriptTextOut3(HDC hdc
)
1962 SCRIPT_ITEM pItem
[255];
1964 WCHAR TestItem1
[] = {' ','\r', 0};
1969 unsigned short pwOutGlyphs1
[256];
1970 WORD pwLogClust
[256];
1971 SCRIPT_VISATTR psva
[256];
1974 GOFFSET pGoffset
[256];
1978 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
1981 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1982 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1983 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1985 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1987 ok (pItem
[0].iCharPos
== 0 && pItem
[2].iCharPos
== cInChars
,
1988 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1989 pItem
[0].iCharPos
, cInChars
, pItem
[2].iCharPos
);
1991 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1992 * ie. ScriptItemize has succeeded and that pItem has been set */
1995 psc
= NULL
; /* must be null on first call */
1998 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1999 cMaxGlyphs
, &pItem
[0].a
,
2000 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
2001 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
2002 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
2003 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
2005 /* Note hdc is needed as glyph info is not yet in psc */
2006 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
2008 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
2010 /* Test Rect Rgn is acceptable */
2015 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
2016 piAdvance
, NULL
, pGoffset
);
2017 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
2020 /* Clean up and go */
2021 ScriptFreeCache(&psc
);
2022 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
2026 #define test_item_ScriptXtoX(a,b,c,d,e,f) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_item_ScriptXtoX(a,b,c,d,e,f)
2028 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS
*psa
, int cChars
, int cGlyphs
, const int* offsets
, const WORD
*pwLogClust
, const int* piAdvance
)
2031 int icChars
, icGlyphs
;
2034 SCRIPT_VISATTR psva
[10];
2039 memset(psva
,0,sizeof(psva
));
2040 direction
= (psa
->fRTL
)?-1:+1;
2042 for(iCP
= 0; iCP
< cChars
; iCP
++)
2047 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
2048 winetest_ok(hr
== S_OK
, "ScriptXtoCP: should return S_OK not %08x\n", hr
);
2049 winetest_ok(piCP
== iCP
, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
2050 winetest_ok(piTrailing
== 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
2053 for(iCP
= 0; iCP
< cChars
; iCP
++)
2055 iX
= offsets
[iCP
]+direction
;
2058 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
2059 winetest_ok(hr
== S_OK
, "ScriptXtoCP leading: should return S_OK not %08x\n", hr
);
2060 winetest_ok(piCP
== iCP
, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
2061 winetest_ok(piTrailing
== 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
2064 for(iCP
= 0; iCP
< cChars
; iCP
++)
2066 iX
= offsets
[iCP
+1]-direction
;
2069 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
2070 winetest_ok(hr
== S_OK
, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr
);
2071 winetest_ok(piCP
== iCP
, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
2072 winetest_ok(piTrailing
== 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
2075 for(iCP
= 0; iCP
<= cChars
+1; iCP
++)
2080 hr
= ScriptCPtoX(iCP
, fTrailing
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piX
);
2081 winetest_ok(hr
== S_OK
, "ScriptCPtoX: should return S_OK not %08x\n", hr
);
2082 winetest_ok(piX
== offsets
[iCP
],
2083 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
], piX
);
2086 for(iCP
= 0; iCP
<= cChars
+1; iCP
++)
2091 hr
= ScriptCPtoX(iCP
, fTrailing
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piX
);
2092 winetest_ok(hr
== S_OK
, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr
);
2093 winetest_ok(piX
== offsets
[iCP
+1],
2094 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
+1], piX
);
2098 static void test_ScriptXtoX(void)
2099 /****************************************************************************************
2100 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2101 ****************************************************************************************/
2103 WORD pwLogClust
[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2104 WORD pwLogClust_RTL
[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2105 WORD pwLogClust_2
[7] = {4, 3, 3, 2, 1, 0 ,0};
2106 int piAdvance
[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2107 int piAdvance_2
[5] = {39, 26, 19, 17, 11};
2108 static const int offsets
[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2109 static const int offsets_RTL
[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2110 static const int offsets_2
[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2111 SCRIPT_VISATTR psva
[10];
2118 memset(&sa
, 0 , sizeof(SCRIPT_ANALYSIS
));
2119 memset(psva
, 0, sizeof(psva
));
2122 hr
= ScriptXtoCP(-1, 10, 10, pwLogClust
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2123 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2125 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
2127 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
2129 for (iX
= 0; iX
<= 7; iX
++)
2133 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2134 ok(piCP
==0 && piTrailing
==0,"%i should return 0(%i) and 0(%i)\n",iX
, piCP
,piTrailing
);
2136 for (iX
= 8; iX
< 16; iX
++)
2140 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2141 ok(piCP
==0 && piTrailing
==1,"%i should return 0(%i) and 1(%i)\n",iX
, piCP
,piTrailing
);
2145 hr
= ScriptXtoCP(-1, 10, 10, pwLogClust_RTL
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2146 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2148 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
2150 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
2153 hr
= ScriptXtoCP(1954, 10, 10, pwLogClust_RTL
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2154 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2155 ok(piCP
== -1, "iX=%d should return piCP=-1 not %d\n", iX
, piCP
);
2156 ok(piTrailing
== 1, "iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
2158 for (iX
= 1; iX
<= 8; iX
++)
2162 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2163 ok(piCP
==0 && piTrailing
==1,"%i should return 0(%i) and 1(%i)\n",iX
,piCP
,piTrailing
);
2165 for (iX
= 9; iX
< 16; iX
++)
2169 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2170 ok(piCP
==0 && piTrailing
==0,"%i should return 0(%i) and 0(%i)\n",iX
,piCP
,piTrailing
);
2174 test_item_ScriptXtoX(&sa
, 10, 10, offsets
, pwLogClust
, piAdvance
);
2176 test_item_ScriptXtoX(&sa
, 10, 10, offsets_RTL
, pwLogClust_RTL
, piAdvance
);
2177 test_item_ScriptXtoX(&sa
, 7, 5, offsets_2
, pwLogClust_2
, piAdvance_2
);
2180 static void test_ScriptString(HDC hdc
)
2182 /*******************************************************************************************
2184 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2185 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2186 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2187 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2192 WCHAR teststr
[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2193 int len
= (sizeof(teststr
) / sizeof(WCHAR
)) - 1;
2194 int Glyphs
= len
* 2 + 16;
2196 DWORD Flags
= SSA_GLYPHS
;
2198 const int Dx
[5] = {10, 10, 10, 10, 10};
2199 const BYTE InClass
= 0;
2200 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
2205 const RECT rc
= {0, 50, 100, 100};
2208 BOOL Disabled
= FALSE
;
2209 const int *clip_len
;
2214 Charset
= -1; /* this flag indicates unicode input */
2215 /* Test without hdc to get E_PENDING */
2216 hr
= ScriptStringAnalyse( NULL
, teststr
, len
, Glyphs
, Charset
, Flags
,
2217 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2219 ok(hr
== E_PENDING
, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr
);
2221 /* test with hdc, this should be a valid test */
2222 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
2223 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2225 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2226 ScriptStringFree(&ssa
);
2228 /* test makes sure that a call with a valid pssa still works */
2229 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
2230 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2232 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2233 ok(ssa
!= NULL
, "ScriptStringAnalyse pssa should not be NULL\n");
2237 hr
= ScriptStringOut(ssa
, X
, Y
, Options
, &rc
, MinSel
, MaxSel
, Disabled
);
2238 ok(hr
== S_OK
, "ScriptStringOut should return S_OK not %08x\n", hr
);
2241 clip_len
= ScriptString_pcOutChars(ssa
);
2242 ok(*clip_len
== len
, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len
, len
);
2244 order
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, *clip_len
* sizeof(UINT
));
2245 hr
= ScriptStringGetOrder(ssa
, order
);
2246 ok(hr
== S_OK
, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr
);
2248 for (i
= 0; i
< *clip_len
; i
++) ok(order
[i
] == i
, "%d: got %d expected %d\n", i
, order
[i
], i
);
2249 HeapFree(GetProcessHeap(), 0, order
);
2251 hr
= ScriptStringFree(&ssa
);
2252 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
2255 static void test_ScriptStringXtoCP_CPtoX(HDC hdc
)
2257 /*****************************************************************************************
2259 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2260 * nature of the fonts between Windows and Wine, the test is implemented by generating
2261 * values using one one function then checking the output of the second. In this way
2262 * the validity of the functions is established using Windows as a base and confirming
2263 * similar behaviour in wine.
2267 static const WCHAR teststr1
[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2268 static const BOOL rtl
[] = {1, 0, 1, 0, 1, 0, 1, 0};
2269 void *String
= (WCHAR
*) &teststr1
; /* ScriptStringAnalysis needs void */
2270 int String_len
= (sizeof(teststr1
)/sizeof(WCHAR
))-1;
2271 int Glyphs
= String_len
* 2 + 16; /* size of buffer as recommended */
2272 int Charset
= -1; /* unicode */
2273 DWORD Flags
= SSA_GLYPHS
;
2275 const BYTE InClass
= 0;
2276 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
2278 int Ch
; /* Character position in string */
2280 int Cp
; /* Character position in string */
2285 /* Test with hdc, this should be a valid test
2286 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2287 * following character positions to X and X to character position functions.
2290 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
2291 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
2294 hr
== E_INVALIDARG
, /* NT */
2295 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr
);
2299 ok(ssa
!= NULL
, "ScriptStringAnalyse ssa should not be NULL\n");
2302 * Loop to generate character positions to provide starting positions for the
2303 * ScriptStringCPtoX and ScriptStringXtoCP functions
2305 for (Cp
= 0; Cp
< String_len
; Cp
++)
2307 /* The fTrailing flag is used to indicate whether the X being returned is at
2308 * the beginning or the end of the character. What happens here is that if
2309 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2310 * returns the beginning of the next character and iTrailing is FALSE. So for this
2311 * loop iTrailing will be FALSE in both cases.
2313 hr
= ScriptStringCPtoX(ssa
, Cp
, TRUE
, &trail
);
2314 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2315 hr
= ScriptStringCPtoX(ssa
, Cp
, FALSE
, &lead
);
2316 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2318 ok(lead
> trail
, "Leading values should be after trailing for rtl characters(%i)\n",Cp
);
2320 ok(lead
< trail
, "Trailing values should be after leading for ltr characters(%i)\n",Cp
);
2322 /* move by 1 pixel so that we are not inbetween 2 characters. That could result in being the lead of a rtl and
2323 at the same time the trail of an ltr */
2325 /* inside the leading edge */
2327 if (rtl
[Cp
]) X
--; else X
++;
2328 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2329 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2330 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
2331 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2334 /* inside the trailing edge */
2336 if (rtl
[Cp
]) X
++; else X
--;
2337 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2338 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2339 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
2340 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2343 /* outside the "trailing" edge */
2344 if (Cp
< String_len
-1)
2346 if (rtl
[Cp
]) X
= lead
; else X
= trail
;
2348 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2349 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2350 ok(Cp
+ 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
+ 1, Ch
, trail
);
2352 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2355 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2359 /* outside the "leading" edge */
2362 if (rtl
[Cp
]) X
= trail
; else X
= lead
;
2364 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2365 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2366 ok(Cp
- 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
- 1, Ch
, trail
);
2367 if (Cp
!= 0 && rtl
[Cp
-1])
2368 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2371 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2376 /* Check beyond the leading boundary of the whole string */
2379 /* having a leading rtl character seems to confuse usp */
2380 /* this looks to be a windows bug we should emulate */
2381 hr
= ScriptStringCPtoX(ssa
, 0, TRUE
, &X
);
2382 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2384 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2385 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2386 ok(Ch
== 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch
);
2387 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
2392 hr
= ScriptStringCPtoX(ssa
, 0, FALSE
, &X
);
2393 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2395 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2396 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2397 ok(Ch
== -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch
);
2398 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2402 /* Check beyond the end boundary of the whole string */
2403 if (rtl
[String_len
-1])
2405 hr
= ScriptStringCPtoX(ssa
, String_len
-1, FALSE
, &X
);
2406 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2410 hr
= ScriptStringCPtoX(ssa
, String_len
-1, TRUE
, &X
);
2411 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2414 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2415 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2416 ok(Ch
== String_len
, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len
, Ch
);
2417 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
2421 * Cleanup the SSA for the next round of tests
2423 hr
= ScriptStringFree(&ssa
);
2424 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
2427 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2428 * generate an SSA for the subsequent tests.
2430 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
2431 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
2433 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2436 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2437 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2438 * ScriptStringFree should also fail.
2441 Cp
= String_len
+ 1;
2442 hr
= ScriptStringCPtoX(ssa
, Cp
, fTrailing
, &X
);
2443 ok(hr
== E_INVALIDARG
, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr
);
2445 ScriptStringFree(&ssa
);
2449 static void test_ScriptCacheGetHeight(HDC hdc
)
2452 SCRIPT_CACHE sc
= NULL
;
2455 hr
= ScriptCacheGetHeight(NULL
, NULL
, NULL
);
2456 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2458 hr
= ScriptCacheGetHeight(NULL
, &sc
, NULL
);
2459 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2461 hr
= ScriptCacheGetHeight(NULL
, &sc
, &height
);
2462 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2466 hr
= ScriptCacheGetHeight(hdc
, &sc
, &height
);
2467 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2468 ok(height
> 0, "expected height > 0\n");
2470 ScriptFreeCache(&sc
);
2473 static void test_ScriptGetGlyphABCWidth(HDC hdc
)
2476 SCRIPT_CACHE sc
= NULL
;
2479 hr
= ScriptGetGlyphABCWidth(NULL
, NULL
, 'a', NULL
);
2480 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2482 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', NULL
);
2483 ok(broken(hr
== E_PENDING
) ||
2484 hr
== E_INVALIDARG
, /* WIN7 */
2485 "expected E_INVALIDARG, got 0x%08x\n", hr
);
2487 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', &abc
);
2488 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2490 if (0) { /* crashes on WinXP */
2491 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', NULL
);
2492 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2495 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', &abc
);
2496 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2498 ScriptFreeCache(&sc
);
2501 static void test_ScriptLayout(void)
2504 static const BYTE levels
[][10] =
2506 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2507 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2508 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2509 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2511 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2512 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2513 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2514 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2515 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2517 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2518 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2520 static const int expect_l2v
[][10] =
2522 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2523 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2524 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2525 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2527 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2528 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2529 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2530 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2531 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2533 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2534 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2536 static const int expect_v2l
[][10] =
2538 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2539 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2540 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2541 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2543 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2544 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2545 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2546 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2547 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2549 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2550 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2553 int i
, j
, vistolog
[sizeof(levels
[0])], logtovis
[sizeof(levels
[0])];
2555 hr
= ScriptLayout(sizeof(levels
[0]), NULL
, vistolog
, logtovis
);
2556 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2558 hr
= ScriptLayout(sizeof(levels
[0]), levels
[0], NULL
, NULL
);
2559 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2561 for (i
= 0; i
< sizeof(levels
)/sizeof(levels
[0]); i
++)
2563 hr
= ScriptLayout(sizeof(levels
[0]), levels
[i
], vistolog
, logtovis
);
2564 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2566 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2568 ok(expect_v2l
[i
][j
] == vistolog
[j
],
2569 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2570 i
, j
, levels
[i
][j
], j
, vistolog
[j
] );
2573 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2575 ok(expect_l2v
[i
][j
] == logtovis
[j
],
2576 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2577 i
, j
, levels
[i
][j
], j
, logtovis
[j
] );
2582 static BOOL CALLBACK
enum_proc(LGRPID group
, LCID lcid
, LPSTR locale
, LONG_PTR lparam
)
2585 SCRIPT_DIGITSUBSTITUTE sds
;
2590 if (!IsValidLocale(lcid
, LCID_INSTALLED
)) return TRUE
;
2592 memset(&sds
, 0, sizeof(sds
));
2593 memset(&sc
, 0, sizeof(sc
));
2594 memset(&ss
, 0, sizeof(ss
));
2596 lcid_old
= GetThreadLocale();
2597 if (!SetThreadLocale(lcid
)) return TRUE
;
2599 hr
= ScriptRecordDigitSubstitution(lcid
, &sds
);
2600 ok(hr
== S_OK
, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr
);
2602 hr
= ScriptApplyDigitSubstitution(&sds
, &sc
, &ss
);
2603 ok(hr
== S_OK
, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr
);
2605 SetThreadLocale(lcid_old
);
2609 static void test_digit_substitution(void)
2613 static const LGRPID groups
[] =
2615 LGRPID_WESTERN_EUROPE
,
2616 LGRPID_CENTRAL_EUROPE
,
2623 LGRPID_TRADITIONAL_CHINESE
,
2624 LGRPID_SIMPLIFIED_CHINESE
,
2634 static BOOL (WINAPI
* pEnumLanguageGroupLocalesA
)(LANGGROUPLOCALE_ENUMPROCA
,LGRPID
,DWORD
,LONG_PTR
);
2636 hKernel32
= GetModuleHandleA("kernel32.dll");
2637 pEnumLanguageGroupLocalesA
= (void*)GetProcAddress(hKernel32
, "EnumLanguageGroupLocalesA");
2639 if (!pEnumLanguageGroupLocalesA
)
2641 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
2645 for (i
= 0; i
< sizeof(groups
)/sizeof(groups
[0]); i
++)
2647 ret
= pEnumLanguageGroupLocalesA(enum_proc
, groups
[i
], 0, 0);
2648 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
2650 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
2654 ok(ret
, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
2658 static void test_ScriptGetProperties(void)
2660 const SCRIPT_PROPERTIES
**props
;
2664 hr
= ScriptGetProperties(NULL
, NULL
);
2665 ok(hr
== E_INVALIDARG
, "ScriptGetProperties succeeded\n");
2667 hr
= ScriptGetProperties(NULL
, &num
);
2668 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2670 hr
= ScriptGetProperties(&props
, NULL
);
2671 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2673 hr
= ScriptGetProperties(&props
, &num
);
2674 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2677 static void test_ScriptBreak(void)
2679 static const WCHAR test
[] = {' ','\r','\n',0};
2680 SCRIPT_ITEM items
[4];
2684 hr
= ScriptItemize(test
, 3, 4, NULL
, NULL
, items
, NULL
);
2685 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
2687 memset(&la
, 0, sizeof(la
));
2688 hr
= ScriptBreak(test
, 1, &items
[0].a
, &la
);
2689 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2691 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2692 ok(la
.fWhiteSpace
, "fWhiteSpace not set\n");
2693 ok(la
.fCharStop
, "fCharStop not set\n");
2694 ok(!la
.fWordStop
, "fWordStop set\n");
2695 ok(!la
.fInvalid
, "fInvalid set\n");
2696 ok(!la
.fReserved
, "fReserved set\n");
2698 memset(&la
, 0, sizeof(la
));
2699 hr
= ScriptBreak(test
+ 1, 1, &items
[1].a
, &la
);
2700 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2702 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2703 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2704 ok(la
.fCharStop
, "fCharStop not set\n");
2705 ok(!la
.fWordStop
, "fWordStop set\n");
2706 ok(!la
.fInvalid
, "fInvalid set\n");
2707 ok(!la
.fReserved
, "fReserved set\n");
2709 memset(&la
, 0, sizeof(la
));
2710 hr
= ScriptBreak(test
+ 2, 1, &items
[2].a
, &la
);
2711 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2713 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2714 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2715 ok(la
.fCharStop
, "fCharStop not set\n");
2716 ok(!la
.fWordStop
, "fWordStop set\n");
2717 ok(!la
.fInvalid
, "fInvalid set\n");
2718 ok(!la
.fReserved
, "fReserved set\n");
2721 static void test_newlines(void)
2723 static const WCHAR test1
[] = {'t','e','x','t','\r','t','e','x','t',0};
2724 static const WCHAR test2
[] = {'t','e','x','t','\n','t','e','x','t',0};
2725 static const WCHAR test3
[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
2726 static const WCHAR test4
[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
2727 static const WCHAR test5
[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
2728 SCRIPT_ITEM items
[5];
2733 hr
= ScriptItemize(test1
, lstrlenW(test1
), 5, NULL
, NULL
, items
, &count
);
2734 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2735 ok(count
== 3, "got %d expected 3\n", count
);
2738 hr
= ScriptItemize(test2
, lstrlenW(test2
), 5, NULL
, NULL
, items
, &count
);
2739 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2740 ok(count
== 3, "got %d expected 3\n", count
);
2743 hr
= ScriptItemize(test3
, lstrlenW(test3
), 5, NULL
, NULL
, items
, &count
);
2744 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2745 ok(count
== 4, "got %d expected 4\n", count
);
2748 hr
= ScriptItemize(test4
, lstrlenW(test4
), 5, NULL
, NULL
, items
, &count
);
2749 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2750 ok(count
== 4, "got %d expected 4\n", count
);
2753 hr
= ScriptItemize(test5
, lstrlenW(test5
), 5, NULL
, NULL
, items
, &count
);
2754 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2755 ok(count
== 4, "got %d expected 4\n", count
);
2765 unsigned short pwOutGlyphs
[256];
2767 /* We need a valid HDC to drive a lot of Script functions which requires the following *
2768 * to set up for the tests. */
2769 hwnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,
2772 ShowWindow(hwnd
, SW_SHOW
);
2775 hdc
= GetDC(hwnd
); /* We now have a hdc */
2776 ok( hdc
!= NULL
, "HDC failed to be created %p\n", hdc
);
2778 memset(&lf
, 0, sizeof(LOGFONTA
));
2779 lstrcpyA(lf
.lfFaceName
, "Tahoma");
2784 hfont
= SelectObject(hdc
, CreateFontIndirectA(&lf
));
2785 ok(hfont
!= NULL
, "SelectObject failed: %p\n", hfont
);
2787 test_ScriptItemize();
2788 test_ScriptItemIzeShapePlace(hdc
,pwOutGlyphs
);
2789 test_ScriptGetCMap(hdc
, pwOutGlyphs
);
2790 test_ScriptCacheGetHeight(hdc
);
2791 test_ScriptGetGlyphABCWidth(hdc
);
2792 test_ScriptShape(hdc
);
2793 test_ScriptShapeOpenType(hdc
);
2794 test_ScriptPlace(hdc
);
2796 test_ScriptGetFontProperties(hdc
);
2797 test_ScriptTextOut(hdc
);
2798 test_ScriptTextOut2(hdc
);
2799 test_ScriptTextOut3(hdc
);
2801 test_ScriptString(hdc
);
2802 test_ScriptStringXtoCP_CPtoX(hdc
);
2804 test_ScriptLayout();
2805 test_digit_substitution();
2806 test_ScriptGetProperties();
2810 ReleaseDC(hwnd
, hdc
);
2811 DestroyWindow(hwnd
);