1 | /****************************************************************************
|
---|
2 | ** $Id: qtextengine_pm.cpp 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** ???
|
---|
5 | **
|
---|
6 | ** Copyright (C) 2003 Trolltech AS. All rights reserved.
|
---|
7 | ** Copyright (C) 2004 Norman ASA. Initial OS/2 Port.
|
---|
8 | ** Copyright (C) 2005 netlabs.org. Further OS/2 Development.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifdef QT_THREAD_SUPPORT
|
---|
39 | # include <private/qmutexpool_p.h>
|
---|
40 | #endif // QT_THREAD_SUPPORT
|
---|
41 | #include "qlibrary.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | //@@TODO (dmik): remove?
|
---|
45 | //// these defines are from usp10.h
|
---|
46 | //typedef void *SCRIPT_CACHE;
|
---|
47 | //typedef struct tag_SCRIPT_CONTROL {
|
---|
48 | // DWORD uDefaultLanguage :16;
|
---|
49 | // DWORD fContextDigits :1;
|
---|
50 | // DWORD fInvertPreBoundDir :1;
|
---|
51 | // DWORD fInvertPostBoundDir :1;
|
---|
52 | // DWORD fLinkStringBefore :1;
|
---|
53 | // DWORD fLinkStringAfter :1;
|
---|
54 | // DWORD fNeutralOverride :1;
|
---|
55 | // DWORD fNumericOverride :1;
|
---|
56 | // DWORD fLegacyBidiClass :1;
|
---|
57 | // DWORD fReserved :8;
|
---|
58 | //} SCRIPT_CONTROL;
|
---|
59 | //
|
---|
60 | //typedef struct tag_SCRIPT_STATE {
|
---|
61 | // WORD uBidiLevel :5;
|
---|
62 | // WORD fOverrideDirection :1;
|
---|
63 | // WORD fInhibitSymSwap :1;
|
---|
64 | // WORD fCharShape :1;
|
---|
65 | // WORD fDigitSubstitute :1;
|
---|
66 | // WORD fInhibitLigate :1;
|
---|
67 | // WORD fDisplayZWG :1;
|
---|
68 | // WORD fArabicNumContext :1;
|
---|
69 | // WORD fGcpClusters :1;
|
---|
70 | // WORD fReserved :1;
|
---|
71 | // WORD fEngineReserved :2;
|
---|
72 | //} SCRIPT_STATE;
|
---|
73 | //
|
---|
74 | //typedef struct tag_SCRIPT_ITEM {
|
---|
75 | // int iCharPos;
|
---|
76 | // QScriptAnalysis a;
|
---|
77 | //} SCRIPT_ITEM;
|
---|
78 | //
|
---|
79 | //typedef GlyphAttributes SCRIPT_VISATTR;
|
---|
80 | //typedef qoffset_t GOFFSET;
|
---|
81 | //
|
---|
82 | //#define USP_E_SCRIPT_NOT_IN_FONT \
|
---|
83 | // MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200) // Script doesn't exist in font
|
---|
84 | //
|
---|
85 | //typedef struct {
|
---|
86 | // DWORD langid :16;
|
---|
87 | // DWORD fNumeric :1;
|
---|
88 | // DWORD fComplex :1;
|
---|
89 | // DWORD fNeedsWordBreaking :1;
|
---|
90 | // DWORD fNeedsCaretInfo :1;
|
---|
91 | // DWORD bCharSet :8;
|
---|
92 | // DWORD fControl :1;
|
---|
93 | // DWORD fPrivateUseArea :1;
|
---|
94 | // DWORD fNeedsCharacterJustify :1;
|
---|
95 | // DWORD fInvalidGlyph :1;
|
---|
96 | // DWORD fInvalidLogAttr :1;
|
---|
97 | // DWORD fCDM :1;
|
---|
98 | // DWORD fAmbiguousCharSet :1;
|
---|
99 | // DWORD fClusterSizeVaries :1;
|
---|
100 | // DWORD fRejectInvalid :1;
|
---|
101 | //} SCRIPT_PROPERTIES;
|
---|
102 | //
|
---|
103 | //#if defined(Q_OS_TEMP) && UNDER_CE < 400
|
---|
104 | //typedef struct _ABC {
|
---|
105 | // int abcA;
|
---|
106 | // UINT abcB;
|
---|
107 | // int abcC;
|
---|
108 | //} ABC;
|
---|
109 | //#endif
|
---|
110 | //
|
---|
111 | //typedef HRESULT (WINAPI *fScriptFreeCache)( SCRIPT_CACHE *);
|
---|
112 | //typedef HRESULT (WINAPI *fScriptItemize)( const WCHAR *, int, int, const SCRIPT_CONTROL *,
|
---|
113 | // const SCRIPT_STATE *, SCRIPT_ITEM *, int *);
|
---|
114 | //typedef HRESULT (WINAPI *fScriptShape)( HDC hdc, SCRIPT_CACHE *, const WCHAR *, int, int,
|
---|
115 | // QScriptAnalysis *, WORD *, WORD *, SCRIPT_VISATTR *, int *);
|
---|
116 | //typedef HRESULT (WINAPI *fScriptPlace)( HDC, SCRIPT_CACHE *, const WORD *, int, const SCRIPT_VISATTR *, QScriptAnalysis *, int *,
|
---|
117 | // GOFFSET *, ABC * );
|
---|
118 | //typedef HRESULT (WINAPI *fScriptTextOut)( const HDC, SCRIPT_CACHE *, int, int, UINT, const RECT *, const QScriptAnalysis *,
|
---|
119 | // const WCHAR *, int, const WORD *, int, const int *, const int *, const GOFFSET *);
|
---|
120 | //typedef HRESULT (WINAPI *fScriptBreak)( const WCHAR *, int, const QScriptAnalysis *, QCharAttributes * );
|
---|
121 | ////typedef HRESULT (WINAPI *fScriptGetFontProperties)( HDC, SCRIPT_CACHE *, SCRIPT_FONTPROPERTIES * );
|
---|
122 | //typedef HRESULT (WINAPI *fScriptGetProperties)( const SCRIPT_PROPERTIES ***, int *);
|
---|
123 | //
|
---|
124 | //fScriptFreeCache ScriptFreeCache = 0;
|
---|
125 | //static fScriptItemize ScriptItemize = 0;
|
---|
126 | //static fScriptShape ScriptShape = 0;
|
---|
127 | //static fScriptPlace ScriptPlace = 0;
|
---|
128 | //fScriptTextOut ScriptTextOut = 0;
|
---|
129 | //static fScriptBreak ScriptBreak = 0;
|
---|
130 | ////static fScriptGetFontProperties ScriptGetFontProperties = 0;
|
---|
131 | //static fScriptGetProperties ScriptGetProperties = 0;
|
---|
132 | //
|
---|
133 | //static bool resolvedUsp10 = FALSE;
|
---|
134 | //bool hasUsp10 = FALSE;
|
---|
135 | //
|
---|
136 | //const SCRIPT_PROPERTIES **script_properties = 0;
|
---|
137 | //int num_scripts = 0;
|
---|
138 | //int usp_latin_script = 0;
|
---|
139 | //
|
---|
140 | //
|
---|
141 | //const QFont::Script japanese_tryScripts[] = {
|
---|
142 | // QFont::Latin,
|
---|
143 | // QFont::Han_Japanese,
|
---|
144 | // QFont::Hangul,
|
---|
145 | // QFont::Han_SimplifiedChinese,
|
---|
146 | // QFont::Han_TraditionalChinese
|
---|
147 | //};
|
---|
148 | //
|
---|
149 | //const QFont::Script korean_tryScripts[] = {
|
---|
150 | // QFont::Latin,
|
---|
151 | // QFont::Hangul,
|
---|
152 | // QFont::Han_Japanese,
|
---|
153 | // QFont::Han_SimplifiedChinese,
|
---|
154 | // QFont::Han_TraditionalChinese
|
---|
155 | //};
|
---|
156 | //
|
---|
157 | //const QFont::Script simplifiedChinese_tryScripts[] = {
|
---|
158 | // QFont::Latin,
|
---|
159 | // QFont::Han_SimplifiedChinese,
|
---|
160 | // QFont::Han_TraditionalChinese,
|
---|
161 | // QFont::Han_Japanese,
|
---|
162 | // QFont::Hangul
|
---|
163 | //};
|
---|
164 | //
|
---|
165 | //const QFont::Script traditionalChinese_tryScripts[] = {
|
---|
166 | // QFont::Latin,
|
---|
167 | // QFont::Han_TraditionalChinese,
|
---|
168 | // QFont::Han_SimplifiedChinese,
|
---|
169 | // QFont::Han_Japanese,
|
---|
170 | // QFont::Hangul
|
---|
171 | //};
|
---|
172 | //
|
---|
173 | //const QFont::Script *tryScripts = japanese_tryScripts;
|
---|
174 | //
|
---|
175 | //static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir);
|
---|
176 | //
|
---|
177 | //static void resolveUsp10()
|
---|
178 | //{
|
---|
179 | //#ifndef QT_NO_COMPONENT
|
---|
180 | // if ( !resolvedUsp10 ) {
|
---|
181 | // // need to resolve the security info functions
|
---|
182 | //
|
---|
183 | //#ifdef QT_THREAD_SUPPORT
|
---|
184 | // // protect initialization
|
---|
185 | // QMutexLocker locker( qt_global_mutexpool ?
|
---|
186 | // qt_global_mutexpool->get( (void*)&resolveUsp10 ) : 0 );
|
---|
187 | // // check triedResolve again, since another thread may have already
|
---|
188 | // // done the initialization
|
---|
189 | // if ( resolvedUsp10 ) {
|
---|
190 | // // another thread did initialize the security function pointers,
|
---|
191 | // // so we shouldn't do it again.
|
---|
192 | // return;
|
---|
193 | // }
|
---|
194 | //#endif
|
---|
195 | //
|
---|
196 | // resolvedUsp10 = TRUE;
|
---|
197 | // QLibrary lib("usp10");
|
---|
198 | // lib.setAutoUnload( FALSE );
|
---|
199 | //
|
---|
200 | // ScriptFreeCache = (fScriptFreeCache) lib.resolve( "ScriptFreeCache" );
|
---|
201 | // ScriptItemize = (fScriptItemize) lib.resolve( "ScriptItemize" );
|
---|
202 | // ScriptShape = (fScriptShape) lib.resolve( "ScriptShape" );
|
---|
203 | // ScriptPlace = (fScriptPlace) lib.resolve( "ScriptPlace" );
|
---|
204 | // ScriptTextOut = (fScriptTextOut) lib.resolve( "ScriptTextOut" );
|
---|
205 | // ScriptBreak = (fScriptBreak) lib.resolve( "ScriptBreak" );
|
---|
206 | // ScriptGetProperties = (fScriptGetProperties) lib.resolve( "ScriptGetProperties" );
|
---|
207 | //
|
---|
208 | // if ( !ScriptFreeCache )
|
---|
209 | // return;
|
---|
210 | //
|
---|
211 | // hasUsp10 = TRUE;
|
---|
212 | // ScriptGetProperties( &script_properties, &num_scripts );
|
---|
213 | //
|
---|
214 | // // get the usp script for western
|
---|
215 | // for( int i = 0; i < num_scripts; i++ ) {
|
---|
216 | // if (script_properties[i]->langid == LANG_ENGLISH &&
|
---|
217 | // !script_properties[i]->fAmbiguousCharSet ) {
|
---|
218 | // usp_latin_script = i;
|
---|
219 | // break;
|
---|
220 | // }
|
---|
221 | // }
|
---|
222 | //
|
---|
223 | // // initialize tryScripts according to locale
|
---|
224 | // LANGID lid = GetUserDefaultLangID();
|
---|
225 | // switch( lid&0xff ) {
|
---|
226 | // case LANG_CHINESE: // Chinese (Taiwan)
|
---|
227 | // if ( lid == 0x0804 ) // Taiwan
|
---|
228 | // tryScripts = traditionalChinese_tryScripts;
|
---|
229 | // else
|
---|
230 | // tryScripts = simplifiedChinese_tryScripts;
|
---|
231 | // break;
|
---|
232 | // case LANG_JAPANESE:
|
---|
233 | // // japanese is already the default
|
---|
234 | // break;
|
---|
235 | // case LANG_KOREAN:
|
---|
236 | // tryScripts = korean_tryScripts;
|
---|
237 | // break;
|
---|
238 | // default:
|
---|
239 | // break;
|
---|
240 | // }
|
---|
241 | //
|
---|
242 | // appendItems = uspAppendItems;
|
---|
243 | // }
|
---|
244 | //#endif
|
---|
245 | //}
|
---|
246 | //
|
---|
247 | //static unsigned char script_for_win_language[ 0x80 ] = {
|
---|
248 | // //0x00 LANG_NEUTRAL Neutral
|
---|
249 | // QFont::Latin,
|
---|
250 | // //0x01 LANG_ARABIC Arabic
|
---|
251 | // QFont::Arabic,
|
---|
252 | // //0x02 LANG_BULGARIAN Bulgarian
|
---|
253 | // QFont::NScripts,
|
---|
254 | // //0x03 LANG_CATALAN Catalan
|
---|
255 | // QFont::NScripts,
|
---|
256 | // //0x04 LANG_CHINESE Chinese
|
---|
257 | // QFont::Han,
|
---|
258 | // //0x05 LANG_CZECH Czech
|
---|
259 | // QFont::NScripts,
|
---|
260 | // //0x06 LANG_DANISH Danish
|
---|
261 | // QFont::NScripts,
|
---|
262 | // //0x07 LANG_GERMAN German
|
---|
263 | // QFont::NScripts,
|
---|
264 | // //0x08 LANG_GREEK Greek
|
---|
265 | // QFont::Greek,
|
---|
266 | // //0x09 LANG_ENGLISH English
|
---|
267 | // QFont::Latin,
|
---|
268 | // //0x0a LANG_SPANISH Spanish
|
---|
269 | // QFont::NScripts,
|
---|
270 | // //0x0b LANG_FINNISH Finnish
|
---|
271 | // QFont::NScripts,
|
---|
272 | // //0x0c LANG_FRENCH French
|
---|
273 | // QFont::NScripts,
|
---|
274 | // //0x0d LANG_HEBREW Hebrew
|
---|
275 | // QFont::Hebrew,
|
---|
276 | // //0x0e LANG_HUNGARIAN Hungarian
|
---|
277 | // QFont::NScripts,
|
---|
278 | // //0x0f LANG_ICELANDIC Icelandic
|
---|
279 | // QFont::NScripts,
|
---|
280 | //
|
---|
281 | // //0x10 LANG_ITALIAN Italian
|
---|
282 | // QFont::NScripts,
|
---|
283 | // //0x11 LANG_JAPANESE Japanese
|
---|
284 | // QFont::Hiragana,
|
---|
285 | // //0x12 LANG_KOREAN Korean
|
---|
286 | // QFont::Hangul,
|
---|
287 | // //0x13 LANG_DUTCH Dutch
|
---|
288 | // QFont::NScripts,
|
---|
289 | // //0x14 LANG_NORWEGIAN Norwegian
|
---|
290 | // QFont::NScripts,
|
---|
291 | // //0x15 LANG_POLISH Polish
|
---|
292 | // QFont::NScripts,
|
---|
293 | // //0x16 LANG_PORTUGUESE Portuguese
|
---|
294 | // QFont::NScripts,
|
---|
295 | // QFont::NScripts,
|
---|
296 | // //0x18 LANG_ROMANIAN Romanian
|
---|
297 | // QFont::NScripts,
|
---|
298 | // //0x19 LANG_RUSSIAN Russian
|
---|
299 | // QFont::Cyrillic,
|
---|
300 | // //0x1a LANG_CROATIAN Croatian
|
---|
301 | // //0x1a LANG_SERBIAN Serbian
|
---|
302 | // QFont::NScripts,
|
---|
303 | // //0x1b LANG_SLOVAK Slovak
|
---|
304 | // QFont::NScripts,
|
---|
305 | // //0x1c LANG_ALBANIAN Albanian
|
---|
306 | // QFont::NScripts,
|
---|
307 | // //0x1d LANG_SWEDISH Swedish
|
---|
308 | // QFont::NScripts,
|
---|
309 | // //0x1e LANG_THAI Thai
|
---|
310 | // QFont::Thai,
|
---|
311 | // //0x1f LANG_TURKISH Turkish
|
---|
312 | // QFont::NScripts,
|
---|
313 | //
|
---|
314 | // //0x20 LANG_URDU Urdu
|
---|
315 | // QFont::NScripts,
|
---|
316 | // //0x21 LANG_INDONESIAN Indonesian
|
---|
317 | // QFont::NScripts,
|
---|
318 | // //0x22 LANG_UKRAINIAN Ukrainian
|
---|
319 | // QFont::NScripts,
|
---|
320 | // //0x23 LANG_BELARUSIAN Belarusian
|
---|
321 | // QFont::NScripts,
|
---|
322 | // //0x24 LANG_SLOVENIAN Slovenian
|
---|
323 | // QFont::NScripts,
|
---|
324 | // //0x25 LANG_ESTONIAN Estonian
|
---|
325 | // QFont::NScripts,
|
---|
326 | // //0x26 LANG_LATVIAN Latvian
|
---|
327 | // QFont::NScripts,
|
---|
328 | // //0x27 LANG_LITHUANIAN Lithuanian
|
---|
329 | // QFont::NScripts,
|
---|
330 | // QFont::NScripts,
|
---|
331 | // //0x29 LANG_FARSI Farsi
|
---|
332 | // QFont::NScripts,
|
---|
333 | // //0x2a LANG_VIETNAMESE Vietnamese
|
---|
334 | // QFont::Latin, // ##### maybe use QFont::CombiningMarks instead?
|
---|
335 | // //0x2b LANG_ARMENIAN Armenian
|
---|
336 | // QFont::Armenian,
|
---|
337 | // //0x2c LANG_AZERI Azeri
|
---|
338 | // QFont::NScripts,
|
---|
339 | // //0x2d LANG_BASQUE Basque
|
---|
340 | // QFont::NScripts,
|
---|
341 | // QFont::NScripts,
|
---|
342 | // //0x2f LANG_MACEDONIAN FYRO Macedonian
|
---|
343 | // QFont::NScripts,
|
---|
344 | //
|
---|
345 | // QFont::NScripts,
|
---|
346 | // QFont::NScripts,
|
---|
347 | // QFont::NScripts,
|
---|
348 | // QFont::NScripts,
|
---|
349 | // QFont::NScripts,
|
---|
350 | // QFont::NScripts,
|
---|
351 | // //0x36 LANG_AFRIKAANS Afrikaans
|
---|
352 | // QFont::NScripts,
|
---|
353 | // //0x37 LANG_GEORGIAN Georgian
|
---|
354 | // QFont::NScripts,
|
---|
355 | // //0x38 LANG_FAEROESE Faeroese
|
---|
356 | // QFont::NScripts,
|
---|
357 | // //0x39 LANG_HINDI Hindi
|
---|
358 | // QFont::Devanagari,
|
---|
359 | // QFont::NScripts,
|
---|
360 | // QFont::NScripts,
|
---|
361 | // QFont::NScripts,
|
---|
362 | // QFont::NScripts,
|
---|
363 | // //0x3e LANG_MALAY Malay
|
---|
364 | // QFont::NScripts,
|
---|
365 | // //0x3f LANG_KAZAK Kazak
|
---|
366 | // QFont::NScripts,
|
---|
367 | //
|
---|
368 | // //0x40 LANG_KYRGYZ Kyrgyz
|
---|
369 | // QFont::NScripts,
|
---|
370 | // //0x41 LANG_SWAHILI Swahili
|
---|
371 | // QFont::NScripts,
|
---|
372 | // QFont::NScripts,
|
---|
373 | // //0x43 LANG_UZBEK Uzbek
|
---|
374 | // QFont::NScripts,
|
---|
375 | // //0x44 LANG_TATAR Tatar
|
---|
376 | // QFont::NScripts,
|
---|
377 | // //0x45 LANG_BENGALI Not supported.
|
---|
378 | // QFont::Bengali,
|
---|
379 | // //0x46 LANG_PUNJABI Punjabi
|
---|
380 | // QFont::Gurmukhi,
|
---|
381 | // //0x47 LANG_GUJARATI Gujarati
|
---|
382 | // QFont::Gujarati,
|
---|
383 | // //0x48 LANG_ORIYA Not supported.
|
---|
384 | // QFont::Oriya,
|
---|
385 | // //0x49 LANG_TAMIL Tamil
|
---|
386 | // QFont::Tamil,
|
---|
387 | // //0x4a LANG_TELUGU Telugu
|
---|
388 | // QFont::Telugu,
|
---|
389 | // //0x4b LANG_KANNADA Kannada
|
---|
390 | // QFont::Kannada,
|
---|
391 | // //0x4c LANG_MALAYALAM Not supported.
|
---|
392 | // QFont::Malayalam,
|
---|
393 | // //0x4d LANG_ASSAMESE Not supported.
|
---|
394 | // QFont::NScripts,
|
---|
395 | // //0x4e LANG_MARATHI Marathi
|
---|
396 | // QFont::NScripts,
|
---|
397 | // //0x4f LANG_SANSKRIT Sanskrit
|
---|
398 | // QFont::Devanagari,
|
---|
399 | //
|
---|
400 | // //0x50 LANG_MONGOLIAN Mongolian
|
---|
401 | // QFont::Mongolian,
|
---|
402 | // QFont::NScripts,
|
---|
403 | // QFont::NScripts,
|
---|
404 | // QFont::NScripts,
|
---|
405 | // QFont::NScripts,
|
---|
406 | // QFont::NScripts,
|
---|
407 | // //0x56 LANG_GALICIAN Galician
|
---|
408 | // QFont::NScripts,
|
---|
409 | // //0x57 LANG_KONKANI Konkani
|
---|
410 | // QFont::NScripts,
|
---|
411 | // //0x58 LANG_MANIPURI Not supported.
|
---|
412 | // QFont::NScripts,
|
---|
413 | // //0x59 LANG_SINDHI Not supported.
|
---|
414 | // QFont::NScripts,
|
---|
415 | // //0x5a LANG_SYRIAC Syriac
|
---|
416 | // QFont::Syriac,
|
---|
417 | // QFont::NScripts,
|
---|
418 | // QFont::NScripts,
|
---|
419 | // QFont::NScripts,
|
---|
420 | // QFont::NScripts,
|
---|
421 | // QFont::NScripts,
|
---|
422 | //
|
---|
423 | // //0x60 LANG_KASHMIRI Not supported.
|
---|
424 | // QFont::NScripts,
|
---|
425 | // //0x61 LANG_NEPALI Not supported.
|
---|
426 | // QFont::NScripts,
|
---|
427 | // QFont::NScripts,
|
---|
428 | // QFont::NScripts,
|
---|
429 | // QFont::NScripts,
|
---|
430 | // //0x65 LANG_DIVEHI Divehi
|
---|
431 | // QFont::NScripts,
|
---|
432 | // QFont::NScripts,
|
---|
433 | // QFont::NScripts,
|
---|
434 | // QFont::NScripts,
|
---|
435 | // QFont::NScripts,
|
---|
436 | // QFont::NScripts,
|
---|
437 | // QFont::NScripts,
|
---|
438 | // QFont::NScripts,
|
---|
439 | // QFont::NScripts,
|
---|
440 | // QFont::NScripts,
|
---|
441 | // QFont::NScripts,
|
---|
442 | //
|
---|
443 | // QFont::NScripts,
|
---|
444 | // QFont::NScripts,
|
---|
445 | // QFont::NScripts,
|
---|
446 | // QFont::NScripts,
|
---|
447 | // QFont::NScripts,
|
---|
448 | // QFont::NScripts,
|
---|
449 | // QFont::NScripts,
|
---|
450 | // QFont::NScripts,
|
---|
451 | // QFont::NScripts,
|
---|
452 | // QFont::NScripts,
|
---|
453 | // QFont::NScripts,
|
---|
454 | // QFont::NScripts,
|
---|
455 | // QFont::NScripts,
|
---|
456 | // QFont::NScripts,
|
---|
457 | // QFont::NScripts,
|
---|
458 | // //0x7f LANG_INVARIANT
|
---|
459 | // QFont::NScripts,
|
---|
460 | //};
|
---|
461 | //
|
---|
462 | //static inline QFont::Script scriptForWinLanguage( DWORD langid )
|
---|
463 | //{
|
---|
464 | // QFont::Script script = (QFont::Script)script_for_win_language[langid];
|
---|
465 | // if ( script == QFont::NScripts )
|
---|
466 | // qWarning( "Qt Uniscribe support: Encountered unhandled language id %x", (unsigned int)langid );
|
---|
467 | // return script;
|
---|
468 | //}
|
---|
469 | //
|
---|
470 | //static inline bool isAsian( unsigned short ch )
|
---|
471 | //{
|
---|
472 | // return (ch > 0x2dff && ch < 0xfb00) || ((ch & 0xff00) == 0x1100);
|
---|
473 | //}
|
---|
474 | //
|
---|
475 | //
|
---|
476 | //// we're not using Uniscribe's BiDi algorithm, since it is (a) not 100% Unicode compliant and
|
---|
477 | //// (b) seems to work wrongly when trying to use it with a base level != 0.
|
---|
478 | ////
|
---|
479 | //// This function does uses Uniscribe to do the script analysis and creates items from this.
|
---|
480 | //static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir)
|
---|
481 | //{
|
---|
482 | // QScriptItemArray &items = engine->items;
|
---|
483 | // const QChar *text = engine->string.unicode();
|
---|
484 | //
|
---|
485 | // if ( start > stop ) {
|
---|
486 | // // #### the algorithm is currently not really safe against this. Still needs fixing.
|
---|
487 | //// qWarning( "Bidi: appendItems() internal error" );
|
---|
488 | // return;
|
---|
489 | // }
|
---|
490 | //
|
---|
491 | // int level = control.level();
|
---|
492 | //
|
---|
493 | // if(dir != QChar::DirON) {
|
---|
494 | // // add level of run (cases I1 & I2)
|
---|
495 | // if( level % 2 ) {
|
---|
496 | // if(dir == QChar::DirL || dir == QChar::DirAN || dir == QChar::DirEN )
|
---|
497 | // level++;
|
---|
498 | // } else {
|
---|
499 | // if( dir == QChar::DirR )
|
---|
500 | // level++;
|
---|
501 | // else if( dir == QChar::DirAN || dir == QChar::DirEN )
|
---|
502 | // level += 2;
|
---|
503 | // }
|
---|
504 | // }
|
---|
505 | //
|
---|
506 | // SCRIPT_ITEM s_items[256];
|
---|
507 | // SCRIPT_ITEM *usp_items = s_items;
|
---|
508 | //
|
---|
509 | // int numItems;
|
---|
510 | // HRESULT res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, 255, 0, 0, usp_items, &numItems );
|
---|
511 | //
|
---|
512 | // if ( res == E_OUTOFMEMORY ) {
|
---|
513 | // int alloc = 256;
|
---|
514 | // usp_items = 0;
|
---|
515 | // while( res == E_OUTOFMEMORY ) {
|
---|
516 | // alloc *= 2;
|
---|
517 | // usp_items = (SCRIPT_ITEM *)realloc( usp_items, alloc * sizeof( SCRIPT_ITEM ) );
|
---|
518 | // res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, alloc-1, 0, 0, usp_items, &numItems );
|
---|
519 | // }
|
---|
520 | // }
|
---|
521 | // items.resize( items.size() + numItems );
|
---|
522 | // int i;
|
---|
523 | // for( i = 0; i < numItems; i++ ) {
|
---|
524 | // QScriptItem item;
|
---|
525 | // item.analysis = usp_items[i].a;
|
---|
526 | // item.position = usp_items[i].iCharPos+start;
|
---|
527 | // item.analysis.bidiLevel = level;
|
---|
528 | // item.analysis.override = control.override();
|
---|
529 | //
|
---|
530 | // int rstart = usp_items[i].iCharPos;
|
---|
531 | // int rstop = usp_items[i+1].iCharPos-1;
|
---|
532 | // bool b = TRUE;
|
---|
533 | // for ( int j = rstart; j <= rstop; j++ ) {
|
---|
534 | //
|
---|
535 | // unsigned short uc = text[j+start].unicode();
|
---|
536 | // QChar::Category category = ::category( uc );
|
---|
537 | // if ( uc == 0xfffcU || uc == 0x2028U ) {
|
---|
538 | // item.analysis.script = usp_latin_script;
|
---|
539 | // item.isObject = TRUE;
|
---|
540 | // b = TRUE;
|
---|
541 | // } else if ((uc >= 9 && uc <=13) ||
|
---|
542 | // (category >= QChar::Separator_Space && category <= QChar::Separator_Paragraph)) {
|
---|
543 | // item.analysis.script = usp_latin_script;
|
---|
544 | // item.isSpace = TRUE;
|
---|
545 | // item.isTab = (uc == '\t');
|
---|
546 | // if (item.isTab)
|
---|
547 | // item.analysis.bidiLevel = control.baseLevel();
|
---|
548 | // b = TRUE;
|
---|
549 | // } else if (b) {
|
---|
550 | // b = FALSE;
|
---|
551 | // } else {
|
---|
552 | // continue;
|
---|
553 | // }
|
---|
554 | //
|
---|
555 | // item.position = j+start;
|
---|
556 | // items.append( item );
|
---|
557 | // item.analysis = usp_items[i].a;
|
---|
558 | // item.analysis.bidiLevel = level;
|
---|
559 | // item.analysis.override = control.override();
|
---|
560 | // item.isSpace = item.isTab = item.isObject = FALSE;
|
---|
561 | // }
|
---|
562 | // }
|
---|
563 | //
|
---|
564 | // if ( usp_items != s_items )
|
---|
565 | // free( usp_items );
|
---|
566 | //
|
---|
567 | // ++stop;
|
---|
568 | // start = stop;
|
---|
569 | //}
|
---|
570 |
|
---|
571 |
|
---|
572 | // -----------------------------------------------------------------------------------------------------
|
---|
573 | //
|
---|
574 | // Text engine classes
|
---|
575 | //
|
---|
576 | // -----------------------------------------------------------------------------------------------------
|
---|
577 |
|
---|
578 |
|
---|
579 | QScriptItemArray::~QScriptItemArray()
|
---|
580 | {
|
---|
581 | clear();
|
---|
582 | free( d );
|
---|
583 | }
|
---|
584 |
|
---|
585 | void QScriptItemArray::clear()
|
---|
586 | {
|
---|
587 | if ( d ) {
|
---|
588 | for ( unsigned int i = 0; i < d->size; i++ ) {
|
---|
589 | QScriptItem &si = d->items[i];
|
---|
590 | if ( si.fontEngine )
|
---|
591 | si.fontEngine->deref();
|
---|
592 | }
|
---|
593 | d->size = 0;
|
---|
594 | }
|
---|
595 | }
|
---|
596 |
|
---|
597 | void QScriptItemArray::resize( int s )
|
---|
598 | {
|
---|
599 | int alloc = ((s + 8) >> 3) << 3;
|
---|
600 | d = (QScriptItemArrayPrivate *)realloc( d, sizeof( QScriptItemArrayPrivate ) +
|
---|
601 | sizeof( QScriptItem ) * alloc );
|
---|
602 | d->alloc = alloc;
|
---|
603 | }
|
---|
604 |
|
---|
605 |
|
---|
606 | void QTextEngine::shape( int item ) const
|
---|
607 | {
|
---|
608 | QScriptItem &si = items[item];
|
---|
609 |
|
---|
610 | if ( si.num_glyphs )
|
---|
611 | return;
|
---|
612 |
|
---|
613 | QFont::Script script = (QFont::Script)si.analysis.script;
|
---|
614 | int from = si.position;
|
---|
615 | int len = length( item );
|
---|
616 |
|
---|
617 | Q_ASSERT( len > 0 );
|
---|
618 |
|
---|
619 | si.glyph_data_offset = used;
|
---|
620 |
|
---|
621 | if ( !si.fontEngine ) {
|
---|
622 | //@@TODO (dmik): remove?
|
---|
623 | // if ( hasUsp10 ) {
|
---|
624 | // const SCRIPT_PROPERTIES *script_prop = script_properties[si.analysis.script];
|
---|
625 | // script = scriptForWinLanguage( script_prop->langid );
|
---|
626 | // if ( script == QFont::Latin && script_prop->fAmbiguousCharSet ) {
|
---|
627 | // // either some asian language or something Uniscribe doesn't recognise
|
---|
628 | // // we look at the first character to find out what it is
|
---|
629 | // bool asian = false;
|
---|
630 | // int l = length(item);
|
---|
631 | // for(int i = 0; i < l; ++i) {
|
---|
632 | // if(isAsian(string.unicode()[si.position+i].unicode())) {
|
---|
633 | // asian = true;
|
---|
634 | // break;
|
---|
635 | // }
|
---|
636 | // }
|
---|
637 | // if (asian) {
|
---|
638 | // // some asian language
|
---|
639 | // int i;
|
---|
640 | // for( i = 0; i < 5; i++ ) {
|
---|
641 | // QFontEngine *fe = fnt->engineForScript( tryScripts[i] );
|
---|
642 | // if ( fe->type() == QFontEngine::Box )
|
---|
643 | // continue;
|
---|
644 | //
|
---|
645 | // if ( fe->canRender( string.unicode()+from, len ) ) {
|
---|
646 | // script = tryScripts[i];
|
---|
647 | // break;
|
---|
648 | // }
|
---|
649 | // }
|
---|
650 | // }
|
---|
651 | // }
|
---|
652 | // }
|
---|
653 | si.fontEngine = fnt->engineForScript( script );
|
---|
654 | //@@TODO (dmik): remove?
|
---|
655 | // if ( si.fontEngine->type() == QFontEngine::Box )
|
---|
656 | // si.fontEngine = fnt->engineForScript( QFont::NoScript );
|
---|
657 | si.fontEngine->ref();
|
---|
658 | }
|
---|
659 |
|
---|
660 | //@@TODO (dmik): remove?
|
---|
661 | // if ( hasUsp10 && si.fontEngine->ttf ) {
|
---|
662 | // int l = len;
|
---|
663 | // si.analysis.logicalOrder = TRUE;
|
---|
664 | // HRESULT res = E_OUTOFMEMORY;
|
---|
665 | // HDC hdc = 0;
|
---|
666 | //
|
---|
667 | // do {
|
---|
668 | // ensureSpace( l );
|
---|
669 | //
|
---|
670 | // res = ScriptShape( hdc, &si.fontEngine->script_cache, (WCHAR *)string.unicode() + from, len,
|
---|
671 | // l, &si.analysis, glyphs( &si ), logClusters( &si ), glyphAttributes( &si ),
|
---|
672 | // &si.num_glyphs );
|
---|
673 | // if ( res == E_PENDING ) {
|
---|
674 | // hdc = si.fontEngine->dc();
|
---|
675 | // SelectObject( hdc, si.fontEngine->hfont );
|
---|
676 | // } else if ( res == USP_E_SCRIPT_NOT_IN_FONT ) {
|
---|
677 | // si.analysis.script = 0;
|
---|
678 | // hdc = 0;
|
---|
679 | // } else if (res == E_OUTOFMEMORY) {
|
---|
680 | // l += 32;
|
---|
681 | // } else if ( res != S_OK ) {
|
---|
682 | // Q_ASSERT( FALSE );
|
---|
683 | // }
|
---|
684 | // } while( res != S_OK );
|
---|
685 | //
|
---|
686 | //
|
---|
687 | // ABC abc;
|
---|
688 | // res = ScriptPlace( hdc, &si.fontEngine->script_cache, glyphs( &si ), si.num_glyphs,
|
---|
689 | // glyphAttributes( &si ), &si.analysis, advances( &si ), offsets( &si ), &abc );
|
---|
690 | // if ( res == E_PENDING ) {
|
---|
691 | // hdc = si.fontEngine->dc();
|
---|
692 | // SelectObject( hdc, si.fontEngine->hfont );
|
---|
693 | // ScriptPlace( hdc, &si.fontEngine->script_cache, glyphs( &si ), si.num_glyphs,
|
---|
694 | // glyphAttributes( &si ), &si.analysis, advances( &si ), offsets( &si ), &abc );
|
---|
695 | // }
|
---|
696 | // si.width = abc.abcA + abc.abcB + abc.abcC;
|
---|
697 | // } else {
|
---|
698 | Q_ASSERT( script < QFont::NScripts );
|
---|
699 | scriptEngines[script].shape( script, string, from, len, (QTextEngine*)this, &si );
|
---|
700 | si.width = 0;
|
---|
701 | advance_t *advances = this->advances( &si );
|
---|
702 | for ( int i = 0; i < si.num_glyphs; i++ )
|
---|
703 | si.width += advances[i];
|
---|
704 | //@@TODO (dmik): remove?
|
---|
705 | // }
|
---|
706 | si.ascent = si.fontEngine->ascent();
|
---|
707 | si.descent = si.fontEngine->descent();
|
---|
708 |
|
---|
709 | ((QTextEngine *)this)->used += si.num_glyphs;
|
---|
710 | }
|
---|
711 |
|
---|