|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 |
|
43 |
|
44 #ifdef Q_WS_X11 |
|
45 #define private public |
|
46 #endif |
|
47 |
|
48 // cannot do private -> public on windows since it seems to mess up some stl headers |
|
49 #include <qfont.h> |
|
50 |
|
51 #ifdef Q_WS_X11 |
|
52 #undef private |
|
53 #endif |
|
54 |
|
55 #include <QtTest/QtTest> |
|
56 |
|
57 |
|
58 |
|
59 #if defined(Q_WS_X11) |
|
60 #define private public |
|
61 #include <private/qtextengine_p.h> |
|
62 #include <qtextlayout.h> |
|
63 #undef private |
|
64 #endif |
|
65 |
|
66 #include <qfontdatabase.h> |
|
67 #include <qfontinfo.h> |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 //TESTED_CLASS= |
|
74 //TESTED_FILES= gui/text/qscriptengine.cpp |
|
75 |
|
76 // This test depends on the fonts in the following package being installed: |
|
77 // http://people.freedesktop.org/~hausmann/harfbuzz-test-fonts-0.1.tar.bz2 |
|
78 |
|
79 class tst_QTextScriptEngine : public QObject |
|
80 { |
|
81 Q_OBJECT |
|
82 |
|
83 public: |
|
84 tst_QTextScriptEngine(); |
|
85 virtual ~tst_QTextScriptEngine(); |
|
86 |
|
87 |
|
88 public slots: |
|
89 void init(); |
|
90 void cleanup(); |
|
91 private slots: |
|
92 void devanagari(); |
|
93 void bengali(); |
|
94 void gurmukhi(); |
|
95 // gujarati missing |
|
96 void oriya(); |
|
97 void tamil(); |
|
98 void telugu(); |
|
99 void kannada(); |
|
100 void malayalam(); |
|
101 // sinhala missing |
|
102 |
|
103 void khmer(); |
|
104 void linearB(); |
|
105 }; |
|
106 |
|
107 tst_QTextScriptEngine::tst_QTextScriptEngine() |
|
108 { |
|
109 } |
|
110 |
|
111 tst_QTextScriptEngine::~tst_QTextScriptEngine() |
|
112 { |
|
113 } |
|
114 |
|
115 void tst_QTextScriptEngine::init() |
|
116 { |
|
117 } |
|
118 |
|
119 void tst_QTextScriptEngine::cleanup() |
|
120 { |
|
121 } |
|
122 |
|
123 struct ShapeTable { |
|
124 unsigned short unicode[16]; |
|
125 unsigned short glyphs[16]; |
|
126 }; |
|
127 |
|
128 #if defined(Q_WS_X11) |
|
129 static bool shaping( const QFont &f, const ShapeTable *s) |
|
130 { |
|
131 QString str = QString::fromUtf16( s->unicode ); |
|
132 QTextLayout layout(str, f); |
|
133 QTextEngine *e = layout.d; |
|
134 e->itemize(); |
|
135 e->shape(0); |
|
136 |
|
137 int nglyphs = 0; |
|
138 const unsigned short *g = s->glyphs; |
|
139 while ( *g ) { |
|
140 nglyphs++; |
|
141 g++; |
|
142 } |
|
143 |
|
144 if( nglyphs != e->layoutData->items[0].num_glyphs ) |
|
145 goto error; |
|
146 |
|
147 for (int i = 0; i < nglyphs; ++i) { |
|
148 if ((e->layoutData->glyphLayout.glyphs[i] & 0xffffff) != s->glyphs[i]) |
|
149 goto error; |
|
150 } |
|
151 return true; |
|
152 error: |
|
153 str = ""; |
|
154 const unsigned short *uc = s->unicode; |
|
155 while (*uc) { |
|
156 str += QString("%1 ").arg(*uc, 4, 16); |
|
157 ++uc; |
|
158 } |
|
159 qDebug("%s: shaping of string %s failed, nglyphs=%d, expected %d", |
|
160 f.family().toLatin1().constData(), |
|
161 str.toLatin1().constData(), |
|
162 e->layoutData->items[0].num_glyphs, nglyphs); |
|
163 |
|
164 str = ""; |
|
165 int i = 0; |
|
166 while (i < e->layoutData->items[0].num_glyphs) { |
|
167 str += QString("%1 ").arg(e->layoutData->glyphLayout.glyphs[i], 4, 16); |
|
168 ++i; |
|
169 } |
|
170 qDebug(" glyph result = %s", str.toLatin1().constData()); |
|
171 return false; |
|
172 } |
|
173 #endif |
|
174 |
|
175 void tst_QTextScriptEngine::devanagari() |
|
176 { |
|
177 #if defined(Q_WS_X11) |
|
178 { |
|
179 if (QFontDatabase().families(QFontDatabase::Devanagari).contains("Raghindi")) { |
|
180 QFont f("Raghindi"); |
|
181 const ShapeTable shape_table [] = { |
|
182 // Ka |
|
183 { { 0x0915, 0x0 }, |
|
184 { 0x0080, 0x0 } }, |
|
185 // Ka Halant |
|
186 { { 0x0915, 0x094d, 0x0 }, |
|
187 { 0x0080, 0x0051, 0x0 } }, |
|
188 // Ka Halant Ka |
|
189 { { 0x0915, 0x094d, 0x0915, 0x0 }, |
|
190 { 0x00c8, 0x0080, 0x0 } }, |
|
191 // Ka MatraI |
|
192 { { 0x0915, 0x093f, 0x0 }, |
|
193 { 0x01d1, 0x0080, 0x0 } }, |
|
194 // Ra Halant Ka |
|
195 { { 0x0930, 0x094d, 0x0915, 0x0 }, |
|
196 { 0x0080, 0x005b, 0x0 } }, |
|
197 // Ra Halant Ka MatraI |
|
198 { { 0x0930, 0x094d, 0x0915, 0x093f, 0x0 }, |
|
199 { 0x01d1, 0x0080, 0x005b, 0x0 } }, |
|
200 // MatraI |
|
201 { { 0x093f, 0x0 }, |
|
202 { 0x01d4, 0x029c, 0x0 } }, |
|
203 // Ka Nukta |
|
204 { { 0x0915, 0x093c, 0x0 }, |
|
205 { 0x00a4, 0x0 } }, |
|
206 // Ka Halant Ra |
|
207 { { 0x0915, 0x094d, 0x0930, 0x0 }, |
|
208 { 0x0110, 0x0 } }, |
|
209 // Ka Halant Ra Halant Ka |
|
210 { { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0x0 }, |
|
211 { 0x0158, 0x0080, 0x0 } }, |
|
212 { { 0x0930, 0x094d, 0x200d, 0x0 }, |
|
213 { 0x00e2, 0x0 } }, |
|
214 { { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0x0 }, |
|
215 { 0x0158, 0x0 } }, |
|
216 |
|
217 { {0}, {0} } |
|
218 }; |
|
219 |
|
220 |
|
221 const ShapeTable *s = shape_table; |
|
222 while (s->unicode[0]) { |
|
223 QVERIFY( shaping(f, s) ); |
|
224 ++s; |
|
225 } |
|
226 } else { |
|
227 QSKIP("couln't find Raghindi", SkipAll); |
|
228 } |
|
229 } |
|
230 |
|
231 { |
|
232 if (QFontDatabase().families(QFontDatabase::Devanagari).contains("Mangal")) { |
|
233 QFont f("Mangal"); |
|
234 const ShapeTable shape_table [] = { |
|
235 // Ka |
|
236 { { 0x0915, 0x0 }, |
|
237 { 0x0080, 0x0 } }, |
|
238 // Ka Halant |
|
239 { { 0x0915, 0x094d, 0x0 }, |
|
240 { 0x0080, 0x0051, 0x0 } }, |
|
241 // Ka Halant Ka |
|
242 { { 0x0915, 0x094d, 0x0915, 0x0 }, |
|
243 { 0x00c8, 0x0080, 0x0 } }, |
|
244 // Ka MatraI |
|
245 { { 0x0915, 0x093f, 0x0 }, |
|
246 { 0x01d1, 0x0080, 0x0 } }, |
|
247 // Ra Halant Ka |
|
248 { { 0x0930, 0x094d, 0x0915, 0x0 }, |
|
249 { 0x0080, 0x005b, 0x0 } }, |
|
250 // Ra Halant Ka MatraI |
|
251 { { 0x0930, 0x094d, 0x0915, 0x093f, 0x0 }, |
|
252 { 0x01d1, 0x0080, 0x005b, 0x0 } }, |
|
253 // MatraI |
|
254 { { 0x093f, 0x0 }, |
|
255 { 0x01d4, 0x029c, 0x0 } }, |
|
256 // Ka Nukta |
|
257 { { 0x0915, 0x093c, 0x0 }, |
|
258 { 0x00a4, 0x0 } }, |
|
259 // Ka Halant Ra |
|
260 { { 0x0915, 0x094d, 0x0930, 0x0 }, |
|
261 { 0x0110, 0x0 } }, |
|
262 // Ka Halant Ra Halant Ka |
|
263 { { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0x0 }, |
|
264 { 0x0158, 0x0080, 0x0 } }, |
|
265 |
|
266 { { 0x92b, 0x94d, 0x930, 0x0 }, |
|
267 { 0x125, 0x0 } }, |
|
268 { { 0x92b, 0x93c, 0x94d, 0x930, 0x0 }, |
|
269 { 0x149, 0x0 } }, |
|
270 { {0}, {0} } |
|
271 }; |
|
272 |
|
273 const ShapeTable *s = shape_table; |
|
274 while (s->unicode[0]) { |
|
275 QVERIFY( shaping(f, s) ); |
|
276 ++s; |
|
277 } |
|
278 } else { |
|
279 QSKIP("couldn't find mangal", SkipAll); |
|
280 } |
|
281 } |
|
282 #else |
|
283 QSKIP("X11 specific test", SkipAll); |
|
284 #endif |
|
285 } |
|
286 |
|
287 void tst_QTextScriptEngine::bengali() |
|
288 { |
|
289 #if defined(Q_WS_X11) |
|
290 { |
|
291 if (QFontDatabase().families(QFontDatabase::Bengali).contains("Akaash")) { |
|
292 QFont f("Akaash"); |
|
293 const ShapeTable shape_table [] = { |
|
294 // Ka |
|
295 { { 0x0995, 0x0 }, |
|
296 { 0x0151, 0x0 } }, |
|
297 // Ka Halant |
|
298 { { 0x0995, 0x09cd, 0x0 }, |
|
299 { 0x0151, 0x017d, 0x0 } }, |
|
300 // Ka Halant Ka |
|
301 { { 0x0995, 0x09cd, 0x0995, 0x0 }, |
|
302 { 0x019b, 0x0 } }, |
|
303 // Ka MatraI |
|
304 { { 0x0995, 0x09bf, 0x0 }, |
|
305 { 0x0173, 0x0151, 0x0 } }, |
|
306 // Ra Halant Ka |
|
307 { { 0x09b0, 0x09cd, 0x0995, 0x0 }, |
|
308 { 0x0151, 0x0276, 0x0 } }, |
|
309 // Ra Halant Ka MatraI |
|
310 { { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0x0 }, |
|
311 { 0x0173, 0x0151, 0x0276, 0x0 } }, |
|
312 // Ka Nukta |
|
313 { { 0x0995, 0x09bc, 0x0 }, |
|
314 { 0x0151, 0x0171, 0x0 } }, |
|
315 // Ka Halant Ra |
|
316 { { 0x0995, 0x09cd, 0x09b0, 0x0 }, |
|
317 { 0x01f4, 0x0 } }, |
|
318 // Ka Halant Ra Halant Ka |
|
319 { { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0x0 }, |
|
320 { 0x025c, 0x0276, 0x0151, 0x0 } }, |
|
321 // Ya + Halant |
|
322 { { 0x09af, 0x09cd, 0x0 }, |
|
323 { 0x016a, 0x017d, 0x0 } }, |
|
324 // Da Halant Ya -> Da Ya-Phala |
|
325 { { 0x09a6, 0x09cd, 0x09af, 0x0 }, |
|
326 { 0x01e5, 0x0 } }, |
|
327 // A Halant Ya -> A Ya-phala |
|
328 { { 0x0985, 0x09cd, 0x09af, 0x0 }, |
|
329 { 0x0145, 0x01cf, 0x0 } }, |
|
330 // Na Halant Ka |
|
331 { { 0x09a8, 0x09cd, 0x0995, 0x0 }, |
|
332 { 0x026f, 0x0151, 0x0 } }, |
|
333 // Na Halant ZWNJ Ka |
|
334 { { 0x09a8, 0x09cd, 0x200c, 0x0995, 0x0 }, |
|
335 { 0x0164, 0x017d, 0x0151, 0x0 } }, |
|
336 // Na Halant ZWJ Ka |
|
337 { { 0x09a8, 0x09cd, 0x200d, 0x0995, 0x0 }, |
|
338 { 0x026f, 0x0151, 0x0 } }, |
|
339 // Ka Halant ZWNJ Ka |
|
340 { { 0x0995, 0x09cd, 0x200c, 0x0995, 0x0 }, |
|
341 { 0x0151, 0x017d, 0x0151, 0x0 } }, |
|
342 // Ka Halant ZWJ Ka |
|
343 { { 0x0995, 0x09cd, 0x200d, 0x0995, 0x0 }, |
|
344 { 0x025c, 0x0151, 0x0 } }, |
|
345 // Na Halant Ra |
|
346 { { 0x09a8, 0x09cd, 0x09b0, 0x0 }, |
|
347 { 0x0207, 0x0 } }, |
|
348 // Na Halant ZWNJ Ra |
|
349 { { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0x0 }, |
|
350 { 0x0164, 0x017d, 0x016b, 0x0 } }, |
|
351 // Na Halant ZWJ Ra |
|
352 { { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0x0 }, |
|
353 { 0x026f, 0x016b, 0x0 } }, |
|
354 // Na Halant Ba |
|
355 { { 0x09a8, 0x09cd, 0x09ac, 0x0 }, |
|
356 { 0x022f, 0x0 } }, |
|
357 // Na Halant ZWNJ Ba |
|
358 { { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0x0 }, |
|
359 { 0x0164, 0x017d, 0x0167, 0x0 } }, |
|
360 // Na Halant ZWJ Ba |
|
361 { { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0x0 }, |
|
362 { 0x026f, 0x0167, 0x0 } }, |
|
363 // Na Halant Dha |
|
364 { { 0x09a8, 0x09cd, 0x09a7, 0x0 }, |
|
365 { 0x01d3, 0x0 } }, |
|
366 // Na Halant ZWNJ Dha |
|
367 { { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0x0 }, |
|
368 { 0x0164, 0x017d, 0x0163, 0x0 } }, |
|
369 // Na Halant ZWJ Dha |
|
370 { { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0x0 }, |
|
371 { 0x026f, 0x0163, 0x0 } }, |
|
372 // Ra Halant Ka MatraAU |
|
373 { { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0x0 }, |
|
374 { 0x0179, 0x0151, 0x0276, 0x017e, 0x0 } }, |
|
375 // Ra Halant Ba Halant Ba |
|
376 { { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0x0 }, |
|
377 { 0x0232, 0x0276, 0x0 } }, |
|
378 { { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0x0 }, |
|
379 { 0x151, 0x276, 0x172, 0x143, 0x0 } }, |
|
380 { { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0x0 }, |
|
381 { 0x151, 0x276, 0x172, 0x144, 0x0 } }, |
|
382 |
|
383 { {0}, {0} } |
|
384 }; |
|
385 |
|
386 |
|
387 const ShapeTable *s = shape_table; |
|
388 while (s->unicode[0]) { |
|
389 QVERIFY( shaping(f, s) ); |
|
390 ++s; |
|
391 } |
|
392 } else { |
|
393 QSKIP("couln't find Akaash", SkipAll); |
|
394 } |
|
395 } |
|
396 { |
|
397 if (QFontDatabase().families(QFontDatabase::Bengali).contains("Mukti Narrow")) { |
|
398 QFont f("Mukti Narrow"); |
|
399 const ShapeTable shape_table [] = { |
|
400 // Ka |
|
401 { { 0x0995, 0x0 }, |
|
402 { 0x0073, 0x0 } }, |
|
403 // Ka Halant |
|
404 { { 0x0995, 0x09cd, 0x0 }, |
|
405 { 0x00b9, 0x0 } }, |
|
406 // Ka Halant Ka |
|
407 { { 0x0995, 0x09cd, 0x0995, 0x0 }, |
|
408 { 0x0109, 0x0 } }, |
|
409 // Ka MatraI |
|
410 { { 0x0995, 0x09bf, 0x0 }, |
|
411 { 0x0095, 0x0073, 0x0 } }, |
|
412 // Ra Halant Ka |
|
413 { { 0x09b0, 0x09cd, 0x0995, 0x0 }, |
|
414 { 0x0073, 0x00e1, 0x0 } }, |
|
415 // Ra Halant Ka MatraI |
|
416 { { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0x0 }, |
|
417 { 0x0095, 0x0073, 0x00e1, 0x0 } }, |
|
418 // MatraI |
|
419 { { 0x09bf, 0x0 }, |
|
420 { 0x0095, 0x01c8, 0x0 } }, |
|
421 // Ka Nukta |
|
422 { { 0x0995, 0x09bc, 0x0 }, |
|
423 { 0x0073, 0x0093, 0x0 } }, |
|
424 // Ka Halant Ra |
|
425 { { 0x0995, 0x09cd, 0x09b0, 0x0 }, |
|
426 { 0x00e5, 0x0 } }, |
|
427 // Ka Halant Ra Halant Ka |
|
428 { { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0x0 }, |
|
429 { 0x234, 0x24e, 0x73, 0x0 } }, |
|
430 // Ya + Halant |
|
431 { { 0x09af, 0x09cd, 0x0 }, |
|
432 { 0x00d2, 0x0 } }, |
|
433 // Da Halant Ya -> Da Ya-Phala |
|
434 { { 0x09a6, 0x09cd, 0x09af, 0x0 }, |
|
435 { 0x0084, 0x00e2, 0x0 } }, |
|
436 // A Halant Ya -> A Ya-phala |
|
437 { { 0x0985, 0x09cd, 0x09af, 0x0 }, |
|
438 { 0x0067, 0x00e2, 0x0 } }, |
|
439 // Na Halant Ka |
|
440 { { 0x09a8, 0x09cd, 0x0995, 0x0 }, |
|
441 { 0x0188, 0x0 } }, |
|
442 // Na Halant ZWNJ Ka |
|
443 { { 0x9a8, 0x9cd, 0x200c, 0x995, 0x0 }, |
|
444 { 0xcc, 0x73, 0x0 } }, |
|
445 // Na Halant ZWJ Ka |
|
446 { { 0x9a8, 0x9cd, 0x200d, 0x995, 0x0 }, |
|
447 { 0x247, 0x73, 0x0 } }, |
|
448 // Ka Halant ZWNJ Ka |
|
449 { { 0x9a8, 0x9cd, 0x200d, 0x995, 0x0 }, |
|
450 { 0x247, 0x73, 0x0 } }, |
|
451 // Ka Halant ZWJ Ka |
|
452 { { 0x9a8, 0x9cd, 0x200d, 0x995, 0x0 }, |
|
453 { 0x247, 0x73, 0x0 } }, |
|
454 // Na Halant Ra |
|
455 { { 0x09a8, 0x09cd, 0x09b0, 0x0 }, |
|
456 { 0x00f8, 0x0 } }, |
|
457 // Na Halant ZWNJ Ra |
|
458 { { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0x0 }, |
|
459 { 0xcc, 0x8d, 0x0 } }, |
|
460 // Na Halant ZWJ Ra |
|
461 { { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0x0 }, |
|
462 { 0x247, 0x8d, 0x0 } }, |
|
463 // Na Halant Ba |
|
464 { { 0x09a8, 0x09cd, 0x09ac, 0x0 }, |
|
465 { 0x0139, 0x0 } }, |
|
466 // Na Halant ZWNJ Ba |
|
467 { { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0x0 }, |
|
468 { 0xcc, 0x89, 0x0 } }, |
|
469 // Na Halant ZWJ Ba |
|
470 { { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0x0 }, |
|
471 { 0x247, 0x89, 0x0 } }, |
|
472 // Na Halant Dha |
|
473 { { 0x09a8, 0x09cd, 0x09a7, 0x0 }, |
|
474 { 0x0145, 0x0 } }, |
|
475 // Na Halant ZWNJ Dha |
|
476 { { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0x0 }, |
|
477 { 0xcc, 0x85, 0x0 } }, |
|
478 // Na Halant ZWJ Dha |
|
479 { { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0x0 }, |
|
480 { 0x247, 0x85, 0x0 } }, |
|
481 // Ra Halant Ka MatraAU |
|
482 { { 0x9b0, 0x9cd, 0x995, 0x9cc, 0x0 }, |
|
483 { 0x232, 0x73, 0xe1, 0xa0, 0x0 } }, |
|
484 // Ra Halant Ba Halant Ba |
|
485 { { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0x0 }, |
|
486 { 0x013b, 0x00e1, 0x0 } }, |
|
487 |
|
488 { {0}, {0} } |
|
489 }; |
|
490 |
|
491 |
|
492 const ShapeTable *s = shape_table; |
|
493 while (s->unicode[0]) { |
|
494 QVERIFY( shaping(f, s) ); |
|
495 ++s; |
|
496 } |
|
497 } else { |
|
498 QSKIP("couln't find Mukti", SkipAll); |
|
499 } |
|
500 } |
|
501 { |
|
502 if (QFontDatabase().families(QFontDatabase::Bengali).contains("Likhan")) { |
|
503 QFont f("Likhan"); |
|
504 const ShapeTable shape_table [] = { |
|
505 { { 0x09a8, 0x09cd, 0x09af, 0x0 }, |
|
506 { 0x0192, 0x0 } }, |
|
507 { { 0x09b8, 0x09cd, 0x09af, 0x0 }, |
|
508 { 0x01d6, 0x0 } }, |
|
509 { { 0x09b6, 0x09cd, 0x09af, 0x0 }, |
|
510 { 0x01bc, 0x0 } }, |
|
511 { { 0x09b7, 0x09cd, 0x09af, 0x0 }, |
|
512 { 0x01c6, 0x0 } }, |
|
513 { { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0x0 }, |
|
514 { 0xd3, 0x12f, 0x0 } }, |
|
515 |
|
516 { {0}, {0} } |
|
517 }; |
|
518 |
|
519 |
|
520 const ShapeTable *s = shape_table; |
|
521 while (s->unicode[0]) { |
|
522 QVERIFY( shaping(f, s) ); |
|
523 ++s; |
|
524 } |
|
525 } else { |
|
526 QSKIP("couln't find Likhan", SkipAll); |
|
527 } |
|
528 } |
|
529 #else |
|
530 QSKIP("X11 specific test", SkipAll); |
|
531 #endif |
|
532 } |
|
533 |
|
534 void tst_QTextScriptEngine::gurmukhi() |
|
535 { |
|
536 #if defined(Q_WS_X11) |
|
537 { |
|
538 if (QFontDatabase().families(QFontDatabase::Gurmukhi).contains("Lohit Punjabi")) { |
|
539 QFont f("Lohit Punjabi"); |
|
540 const ShapeTable shape_table [] = { |
|
541 { { 0xA15, 0xA4D, 0xa39, 0x0 }, |
|
542 { 0x3b, 0x8b, 0x0 } }, |
|
543 { {0}, {0} } |
|
544 }; |
|
545 |
|
546 |
|
547 const ShapeTable *s = shape_table; |
|
548 while (s->unicode[0]) { |
|
549 QVERIFY( shaping(f, s) ); |
|
550 ++s; |
|
551 } |
|
552 } else { |
|
553 QSKIP("couln't find Lohit Punjabi", SkipAll); |
|
554 } |
|
555 } |
|
556 #endif |
|
557 } |
|
558 |
|
559 void tst_QTextScriptEngine::oriya() |
|
560 { |
|
561 #if defined(Q_WS_X11) |
|
562 { |
|
563 if (QFontDatabase().families(QFontDatabase::Oriya).contains("utkal")) { |
|
564 QFont f("utkal"); |
|
565 const ShapeTable shape_table [] = { |
|
566 { { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0x0 }, |
|
567 { 0x150, 0x125, 0x0 } }, |
|
568 { { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0x0 }, |
|
569 { 0x151, 0x120, 0x0 } }, |
|
570 { { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0x0 }, |
|
571 { 0x152, 0x120, 0x0 } }, |
|
572 { { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0x0 }, |
|
573 { 0x152, 0x120, 0x0 } }, |
|
574 { { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0x0 }, |
|
575 { 0x176, 0x0 } }, |
|
576 { { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0x0 }, |
|
577 { 0x177, 0x0 } }, |
|
578 { { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0x0 }, |
|
579 { 0x176, 0x124, 0x0 } }, |
|
580 { {0}, {0} } |
|
581 |
|
582 }; |
|
583 |
|
584 const ShapeTable *s = shape_table; |
|
585 while (s->unicode[0]) { |
|
586 QVERIFY( shaping(f, s) ); |
|
587 ++s; |
|
588 } |
|
589 } else { |
|
590 QSKIP("couln't find utkal", SkipAll); |
|
591 } |
|
592 } |
|
593 #else |
|
594 QSKIP("X11 specific test", SkipAll); |
|
595 #endif |
|
596 } |
|
597 |
|
598 |
|
599 void tst_QTextScriptEngine::tamil() |
|
600 { |
|
601 #if defined(Q_WS_X11) |
|
602 { |
|
603 if (QFontDatabase().families(QFontDatabase::Tamil).contains("AkrutiTml1")) { |
|
604 QFont f("AkrutiTml1"); |
|
605 const ShapeTable shape_table [] = { |
|
606 { { 0x0b95, 0x0bc2, 0x0 }, |
|
607 { 0x004e, 0x0 } }, |
|
608 { { 0x0bae, 0x0bc2, 0x0 }, |
|
609 { 0x009e, 0x0 } }, |
|
610 { { 0x0b9a, 0x0bc2, 0x0 }, |
|
611 { 0x0058, 0x0 } }, |
|
612 { { 0x0b99, 0x0bc2, 0x0 }, |
|
613 { 0x0053, 0x0 } }, |
|
614 { { 0x0bb0, 0x0bc2, 0x0 }, |
|
615 { 0x00a8, 0x0 } }, |
|
616 { { 0x0ba4, 0x0bc2, 0x0 }, |
|
617 { 0x008e, 0x0 } }, |
|
618 { { 0x0b9f, 0x0bc2, 0x0 }, |
|
619 { 0x0062, 0x0 } }, |
|
620 { { 0x0b95, 0x0bc6, 0x0 }, |
|
621 { 0x000a, 0x0031, 0x0 } }, |
|
622 { { 0x0b95, 0x0bca, 0x0 }, |
|
623 { 0x000a, 0x0031, 0x0007, 0x0 } }, |
|
624 { { 0x0b95, 0x0bc6, 0x0bbe, 0x0 }, |
|
625 { 0x000a, 0x0031, 0x007, 0x0 } }, |
|
626 { { 0x0b95, 0x0bcd, 0x0bb7, 0x0 }, |
|
627 { 0x0049, 0x0 } }, |
|
628 { { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0x0 }, |
|
629 { 0x000a, 0x0049, 0x007, 0x0 } }, |
|
630 { { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0x0 }, |
|
631 { 0x000a, 0x0049, 0x007, 0x0 } }, |
|
632 { { 0x0b9f, 0x0bbf, 0x0 }, |
|
633 { 0x005f, 0x0 } }, |
|
634 { { 0x0b9f, 0x0bc0, 0x0 }, |
|
635 { 0x0060, 0x0 } }, |
|
636 { { 0x0bb2, 0x0bc0, 0x0 }, |
|
637 { 0x00ab, 0x0 } }, |
|
638 { { 0x0bb2, 0x0bbf, 0x0 }, |
|
639 { 0x00aa, 0x0 } }, |
|
640 { { 0x0bb0, 0x0bcd, 0x0 }, |
|
641 { 0x00a4, 0x0 } }, |
|
642 { { 0x0bb0, 0x0bbf, 0x0 }, |
|
643 { 0x00a5, 0x0 } }, |
|
644 { { 0x0bb0, 0x0bc0, 0x0 }, |
|
645 { 0x00a6, 0x0 } }, |
|
646 { { 0x0b83, 0x0 }, |
|
647 { 0x0025, 0x0 } }, |
|
648 { { 0x0b83, 0x0b95, 0x0 }, |
|
649 { 0x0025, 0x0031, 0x0 } }, |
|
650 |
|
651 { {0}, {0} } |
|
652 }; |
|
653 |
|
654 |
|
655 const ShapeTable *s = shape_table; |
|
656 while (s->unicode[0]) { |
|
657 QVERIFY( shaping(f, s) ); |
|
658 ++s; |
|
659 } |
|
660 } else { |
|
661 QSKIP("couln't find AkrutiTml1", SkipAll); |
|
662 } |
|
663 } |
|
664 #else |
|
665 QSKIP("X11 specific test", SkipAll); |
|
666 #endif |
|
667 } |
|
668 |
|
669 |
|
670 void tst_QTextScriptEngine::telugu() |
|
671 { |
|
672 #if defined(Q_WS_X11) |
|
673 { |
|
674 if (QFontDatabase().families(QFontDatabase::Telugu).contains("Pothana2000")) { |
|
675 QFont f("Pothana2000"); |
|
676 const ShapeTable shape_table [] = { |
|
677 { { 0xc15, 0xc4d, 0x0 }, |
|
678 { 0xbb, 0x0 } }, |
|
679 { { 0xc15, 0xc4d, 0xc37, 0x0 }, |
|
680 { 0x4b, 0x0 } }, |
|
681 { { 0xc15, 0xc4d, 0xc37, 0xc4d, 0x0 }, |
|
682 { 0xe0, 0x0 } }, |
|
683 { { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0x0 }, |
|
684 { 0x4b, 0x91, 0x0 } }, |
|
685 { { 0xc15, 0xc4d, 0xc30, 0x0 }, |
|
686 { 0x5a, 0xb2, 0x0 } }, |
|
687 { { 0xc15, 0xc4d, 0xc30, 0xc4d, 0x0 }, |
|
688 { 0xbb, 0xb2, 0x0 } }, |
|
689 { { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0x0 }, |
|
690 { 0x5a, 0xb2, 0x83, 0x0 } }, |
|
691 { { 0xc15, 0xc4d, 0xc30, 0xc3f, 0x0 }, |
|
692 { 0xe2, 0xb2, 0x0 } }, |
|
693 { { 0xc15, 0xc4d, 0xc15, 0xc48, 0x0 }, |
|
694 { 0xe6, 0xb3, 0x83, 0x0 } }, |
|
695 { { 0xc15, 0xc4d, 0xc30, 0xc48, 0x0 }, |
|
696 { 0xe6, 0xb3, 0x9f, 0x0 } }, |
|
697 { {0}, {0} } |
|
698 |
|
699 }; |
|
700 |
|
701 const ShapeTable *s = shape_table; |
|
702 while (s->unicode[0]) { |
|
703 QVERIFY( shaping(f, s) ); |
|
704 ++s; |
|
705 } |
|
706 } else { |
|
707 QSKIP("couln't find Pothana2000", SkipAll); |
|
708 } |
|
709 } |
|
710 #else |
|
711 QSKIP("X11 specific test", SkipAll); |
|
712 #endif |
|
713 } |
|
714 |
|
715 |
|
716 void tst_QTextScriptEngine::kannada() |
|
717 { |
|
718 #if defined(Q_WS_X11) |
|
719 { |
|
720 if (QFontDatabase().families(QFontDatabase::Kannada).contains("Sampige")) { |
|
721 QFont f("Sampige"); |
|
722 const ShapeTable shape_table [] = { |
|
723 { { 0x0ca8, 0x0ccd, 0x0ca8, 0x0 }, |
|
724 { 0x0049, 0x00ba, 0x0 } }, |
|
725 { { 0x0ca8, 0x0ccd, 0x0ca1, 0x0 }, |
|
726 { 0x0049, 0x00b3, 0x0 } }, |
|
727 { { 0x0caf, 0x0cc2, 0x0 }, |
|
728 { 0x004f, 0x005d, 0x0 } }, |
|
729 { { 0x0ce0, 0x0 }, |
|
730 { 0x006a, 0x0 } }, |
|
731 { { 0x0ce6, 0x0ce7, 0x0ce8, 0x0 }, |
|
732 { 0x006b, 0x006c, 0x006d, 0x0 } }, |
|
733 { { 0x0cb5, 0x0ccb, 0x0 }, |
|
734 { 0x015f, 0x0067, 0x0 } }, |
|
735 { { 0x0cb0, 0x0ccd, 0x0cae, 0x0 }, |
|
736 { 0x004e, 0x0082, 0x0 } }, |
|
737 { { 0x0cb0, 0x0ccd, 0x0c95, 0x0 }, |
|
738 { 0x0036, 0x0082, 0x0 } }, |
|
739 { { 0x0c95, 0x0ccd, 0x0cb0, 0x0 }, |
|
740 { 0x0036, 0x00c1, 0x0 } }, |
|
741 { { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0x0 }, |
|
742 { 0x0050, 0x00a7, 0x0 } }, |
|
743 |
|
744 { {0}, {0} } |
|
745 }; |
|
746 |
|
747 |
|
748 const ShapeTable *s = shape_table; |
|
749 while (s->unicode[0]) { |
|
750 QVERIFY( shaping(f, s) ); |
|
751 ++s; |
|
752 } |
|
753 } else { |
|
754 QSKIP("couln't find Sampige", SkipAll); |
|
755 } |
|
756 } |
|
757 { |
|
758 if (QFontDatabase().families(QFontDatabase::Kannada).contains("Tunga")) { |
|
759 QFont f("Tunga"); |
|
760 const ShapeTable shape_table [] = { |
|
761 { { 0x0cb7, 0x0cc6, 0x0 }, |
|
762 { 0x00b0, 0x006c, 0x0 } }, |
|
763 { { 0x0cb7, 0x0ccd, 0x0 }, |
|
764 { 0x0163, 0x0 } }, |
|
765 |
|
766 { {0}, {0} } |
|
767 }; |
|
768 |
|
769 |
|
770 const ShapeTable *s = shape_table; |
|
771 while (s->unicode[0]) { |
|
772 QVERIFY( shaping(f, s) ); |
|
773 ++s; |
|
774 } |
|
775 } else { |
|
776 QSKIP("couln't find Tunga", SkipAll); |
|
777 } |
|
778 } |
|
779 #else |
|
780 QSKIP("X11 specific test", SkipAll); |
|
781 #endif |
|
782 } |
|
783 |
|
784 |
|
785 |
|
786 void tst_QTextScriptEngine::malayalam() |
|
787 { |
|
788 #if defined(Q_WS_X11) |
|
789 { |
|
790 if (QFontDatabase().families(QFontDatabase::Malayalam).contains("AkrutiMal2")) { |
|
791 QFont f("AkrutiMal2"); |
|
792 const ShapeTable shape_table [] = { |
|
793 { { 0x0d15, 0x0d46, 0x0 }, |
|
794 { 0x005e, 0x0034, 0x0 } }, |
|
795 { { 0x0d15, 0x0d47, 0x0 }, |
|
796 { 0x005f, 0x0034, 0x0 } }, |
|
797 { { 0x0d15, 0x0d4b, 0x0 }, |
|
798 { 0x005f, 0x0034, 0x0058, 0x0 } }, |
|
799 { { 0x0d15, 0x0d48, 0x0 }, |
|
800 { 0x0060, 0x0034, 0x0 } }, |
|
801 { { 0x0d15, 0x0d4a, 0x0 }, |
|
802 { 0x005e, 0x0034, 0x0058, 0x0 } }, |
|
803 { { 0x0d30, 0x0d4d, 0x0d15, 0x0 }, |
|
804 { 0x009e, 0x0034, 0x0 } }, |
|
805 { { 0x0d15, 0x0d4d, 0x0d35, 0x0 }, |
|
806 { 0x0034, 0x007a, 0x0 } }, |
|
807 { { 0x0d15, 0x0d4d, 0x0d2f, 0x0 }, |
|
808 { 0x0034, 0x00a2, 0x0 } }, |
|
809 { { 0x0d1f, 0x0d4d, 0x0d1f, 0x0 }, |
|
810 { 0x0069, 0x0 } }, |
|
811 { { 0x0d26, 0x0d4d, 0x0d26, 0x0 }, |
|
812 { 0x0074, 0x0 } }, |
|
813 { { 0x0d30, 0x0d4d, 0x0 }, |
|
814 { 0x009e, 0x0 } }, |
|
815 { { 0x0d30, 0x0d4d, 0x200c, 0x0 }, |
|
816 { 0x009e, 0x0 } }, |
|
817 { { 0x0d30, 0x0d4d, 0x200d, 0x0 }, |
|
818 { 0x009e, 0x0 } }, |
|
819 |
|
820 |
|
821 { {0}, {0} } |
|
822 }; |
|
823 |
|
824 |
|
825 const ShapeTable *s = shape_table; |
|
826 while (s->unicode[0]) { |
|
827 QVERIFY( shaping(f, s) ); |
|
828 ++s; |
|
829 } |
|
830 } else { |
|
831 QSKIP("couln't find AkrutiMal2", SkipAll); |
|
832 } |
|
833 } |
|
834 #else |
|
835 QSKIP("X11 specific test", SkipAll); |
|
836 #endif |
|
837 } |
|
838 |
|
839 |
|
840 |
|
841 void tst_QTextScriptEngine::khmer() |
|
842 { |
|
843 #if defined(Q_WS_X11) |
|
844 { |
|
845 if (QFontDatabase().families(QFontDatabase::Khmer).contains("Khmer OS")) { |
|
846 QFont f("Khmer OS"); |
|
847 const ShapeTable shape_table [] = { |
|
848 { { 0x179a, 0x17cd, 0x0 }, |
|
849 { 0x24c, 0x27f, 0x0 } }, |
|
850 { { 0x179f, 0x17c5, 0x0 }, |
|
851 { 0x273, 0x203, 0x0 } }, |
|
852 { { 0x1790, 0x17d2, 0x1784, 0x17c3, 0x0 }, |
|
853 { 0x275, 0x242, 0x182, 0x0 } }, |
|
854 { { 0x179a, 0x0 }, |
|
855 { 0x24c, 0x0 } }, |
|
856 { { 0x1781, 0x17d2, 0x1798, 0x17c2, 0x0 }, |
|
857 { 0x274, 0x233, 0x197, 0x0 } }, |
|
858 { { 0x1798, 0x17b6, 0x0 }, |
|
859 { 0x1cb, 0x0 } }, |
|
860 { { 0x179a, 0x17b8, 0x0 }, |
|
861 { 0x24c, 0x26a, 0x0 } }, |
|
862 { { 0x1787, 0x17b6, 0x0 }, |
|
863 { 0x1ba, 0x0 } }, |
|
864 { { 0x1798, 0x17d2, 0x1796, 0x17bb, 0x0 }, |
|
865 { 0x24a, 0x195, 0x26d, 0x0 } }, |
|
866 { {0}, {0} } |
|
867 }; |
|
868 |
|
869 |
|
870 const ShapeTable *s = shape_table; |
|
871 while (s->unicode[0]) { |
|
872 QVERIFY( shaping(f, s) ); |
|
873 ++s; |
|
874 } |
|
875 } else { |
|
876 QSKIP("couln't find Khmer OS", SkipAll); |
|
877 } |
|
878 } |
|
879 #else |
|
880 QSKIP("X11 specific test", SkipAll); |
|
881 #endif |
|
882 } |
|
883 |
|
884 void tst_QTextScriptEngine::linearB() |
|
885 { |
|
886 #if defined(Q_WS_X11) |
|
887 { |
|
888 if (QFontDatabase().families(QFontDatabase::Any).contains("Penuturesu")) { |
|
889 QFont f("Penuturesu"); |
|
890 const ShapeTable shape_table [] = { |
|
891 { { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 }, |
|
892 { 0x5, 0x6, 0x7, 0 } }, |
|
893 { {0}, {0} } |
|
894 }; |
|
895 |
|
896 |
|
897 const ShapeTable *s = shape_table; |
|
898 while (s->unicode[0]) { |
|
899 QVERIFY( shaping(f, s) ); |
|
900 ++s; |
|
901 } |
|
902 } else { |
|
903 QSKIP("couln't find Penuturesu", SkipAll); |
|
904 } |
|
905 } |
|
906 #else |
|
907 QSKIP("X11 specific test", SkipAll); |
|
908 #endif |
|
909 } |
|
910 |
|
911 |
|
912 QTEST_MAIN(tst_QTextScriptEngine) |
|
913 #include "tst_qtextscriptengine.moc" |