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
,
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
== 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')
158 static void test_ScriptItemize( void )
160 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
161 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}};
162 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
}};
164 static const WCHAR test1b
[] = {' ', ' ', ' ', ' ',0};
165 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
}};
166 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
}};
168 static const WCHAR test1c
[] = {' ', ' ', ' ', '1', '2', ' ',0};
169 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
}};
170 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
}};
173 static const WCHAR test2
[] = {'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0};
174 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
}};
175 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
}};
176 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
}};
178 static const WCHAR test2b
[] = {'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0};
179 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
}};
180 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
}};
181 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
}};
184 static const WCHAR test2c
[] = {' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0};
185 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
}};
186 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
}};
187 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
}};
188 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
}};
191 static const WCHAR test2d
[] = {'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0};
192 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
}};
193 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
}};
194 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
}};
195 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
}};
198 static const WCHAR test3
[] =
199 {0x0e04,0x0e27,0x0e32,0x0e21,0x0e1e,0x0e22,0x0e32,0x0e22,0x0e32, 0x0e21
200 ,0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e44,0x0e2b,0x0e19
201 ,0x0e04,0x0e27,0x0e32,0x0e21,0x0e2a, 0x0e33,0x0e40,0x0e23,0x0e47,0x0e08,
202 0x0e2d,0x0e22,0x0e39,0x0e48,0x0e17,0x0e35,0x0e48,0x0e19,0x0e31,0x0e48,0x0e19,0};
204 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
}};
205 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
}};
207 static const WCHAR test4
[] = {'1','2','3','-','5','2',' ','i','s',' ','7','1','.',0};
209 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
}};
210 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
}};
211 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
}};
214 static const WCHAR test5
[] =
215 {0x0627,0x0644,0x0635,0x0651,0x0650,0x062d,0x0629,0x064f,' ',0x062a,0x064e,
216 0x0627,0x062c,0x064c,' ',0x0639,0x064e,0x0644,0x0649,' ',
217 0x0631,0x064f,0x0624,0x0648,0x0633,0x0650,' ',0x0627,0x0644
218 ,0x0623,0x0635,0x0650,0x062d,0x0651,0x064e,0x0627,0x0621,0x0650,0};
219 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
}};
222 static const WCHAR test6
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd, '.',0};
223 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
}};
224 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
}};
225 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
}};
226 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};
227 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
}};
228 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
}};
229 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
}};
230 static const WCHAR test8
[] = {0x0633, 0x0644, 0x0627, 0x0645,0};
231 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
}};
233 /* Syriac (Like Arabic )*/
234 static const WCHAR test9
[] = {0x0710, 0x0712, 0x0712, 0x0714, '.',0};
235 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
}};
236 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
}};
237 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
}};
239 static const WCHAR test10
[] = {0x0717, 0x0718, 0x071a, 0x071b,0};
240 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
}};
243 static const WCHAR test11
[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
244 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
}};
245 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
}};
248 static const WCHAR test12
[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
249 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
}};
250 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
}};
253 static const WCHAR test13
[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
254 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
}};
255 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
}};
258 static const WCHAR test14
[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
259 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
}};
260 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
}};
263 static const WCHAR test15
[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
264 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
}};
265 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
}};
268 static const WCHAR test16
[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
269 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
}};
270 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
}};
273 static const WCHAR test17
[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
274 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
}};
275 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
}};
278 static const WCHAR test18
[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
279 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
}};
280 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
}};
283 static const WCHAR test19
[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
284 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
}};
285 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
}};
288 static const WCHAR test20
[] = {0x0309,'a','b','c','d',0};
289 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
}};
290 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
}};
292 static const WCHAR test21
[] = {0x0710, 0x0712, 0x0308, 0x0712, 0x0714,0};
293 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
}};
295 /* Latin Punctuation */
296 static const WCHAR test22
[] = {'#','$',',','!','\"','*',0};
297 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
}};
298 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
}};
299 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
}};
302 static const WCHAR test23
[] = {'1','2','3',0x00b2,0x00b3,0x2070,0};
303 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
}};
304 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
}};
307 static const WCHAR test24
[] = {0x1019,0x103c,0x1014,0x103a,0x1019,0x102c,0x1021,0x1000,0x1039,0x1001,0x101b,0x102c};
308 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
}};
309 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
}};
312 static const WCHAR test25
[] = {0x1956,0x196d,0x1970,0x1956,0x196c,0x1973,0x1951,0x1968,0x1952,0x1970};
313 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
}};
314 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
}};
317 static const WCHAR test26
[] = {0x1992,0x19c4};
318 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
}};
319 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
}};
322 static const WCHAR test27
[] = {0x1781,0x17c1,0x1798,0x179a,0x1797,0x17b6,0x179f,0x17b6};
323 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
}};
324 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
}};
327 static const WCHAR test28
[] = {0x8bed,0x7d20,0x6587,0x5b57};
328 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
}};
329 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
}};
332 static const WCHAR test29
[] = {0x2ff0,0x2ff3,0x2ffb,0x2ff0,0x65e5,0x65e5,0x5de5,0x7f51,0x4e02,0x4e5e};
333 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
}};
334 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
}};
336 SCRIPT_ITEM items
[15];
337 SCRIPT_CONTROL Control
;
343 usp10
= LoadLibraryA("usp10.dll");
344 ok (usp10
!= 0,"Unable to LoadLibrary on usp10.dll\n");
345 pScriptItemizeOpenType
= (void*)GetProcAddress(usp10
, "ScriptItemizeOpenType");
346 pScriptShapeOpenType
= (void*)GetProcAddress(usp10
, "ScriptShapeOpenType");
347 pGetGlyphIndicesW
= (void*)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetGlyphIndicesW");
349 memset(&Control
, 0, sizeof(Control
));
350 memset(&State
, 0, sizeof(State
));
352 hr
= ScriptItemize(NULL
, 4, 10, &Control
, &State
, items
, NULL
);
353 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pwcInChars is NULL\n");
355 hr
= ScriptItemize(test1
, 4, 10, &Control
, &State
, NULL
, NULL
);
356 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if pItems is NULL\n");
358 hr
= ScriptItemize(test1
, 4, 1, &Control
, &State
, items
, NULL
);
359 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cMaxItems < 2.\n");
361 hr
= ScriptItemize(test1
, 0, 10, NULL
, NULL
, items
, &nItems
);
362 ok (hr
== E_INVALIDARG
, "ScriptItemize should return E_INVALIDARG if cInChars is 0\n");
364 test_items_ok(test1
,4,NULL
,NULL
,1,t11
,FALSE
,0);
365 test_items_ok(test1b
,4,NULL
,NULL
,1,t1b1
,FALSE
,0);
366 test_items_ok(test1c
,6,NULL
,NULL
,1,t1c1
,FALSE
,0);
367 test_items_ok(test2
,16,NULL
,NULL
,6,t21
,FALSE
,0);
368 test_items_ok(test2b
,11,NULL
,NULL
,4,t2b1
,FALSE
,0);
369 test_items_ok(test2c
,11,NULL
,NULL
,4,t2c1
,FALSE
,0);
370 test_items_ok(test2d
,11,NULL
,NULL
,4,t2d1
,FALSE
,0);
371 test_items_ok(test3
,41,NULL
,NULL
,1,t31
,FALSE
,0);
372 test_items_ok(test4
,12,NULL
,NULL
,5,t41
,FALSE
,0);
373 test_items_ok(test5
,38,NULL
,NULL
,1,t51
,FALSE
,0);
374 test_items_ok(test6
,5,NULL
,NULL
,2,t61
,FALSE
,0);
375 test_items_ok(test7
,29,NULL
,NULL
,3,t71
,FALSE
,0);
376 test_items_ok(test8
,4,NULL
,NULL
,1,t81
,FALSE
,0);
377 test_items_ok(test9
,5,NULL
,NULL
,2,t91
,FALSE
,0);
378 test_items_ok(test10
,4,NULL
,NULL
,1,t101
,FALSE
,0);
379 test_items_ok(test11
,8,NULL
,NULL
,1,t111
,FALSE
,0);
380 test_items_ok(test12
,5,NULL
,NULL
,1,t121
,FALSE
,0);
381 test_items_ok(test13
,7,NULL
,NULL
,1,t131
,FALSE
,0);
382 test_items_ok(test14
,7,NULL
,NULL
,1,t141
,FALSE
,0);
383 test_items_ok(test15
,5,NULL
,NULL
,1,t151
,FALSE
,0);
384 test_items_ok(test16
,5,NULL
,NULL
,1,t161
,FALSE
,0);
385 test_items_ok(test17
,6,NULL
,NULL
,1,t171
,FALSE
,0);
386 test_items_ok(test18
,5,NULL
,NULL
,1,t181
,FALSE
,0);
387 test_items_ok(test19
,6,NULL
,NULL
,1,t191
,FALSE
,0);
388 test_items_ok(test20
,5,NULL
,NULL
,2,t201
,FALSE
,0);
389 test_items_ok(test21
,5,NULL
,NULL
,1,t211
,FALSE
,0);
390 test_items_ok(test22
,6,NULL
,NULL
,2,t221
,FALSE
,0);
391 test_items_ok(test23
,6,NULL
,NULL
,2,t231
,FALSE
,0);
392 test_items_ok(test24
,12,NULL
,NULL
,1,t241
,FALSE
,0);
393 test_items_ok(test25
,10,NULL
,NULL
,1,t251
,FALSE
,0);
394 test_items_ok(test26
,2,NULL
,NULL
,1,t261
,FALSE
,0);
395 test_items_ok(test27
,8,NULL
,NULL
,1,t271
,FALSE
,0);
396 test_items_ok(test28
,4,NULL
,NULL
,1,t281
,FALSE
,0);
397 test_items_ok(test29
,10,NULL
,NULL
,2,t291
,FALSE
,0);
399 State
.uBidiLevel
= 0;
400 test_items_ok(test1
,4,&Control
,&State
,1,t11
,FALSE
,0);
401 test_items_ok(test1b
,4,&Control
,&State
,1,t1b1
,FALSE
,0);
402 test_items_ok(test1c
,6,&Control
,&State
,1,t1c1
,FALSE
,0);
403 test_items_ok(test2
,16,&Control
,&State
,4,t22
,FALSE
,0);
404 test_items_ok(test2b
,11,&Control
,&State
,4,t2b1
,FALSE
,0);
405 test_items_ok(test2c
,11,&Control
,&State
,5,t2c2
,FALSE
,0);
406 test_items_ok(test2d
,11,&Control
,&State
,5,t2d2
,FALSE
,0);
407 test_items_ok(test3
,41,&Control
,&State
,1,t31
,FALSE
,0);
408 test_items_ok(test4
,12,&Control
,&State
,5,t41
,FALSE
,0);
409 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
410 test_items_ok(test6
,5,&Control
,&State
,2,t61
,FALSE
,0);
411 test_items_ok(test7
,29,&Control
,&State
,3,t72
,FALSE
,0);
412 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
413 test_items_ok(test9
,5,&Control
,&State
,2,t91
,FALSE
,0);
414 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
415 test_items_ok(test11
,8,&Control
,&State
,1,t111
,FALSE
,0);
416 test_items_ok(test12
,5,&Control
,&State
,1,t121
,FALSE
,0);
417 test_items_ok(test13
,7,&Control
,&State
,1,t131
,FALSE
,0);
418 test_items_ok(test14
,7,&Control
,&State
,1,t141
,FALSE
,0);
419 test_items_ok(test15
,5,&Control
,&State
,1,t151
,FALSE
,0);
420 test_items_ok(test16
,5,&Control
,&State
,1,t161
,FALSE
,0);
421 test_items_ok(test17
,6,&Control
,&State
,1,t171
,FALSE
,0);
422 test_items_ok(test18
,5,&Control
,&State
,1,t181
,FALSE
,0);
423 test_items_ok(test19
,6,&Control
,&State
,1,t191
,FALSE
,0);
424 test_items_ok(test20
,5,&Control
,&State
,2,t201
,FALSE
,0);
425 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
426 test_items_ok(test22
,6,&Control
,&State
,2,t221
,FALSE
,0);
427 test_items_ok(test23
,6,&Control
,&State
,2,t231
,FALSE
,0);
428 test_items_ok(test24
,12,&Control
,&State
,1,t241
,FALSE
,0);
429 test_items_ok(test25
,10,&Control
,&State
,1,t251
,FALSE
,0);
430 test_items_ok(test26
,2,&Control
,&State
,1,t261
,FALSE
,0);
431 test_items_ok(test27
,8,&Control
,&State
,1,t271
,FALSE
,0);
432 test_items_ok(test28
,4,&Control
,&State
,1,t281
,FALSE
,0);
433 test_items_ok(test29
,10,&Control
,&State
,2,t291
,FALSE
,0);
435 State
.uBidiLevel
= 1;
436 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
437 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
438 test_items_ok(test1c
,6,&Control
,&State
,3,t1c2
,FALSE
,0);
439 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
440 test_items_ok(test2b
,11,&Control
,&State
,4,t2b2
,FALSE
,0);
441 test_items_ok(test2c
,11,&Control
,&State
,4,t2c3
,FALSE
,0);
442 test_items_ok(test2d
,11,&Control
,&State
,4,t2d3
,FALSE
,0);
443 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
444 test_items_ok(test4
,12,&Control
,&State
,4,t42
,FALSE
,0);
445 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
446 test_items_ok(test6
,5,&Control
,&State
,2,t62
,FALSE
,0);
447 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
448 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
449 test_items_ok(test9
,5,&Control
,&State
,2,t92
,FALSE
,0);
450 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
451 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
452 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
453 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
454 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
455 test_items_ok(test15
,5,&Control
,&State
,1,t152
,FALSE
,0);
456 test_items_ok(test16
,5,&Control
,&State
,1,t162
,FALSE
,0);
457 test_items_ok(test17
,6,&Control
,&State
,1,t172
,FALSE
,0);
458 test_items_ok(test18
,5,&Control
,&State
,1,t182
,FALSE
,0);
459 test_items_ok(test19
,6,&Control
,&State
,1,t192
,FALSE
,0);
460 test_items_ok(test20
,5,&Control
,&State
,2,t202
,FALSE
,0);
461 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
462 test_items_ok(test22
,6,&Control
,&State
,2,t222
,FALSE
,1);
463 test_items_ok(test23
,6,&Control
,&State
,2,t232
,FALSE
,0);
464 test_items_ok(test24
,12,&Control
,&State
,1,t242
,FALSE
,0);
465 test_items_ok(test25
,10,&Control
,&State
,1,t252
,FALSE
,0);
466 test_items_ok(test26
,2,&Control
,&State
,1,t262
,FALSE
,0);
467 test_items_ok(test27
,8,&Control
,&State
,1,t272
,FALSE
,0);
468 test_items_ok(test28
,4,&Control
,&State
,1,t282
,FALSE
,0);
469 test_items_ok(test29
,10,&Control
,&State
,2,t292
,FALSE
,0);
471 State
.uBidiLevel
= 1;
472 Control
.fMergeNeutralItems
= TRUE
;
473 test_items_ok(test1
,4,&Control
,&State
,1,t12
,FALSE
,0);
474 test_items_ok(test1b
,4,&Control
,&State
,1,t1b2
,FALSE
,0);
475 test_items_ok(test1c
,6,&Control
,&State
,3,t1c2
,FALSE
,0);
476 test_items_ok(test2
,16,&Control
,&State
,4,t23
,FALSE
,0);
477 test_items_ok(test2b
,11,&Control
,&State
,2,t2b3
,FALSE
,4);
478 test_items_ok(test2c
,11,&Control
,&State
,2,t2c4
,FALSE
,4);
479 test_items_ok(test2d
,11,&Control
,&State
,2,t2d4
,FALSE
,4);
480 test_items_ok(test3
,41,&Control
,&State
,1,t32
,FALSE
,0);
481 test_items_ok(test4
,12,&Control
,&State
,3,t43
,FALSE
,4);
482 test_items_ok(test5
,38,&Control
,&State
,1,t51
,FALSE
,0);
483 test_items_ok(test6
,5,&Control
,&State
,1,t63
,FALSE
,2);
484 test_items_ok(test7
,29,&Control
,&State
,3,t73
,FALSE
,0);
485 test_items_ok(test8
,4,&Control
,&State
,1,t81
,FALSE
,0);
486 test_items_ok(test9
,5,&Control
,&State
,1,t93
,FALSE
,2);
487 test_items_ok(test10
,4,&Control
,&State
,1,t101
,FALSE
,0);
488 test_items_ok(test11
,8,&Control
,&State
,1,t112
,FALSE
,0);
489 test_items_ok(test12
,5,&Control
,&State
,1,t122
,FALSE
,0);
490 test_items_ok(test13
,7,&Control
,&State
,1,t132
,FALSE
,0);
491 test_items_ok(test14
,7,&Control
,&State
,1,t142
,FALSE
,0);
492 test_items_ok(test15
,5,&Control
,&State
,1,t152
,FALSE
,0);
493 test_items_ok(test16
,5,&Control
,&State
,1,t162
,FALSE
,0);
494 test_items_ok(test17
,6,&Control
,&State
,1,t172
,FALSE
,0);
495 test_items_ok(test18
,5,&Control
,&State
,1,t182
,FALSE
,0);
496 test_items_ok(test19
,6,&Control
,&State
,1,t192
,FALSE
,0);
497 test_items_ok(test20
,5,&Control
,&State
,2,t202
,FALSE
,0);
498 test_items_ok(test21
,5,&Control
,&State
,1,t211
,FALSE
,0);
499 test_items_ok(test22
,6,&Control
,&State
,1,t223
,FALSE
,2);
500 test_items_ok(test23
,6,&Control
,&State
,2,t232
,FALSE
,0);
501 test_items_ok(test24
,12,&Control
,&State
,1,t242
,FALSE
,0);
502 test_items_ok(test25
,10,&Control
,&State
,1,t252
,FALSE
,0);
503 test_items_ok(test26
,2,&Control
,&State
,1,t262
,FALSE
,0);
504 test_items_ok(test27
,8,&Control
,&State
,1,t272
,FALSE
,0);
505 test_items_ok(test28
,4,&Control
,&State
,1,t282
,FALSE
,0);
506 test_items_ok(test29
,10,&Control
,&State
,2,t292
,FALSE
,0);
509 static inline void _test_shape_ok(int valid
, HDC hdc
, LPCWSTR string
,
510 DWORD cchString
, SCRIPT_CONTROL
*Control
,
511 SCRIPT_STATE
*State
, DWORD item
, DWORD nGlyphs
,
512 const shapeTest_char
* charItems
,
513 const shapeTest_glyph
* glyphItems
)
516 int x
, outnItems
=0, outnGlyphs
=0;
517 SCRIPT_ITEM outpItems
[15];
518 SCRIPT_CACHE sc
= NULL
;
521 int maxGlyphs
= cchString
* 1.5;
522 SCRIPT_GLYPHPROP
*glyphProp
;
523 SCRIPT_CHARPROP
*charProp
;
526 hr
= pScriptItemizeOpenType(string
, cchString
, 15, Control
, State
, outpItems
, tags
, &outnItems
);
527 if (hr
== USP_E_SCRIPT_NOT_IN_FONT
)
530 winetest_win_skip("Select font does not support script\n");
532 winetest_trace("Select font does not support script\n");
536 winetest_ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
538 winetest_trace("ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
541 if (outnItems
<= item
)
544 winetest_win_skip("Did not get enough items\n");
546 winetest_trace("Did not get enough items\n");
550 logclust
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * cchString
);
551 memset(logclust
,'a',sizeof(WORD
) * cchString
);
552 charProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_CHARPROP
) * cchString
);
553 memset(charProp
,'a',sizeof(SCRIPT_CHARPROP
) * cchString
);
554 glyphs
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORD
) * maxGlyphs
);
555 memset(glyphs
,'a',sizeof(WORD
) * cchString
);
556 glyphProp
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_GLYPHPROP
) * maxGlyphs
);
557 memset(glyphProp
,'a',sizeof(SCRIPT_GLYPHPROP
) * cchString
);
559 hr
= pScriptShapeOpenType(hdc
, &sc
, &outpItems
[item
].a
, tags
[item
], 0x00000000, NULL
, NULL
, 0, string
, cchString
, maxGlyphs
, logclust
, charProp
, glyphs
, glyphProp
, &outnGlyphs
);
561 winetest_ok(hr
== S_OK
, "ScriptShapeOpenType failed (%x)\n",hr
);
563 winetest_trace("ScriptShapeOpenType failed (%x)\n",hr
);
567 for (x
= 0; x
< cchString
; x
++)
570 winetest_ok(logclust
[x
] == charItems
[x
].wLogClust
, "%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
571 else if (logclust
[x
] != charItems
[x
].wLogClust
)
572 winetest_trace("%i: invalid LogClust(%i)\n",x
,logclust
[x
]);
574 winetest_ok(charProp
[x
].fCanGlyphAlone
== charItems
[x
].CharProp
.fCanGlyphAlone
, "%i: invalid fCanGlyphAlone\n",x
);
575 else if (charProp
[x
].fCanGlyphAlone
!= charItems
[x
].CharProp
.fCanGlyphAlone
)
576 winetest_trace("%i: invalid fCanGlyphAlone\n",x
);
580 winetest_ok(nGlyphs
== outnGlyphs
, "got incorrect number of glyphs (%i)\n",outnGlyphs
);
581 else if (nGlyphs
!= outnGlyphs
)
582 winetest_trace("got incorrect number of glyphs (%i)\n",outnGlyphs
);
583 for (x
= 0; x
< outnGlyphs
; x
++)
585 if (glyphItems
[x
].Glyph
)
588 winetest_ok(glyphs
[x
]!=0, "%i: Glyph not present when it should be\n",x
);
589 else if (glyphs
[x
]==0)
590 winetest_trace("%i: Glyph not present when it should be\n",x
);
595 winetest_ok(glyphs
[x
]==0, "%i: Glyph present when it should not be\n",x
);
596 else if (glyphs
[x
]!=0)
597 winetest_trace("%i: Glyph present when it should not be\n",x
);
600 winetest_ok(glyphProp
[x
].sva
.uJustification
== glyphItems
[x
].GlyphProp
.sva
.uJustification
, "%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
601 else if (glyphProp
[x
].sva
.uJustification
!= glyphItems
[x
].GlyphProp
.sva
.uJustification
)
602 winetest_trace("%i: uJustification incorrect (%i)\n",x
,glyphProp
[x
].sva
.uJustification
);
604 winetest_ok(glyphProp
[x
].sva
.fClusterStart
== glyphItems
[x
].GlyphProp
.sva
.fClusterStart
, "%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
605 else if (glyphProp
[x
].sva
.fClusterStart
!= glyphItems
[x
].GlyphProp
.sva
.fClusterStart
)
606 winetest_trace("%i: fClusterStart incorrect (%i)\n",x
,glyphProp
[x
].sva
.fClusterStart
);
608 winetest_ok(glyphProp
[x
].sva
.fDiacritic
== glyphItems
[x
].GlyphProp
.sva
.fDiacritic
, "%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
609 else if (glyphProp
[x
].sva
.fDiacritic
!= glyphItems
[x
].GlyphProp
.sva
.fDiacritic
)
610 winetest_trace("%i: fDiacritic incorrect (%i)\n",x
,glyphProp
[x
].sva
.fDiacritic
);
612 winetest_ok(glyphProp
[x
].sva
.fZeroWidth
== glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
, "%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
613 else if (glyphProp
[x
].sva
.fZeroWidth
!= glyphItems
[x
].GlyphProp
.sva
.fZeroWidth
)
614 winetest_trace("%i: fZeroWidth incorrect (%i)\n",x
,glyphProp
[x
].sva
.fZeroWidth
);
617 HeapFree(GetProcessHeap(),0,logclust
);
618 HeapFree(GetProcessHeap(),0,charProp
);
619 HeapFree(GetProcessHeap(),0,glyphs
);
620 HeapFree(GetProcessHeap(),0,glyphProp
);
621 ScriptFreeCache(&sc
);
624 #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)
626 #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)
628 typedef struct tagRangeP
{
633 static int CALLBACK
enumFontProc( const LOGFONT
*lpelfe
, const TEXTMETRIC
*lpntme
,
634 DWORD FontType
, LPARAM lParam
)
636 NEWTEXTMETRICEX
*ntme
= (NEWTEXTMETRICEX
*)lpntme
;
637 fontEnumParam
*rp
= (fontEnumParam
*) lParam
;
642 if (FontType
!= TRUETYPE_FONTTYPE
)
646 while (i
> sizeof(DWORD
)*8)
649 i
-= (sizeof(DWORD
)*8);
656 if (ntme
->ntmFontSig
.fsUsb
[idx
] & mask
)
658 memcpy(&(rp
->lf
),lpelfe
,sizeof(LOGFONT
));
664 static int _find_font_for_range(HDC hdc
, const CHAR
*recommended
, BYTE range
, const WCHAR check
, HFONT
*hfont
, HFONT
*origFont
)
667 fontEnumParam lParam
;
669 lParam
.range
= range
;
670 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
675 lstrcpyA(lParam
.lf
.lfFaceName
, recommended
);
676 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0))
678 *hfont
= CreateFontIndirectA(&lParam
.lf
);
681 winetest_trace("using font %s\n",lParam
.lf
.lfFaceName
);
689 memset(&lParam
.lf
,0,sizeof(LOGFONT
));
690 lParam
.lf
.lfCharSet
= DEFAULT_CHARSET
;
692 if (!EnumFontFamiliesExA(hdc
, &lParam
.lf
, enumFontProc
, (LPARAM
)&lParam
, 0) && lParam
.lf
.lfFaceName
[0])
694 *hfont
= CreateFontIndirectA(&lParam
.lf
);
696 winetest_trace("trying font %s: failures will only be warnings\n",lParam
.lf
.lfFaceName
);
704 *origFont
= SelectObject(hdc
,*hfont
);
705 if (pGetGlyphIndicesW
&& (pGetGlyphIndicesW(hdc
, &check
, 1, &glyph
, 0) == GDI_ERROR
|| glyph
==0))
707 winetest_trace(" Font fails to contain required glyphs\n");
708 SelectObject(hdc
,*origFont
);
709 DeleteObject(*hfont
);
717 winetest_trace("Failed to find usable font\n");
722 #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)
724 static void test_ScriptShapeOpenType(HDC hdc
)
727 SCRIPT_CACHE sc
= NULL
;
728 WORD glyphs
[4], logclust
[4];
729 SCRIPT_GLYPHPROP glyphProp
[4];
730 SCRIPT_ITEM items
[2];
732 SCRIPT_CONTROL Control
;
735 HFONT hfont
, hfont_orig
;
738 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
739 static const shapeTest_char t1_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
740 static const shapeTest_glyph t1_g
[] = {
741 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
742 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
743 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
744 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
746 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
747 static const shapeTest_char t2_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{3,{0,0}}};
748 static const shapeTest_glyph t2_g
[] = {
749 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
750 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
751 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
752 {0,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
755 static const WCHAR test_hebrew
[] = {0x05e9, 0x05dc, 0x05d5, 0x05dd,0};
756 static const shapeTest_char hebrew_c
[] = {{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
757 static const shapeTest_glyph hebrew_g
[] = {
758 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
759 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
760 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
761 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}} };
764 static const WCHAR test_arabic
[] = {0x0633,0x0644,0x0627,0x0645,0};
765 static const shapeTest_char arabic_c
[] = {{2,{0,0}},{1,{0,0}},{1,{0,0}},{0,{0,0}}};
766 static const shapeTest_glyph arabic_g
[] = {
767 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
768 {1,{{SCRIPT_JUSTIFY_ARABIC_NORMAL
,1,0,0,0,0},0}},
769 {1,{{SCRIPT_JUSTIFY_ARABIC_SEEN
,1,0,0,0,0},0}} };
772 static const WCHAR test_thai
[] = {0x0e2a, 0x0e04, 0x0e23, 0x0e34, 0x0e1b, 0x0e15, 0x0e4c, 0x0e44, 0x0e17, 0x0e22,};
773 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}}};
774 static const shapeTest_glyph thai_g
[] = {
775 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
776 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
777 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
778 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
779 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
780 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
781 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
782 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
783 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
784 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}}};
787 static const WCHAR test_syriac
[] = {0x0710, 0x0710, 0x0710, 0x0728, 0x0718, 0x0723,0};
788 static const shapeTest_char syriac_c
[] = {{5,{0,0}},{4,{0,0}},{3,{0,0}},{2,{0,0}},{1,{0,0}},{0,{0,0}}};
789 static const shapeTest_glyph syriac_g
[] = {
790 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
791 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
792 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
793 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
794 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
795 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
798 static const WCHAR test_thaana
[] = {0x078a, 0x07ae, 0x0792, 0x07b0, 0x0020, 0x0796, 0x07aa, 0x0789, 0x07b0, 0x0795, 0x07ac, 0x0791, 0x07b0};
799 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}}};
800 static const shapeTest_glyph thaana_g
[] = {
801 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
802 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
803 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
804 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
805 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
806 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
807 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
808 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
809 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
810 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
811 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
812 {1,{{SCRIPT_JUSTIFY_NONE
,0,1,1,0,0},0}},
813 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
816 static const WCHAR test_phagspa
[] = {0xa84f, 0xa861, 0xa843, 0x0020, 0xa863, 0xa861, 0xa859, 0x0020, 0xa850, 0xa85c, 0xa85e};
817 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}}};
818 static const shapeTest_glyph phagspa_g
[] = {
819 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
820 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
821 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
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}},
826 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
827 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
828 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
829 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
832 static const WCHAR test_lao
[] = {0x0ead, 0x0eb1, 0x0e81, 0x0eaa, 0x0ead, 0x0e99, 0x0ea5, 0x0eb2, 0x0ea7, 0};
833 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}}};
834 static const shapeTest_glyph lao_g
[] = {
835 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
836 {1,{{SCRIPT_JUSTIFY_CHARACTER
,0,1,1,0,0},0}},
837 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
838 {1,{{SCRIPT_JUSTIFY_CHARACTER
,1,0,0,0,0},0}},
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}},
843 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
846 static const WCHAR test_tibetan
[] = {0x0f04, 0x0f05, 0x0f0e, 0x0020, 0x0f51, 0x0f7c, 0x0f53, 0x0f0b, 0x0f5a, 0x0f53, 0x0f0b, 0x0f51, 0x0f44, 0x0f0b, 0x0f54, 0x0f7c, 0x0f0d};
847 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}}};
848 static const shapeTest_glyph tibetan_g
[] = {
849 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
850 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
851 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
852 {1,{{SCRIPT_JUSTIFY_BLANK
,1,0,0,0,0},0}},
853 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
854 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
855 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
856 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
857 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
858 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
859 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
860 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
861 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
862 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
863 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
864 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
865 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
868 static const WCHAR test_devanagari
[] = {0x0926, 0x0947, 0x0935, 0x0928, 0x093e, 0x0917, 0x0930, 0x0940};
869 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}}};
870 static const shapeTest_glyph devanagari_g
[] = {
871 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
872 {1,{{SCRIPT_JUSTIFY_NONE
,0,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
,0,0,0,0,0},0}},
876 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
877 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
878 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
881 static const WCHAR test_bengali
[] = {0x09ac, 0x09be, 0x0982, 0x09b2, 0x09be};
882 static const shapeTest_char bengali_c
[] = {{0,{0,0}},{0,{0,0}},{0,{0,0}},{3,{0,0}},{3,{0,0}}};
883 static const shapeTest_glyph bengali_g
[] = {
884 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
885 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
886 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
887 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
888 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
891 static const WCHAR test_gurmukhi
[] = {0x0a17, 0x0a41, 0x0a30, 0x0a2e, 0x0a41, 0x0a16, 0x0a40};
892 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}}};
893 static const shapeTest_glyph gurmukhi_g
[] = {
894 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
895 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
896 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
897 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
898 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
899 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
900 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
903 static const WCHAR test_gujarati
[] = {0x0a97, 0x0ac1, 0x0a9c, 0x0ab0, 0x0abe, 0x0aa4, 0x0ac0};
904 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}}};
905 static const shapeTest_glyph gujarati_g
[] = {
906 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
907 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
908 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
909 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
910 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
911 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
912 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
915 static const WCHAR test_oriya
[] = {0x0b13, 0x0b21, 0x0b3c, 0x0b3f, 0x0b06};
916 static const shapeTest_char oriya_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
917 static const shapeTest_glyph oriya_g
[] = {
918 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
919 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
920 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
921 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
924 static const WCHAR test_tamil
[] = {0x0ba4, 0x0bae, 0x0bbf, 0x0bb4, 0x0bcd};
925 static const shapeTest_char tamil_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}},{3,{0,0}}};
926 static const shapeTest_glyph tamil_g
[] = {
927 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
928 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
929 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
930 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}} };
933 static const WCHAR test_telugu
[] = {0x0c24, 0x0c46, 0x0c32, 0x0c41, 0x0c17, 0x0c41};
934 static const shapeTest_char telugu_c
[] = {{0,{0,0}},{0,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
935 static const shapeTest_glyph telugu_g
[] = {
936 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
937 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
938 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
939 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
940 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
941 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
944 static const WCHAR test_malayalam
[] = {0x0d2e, 0x0d32, 0x0d2f, 0x0d3e, 0x0d33, 0x0d02};
945 static const shapeTest_char malayalam_c
[] = {{0,{0,0}},{1,{0,0}},{2,{0,0}},{2,{0,0}},{4,{0,0}},{4,{0,0}}};
946 static const shapeTest_glyph malayalam_g
[] = {
947 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
948 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
949 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
950 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
951 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
952 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
955 static const WCHAR test_kannada
[] = {0x0c95, 0x0ca8, 0x0ccd, 0x0ca8, 0x0ca1};
956 static const shapeTest_char kannada_c
[] = {{0,{0,0}},{1,{0,0}},{1,{0,0}},{1,{0,0}},{3,{0,0}}};
957 static const shapeTest_glyph kannada_g
[] = {
958 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
959 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
960 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}},
961 {1,{{SCRIPT_JUSTIFY_NONE
,1,0,0,0,0},0}},
962 {1,{{SCRIPT_JUSTIFY_NONE
,0,0,0,0,0},0}} };
964 if (!pScriptItemizeOpenType
|| !pScriptShapeOpenType
)
966 win_skip("ScriptShapeOpenType not available on this platform\n");
970 memset(&Control
, 0 , sizeof(Control
));
971 memset(&State
, 0 , sizeof(State
));
973 hr
= pScriptItemizeOpenType(test1
, 4, 2, &Control
, &State
, items
, tags
, &outnItems
);
974 ok(!hr
, "ScriptItemizeOpenType should return S_OK not %08x\n", hr
);
975 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
977 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, NULL
, &nb
);
978 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
980 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, NULL
);
981 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
983 hr
= pScriptShapeOpenType(NULL
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
984 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_PENDING not %08x\n", hr
);
986 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, NULL
, NULL
, glyphs
, glyphProp
, &nb
);
987 ok( hr
== E_INVALIDARG
,
988 "ScriptShapeOpenType should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
989 hr
= pScriptShapeOpenType(hdc
, &sc
, &items
[0].a
, tags
[0], 0x00000000, NULL
, NULL
, 0, test1
, 4, 4, logclust
, NULL
, glyphs
, glyphProp
, &nb
);
990 ok(hr
== E_INVALIDARG
, "ScriptShapeOpenType should return E_INVALIDARG not %08x\n", hr
);
992 ScriptFreeCache(&sc
);
994 test_shape_ok(hdc
, test1
, 4, &Control
, &State
, 0, 4, t1_c
, t1_g
);
995 test_shape_ok(hdc
, test2
, 4, &Control
, &State
, 1, 4, t2_c
, t2_g
);
997 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 11, test_hebrew
[0], &hfont
, &hfont_orig
);
1000 test_shape_ok_valid(test_valid
, hdc
, test_hebrew
, 4, &Control
, &State
, 0, 4, hebrew_c
, hebrew_g
);
1001 SelectObject(hdc
, hfont_orig
);
1002 DeleteObject(hfont
);
1005 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 13, test_arabic
[0], &hfont
, &hfont_orig
);
1008 test_shape_ok_valid(test_valid
, hdc
, test_arabic
, 4, &Control
, &State
, 0, 3, arabic_c
, arabic_g
);
1009 SelectObject(hdc
, hfont_orig
);
1010 DeleteObject(hfont
);
1013 test_valid
= find_font_for_range(hdc
, "Microsoft Sans Serif", 24, test_thai
[0], &hfont
, &hfont_orig
);
1016 test_shape_ok_valid(test_valid
, hdc
, test_thai
, 10, &Control
, &State
, 0, 10, thai_c
, thai_g
);
1017 SelectObject(hdc
, hfont_orig
);
1018 DeleteObject(hfont
);
1021 test_valid
= find_font_for_range(hdc
, "Estrangelo Edessa", 71, test_syriac
[0], &hfont
, &hfont_orig
);
1024 test_shape_ok_valid(test_valid
, hdc
, test_syriac
, 6, &Control
, &State
, 0, 6, syriac_c
, syriac_g
);
1025 SelectObject(hdc
, hfont_orig
);
1026 DeleteObject(hfont
);
1029 test_valid
= find_font_for_range(hdc
, "MV Boli", 72, test_thaana
[0], &hfont
, &hfont_orig
);
1032 test_shape_ok_valid(test_valid
, hdc
, test_thaana
, 13, &Control
, &State
, 0, 13, thaana_c
, thaana_g
);
1033 SelectObject(hdc
, hfont_orig
);
1034 DeleteObject(hfont
);
1037 test_valid
= find_font_for_range(hdc
, "Microsoft PhagsPa", 53, test_phagspa
[0], &hfont
, &hfont_orig
);
1040 test_shape_ok_valid(test_valid
, hdc
, test_phagspa
, 11, &Control
, &State
, 0, 11, phagspa_c
, phagspa_g
);
1041 SelectObject(hdc
, hfont_orig
);
1042 DeleteObject(hfont
);
1045 test_valid
= find_font_for_range(hdc
, "DokChampa", 25, test_lao
[0], &hfont
, &hfont_orig
);
1048 test_shape_ok_valid(test_valid
, hdc
, test_lao
, 9, &Control
, &State
, 0, 9, lao_c
, lao_g
);
1049 SelectObject(hdc
, hfont_orig
);
1050 DeleteObject(hfont
);
1053 test_valid
= find_font_for_range(hdc
, "Microsoft Himalaya", 70, test_tibetan
[0], &hfont
, &hfont_orig
);
1056 test_shape_ok_valid(test_valid
, hdc
, test_tibetan
, 17, &Control
, &State
, 0, 17, tibetan_c
, tibetan_g
);
1057 SelectObject(hdc
, hfont_orig
);
1058 DeleteObject(hfont
);
1061 test_valid
= find_font_for_range(hdc
, "Mangal", 15, test_devanagari
[0], &hfont
, &hfont_orig
);
1064 test_shape_ok_valid(test_valid
, hdc
, test_devanagari
, 8, &Control
, &State
, 0, 8, devanagari_c
, devanagari_g
);
1065 SelectObject(hdc
, hfont_orig
);
1066 DeleteObject(hfont
);
1069 test_valid
= find_font_for_range(hdc
, "Vrinda", 16, test_bengali
[0], &hfont
, &hfont_orig
);
1072 test_shape_ok_valid(test_valid
, hdc
, test_bengali
, 5, &Control
, &State
, 0, 5, bengali_c
, bengali_g
);
1073 SelectObject(hdc
, hfont_orig
);
1074 DeleteObject(hfont
);
1077 test_valid
= find_font_for_range(hdc
, "Raavi", 17, test_gurmukhi
[0], &hfont
, &hfont_orig
);
1080 test_shape_ok_valid(test_valid
, hdc
, test_gurmukhi
, 7, &Control
, &State
, 0, 7, gurmukhi_c
, gurmukhi_g
);
1081 SelectObject(hdc
, hfont_orig
);
1082 DeleteObject(hfont
);
1085 test_valid
= find_font_for_range(hdc
, "Shruti", 18, test_gujarati
[0], &hfont
, &hfont_orig
);
1088 test_shape_ok_valid(test_valid
, hdc
, test_gujarati
, 7, &Control
, &State
, 0, 7, gujarati_c
, gujarati_g
);
1089 SelectObject(hdc
, hfont_orig
);
1090 DeleteObject(hfont
);
1093 test_valid
= find_font_for_range(hdc
, "Kalinga", 19, test_oriya
[0], &hfont
, &hfont_orig
);
1096 test_shape_ok_valid(test_valid
, hdc
, test_oriya
, 5, &Control
, &State
, 0, 4, oriya_c
, oriya_g
);
1097 SelectObject(hdc
, hfont_orig
);
1098 DeleteObject(hfont
);
1101 test_valid
= find_font_for_range(hdc
, "Latha", 20, test_tamil
[0], &hfont
, &hfont_orig
);
1104 test_shape_ok_valid(test_valid
, hdc
, test_tamil
, 5, &Control
, &State
, 0, 4, tamil_c
, tamil_g
);
1105 SelectObject(hdc
, hfont_orig
);
1106 DeleteObject(hfont
);
1109 test_valid
= find_font_for_range(hdc
, "Gautami", 21, test_telugu
[0], &hfont
, &hfont_orig
);
1112 test_shape_ok_valid(test_valid
, hdc
, test_telugu
, 6, &Control
, &State
, 0, 6, telugu_c
, telugu_g
);
1113 SelectObject(hdc
, hfont_orig
);
1114 DeleteObject(hfont
);
1117 test_valid
= find_font_for_range(hdc
, "Kartika", 23, test_malayalam
[0], &hfont
, &hfont_orig
);
1120 test_shape_ok_valid(test_valid
, hdc
, test_malayalam
, 6, &Control
, &State
, 0, 6, malayalam_c
, malayalam_g
);
1121 SelectObject(hdc
, hfont_orig
);
1122 DeleteObject(hfont
);
1125 test_valid
= find_font_for_range(hdc
, "Tunga", 22, test_kannada
[0], &hfont
, &hfont_orig
);
1128 test_shape_ok_valid(test_valid
, hdc
, test_kannada
, 5, &Control
, &State
, 0, 4, kannada_c
, kannada_g
);
1129 SelectObject(hdc
, hfont_orig
);
1130 DeleteObject(hfont
);
1134 static void test_ScriptShape(HDC hdc
)
1136 static const WCHAR test1
[] = {'w', 'i', 'n', 'e',0};
1137 static const WCHAR test2
[] = {0x202B, 'i', 'n', 0x202C,0};
1139 SCRIPT_CACHE sc
= NULL
;
1140 WORD glyphs
[4], glyphs2
[4], logclust
[4];
1141 SCRIPT_VISATTR attrs
[4];
1142 SCRIPT_ITEM items
[2];
1145 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
1146 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
1147 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1149 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, NULL
, &nb
);
1150 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
1152 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, NULL
);
1153 ok(hr
== E_INVALIDARG
, "ScriptShape should return E_INVALIDARG not %08x\n", hr
);
1155 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
1156 ok(hr
== E_PENDING
, "ScriptShape should return E_PENDING not %08x\n", hr
);
1158 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, NULL
, attrs
, &nb
);
1159 ok(broken(hr
== S_OK
) ||
1160 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1161 hr
== E_FAIL
, /* WIN7 */
1162 "ScriptShape should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1163 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1165 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1166 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1167 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1170 memset(glyphs
,-1,sizeof(glyphs
));
1171 memset(logclust
,-1,sizeof(logclust
));
1172 memset(attrs
,-1,sizeof(attrs
));
1173 hr
= ScriptShape(NULL
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1174 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1175 ok(nb
== 4, "Wrong number of items\n");
1176 ok(logclust
[0] == 0, "clusters out of order\n");
1177 ok(logclust
[1] == 1, "clusters out of order\n");
1178 ok(logclust
[2] == 2, "clusters out of order\n");
1179 ok(logclust
[3] == 3, "clusters out of order\n");
1180 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1181 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1182 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1183 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1184 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1185 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1186 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1187 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1188 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1189 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1190 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1191 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1192 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1193 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1194 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1195 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1197 ScriptFreeCache(&sc
);
1200 memset(glyphs2
,-1,sizeof(glyphs2
));
1201 memset(logclust
,-1,sizeof(logclust
));
1202 memset(attrs
,-1,sizeof(attrs
));
1203 hr
= ScriptShape(hdc
, &sc
, test2
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
1204 ok(hr
== S_OK
, "ScriptShape should return S_OK not %08x\n", hr
);
1205 ok(nb
== 4, "Wrong number of items\n");
1206 ok(glyphs2
[0] == 0 || broken(glyphs2
[0] == 0x80), "Incorrect glyph for 0x202B\n");
1207 ok(glyphs2
[3] == 0 || broken(glyphs2
[3] == 0x80), "Incorrect glyph for 0x202C\n");
1208 ok(logclust
[0] == 0, "clusters out of order\n");
1209 ok(logclust
[1] == 1, "clusters out of order\n");
1210 ok(logclust
[2] == 2, "clusters out of order\n");
1211 ok(logclust
[3] == 3, "clusters out of order\n");
1212 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1213 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1214 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1215 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1216 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1217 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1218 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1219 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1220 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1221 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1222 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1223 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1224 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1225 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1226 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1227 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1229 /* modify LTR to RTL */
1230 items
[0].a
.fRTL
= 1;
1231 memset(glyphs2
,-1,sizeof(glyphs2
));
1232 memset(logclust
,-1,sizeof(logclust
));
1233 memset(attrs
,-1,sizeof(attrs
));
1234 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs2
, logclust
, attrs
, &nb
);
1235 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1236 ok(nb
== 4, "Wrong number of items\n");
1237 ok(glyphs2
[0] == glyphs
[3], "Glyphs not reordered properly\n");
1238 ok(glyphs2
[1] == glyphs
[2], "Glyphs not reordered properly\n");
1239 ok(glyphs2
[2] == glyphs
[1], "Glyphs not reordered properly\n");
1240 ok(glyphs2
[3] == glyphs
[0], "Glyphs not reordered properly\n");
1241 ok(logclust
[0] == 3, "clusters out of order\n");
1242 ok(logclust
[1] == 2, "clusters out of order\n");
1243 ok(logclust
[2] == 1, "clusters out of order\n");
1244 ok(logclust
[3] == 0, "clusters out of order\n");
1245 ok(attrs
[0].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1246 ok(attrs
[1].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1247 ok(attrs
[2].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1248 ok(attrs
[3].uJustification
== SCRIPT_JUSTIFY_CHARACTER
, "uJustification incorrect\n");
1249 ok(attrs
[0].fClusterStart
== 1, "fClusterStart incorrect\n");
1250 ok(attrs
[1].fClusterStart
== 1, "fClusterStart incorrect\n");
1251 ok(attrs
[2].fClusterStart
== 1, "fClusterStart incorrect\n");
1252 ok(attrs
[3].fClusterStart
== 1, "fClusterStart incorrect\n");
1253 ok(attrs
[0].fDiacritic
== 0, "fDiacritic incorrect\n");
1254 ok(attrs
[1].fDiacritic
== 0, "fDiacritic incorrect\n");
1255 ok(attrs
[2].fDiacritic
== 0, "fDiacritic incorrect\n");
1256 ok(attrs
[3].fDiacritic
== 0, "fDiacritic incorrect\n");
1257 ok(attrs
[0].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1258 ok(attrs
[1].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1259 ok(attrs
[2].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1260 ok(attrs
[3].fZeroWidth
== 0, "fZeroWidth incorrect\n");
1262 ScriptFreeCache(&sc
);
1265 static void test_ScriptPlace(HDC hdc
)
1267 static const WCHAR test1
[] = {'t', 'e', 's', 't',0};
1270 SCRIPT_CACHE sc
= NULL
;
1271 WORD glyphs
[4], logclust
[4];
1272 SCRIPT_VISATTR attrs
[4];
1273 SCRIPT_ITEM items
[2];
1278 hr
= ScriptItemize(test1
, 4, 2, NULL
, NULL
, items
, NULL
);
1279 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
1280 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1282 hr
= ScriptShape(hdc
, &sc
, test1
, 4, 4, &items
[0].a
, glyphs
, logclust
, attrs
, &nb
);
1283 ok(!hr
, "ScriptShape should return S_OK not %08x\n", hr
);
1284 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1286 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, NULL
, &items
[0].a
, widths
, NULL
, NULL
);
1287 ok(hr
== E_INVALIDARG
, "ScriptPlace should return E_INVALIDARG not %08x\n", hr
);
1289 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, NULL
);
1290 ok(broken(hr
== E_PENDING
) ||
1291 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1292 hr
== E_FAIL
, /* WIN7 */
1293 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1295 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
1296 ok(hr
== E_PENDING
, "ScriptPlace should return E_PENDING not %08x\n", hr
);
1298 hr
= ScriptPlace(NULL
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, NULL
, abc
);
1299 ok(broken(hr
== E_PENDING
) ||
1300 hr
== E_INVALIDARG
|| /* Vista, W2K8 */
1301 hr
== E_FAIL
, /* WIN7 */
1302 "ScriptPlace should return E_FAIL or E_INVALIDARG, not %08x\n", hr
);
1304 hr
= ScriptPlace(hdc
, &sc
, glyphs
, 4, attrs
, &items
[0].a
, widths
, offset
, NULL
);
1305 ok(!hr
, "ScriptPlace should return S_OK not %08x\n", hr
);
1306 ok(items
[0].a
.fNoGlyphIndex
== FALSE
, "fNoGlyphIndex TRUE\n");
1308 ret
= ExtTextOutW(hdc
, 1, 1, 0, NULL
, glyphs
, 4, widths
);
1309 ok(ret
, "ExtTextOutW should return TRUE\n");
1311 ScriptFreeCache(&sc
);
1314 static void test_ScriptItemIzeShapePlace(HDC hdc
, unsigned short pwOutGlyphs
[256])
1318 const SCRIPT_PROPERTIES
**ppSp
;
1322 SCRIPT_ITEM pItem
[255];
1324 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1325 WCHAR TestItem2
[] = {'T', 'e', 's', 't', 'b', 0};
1326 WCHAR TestItem3
[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
1327 WCHAR TestItem4
[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
1328 WCHAR TestItem5
[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
1329 WCHAR TestItem6
[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
1334 unsigned short pwOutGlyphs1
[256];
1335 unsigned short pwOutGlyphs2
[256];
1336 unsigned short pwLogClust
[256];
1337 SCRIPT_VISATTR psva
[256];
1340 GOFFSET pGoffset
[256];
1344 /* Start testing usp10 functions */
1345 /* This test determines that the pointer returned by ScriptGetProperties is valid
1346 * by checking a known value in the table */
1347 hr
= ScriptGetProperties(&ppSp
, &iMaxProps
);
1348 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
1349 trace("number of script properties %d\n", iMaxProps
);
1350 ok (iMaxProps
> 0, "Number of scripts returned should not be 0\n");
1352 ok( ppSp
[0]->langid
== 0, "Langid[0] not = to 0\n"); /* Check a known value to ensure */
1355 /* This is a valid test that will cause parsing to take place */
1358 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1359 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1360 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1362 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1364 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1365 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1366 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1368 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1369 * ie. ScriptItemize has succeeded and that pItem has been set */
1372 psc
= NULL
; /* must be null on first call */
1374 cMaxGlyphs
= cInChars
;
1375 hr
= ScriptShape(NULL
, &psc
, TestItem1
, cChars
,
1376 cMaxGlyphs
, &pItem
[0].a
,
1377 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1378 ok (hr
== E_PENDING
, "If psc is NULL (%08x) the E_PENDING should be returned\n", hr
);
1380 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1381 cMaxGlyphs
, &pItem
[0].a
,
1382 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1383 ok (hr
== E_OUTOFMEMORY
, "If not enough output area cChars (%d) is > than CMaxGlyphs "
1384 "(%d) but not E_OUTOFMEMORY\n",
1385 cChars
, cMaxGlyphs
);
1387 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1388 cMaxGlyphs
, &pItem
[0].a
,
1389 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1390 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1391 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1392 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1394 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1396 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1397 hr
= ScriptPlace(NULL
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1399 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1400 for (cnt
=0; cnt
< pcGlyphs
; cnt
++)
1401 pwOutGlyphs
[cnt
] = pwOutGlyphs1
[cnt
]; /* Send to next function */
1404 /* This test will check to make sure that SCRIPT_CACHE is reused and that not translation *
1405 * takes place if fNoGlyphIndex is set. */
1409 hr
= ScriptItemize(TestItem2
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1410 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1411 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1413 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1414 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1415 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1416 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue */
1420 pItem
[0].a
.fNoGlyphIndex
= 1; /* say no translate */
1421 hr
= ScriptShape(NULL
, &psc
, TestItem2
, cChars
,
1422 cMaxGlyphs
, &pItem
[0].a
,
1423 pwOutGlyphs2
, pwLogClust
, psva
, &pcGlyphs
);
1424 ok (hr
!= E_PENDING
, "If psc should not be NULL (%08x) and the E_PENDING should be returned\n", hr
);
1425 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1426 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1427 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1428 for (cnt
=0; cnt
< cChars
&& TestItem2
[cnt
] == pwOutGlyphs2
[cnt
]; cnt
++) {}
1429 ok (cnt
== cChars
, "Translation to place when told not to. WCHAR %d - %04x != %04x\n",
1430 cnt
, TestItem2
[cnt
], pwOutGlyphs2
[cnt
]);
1432 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs2
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1434 ok (hr
== 0, "ScriptPlace should return 0 not (%08x)\n", hr
);
1437 ScriptFreeCache( &psc
);
1438 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1442 /* This is a valid test that will cause parsing to take place and create 3 script_items */
1443 cInChars
= (sizeof(TestItem3
)/2)-1;
1445 hr
= ScriptItemize(TestItem3
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1446 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1449 ok (pcItems
== 3, "The number of SCRIPT_ITEMS should be 3 not %d\n", pcItems
);
1452 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1453 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1454 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1455 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1456 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1457 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1458 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== cInChars
,
1459 "Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
1460 pItem
[2].iCharPos
, pItem
[3].iCharPos
, cInChars
);
1464 /* This is a valid test that will cause parsing to take place and create 5 script_items */
1465 cInChars
= (sizeof(TestItem4
)/2)-1;
1467 hr
= ScriptItemize(TestItem4
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1468 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1471 ok (pcItems
== 5, "The number of SCRIPT_ITEMS should be 5 not %d\n", pcItems
);
1474 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== 6,
1475 "Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
1476 pItem
[0].iCharPos
, pItem
[1].iCharPos
);
1477 ok (pItem
[0].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1478 pItem
[0].a
.s
.uBidiLevel
);
1479 ok (pItem
[1].iCharPos
== 6 && pItem
[2].iCharPos
== 11,
1480 "Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
1481 pItem
[1].iCharPos
, pItem
[2].iCharPos
);
1482 ok (pItem
[1].a
.s
.uBidiLevel
== 1, "Should have been bidi=1 not %d\n",
1483 pItem
[1].a
.s
.uBidiLevel
);
1484 ok (pItem
[2].iCharPos
== 11 && pItem
[3].iCharPos
== 12,
1485 "Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
1486 pItem
[2].iCharPos
, pItem
[3].iCharPos
);
1487 ok (pItem
[2].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1488 pItem
[2].a
.s
.uBidiLevel
);
1489 ok (pItem
[3].iCharPos
== 12 && pItem
[4].iCharPos
== 13,
1490 "Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
1491 pItem
[3].iCharPos
, pItem
[4].iCharPos
);
1492 ok (pItem
[3].a
.s
.uBidiLevel
== 0, "Should have been bidi=0 not %d\n",
1493 pItem
[3].a
.s
.uBidiLevel
);
1494 ok (pItem
[4].iCharPos
== 13 && pItem
[5].iCharPos
== cInChars
,
1495 "Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
1496 pItem
[4].iCharPos
, pItem
[5].iCharPos
, cInChars
);
1501 * This test is for when the first unicode character requires bidi support
1503 cInChars
= (sizeof(TestItem5
)-1)/sizeof(WCHAR
);
1504 hr
= ScriptItemize(TestItem5
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1505 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1506 ok (pcItems
== 4, "There should have been 4 items, found %d\n", pcItems
);
1507 ok (pItem
[0].a
.s
.uBidiLevel
== 1, "The first character should have been bidi=1 not %d\n",
1508 pItem
[0].a
.s
.uBidiLevel
);
1510 /* This test checks to make sure that the test to see if there are sufficient buffers to store *
1511 * the pointer to the last char works. Note that windows often needs a greater number of *
1512 * SCRIPT_ITEMS to process a string than is returned in pcItems. */
1513 cInChars
= (sizeof(TestItem6
)/2)-1;
1515 hr
= ScriptItemize(TestItem6
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1516 ok (hr
== E_OUTOFMEMORY
, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr
);
1520 static void test_ScriptGetCMap(HDC hdc
, unsigned short pwOutGlyphs
[256])
1523 SCRIPT_CACHE psc
= NULL
;
1526 unsigned short pwOutGlyphs2
[256];
1527 unsigned short pwOutGlyphs3
[256];
1531 static const WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1532 static const WCHAR TestItem2
[] = {0x202B, 'i', 'n', 0x202C,0};
1533 static const WCHAR TestItem3
[] = {'a','b','c','d','(','<','{','[',0x2039,0};
1534 static const WCHAR TestItem3b
[] = {'a','b','c','d',')','>','}',']',0x203A,0};
1536 /* Check to make sure that SCRIPT_CACHE gets allocated ok */
1538 cInChars
= cChars
= 5;
1539 /* Some sanity checks for ScriptGetCMap */
1541 hr
= ScriptGetCMap(NULL
, NULL
, NULL
, 0, 0, NULL
);
1542 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL,0,0,NULL), "
1543 "expected E_INVALIDARG, got %08x\n", hr
);
1545 hr
= ScriptGetCMap(NULL
, NULL
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1546 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1547 "expected E_INVALIDARG, got %08x\n", hr
);
1549 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1551 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1552 ok( hr
== E_PENDING
, "(NULL,&psc,NULL,0,0,NULL), expected E_PENDING, "
1554 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1556 /* Set psc to NULL but add hdc, to be able to check if a pointer is returned in psc */
1558 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, 0, pwOutGlyphs3
);
1559 ok( hr
== S_OK
, "ScriptGetCMap(NULL,&psc,NULL,0,0,NULL), expected S_OK, "
1561 ok( psc
!= NULL
, "ScritpGetCMap expected psc to be not NULL\n");
1562 ScriptFreeCache( &psc
);
1564 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1566 hr
= ScriptGetCMap(NULL
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1567 ok( hr
== E_PENDING
, "(NULL,&psc,), expected E_PENDING, got %08x\n", hr
);
1568 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1569 /* Check to see if the results are the same as those returned by ScriptShape */
1570 hr
= ScriptGetCMap(hdc
, &psc
, TestItem1
, cInChars
, dwFlags
, pwOutGlyphs3
);
1571 ok (hr
== 0, "ScriptGetCMap should return 0 not (%08x)\n", hr
);
1572 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1573 for (cnt
=0; cnt
< cChars
&& pwOutGlyphs
[cnt
] == pwOutGlyphs3
[cnt
]; cnt
++) {}
1574 ok (cnt
== cInChars
, "Translation not correct. WCHAR %d - %04x != %04x\n",
1575 cnt
, pwOutGlyphs
[cnt
], pwOutGlyphs3
[cnt
]);
1577 ScriptFreeCache( &psc
);
1578 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1580 cInChars
= cChars
= 4;
1581 hr
= ScriptGetCMap(hdc
, &psc
, TestItem2
, cInChars
, dwFlags
, pwOutGlyphs3
);
1582 ok (hr
== S_FALSE
, "ScriptGetCMap should return S_FALSE not (%08x)\n", hr
);
1583 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1584 ok(pwOutGlyphs3
[0] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1585 ok(pwOutGlyphs3
[3] == 0 || broken(pwOutGlyphs3
[0] == 0x80), "Glyph 0 should be default glyph\n");
1588 cInChars
= cChars
= 9;
1589 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3b
, cInChars
, dwFlags
, pwOutGlyphs2
);
1590 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1591 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1593 cInChars
= cChars
= 9;
1595 hr
= ScriptGetCMap(hdc
, &psc
, TestItem3
, cInChars
, dwFlags
, pwOutGlyphs3
);
1596 ok (hr
== S_OK
, "ScriptGetCMap should return S_OK not (%08x)\n", hr
);
1597 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1598 ok(pwOutGlyphs3
[0] == pwOutGlyphs2
[0], "glyph incorrectly altered\n");
1599 ok(pwOutGlyphs3
[1] == pwOutGlyphs2
[1], "glyph incorreclty altered\n");
1600 ok(pwOutGlyphs3
[2] == pwOutGlyphs2
[2], "glyph incorreclty altered\n");
1601 ok(pwOutGlyphs3
[3] == pwOutGlyphs2
[3], "glyph incorreclty altered\n");
1602 ok(pwOutGlyphs3
[4] == pwOutGlyphs2
[4], "glyph not mirrored correctly\n");
1603 ok(pwOutGlyphs3
[5] == pwOutGlyphs2
[5], "glyph not mirrored correctly\n");
1604 ok(pwOutGlyphs3
[6] == pwOutGlyphs2
[6], "glyph not mirrored correctly\n");
1605 ok(pwOutGlyphs3
[7] == pwOutGlyphs2
[7], "glyph not mirrored correctly\n");
1606 ok(pwOutGlyphs3
[8] == pwOutGlyphs2
[8], "glyph not mirrored correctly\n");
1608 ScriptFreeCache( &psc
);
1609 ok (!psc
, "psc is not null after ScriptFreeCache\n");
1612 static void test_ScriptGetFontProperties(HDC hdc
)
1615 SCRIPT_CACHE psc
,old_psc
;
1616 SCRIPT_FONTPROPERTIES sfp
;
1618 /* Some sanity checks for ScriptGetFontProperties */
1620 hr
= ScriptGetFontProperties(NULL
,NULL
,NULL
);
1621 ok( hr
== E_INVALIDARG
, "(NULL,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1623 hr
= ScriptGetFontProperties(NULL
,NULL
,&sfp
);
1624 ok( hr
== E_INVALIDARG
, "(NULL,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1626 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1628 hr
= ScriptGetFontProperties(NULL
,&psc
,NULL
);
1629 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1630 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1632 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1634 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1635 ok( hr
== E_PENDING
, "(NULL,&psc,&sfp), expected E_PENDING, got %08x\n", hr
);
1636 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1638 hr
= ScriptGetFontProperties(hdc
,NULL
,NULL
);
1639 ok( hr
== E_INVALIDARG
, "(hdc,NULL,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1641 hr
= ScriptGetFontProperties(hdc
,NULL
,&sfp
);
1642 ok( hr
== E_INVALIDARG
, "(hdc,NULL,&sfp), expected E_INVALIDARG, got %08x\n", hr
);
1644 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1646 hr
= ScriptGetFontProperties(hdc
,&psc
,NULL
);
1647 ok( hr
== E_INVALIDARG
, "(hdc,&psc,NULL), expected E_INVALIDARG, got %08x\n", hr
);
1648 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1650 /* Pass an invalid sfp */
1652 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
) - 1;
1653 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1654 ok( hr
== E_INVALIDARG
, "(hdc,&psc,&sfp) invalid, expected E_INVALIDARG, got %08x\n", hr
);
1655 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1656 ScriptFreeCache(&psc
);
1657 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1659 /* Give it the correct cBytes, we don't care about what's coming back */
1660 sfp
.cBytes
= sizeof(SCRIPT_FONTPROPERTIES
);
1662 hr
= ScriptGetFontProperties(hdc
,&psc
,&sfp
);
1663 ok( hr
== S_OK
, "(hdc,&psc,&sfp) partly initialized, expected S_OK, got %08x\n", hr
);
1664 ok( psc
!= NULL
, "Expected a pointer in psc, got NULL\n");
1666 /* Save the psc pointer */
1668 /* Now a NULL hdc again */
1669 hr
= ScriptGetFontProperties(NULL
,&psc
,&sfp
);
1670 ok( hr
== S_OK
, "(NULL,&psc,&sfp), expected S_OK, got %08x\n", hr
);
1671 ok( psc
== old_psc
, "Expected psc not to be changed, was %p is now %p\n", old_psc
, psc
);
1672 ScriptFreeCache(&psc
);
1673 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1676 static void test_ScriptTextOut(HDC hdc
)
1682 SCRIPT_ITEM pItem
[255];
1684 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1689 unsigned short pwOutGlyphs1
[256];
1690 WORD pwLogClust
[256];
1691 SCRIPT_VISATTR psva
[256];
1694 GOFFSET pGoffset
[256];
1699 BOOL fTrailing
= FALSE
;
1700 SCRIPT_LOGATTR
*psla
;
1701 SCRIPT_LOGATTR sla
[256];
1703 /* This is a valid test that will cause parsing to take place */
1706 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1707 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1708 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1710 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1712 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1713 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1714 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1716 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1717 * ie. ScriptItemize has succeeded and that pItem has been set */
1720 psc
= NULL
; /* must be null on first call */
1723 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1724 cMaxGlyphs
, &pItem
[0].a
,
1725 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1726 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1727 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1728 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1730 /* Note hdc is needed as glyph info is not yet in psc */
1731 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1733 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1734 ScriptFreeCache(&psc
); /* Get rid of psc for next test set */
1735 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1737 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0, NULL
, NULL
, NULL
);
1738 ok (hr
== E_INVALIDARG
, "Should return 0 not (%08x)\n", hr
);
1740 hr
= ScriptTextOut(NULL
, NULL
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1741 piAdvance
, NULL
, pGoffset
);
1742 ok( hr
== E_INVALIDARG
, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
1743 "expected E_INVALIDARG, got %08x\n", hr
);
1745 /* Set psc to NULL, to be able to check if a pointer is returned in psc */
1747 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, NULL
, NULL
, 0, NULL
, 0,
1749 ok( hr
== E_INVALIDARG
, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
1751 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1753 /* hdc is required for this one rather than the usual optional */
1755 hr
= ScriptTextOut(NULL
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1756 piAdvance
, NULL
, pGoffset
);
1757 ok( hr
== E_INVALIDARG
, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr
);
1758 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1760 /* Set that it returns 0 status */
1761 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1762 piAdvance
, NULL
, pGoffset
);
1763 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1765 /* Test Rect Rgn is acceptable */
1770 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1771 piAdvance
, NULL
, pGoffset
);
1772 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1775 hr
= ScriptCPtoX(iCP
, fTrailing
, cChars
, pcGlyphs
, (const WORD
*) &pwLogClust
,
1776 (const SCRIPT_VISATTR
*) &psva
, (const int *)&piAdvance
, &pItem
[0].a
, &piX
);
1777 ok(hr
== S_OK
, "ScriptCPtoX Stub should return S_OK not %08x\n", hr
);
1779 psla
= (SCRIPT_LOGATTR
*)&sla
;
1780 hr
= ScriptBreak(TestItem1
, cChars
, &pItem
[0].a
, psla
);
1781 ok(hr
== S_OK
, "ScriptBreak Stub should return S_OK not %08x\n", hr
);
1783 /* Clean up and go */
1784 ScriptFreeCache(&psc
);
1785 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1790 static void test_ScriptTextOut2(HDC hdc
)
1792 /* Intent is to validate that the HDC passed into ScriptTextOut is
1793 * used instead of the (possibly) invalid cached one
1800 SCRIPT_ITEM pItem
[255];
1802 WCHAR TestItem1
[] = {'T', 'e', 's', 't', 'a', 0};
1807 unsigned short pwOutGlyphs1
[256];
1808 WORD pwLogClust
[256];
1809 SCRIPT_VISATTR psva
[256];
1812 GOFFSET pGoffset
[256];
1815 /* Create an extra DC that will be used until the ScriptTextOut */
1816 hdc1
= CreateCompatibleDC(hdc
);
1817 ok (hdc1
!= 0, "CreateCompatibleDC failed to create a DC\n");
1818 hdc2
= CreateCompatibleDC(hdc
);
1819 ok (hdc2
!= 0, "CreateCompatibleDC failed to create a DC\n");
1821 /* This is a valid test that will cause parsing to take place */
1824 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1825 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1826 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1828 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1830 ok (pItem
[0].iCharPos
== 0 && pItem
[1].iCharPos
== cInChars
,
1831 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1832 pItem
[0].iCharPos
, cInChars
, pItem
[1].iCharPos
);
1834 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1835 * ie. ScriptItemize has succeeded and that pItem has been set */
1838 psc
= NULL
; /* must be null on first call */
1841 hr
= ScriptShape(hdc2
, &psc
, TestItem1
, cChars
,
1842 cMaxGlyphs
, &pItem
[0].a
,
1843 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1844 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1845 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1846 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1848 /* Note hdc is needed as glyph info is not yet in psc */
1849 hr
= ScriptPlace(hdc2
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1851 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1853 /* key part!!! cached dc is being deleted */
1854 hr
= DeleteDC(hdc2
);
1855 ok(hr
== 1, "DeleteDC should return 1 not %08x\n", hr
);
1857 /* At this point the cached hdc (hdc2) has been destroyed,
1858 * however, we are passing in a *real* hdc (the original hdc).
1859 * The text should be written to that DC
1861 hr
= ScriptTextOut(hdc1
, &psc
, 0, 0, 0, NULL
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1862 piAdvance
, NULL
, pGoffset
);
1863 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1864 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1868 /* Clean up and go */
1869 ScriptFreeCache(&psc
);
1870 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1875 static void test_ScriptTextOut3(HDC hdc
)
1881 SCRIPT_ITEM pItem
[255];
1883 WCHAR TestItem1
[] = {' ','\r', 0};
1888 unsigned short pwOutGlyphs1
[256];
1889 WORD pwLogClust
[256];
1890 SCRIPT_VISATTR psva
[256];
1893 GOFFSET pGoffset
[256];
1897 /* This is to ensure that nonexistent glyphs are translated into a valid glyph number */
1900 hr
= ScriptItemize(TestItem1
, cInChars
, cMaxItems
, NULL
, NULL
, pItem
, &pcItems
);
1901 ok (hr
== 0, "ScriptItemize should return 0, returned %08x\n", hr
);
1902 /* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is *
1904 ok (pcItems
> 0, "The number of SCRIPT_ITEMS should be greater than 0\n");
1906 ok (pItem
[0].iCharPos
== 0 && pItem
[2].iCharPos
== cInChars
,
1907 "Start pos not = 0 (%d) or end pos not = %d (%d)\n",
1908 pItem
[0].iCharPos
, cInChars
, pItem
[2].iCharPos
);
1910 /* It would appear that we have a valid SCRIPT_ANALYSIS and can continue
1911 * ie. ScriptItemize has succeeded and that pItem has been set */
1914 psc
= NULL
; /* must be null on first call */
1917 hr
= ScriptShape(hdc
, &psc
, TestItem1
, cChars
,
1918 cMaxGlyphs
, &pItem
[0].a
,
1919 pwOutGlyphs1
, pwLogClust
, psva
, &pcGlyphs
);
1920 ok (hr
== 0, "ScriptShape should return 0 not (%08x)\n", hr
);
1921 ok (psc
!= NULL
, "psc should not be null and have SCRIPT_CACHE buffer address\n");
1922 ok (pcGlyphs
== cChars
, "Chars in (%d) should equal Glyphs out (%d)\n", cChars
, pcGlyphs
);
1924 /* Note hdc is needed as glyph info is not yet in psc */
1925 hr
= ScriptPlace(hdc
, &psc
, pwOutGlyphs1
, pcGlyphs
, psva
, &pItem
[0].a
, piAdvance
,
1927 ok (hr
== 0, "Should return 0 not (%08x)\n", hr
);
1929 /* Test Rect Rgn is acceptable */
1934 hr
= ScriptTextOut(hdc
, &psc
, 0, 0, 0, &rect
, &pItem
[0].a
, NULL
, 0, pwOutGlyphs1
, pcGlyphs
,
1935 piAdvance
, NULL
, pGoffset
);
1936 ok (hr
== 0, "ScriptTextOut should return 0 not (%08x)\n", hr
);
1939 /* Clean up and go */
1940 ScriptFreeCache(&psc
);
1941 ok( psc
== NULL
, "Expected psc to be NULL, got %p\n", psc
);
1945 #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)
1947 static void _test_item_ScriptXtoX(SCRIPT_ANALYSIS
*psa
, int cChars
, int cGlyphs
, const int* offsets
, const WORD
*pwLogClust
, const int* piAdvance
)
1950 int icChars
, icGlyphs
;
1953 SCRIPT_VISATTR psva
[10];
1958 memset(psva
,0,sizeof(psva
));
1959 direction
= (psa
->fRTL
)?-1:+1;
1961 for(iCP
= 0; iCP
< cChars
; iCP
++)
1966 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
1967 winetest_ok(hr
== S_OK
, "ScriptXtoCP: should return S_OK not %08x\n", hr
);
1968 winetest_ok(piCP
== iCP
, "ScriptXtoCP: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1969 winetest_ok(piTrailing
== 0, "ScriptXtoCP: iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1972 for(iCP
= 0; iCP
< cChars
; iCP
++)
1974 iX
= offsets
[iCP
]+direction
;
1977 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
1978 winetest_ok(hr
== S_OK
, "ScriptXtoCP leading: should return S_OK not %08x\n", hr
);
1979 winetest_ok(piCP
== iCP
, "ScriptXtoCP leading: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1980 winetest_ok(piTrailing
== 0, "ScriptXtoCP leading: iX=%d should return piTrailing=0 not %d\n", iX
, piTrailing
);
1983 for(iCP
= 0; iCP
< cChars
; iCP
++)
1985 iX
= offsets
[iCP
+1]-direction
;
1988 hr
= ScriptXtoCP(iX
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piCP
, &piTrailing
);
1989 winetest_ok(hr
== S_OK
, "ScriptXtoCP trailing: should return S_OK not %08x\n", hr
);
1990 winetest_ok(piCP
== iCP
, "ScriptXtoCP trailing: iX=%d should return piCP=%d not %d\n", iX
, iCP
, piCP
);
1991 winetest_ok(piTrailing
== 1, "ScriptXtoCP trailing: iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
1994 for(iCP
= 0; iCP
<= cChars
+1; iCP
++)
1999 hr
= ScriptCPtoX(iCP
, fTrailing
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piX
);
2000 winetest_ok(hr
== S_OK
, "ScriptCPtoX: should return S_OK not %08x\n", hr
);
2001 winetest_ok(piX
== offsets
[iCP
],
2002 "ScriptCPtoX: iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
], piX
);
2005 for(iCP
= 0; iCP
<= cChars
+1; iCP
++)
2010 hr
= ScriptCPtoX(iCP
, fTrailing
, icChars
, icGlyphs
, pwLogClust
, psva
, piAdvance
, psa
, &piX
);
2011 winetest_ok(hr
== S_OK
, "ScriptCPtoX trailing: should return S_OK not %08x\n", hr
);
2012 winetest_ok(piX
== offsets
[iCP
+1],
2013 "ScriptCPtoX trailing: iCP=%d should return piX=%d not %d\n", iCP
, offsets
[iCP
+1], piX
);
2017 static void test_ScriptXtoX(void)
2018 /****************************************************************************************
2019 * This routine tests the ScriptXtoCP and ScriptCPtoX functions using static variables *
2020 ****************************************************************************************/
2022 WORD pwLogClust
[10] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 3};
2023 WORD pwLogClust_RTL
[10] = {3, 3, 3, 2, 2, 1, 1, 0, 0, 0};
2024 WORD pwLogClust_2
[7] = {4, 3, 3, 2, 1, 0 ,0};
2025 int piAdvance
[10] = {201, 190, 210, 180, 170, 204, 189, 195, 212, 203};
2026 int piAdvance_2
[5] = {39, 26, 19, 17, 11};
2027 static const int offsets
[13] = {0, 67, 134, 201, 296, 391, 496, 601, 1052, 1503, 1954, 1954, 1954};
2028 static const int offsets_RTL
[13] = {781, 721, 661, 601, 496, 391, 296, 201, 134, 67, 0, 0, 0};
2029 static const int offsets_2
[10] = {112, 101, 92, 84, 65, 39, 19, 0, 0, 0};
2030 SCRIPT_VISATTR psva
[10];
2037 memset(&sa
, 0 , sizeof(SCRIPT_ANALYSIS
));
2038 memset(psva
, 0, sizeof(psva
));
2041 hr
= ScriptXtoCP(-1, 10, 10, pwLogClust
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2042 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2044 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
2046 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
2048 for (iX
= 0; iX
<= 7; iX
++)
2052 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2053 ok(piCP
==0 && piTrailing
==0,"%i should return 0(%i) and 0(%i)\n",iX
, piCP
,piTrailing
);
2055 for (iX
= 8; iX
< 16; iX
++)
2059 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2060 ok(piCP
==0 && piTrailing
==1,"%i should return 0(%i) and 1(%i)\n",iX
, piCP
,piTrailing
);
2064 hr
= ScriptXtoCP(-1, 10, 10, pwLogClust_RTL
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2065 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2067 ok(piCP
== -1, "Negative iX should return piCP=-1 not %d\n", piCP
);
2069 ok(piCP
== 10, "Negative iX should return piCP=10 not %d\n", piCP
);
2072 hr
= ScriptXtoCP(1954, 10, 10, pwLogClust_RTL
, psva
, piAdvance
, &sa
, &piCP
, &piTrailing
);
2073 ok(hr
== S_OK
, "ScriptXtoCP should return S_OK not %08x\n", hr
);
2074 ok(piCP
== -1, "iX=%d should return piCP=-1 not %d\n", iX
, piCP
);
2075 ok(piTrailing
== 1, "iX=%d should return piTrailing=1 not %d\n", iX
, piTrailing
);
2077 for (iX
= 1; iX
<= 8; iX
++)
2081 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2082 ok(piCP
==0 && piTrailing
==1,"%i should return 0(%i) and 1(%i)\n",iX
,piCP
,piTrailing
);
2084 for (iX
= 9; iX
< 16; iX
++)
2088 hr
= ScriptXtoCP(iX
, 1, 1, &clust
, psva
, &advance
, &sa
, &piCP
, &piTrailing
);
2089 ok(piCP
==0 && piTrailing
==0,"%i should return 0(%i) and 0(%i)\n",iX
,piCP
,piTrailing
);
2093 test_item_ScriptXtoX(&sa
, 10, 10, offsets
, pwLogClust
, piAdvance
);
2095 test_item_ScriptXtoX(&sa
, 10, 10, offsets_RTL
, pwLogClust_RTL
, piAdvance
);
2096 test_item_ScriptXtoX(&sa
, 7, 5, offsets_2
, pwLogClust_2
, piAdvance_2
);
2099 static void test_ScriptString(HDC hdc
)
2101 /*******************************************************************************************
2103 * This set of tests are for the string functions of uniscribe. The ScriptStringAnalyse
2104 * function allocates memory pointed to by the SCRIPT_STRING_ANALYSIS ssa pointer. This
2105 * memory is freed by ScriptStringFree. There needs to be a valid hdc for this as
2106 * ScriptStringAnalyse calls ScriptSItemize, ScriptShape and ScriptPlace which require it.
2111 WCHAR teststr
[] = {'T','e','s','t','1',' ','a','2','b','3', '\0'};
2112 int len
= (sizeof(teststr
) / sizeof(WCHAR
)) - 1;
2113 int Glyphs
= len
* 2 + 16;
2115 DWORD Flags
= SSA_GLYPHS
;
2117 const int Dx
[5] = {10, 10, 10, 10, 10};
2118 const BYTE InClass
= 0;
2119 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
2124 const RECT rc
= {0, 50, 100, 100};
2127 BOOL Disabled
= FALSE
;
2128 const int *clip_len
;
2133 Charset
= -1; /* this flag indicates unicode input */
2134 /* Test without hdc to get E_PENDING */
2135 hr
= ScriptStringAnalyse( NULL
, teststr
, len
, Glyphs
, Charset
, Flags
,
2136 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2138 ok(hr
== E_PENDING
, "ScriptStringAnalyse Stub should return E_PENDING not %08x\n", hr
);
2140 /* test with hdc, this should be a valid test */
2141 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
2142 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2144 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2145 ScriptStringFree(&ssa
);
2147 /* test makes sure that a call with a valid pssa still works */
2148 hr
= ScriptStringAnalyse( hdc
, teststr
, len
, Glyphs
, Charset
, Flags
,
2149 ReqWidth
, NULL
, NULL
, Dx
, NULL
,
2151 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2152 ok(ssa
!= NULL
, "ScriptStringAnalyse pssa should not be NULL\n");
2156 hr
= ScriptStringOut(ssa
, X
, Y
, Options
, &rc
, MinSel
, MaxSel
, Disabled
);
2157 ok(hr
== S_OK
, "ScriptStringOut should return S_OK not %08x\n", hr
);
2160 clip_len
= ScriptString_pcOutChars(ssa
);
2161 ok(*clip_len
== len
, "ScriptString_pcOutChars failed, got %d, expected %d\n", *clip_len
, len
);
2163 order
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, *clip_len
* sizeof(UINT
));
2164 hr
= ScriptStringGetOrder(ssa
, order
);
2165 ok(hr
== S_OK
, "ScriptStringGetOrder failed, got %08x, expected S_OK\n", hr
);
2167 for (i
= 0; i
< *clip_len
; i
++) ok(order
[i
] == i
, "%d: got %d expected %d\n", i
, order
[i
], i
);
2168 HeapFree(GetProcessHeap(), 0, order
);
2170 hr
= ScriptStringFree(&ssa
);
2171 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
2174 static void test_ScriptStringXtoCP_CPtoX(HDC hdc
)
2176 /*****************************************************************************************
2178 * This test is for the ScriptStringXtoCP and ScriptStringXtoCP functions. Due to the
2179 * nature of the fonts between Windows and Wine, the test is implemented by generating
2180 * values using one one function then checking the output of the second. In this way
2181 * the validity of the functions is established using Windows as a base and confirming
2182 * similar behaviour in wine.
2186 static const WCHAR teststr1
[] = {0x05e9, 'i', 0x05dc, 'n', 0x05d5, 'e', 0x05dd, '.',0};
2187 static const BOOL rtl
[] = {1, 0, 1, 0, 1, 0, 1, 0};
2188 void *String
= (WCHAR
*) &teststr1
; /* ScriptStringAnalysis needs void */
2189 int String_len
= (sizeof(teststr1
)/sizeof(WCHAR
))-1;
2190 int Glyphs
= String_len
* 2 + 16; /* size of buffer as recommended */
2191 int Charset
= -1; /* unicode */
2192 DWORD Flags
= SSA_GLYPHS
;
2194 const BYTE InClass
= 0;
2195 SCRIPT_STRING_ANALYSIS ssa
= NULL
;
2197 int Ch
; /* Character position in string */
2199 int Cp
; /* Character position in string */
2204 /* Test with hdc, this should be a valid test
2205 * Here we generate an SCRIPT_STRING_ANALYSIS that will be used as input to the
2206 * following character positions to X and X to character position functions.
2209 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
2210 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
2213 hr
== E_INVALIDARG
, /* NT */
2214 "ScriptStringAnalyse should return S_OK or E_INVALIDARG not %08x\n", hr
);
2218 ok(ssa
!= NULL
, "ScriptStringAnalyse ssa should not be NULL\n");
2221 * Loop to generate character positions to provide starting positions for the
2222 * ScriptStringCPtoX and ScriptStringXtoCP functions
2224 for (Cp
= 0; Cp
< String_len
; Cp
++)
2226 /* The fTrailing flag is used to indicate whether the X being returned is at
2227 * the beginning or the end of the character. What happens here is that if
2228 * fTrailing indicates the end of the character, ie. FALSE, then ScriptStringXtoCP
2229 * returns the beginning of the next character and iTrailing is FALSE. So for this
2230 * loop iTrailing will be FALSE in both cases.
2232 hr
= ScriptStringCPtoX(ssa
, Cp
, TRUE
, &trail
);
2233 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2234 hr
= ScriptStringCPtoX(ssa
, Cp
, FALSE
, &lead
);
2235 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2237 ok(lead
> trail
, "Leading values should be after trailing for rtl characters(%i)\n",Cp
);
2239 ok(lead
< trail
, "Trailing values should be after leading for ltr characters(%i)\n",Cp
);
2241 /* move by 1 pixel so that we are not inbetween 2 characters. That could result in being the lead of a rtl and
2242 at the same time the trail of an ltr */
2244 /* inside the leading edge */
2246 if (rtl
[Cp
]) X
--; else X
++;
2247 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2248 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2249 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
2250 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2253 /* inside the trailing edge */
2255 if (rtl
[Cp
]) X
++; else X
--;
2256 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2257 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2258 ok(Cp
== Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
, Ch
, trail
);
2259 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2262 /* outside the "trailing" edge */
2263 if (Cp
< String_len
-1)
2265 if (rtl
[Cp
]) X
= lead
; else X
= trail
;
2267 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2268 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2269 ok(Cp
+ 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
+ 1, Ch
, trail
);
2271 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2274 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2278 /* outside the "leading" edge */
2281 if (rtl
[Cp
]) X
= trail
; else X
= lead
;
2283 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2284 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2285 ok(Cp
- 1 == Ch
, "ScriptStringXtoCP should return Ch = %d not %d for X = %d\n", Cp
- 1, Ch
, trail
);
2286 if (Cp
!= 0 && rtl
[Cp
-1])
2287 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = %d\n",
2290 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = %d\n",
2295 /* Check beyond the leading boundary of the whole string */
2298 /* having a leading rtl character seems to confuse usp */
2299 /* this looks to be a windows bug we should emulate */
2300 hr
= ScriptStringCPtoX(ssa
, 0, TRUE
, &X
);
2301 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2303 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2304 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2305 ok(Ch
== 1, "ScriptStringXtoCP should return Ch = 1 not %d for X outside leading edge when rtl\n", Ch
);
2306 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside leading edge when rtl\n",
2311 hr
= ScriptStringCPtoX(ssa
, 0, FALSE
, &X
);
2312 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2314 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2315 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2316 ok(Ch
== -1, "ScriptStringXtoCP should return Ch = -1 not %d for X outside leading edge\n", Ch
);
2317 ok(iTrailing
== TRUE
, "ScriptStringXtoCP should return iTrailing = 1 not %d for X = outside leading edge\n",
2321 /* Check beyond the end boundary of the whole string */
2322 if (rtl
[String_len
-1])
2324 hr
= ScriptStringCPtoX(ssa
, String_len
-1, FALSE
, &X
);
2325 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2329 hr
= ScriptStringCPtoX(ssa
, String_len
-1, TRUE
, &X
);
2330 ok(hr
== S_OK
, "ScriptStringCPtoX should return S_OK not %08x\n", hr
);
2333 hr
= ScriptStringXtoCP(ssa
, X
, &Ch
, &iTrailing
);
2334 ok(hr
== S_OK
, "ScriptStringXtoCP should return S_OK not %08x\n", hr
);
2335 ok(Ch
== String_len
, "ScriptStringXtoCP should return Ch = %i not %d for X outside trailing edge\n", String_len
, Ch
);
2336 ok(iTrailing
== FALSE
, "ScriptStringXtoCP should return iTrailing = 0 not %d for X = outside trailing edge\n",
2340 * Cleanup the SSA for the next round of tests
2342 hr
= ScriptStringFree(&ssa
);
2343 ok(hr
== S_OK
, "ScriptStringFree should return S_OK not %08x\n", hr
);
2346 * Test to see that exceeding the number of chars returns E_INVALIDARG. First
2347 * generate an SSA for the subsequent tests.
2349 hr
= ScriptStringAnalyse( hdc
, String
, String_len
, Glyphs
, Charset
, Flags
,
2350 ReqWidth
, NULL
, NULL
, NULL
, NULL
,
2352 ok(hr
== S_OK
, "ScriptStringAnalyse should return S_OK not %08x\n", hr
);
2355 * When ScriptStringCPtoX is called with a character position Cp that exceeds the
2356 * string length, return E_INVALIDARG. This also invalidates the ssa so a
2357 * ScriptStringFree should also fail.
2360 Cp
= String_len
+ 1;
2361 hr
= ScriptStringCPtoX(ssa
, Cp
, fTrailing
, &X
);
2362 ok(hr
== E_INVALIDARG
, "ScriptStringCPtoX should return E_INVALIDARG not %08x\n", hr
);
2364 ScriptStringFree(&ssa
);
2368 static void test_ScriptCacheGetHeight(HDC hdc
)
2371 SCRIPT_CACHE sc
= NULL
;
2374 hr
= ScriptCacheGetHeight(NULL
, NULL
, NULL
);
2375 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2377 hr
= ScriptCacheGetHeight(NULL
, &sc
, NULL
);
2378 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2380 hr
= ScriptCacheGetHeight(NULL
, &sc
, &height
);
2381 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2385 hr
= ScriptCacheGetHeight(hdc
, &sc
, &height
);
2386 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2387 ok(height
> 0, "expected height > 0\n");
2389 ScriptFreeCache(&sc
);
2392 static void test_ScriptGetGlyphABCWidth(HDC hdc
)
2395 SCRIPT_CACHE sc
= NULL
;
2398 hr
= ScriptGetGlyphABCWidth(NULL
, NULL
, 'a', NULL
);
2399 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2401 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', NULL
);
2402 ok(broken(hr
== E_PENDING
) ||
2403 hr
== E_INVALIDARG
, /* WIN7 */
2404 "expected E_INVALIDARG, got 0x%08x\n", hr
);
2406 hr
= ScriptGetGlyphABCWidth(NULL
, &sc
, 'a', &abc
);
2407 ok(hr
== E_PENDING
, "expected E_PENDING, got 0x%08x\n", hr
);
2409 if (0) { /* crashes on WinXP */
2410 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', NULL
);
2411 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2414 hr
= ScriptGetGlyphABCWidth(hdc
, &sc
, 'a', &abc
);
2415 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2417 ScriptFreeCache(&sc
);
2420 static void test_ScriptLayout(void)
2423 static const BYTE levels
[][10] =
2425 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2426 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
2427 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
2428 { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
2430 { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
2431 { 1, 1, 1, 2, 2, 2, 1, 1, 1, 1 },
2432 { 2, 2, 2, 1, 1, 1, 2, 2, 2, 2 },
2433 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 },
2434 { 1, 1, 2, 2, 3, 3, 2, 2, 1, 1 },
2436 { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 },
2437 { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 },
2439 static const int expect_l2v
[][10] =
2441 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2442 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2443 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2444 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2446 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2447 /**/ { 9, 8, 7, 4, 5, 6, 3 ,2 ,1, 0},
2448 /**/ { 7, 8, 9, 6, 5, 4, 0 ,1 ,2, 3},
2449 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2450 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2452 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2453 /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9},
2455 static const int expect_v2l
[][10] =
2457 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2458 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2459 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
2460 { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
2462 { 0, 1, 2, 3, 4, 9, 8 ,7 ,6, 5},
2463 { 9, 8, 7, 6, 3, 4, 5 ,2 ,1, 0},
2464 { 6, 7, 8, 9, 5, 4, 3 ,0 ,1, 2},
2465 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2466 { 9, 8, 2, 3, 5, 4, 6 ,7 ,1, 0},
2468 { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9},
2469 { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9},
2472 int i
, j
, vistolog
[sizeof(levels
[0])], logtovis
[sizeof(levels
[0])];
2474 hr
= ScriptLayout(sizeof(levels
[0]), NULL
, vistolog
, logtovis
);
2475 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2477 hr
= ScriptLayout(sizeof(levels
[0]), levels
[0], NULL
, NULL
);
2478 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
2480 for (i
= 0; i
< sizeof(levels
)/sizeof(levels
[0]); i
++)
2482 hr
= ScriptLayout(sizeof(levels
[0]), levels
[i
], vistolog
, logtovis
);
2483 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
2485 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2487 ok(expect_v2l
[i
][j
] == vistolog
[j
],
2488 "failure: levels[%d][%d] = %d, vistolog[%d] = %d\n",
2489 i
, j
, levels
[i
][j
], j
, vistolog
[j
] );
2492 for (j
= 0; j
< sizeof(levels
[i
]); j
++)
2494 ok(expect_l2v
[i
][j
] == logtovis
[j
],
2495 "failure: levels[%d][%d] = %d, logtovis[%d] = %d\n",
2496 i
, j
, levels
[i
][j
], j
, logtovis
[j
] );
2501 static BOOL CALLBACK
enum_proc(LGRPID group
, LCID lcid
, LPSTR locale
, LONG_PTR lparam
)
2504 SCRIPT_DIGITSUBSTITUTE sds
;
2509 if (!IsValidLocale(lcid
, LCID_INSTALLED
)) return TRUE
;
2511 memset(&sds
, 0, sizeof(sds
));
2512 memset(&sc
, 0, sizeof(sc
));
2513 memset(&ss
, 0, sizeof(ss
));
2515 lcid_old
= GetThreadLocale();
2516 if (!SetThreadLocale(lcid
)) return TRUE
;
2518 hr
= ScriptRecordDigitSubstitution(lcid
, &sds
);
2519 ok(hr
== S_OK
, "ScriptRecordDigitSubstitution failed: 0x%08x\n", hr
);
2521 hr
= ScriptApplyDigitSubstitution(&sds
, &sc
, &ss
);
2522 ok(hr
== S_OK
, "ScriptApplyDigitSubstitution failed: 0x%08x\n", hr
);
2524 SetThreadLocale(lcid_old
);
2528 static void test_digit_substitution(void)
2532 static const LGRPID groups
[] =
2534 LGRPID_WESTERN_EUROPE
,
2535 LGRPID_CENTRAL_EUROPE
,
2542 LGRPID_TRADITIONAL_CHINESE
,
2543 LGRPID_SIMPLIFIED_CHINESE
,
2553 static BOOL (WINAPI
* pEnumLanguageGroupLocalesA
)(LANGGROUPLOCALE_ENUMPROCA
,LGRPID
,DWORD
,LONG_PTR
);
2555 hKernel32
= GetModuleHandleA("kernel32.dll");
2556 pEnumLanguageGroupLocalesA
= (void*)GetProcAddress(hKernel32
, "EnumLanguageGroupLocalesA");
2558 if (!pEnumLanguageGroupLocalesA
)
2560 win_skip("EnumLanguageGroupLocalesA not available on this platform\n");
2564 for (i
= 0; i
< sizeof(groups
)/sizeof(groups
[0]); i
++)
2566 ret
= pEnumLanguageGroupLocalesA(enum_proc
, groups
[i
], 0, 0);
2567 if (!ret
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
2569 win_skip("EnumLanguageGroupLocalesA not implemented on this platform\n");
2573 ok(ret
, "EnumLanguageGroupLocalesA failed unexpectedly: %u\n", GetLastError());
2577 static void test_ScriptGetProperties(void)
2579 const SCRIPT_PROPERTIES
**props
;
2583 hr
= ScriptGetProperties(NULL
, NULL
);
2584 ok(hr
== E_INVALIDARG
, "ScriptGetProperties succeeded\n");
2586 hr
= ScriptGetProperties(NULL
, &num
);
2587 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2589 hr
= ScriptGetProperties(&props
, NULL
);
2590 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2592 hr
= ScriptGetProperties(&props
, &num
);
2593 ok(hr
== S_OK
, "ScriptGetProperties failed: 0x%08x\n", hr
);
2596 static void test_ScriptBreak(void)
2598 static const WCHAR test
[] = {' ','\r','\n',0};
2599 SCRIPT_ITEM items
[4];
2603 hr
= ScriptItemize(test
, 3, 4, NULL
, NULL
, items
, NULL
);
2604 ok(!hr
, "ScriptItemize should return S_OK not %08x\n", hr
);
2606 memset(&la
, 0, sizeof(la
));
2607 hr
= ScriptBreak(test
, 1, &items
[0].a
, &la
);
2608 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2610 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2611 ok(la
.fWhiteSpace
, "fWhiteSpace not set\n");
2612 ok(la
.fCharStop
, "fCharStop not set\n");
2613 ok(!la
.fWordStop
, "fWordStop set\n");
2614 ok(!la
.fInvalid
, "fInvalid set\n");
2615 ok(!la
.fReserved
, "fReserved set\n");
2617 memset(&la
, 0, sizeof(la
));
2618 hr
= ScriptBreak(test
+ 1, 1, &items
[1].a
, &la
);
2619 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2621 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2622 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2623 ok(la
.fCharStop
, "fCharStop not set\n");
2624 ok(!la
.fWordStop
, "fWordStop set\n");
2625 ok(!la
.fInvalid
, "fInvalid set\n");
2626 ok(!la
.fReserved
, "fReserved set\n");
2628 memset(&la
, 0, sizeof(la
));
2629 hr
= ScriptBreak(test
+ 2, 1, &items
[2].a
, &la
);
2630 ok(!hr
, "ScriptBreak should return S_OK not %08x\n", hr
);
2632 ok(!la
.fSoftBreak
, "fSoftBreak set\n");
2633 ok(!la
.fWhiteSpace
, "fWhiteSpace set\n");
2634 ok(la
.fCharStop
, "fCharStop not set\n");
2635 ok(!la
.fWordStop
, "fWordStop set\n");
2636 ok(!la
.fInvalid
, "fInvalid set\n");
2637 ok(!la
.fReserved
, "fReserved set\n");
2640 static void test_newlines(void)
2642 static const WCHAR test1
[] = {'t','e','x','t','\r','t','e','x','t',0};
2643 static const WCHAR test2
[] = {'t','e','x','t','\n','t','e','x','t',0};
2644 static const WCHAR test3
[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
2645 static const WCHAR test4
[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
2646 static const WCHAR test5
[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
2647 SCRIPT_ITEM items
[5];
2652 hr
= ScriptItemize(test1
, lstrlenW(test1
), 5, NULL
, NULL
, items
, &count
);
2653 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2654 ok(count
== 3, "got %d expected 3\n", count
);
2657 hr
= ScriptItemize(test2
, lstrlenW(test2
), 5, NULL
, NULL
, items
, &count
);
2658 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2659 ok(count
== 3, "got %d expected 3\n", count
);
2662 hr
= ScriptItemize(test3
, lstrlenW(test3
), 5, NULL
, NULL
, items
, &count
);
2663 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2664 ok(count
== 4, "got %d expected 4\n", count
);
2667 hr
= ScriptItemize(test4
, lstrlenW(test4
), 5, NULL
, NULL
, items
, &count
);
2668 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2669 ok(count
== 4, "got %d expected 4\n", count
);
2672 hr
= ScriptItemize(test5
, lstrlenW(test5
), 5, NULL
, NULL
, items
, &count
);
2673 ok(hr
== S_OK
, "ScriptItemize failed: 0x%08x\n", hr
);
2674 ok(count
== 4, "got %d expected 4\n", count
);
2684 unsigned short pwOutGlyphs
[256];
2686 /* We need a valid HDC to drive a lot of Script functions which requires the following *
2687 * to set up for the tests. */
2688 hwnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,
2691 ShowWindow(hwnd
, SW_SHOW
);
2694 hdc
= GetDC(hwnd
); /* We now have a hdc */
2695 ok( hdc
!= NULL
, "HDC failed to be created %p\n", hdc
);
2697 memset(&lf
, 0, sizeof(LOGFONTA
));
2698 lstrcpyA(lf
.lfFaceName
, "Tahoma");
2703 hfont
= SelectObject(hdc
, CreateFontIndirectA(&lf
));
2704 ok(hfont
!= NULL
, "SelectObject failed: %p\n", hfont
);
2706 test_ScriptItemize();
2707 test_ScriptItemIzeShapePlace(hdc
,pwOutGlyphs
);
2708 test_ScriptGetCMap(hdc
, pwOutGlyphs
);
2709 test_ScriptCacheGetHeight(hdc
);
2710 test_ScriptGetGlyphABCWidth(hdc
);
2711 test_ScriptShape(hdc
);
2712 test_ScriptShapeOpenType(hdc
);
2713 test_ScriptPlace(hdc
);
2715 test_ScriptGetFontProperties(hdc
);
2716 test_ScriptTextOut(hdc
);
2717 test_ScriptTextOut2(hdc
);
2718 test_ScriptTextOut3(hdc
);
2720 test_ScriptString(hdc
);
2721 test_ScriptStringXtoCP_CPtoX(hdc
);
2723 test_ScriptLayout();
2724 test_digit_substitution();
2725 test_ScriptGetProperties();
2729 ReleaseDC(hwnd
, hdc
);
2730 DestroyWindow(hwnd
);