]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/qte/qte-2.3.10/bidimetrics.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / qte / qte-2.3.10 / bidimetrics.patch
1
2 #
3 # Patch managed by http://www.holgerschurig.de/patcher.html
4 #
5
6 Index: qt-2.3.10/src/kernel/qgfxraster_qws.cpp
7 ===================================================================
8 --- qt-2.3.10.orig/src/kernel/qgfxraster_qws.cpp        2005-05-13 22:22:11.000000000 +0200
9 +++ qt-2.3.10/src/kernel/qgfxraster_qws.cpp     2005-05-13 22:22:13.000000000 +0200
10 @@ -51,6 +51,11 @@
11  #include <fcntl.h>
12  #include <errno.h>
13  
14 +//HAQ bidi patch
15 +#ifdef USE_BIDI
16 +#include "qbidi.h"
17 +#endif
18 +// end HAQ patch
19  
20  extern bool qws_sw_cursor;
21  
22 @@ -1382,6 +1387,53 @@
23         setAlphaType(BigEndianMask);
24      }
25  
26 +#ifdef USE_BIDI
27 +    // HAQ do bidi
28 +    QString  n;
29 +    qApplyBidi(s, n);
30 +
31 +    for( loopc=0; loopc < int(n.length()); loopc++ ) {
32 +       QGlyph glyph = memorymanager->lockGlyph(myfont, n[loopc]);
33 +       int myw=glyph.metrics->width;
34 +       srcwidth = myw;
35 +       srcheight = glyph.metrics->height;
36 +       setAlphaSource(glyph.data,glyph.metrics->linestep);
37 +       int myx=x;
38 +       int myy=y;
39 +       myx+=glyph.metrics->bearingx;
40 +       myy-=glyph.metrics->bearingy;
41 +
42 +       // HAQ hack to show arabic tashkeel (diacriticals) above 
43 +       // the previous character (which in reversed arabic, as it is here, is the next character)
44 +
45 +       QChar c = n[loopc];
46 +       if (ISTASHKEEL(c.unicode())) {
47 +               //printf("glyph %d bearingx %d width %d advance %d\n",
48 +               //      c.unicode(),glyph.metrics->bearingx, glyph.metrics->width, glyph.metrics->advance);
49 +
50 +               if (loopc < int(n.length()-1)) // if there is a following character then place this glyph over it
51 +                {
52 +                       QGlyph nextGlyph = memorymanager->lockGlyph(myfont, n[loopc+1]);
53 +                       int nextCharWidth = nextGlyph.metrics->width;
54 +                       myx += nextCharWidth/2 - glyph.metrics->width;
55 +                       // pre-undo the advance in x so that the next glyph is placed over this one
56 +                       x -= glyph.metrics->advance;
57 +               }
58 +       }
59 +
60 +       if(glyph.metrics->width<1 || glyph.metrics->height<1
61 +           || glyph.metrics->linestep==0)
62 +       {
63 +           // non-printing characters
64 +       } else {
65 +           blt(myx,myy,myw,glyph.metrics->height,0,0);
66 +       }
67 +       x+=glyph.metrics->advance;
68 +       // ... unlock glyph
69 +    }
70 +
71 +#else
72 +
73      for( loopc=0; loopc < int(s.length()); loopc++ ) {
74         QGlyph glyph = memorymanager->lockGlyph(myfont, s[loopc]);
75         int myw=glyph.metrics->width;
76 @@ -1402,6 +1454,9 @@
77         x+=glyph.metrics->advance;
78         // ... unlock glyph
79      }
80 +
81 +#endif
82 +
83  #ifdef DEBUG_LOCKS
84      qDebug("unaccelerated drawText unlock");
85  #endif
86 Index: qt-2.3.10/src/kernel/qfont_qws.cpp
87 ===================================================================
88 --- qt-2.3.10.orig/src/kernel/qfont_qws.cpp     2005-05-13 22:22:11.000000000 +0200
89 +++ qt-2.3.10/src/kernel/qfont_qws.cpp  2005-05-13 22:22:13.000000000 +0200
90 @@ -49,6 +49,12 @@
91  #include "qfontmanager_qws.h"
92  #include "qmemorymanager_qws.h"
93  
94 +//HAQ
95 +#ifdef USE_BIDI
96 +#include "qbidi.h"
97 +#endif
98 +// end HAQ
99 +
100  // QFont_Private accesses QFont protected functions
101  
102  class QFont_Private : public QFont
103 @@ -385,17 +391,46 @@
104  
105  int QFontMetrics::width( QChar ch ) const
106  {
107 +#ifdef USE_BIDI  
108 +
109 +    int advance;
110 +    if (ISTASHKEEL(ch.unicode())) {
111 +      advance = 0;
112 +    }
113 +    else
114 +      advance = memorymanager->lockGlyphMetrics(((QFontMetrics*)this)->internal()->handle(),ch)->advance;
115 +    return advance;
116 +
117 +#else
118 +
119      return memorymanager->lockGlyphMetrics(((QFontMetrics*)this)->internal()->handle(),ch)->advance;
120 +
121 +#endif
122  }
123  
124  int QFontMetrics::width( const QString &str, int len ) const
125  {
126 +#ifdef USE_BIDI
127 +
128 +    QString n;
129 +    qApplyBidi(str, n);
130 +    if (len < 0) len = n.length();
131 +    int ret=0;
132 +    for (int i=0; i<len; i++)
133 +      ret += width(n[i]);
134 +    return ret;
135 +
136 +#else
137 +
138      if ( len < 0 )
139         len = str.length();
140      int ret=0;
141      for (int i=0; i<len; i++)
142         ret += width(str[i]);
143      return ret;
144 +
145 +#endif
146 +
147  }
148  
149  QRect QFontMetrics::boundingRect( const QString &str, int len ) const
150 Index: qt-2.3.10/src/kernel/qbidi.h
151 ===================================================================
152 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
153 +++ qt-2.3.10/src/kernel/qbidi.h        2005-05-13 22:22:13.000000000 +0200
154 @@ -0,0 +1,6 @@
155 +#include "stdio.h"
156 +#include <qstring.h>
157 +
158 +#define ISTASHKEEL(x) ((x >= 0x64B && x<=0x658) || (x>=0x6d6 && x <= 0x6dc) || (x>=0x6df && x <= 0x6e4) || x==0x6e7 || x == 0x6e8 || (x>=0x6ea && x <= 0x6ed) || (x>=0xfe70 && x <= 0xfe7f))
159 +
160 +void qApplyBidi(const QString& s, QString& news);
161 Index: qt-2.3.10/src/kernel/qbidi.cpp
162 ===================================================================
163 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
164 +++ qt-2.3.10/src/kernel/qbidi.cpp      2005-05-13 22:22:13.000000000 +0200
165 @@ -0,0 +1,45 @@
166 +#include <malloc.h>
167 +#include "qbidi.h"
168 +
169 +
170 +#define BLOCKTYPE unsigned short*
171 +#define CHARTYPE unsigned short
172 +
173 +extern "C" {
174 +
175 +int doShape(BLOCKTYPE line, CHARTYPE* to, int from, int count);
176 +int doBidi(BLOCKTYPE line, int count, int applyShape, int reorderCombining, int removeMarks);
177 +
178 +}
179 +
180 +void qApplyBidi(const QString& s, QString& news) {
181 +       //convert to utf16 zero-terminated
182 +       //printf(": qs length is %d\n",s.length());
183 +        int loopc;
184 +       int slength = sizeof(unsigned short) * (s.length());
185 +       //printf(": slength is %d\n",slength);
186 +       unsigned short* sutf16 = (unsigned short*)malloc(slength);
187 +       for( loopc=0; loopc < int(s.length()); loopc++ ) {
188 +         sutf16[loopc] = s[loopc].unicode();
189 +         //printf(": char %d is %x\n",loopc,sutf16[loopc]);
190 +       }
191 +       //printf(": mark 0\n");
192 +       ///sutf16[s.length()] = 0;
193 +
194 +       unsigned short* sutf16s = (unsigned short*)malloc(slength);
195 +       doShape(sutf16,sutf16s,0,s.length());
196 +       //printf(": do bidi\n");
197 +       doBidi(sutf16s, s.length(),0,0,0);
198 +       //sutf16s[s.length()] = 0;
199 +
200 +       //printf(": back to QString\n");
201 +       news = "";
202 +       for( loopc=0; loopc < s.length(); loopc++ ) {
203 +         QChar newChar((short) sutf16s[loopc]);
204 +         news = news + newChar;
205 +         //printf(": add char %x\n",newChar.unicode());
206 +       }
207 +
208 +       free(sutf16);
209 +       free(sutf16s);
210 +}
211 Index: qt-2.3.10/src/kernel/minibidi.c
212 ===================================================================
213 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
214 +++ qt-2.3.10/src/kernel/minibidi.c     2005-05-13 22:22:13.000000000 +0200
215 @@ -0,0 +1,2127 @@
216 +/************************************************************************
217 + * $Id: minibidi.c,v 1.2 2005/04/08 18:01:45 lynch Exp $
218 + *
219 + * ------------
220 + * Description:
221 + * ------------
222 + * This is an implemention of Unicode's Bidirectional Algorithm
223 + * (known as UAX #9).
224 + *
225 + *   http://www.unicode.org/reports/tr9/
226 + * 
227 + * Author: Ahmad Khalifa
228 + *
229 + * -----------------
230 + * Revision Details:    (Updated by Revision Control System)
231 + * -----------------
232 + *  $Date: 2005/04/08 18:01:45 $
233 + *  $Author: lynch $
234 + *  $Revision: 1.2 $
235 + *  $Source: /home/arabeyes/cvs/projects/external/qt_e/minibidi.c,v $
236 + *
237 + * (www.arabeyes.org - under MIT license)
238 + *
239 + ************************************************************************/
240 +
241 +#include <malloc.h>            /* malloc() and free() definition */
242 +
243 +/*
244 + * Datatype Extension Macros
245 + */
246 +#define BLOCKTYPE unsigned short*
247 +#define CHARTYPE unsigned short
248 +#define GETCHAR(from,i) from[i]
249 +
250 +#define GetType(x) getType(x)
251 +/*=====TESTING mode===========*/
252 +//#define GetType(x) getCAPRtl(x)
253 +
254 +#define lenof(x) sizeof(x) / sizeof(x[0])
255 +
256 +/* character types */
257 +enum
258 +{
259 +       /* Strong Char Types */
260 +       L,              /* Left-to-Right char */
261 +       LRE,    /* Left-to-Right Embedding */
262 +       LRO,    /* Left-to-Right Override */
263 +       R,              /* Right-to-Left char */
264 +       AL,             /* Right-to-Left Arabic char */
265 +       RLE,    /* Right-to-Left Embedding */
266 +       RLO,    /* Right-to-Left Override */
267 +       /* Weak Char Types */
268 +       PDF,    /* Pop Directional Format */
269 +       EN,             /* European Number */
270 +       ES,             /* European Number Separator */
271 +       ET,             /* European Number Terminator */
272 +       AN,             /* Arabic Number */
273 +       CS,             /* Common Number Separator */
274 +       NSM,    /* Non Spacing Mark */
275 +       BN,             /* Boundary Neutral */
276 +       /* Neutral Char Types */
277 +       B,              /* Paragraph Separator */
278 +       S,              /* Segment Separator */
279 +       WS,             /* Whitespace */
280 +       ON,             /* Other Neutrals */
281 +};
282 +
283 +/* Shaping Types */
284 +enum
285 +{
286 +       SL, /* Left-Joining, doesnt exist in U+0600 - U+06FF */
287 +       SR, /* Right-Joining, ie has Isolated, Final */
288 +       SD, /* Dual-Joining, ie has Isolated, Final, Initial, Medial */
289 +       SU, /* Non-Joining */
290 +       SC  /* Join-Causing, like U+0640 (TATWEEL) */
291 +};
292 +
293 +#define odd(x) (x%2)
294 +/* Returns the first odd/even value greater than x */
295 +#define leastGreaterOdd(x) odd(x) ? (x+2) : (x+1)
296 +#define leastGreaterEven(x) odd(x) ? (x+1) : (x+2)
297 +
298 +/* Shaping Helpers */
299 +#define STYPE(xh) ((xh >= SHAPE_FIRST) && (xh <= SHAPE_LAST)) ? \
300 +                   shapetypes[xh-SHAPE_FIRST].type : SU
301 +#define SISOLATED(xh) shapetypes[xh-SHAPE_FIRST].form_b
302 +#define SFINAL(xh) xh+1
303 +#define SINITIAL(xh) xh+2
304 +#define SMEDIAL(xh) xh+3
305 +
306 +
307 +/* function declarations */
308 +int findIndexOfRun(unsigned char* level , int start, int count, int tlevel);
309 +unsigned char getType(CHARTYPE ch);
310 +unsigned char getCAPRtl(CHARTYPE ch);
311 +void doMirror(BLOCKTYPE ch);
312 +
313 +typedef struct{
314 +       unsigned char type;
315 +       unsigned short form_b;
316 +} shape_node;
317 +
318 +/* Kept near the actual table, for verification. */
319 +#define SHAPE_FIRST 0x621
320 +#define SHAPE_LAST 0x668
321 +/* very bad Memory alignment for 32-bit machines
322 + * could split it to 2 arrays or promote type to 2 bytes type
323 + */
324 +shape_node shapetypes[] = {
325 +/* index, Typ, Iso */
326 +/* 621 */ {SU, 0xFE80},
327 +/* 622 */ {SR, 0xFE81},
328 +/* 623 */ {SR, 0xFE83},
329 +/* 624 */ {SR, 0xFE85},
330 +/* 625 */ {SR, 0xFE87},
331 +/* 626 */ {SD, 0xFE89},
332 +/* 627 */ {SR, 0xFE8D},
333 +/* 628 */ {SD, 0xFE8F},
334 +/* 629 */ {SR, 0xFE93},
335 +/* 62A */ {SD, 0xFE95},
336 +/* 62B */ {SD, 0xFE99},
337 +/* 62C */ {SD, 0xFE9D},
338 +/* 62D */ {SD, 0xFEA1},
339 +/* 62E */ {SD, 0xFEA5},
340 +/* 62F */ {SR, 0xFEA9},
341 +/* 630 */ {SR, 0xFEAB},
342 +/* 631 */ {SR, 0xFEAD},
343 +/* 632 */ {SR, 0xFEAF},
344 +/* 633 */ {SD, 0xFEB1},
345 +/* 634 */ {SD, 0xFEB5},
346 +/* 635 */ {SD, 0xFEB9},
347 +/* 636 */ {SD, 0xFEBD},
348 +/* 637 */ {SD, 0xFEC1},
349 +/* 638 */ {SD, 0xFEC5},
350 +/* 639 */ {SD, 0xFEC9},
351 +/* 63A */ {SD, 0xFECD},
352 +/* 63B */ {SU, 0x0},
353 +/* 63C */ {SU, 0x0},
354 +/* 63D */ {SU, 0x0},
355 +/* 63E */ {SU, 0x0},
356 +/* 63F */ {SU, 0x0},
357 +/* 640 */ {SC, 0x0},
358 +/* 641 */ {SD, 0xFED1},
359 +/* 642 */ {SD, 0xFED5},
360 +/* 643 */ {SD, 0xFED9},
361 +/* 644 */ {SD, 0xFEDD},
362 +/* 645 */ {SD, 0xFEE1},
363 +/* 646 */ {SD, 0xFEE5},
364 +/* 647 */ {SD, 0xFEE9},
365 +/* 648 */ {SR, 0xFEED},
366 +/* 649 */ {SR, 0xFEEF}, /* SD */
367 +/* 64A */ {SD, 0xFEF1},
368 +/* 64B */ {SU, 0xFEF1},
369 +/* 64C */ {SU, 0xFEF1},
370 +/* 64D */ {SU, 0xFEF1},
371 +/* 64E */ {SU, 0xFEF1},
372 +/* 64F */ {SU, 0xFEF1},
373 +/* 650 */ {SU,0xFEF1},
374 +/* 651 */ {SU,0xFEF1},
375 +/* 652 */ {SU,0xFEF1},
376 +/* 653 */ {SU, 0xFEF1},
377 +/* 654 */ {SU, 0xFEF1},
378 +/* 655 */ {SU, 0xFEF1},
379 +/* 656 */ {SU, 0xFEF1},
380 +/* 657 */ {SU, 0xFEF1},
381 +/* 658 */ {SU, 0xFEF1},
382 +/* 659 */ {SU, 0xFEF1},
383 +/* 65a */ {SU, 0xFEF1},
384 +/* 65b */ {SU, 0xFEF1},
385 +/* 65c */ {SU, 0xFEF1},
386 +/* 65d */ {SU, 0xFEF1},
387 +/* 65e */ {SU, 0xFEF1},
388 +/* 65f */ {SU, 0xFEF1},
389 +/* 660 */ {SU, 0xFEF1},
390 +/* 661 */ {SU, 0xFEF1},
391 +/* 662 */ {SU, 0xFEF1},
392 +/* 663 */ {SU, 0xFEF1},
393 +/* 664 */ {SU, 0xFEF1},
394 +/* 665 */ {SU, 0xFEF1},
395 +/* 666 */ {SU, 0xFEF1},
396 +/* 667 */ {SU, 0xFEF1},
397 +/* 668 */ {SU, 0xFEF1}
398 +};
399 +
400 +/*
401 + * Flips the text buffer, according to max level, and
402 + * all higher levels
403 + * 
404 + * Input:
405 + * from: text buffer, on which to apply flipping
406 + * level: resolved levels buffer
407 + * max: the maximum level found in this line (should be unsigned char)
408 + * count: line size in wchar_t
409 + */
410 +void flipThisRun(BLOCKTYPE from, unsigned char* level, int max, int count)
411 +{
412 +   int i, j, rcount, tlevel;
413 +   CHARTYPE temp;
414 +
415 +
416 +   j = i = 0;
417 +   while(i<count && j<count)
418 +   {
419 +
420 +      /* find the start of the run of level=max */
421 +      tlevel = max;
422 +      i = j = findIndexOfRun(level, i, count, max);
423 +      /* find the end of the run */
424 +      while((tlevel <= level[i]) && (i < count))
425 +      {
426 +        i++;
427 +      }
428 +      rcount = i-j;
429 +      for(; rcount>((i-j)/2); rcount--)
430 +      {
431 +        temp = GETCHAR(from, j+rcount-1);
432 +        GETCHAR(from, j+rcount-1) = GETCHAR(from, i-rcount);
433 +        GETCHAR(from, i-rcount) = temp;
434 +      }
435 +   }
436 +}
437 +
438 +/*
439 + * Finds the index of a run with level equals tlevel
440 + */
441 +int findIndexOfRun(unsigned char* level , int start, int count, int tlevel)
442 +{
443 +   int i;
444 +   for(i=start; i<count; i++)
445 +   {
446 +      if(tlevel <= level[i])
447 +      {
448 +        return i;
449 +      }
450 +   }
451 +   return count;
452 +}
453 +
454 +unsigned char GetParagraphLevel(BLOCKTYPE line, int count)
455 +{
456 +       int i;
457 +       for( i=0; i<count ; i++)
458 +       {
459 +               if(GetType(GETCHAR(line, i)) == R || GetType(/*line[i]*/ GETCHAR(line, i)) == AL)
460 +                       return 1;
461 +               else if(GetType(GETCHAR(line, i)) == L)
462 +                       return 0;
463 +       }
464 +       return 0;               /* Compiler Nag-Stopper */
465 +}
466 +
467 +/*
468 + * Returns character type of ch, by calling RLE table lookup
469 + * function
470 + */
471 +unsigned char getCAPRtl(CHARTYPE ch)
472 +{
473 +/* CAPRtl Charset */
474 +int TypesFromChar[]  =
475 +{
476 +//0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f
477 + ON, ON, ON, ON,  L,  R, ON, ON, ON, ON, ON, ON, ON, B, RLO,RLE, /*00-0f*/
478 + LRO,LRE,PDF,WS, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, /*10-1f*/
479 +
480 + WS, ON, ON, ON, ET, ON, ON, ON, ON, ON, ON, ET, CS, ON, ES, ES, /*20-2f*/
481 + EN, EN, EN, EN, EN, EN, AN, AN, AN, AN, LRE, RLE, RLO, PDF, LRO, ON, /*30-3f*/
482 +  R, AL, AL, AL, AL, AL, AL,  R,  R,  R,  R,  R,  R,  R,  R,  R, /*40-4f*/
483 +  R,  R,  R,  R,  R,  R,  R,  R,  R,  R,  R, ON,  B, ON, ON, ON, /*50-5f*/
484 + NSM, L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L, /*60-6f*/
485 +  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L, ON,  S, ON, ON, ON, /*70-7f*/
486 +};
487 +
488 +//0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f
489 +// ON, ON, ON, ON,  L,  R, ON, ON, ON, ON, ON, ON, ON, B, RLO,RLE, /*00-0f*/
490 +//LRO,LRE,PDF,WS, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, /*10-1f*/
491 +
492 +// WS, ON, ON, ON, ET, ON, ON, ON, ON, ON, ON, ET, CS, ON, ES, ES, /*20-2f*/
493 +// EN, EN, EN, EN, EN, EN, AN, AN, AN, AN, CS, ON, ON, ON, ON, ON, /*30-3f*/
494 +//  R, AL, AL, AL, AL, AL, AL,  R,  R,  R,  R,  R,  R,  R,  R,  R, /*40-4f*/
495 +//  R,  R,  R,  R,  R,  R,  R,  R,  R,  R,  R, ON,  B, ON, ON, ON, /*50-5f*/
496 +// NSM, L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L, /*60-6f*/
497 +//  L,  L,  L,  L,  L,  L,  L,  L,  L,  L,  L, ON,  S, ON, ON, ON, /*70-7f*/
498 +//};
499 +       if(ch <0x7f)
500 +               return TypesFromChar[ch];
501 +       else 
502 +               return R;
503 +}
504 +
505 +unsigned char getType(CHARTYPE ch)
506 +{
507 +    static const struct {
508 +       CHARTYPE first, last, type;
509 +    } lookup[] = {
510 +        {0x0000, 0x0008, BN},
511 +        {0x0009, 0x0009, S},
512 +        {0x000a, 0x000a, B},
513 +        {0x000b, 0x000b, S},
514 +        {0x000c, 0x000c, WS},
515 +        {0x000d, 0x000d, B},
516 +        {0x000e, 0x001b, BN},
517 +        {0x001c, 0x001e, B},
518 +        {0x001f, 0x001f, S},
519 +        {0x0020, 0x0020, WS},
520 +        {0x0023, 0x0025, ET},
521 +        {0x002b, 0x002b, ES},
522 +        {0x002c, 0x002c, CS},
523 +        {0x002d, 0x002d, ES},
524 +        {0x002e, 0x002f, CS},
525 +        {0x0030, 0x0039, EN},
526 +        {0x003a, 0x003a, CS},
527 +        {0x0041, 0x005a, L},
528 +        {0x0061, 0x007a, L},
529 +        {0x007f, 0x0084, BN},
530 +        {0x0085, 0x0085, B},
531 +        {0x0086, 0x009f, BN},
532 +        {0x00a0, 0x00a0, CS},
533 +        {0x00a2, 0x00a5, ET},
534 +        {0x00aa, 0x00aa, L},
535 +        {0x00ad, 0x00ad, BN},
536 +        {0x00b0, 0x00b1, ET},
537 +        {0x00b2, 0x00b3, EN},
538 +        {0x00b5, 0x00b5, L},
539 +        {0x00b9, 0x00b9, EN},
540 +        {0x00ba, 0x00ba, L},
541 +        {0x00c0, 0x00d6, L},
542 +        {0x00d8, 0x00f6, L},
543 +        {0x00f8, 0x0236, L},
544 +        {0x0250, 0x02b8, L},
545 +        {0x02bb, 0x02c1, L},
546 +        {0x02d0, 0x02d1, L},
547 +        {0x02e0, 0x02e4, L},
548 +        {0x02ee, 0x02ee, L},
549 +        {0x0300, 0x0357, NSM},
550 +        {0x035d, 0x036f, NSM},
551 +        {0x037a, 0x037a, L},
552 +        {0x0386, 0x0386, L},
553 +        {0x0388, 0x038a, L},
554 +        {0x038c, 0x038c, L},
555 +        {0x038e, 0x03a1, L},
556 +        {0x03a3, 0x03ce, L},
557 +        {0x03d0, 0x03f5, L},
558 +        {0x03f7, 0x03fb, L},
559 +        {0x0400, 0x0482, L},
560 +        {0x0483, 0x0486, NSM},
561 +        {0x0488, 0x0489, NSM},
562 +        {0x048a, 0x04ce, L},
563 +        {0x04d0, 0x04f5, L},
564 +        {0x04f8, 0x04f9, L},
565 +        {0x0500, 0x050f, L},
566 +        {0x0531, 0x0556, L},
567 +        {0x0559, 0x055f, L},
568 +        {0x0561, 0x0587, L},
569 +        {0x0589, 0x0589, L},
570 +        {0x0591, 0x05a1, NSM},
571 +        {0x05a3, 0x05b9, NSM},
572 +        {0x05bb, 0x05bd, NSM},
573 +        {0x05be, 0x05be, R},
574 +        {0x05bf, 0x05bf, NSM},
575 +        {0x05c0, 0x05c0, R},
576 +        {0x05c1, 0x05c2, NSM},
577 +        {0x05c3, 0x05c3, R},
578 +        {0x05c4, 0x05c4, NSM},
579 +        {0x05d0, 0x05ea, R},
580 +        {0x05f0, 0x05f4, R},
581 +        {0x0600, 0x0603, AL},
582 +        {0x060c, 0x060c, CS},
583 +        {0x060d, 0x060d, AL},
584 +        {0x0610, 0x0615, NSM},
585 +        {0x061b, 0x061b, AL},
586 +        {0x061f, 0x061f, AL},
587 +        {0x0621, 0x063a, AL},
588 +        {0x0640, 0x064a, AL},
589 +        {0x064b, 0x0658, NSM},
590 +        {0x0660, 0x0669, AN},
591 +        {0x066a, 0x066a, ET},
592 +        {0x066b, 0x066c, AN},
593 +        {0x066d, 0x066f, AL},
594 +        {0x0670, 0x0670, NSM},
595 +        {0x0671, 0x06d5, AL},
596 +        {0x06d6, 0x06dc, NSM},
597 +        {0x06dd, 0x06dd, AL},
598 +        {0x06de, 0x06e4, NSM},
599 +        {0x06e5, 0x06e6, AL},
600 +        {0x06e7, 0x06e8, NSM},
601 +        {0x06ea, 0x06ed, NSM},
602 +        {0x06ee, 0x06ef, AL},
603 +        {0x06f0, 0x06f9, EN},
604 +        {0x06fa, 0x070d, AL},
605 +        {0x070f, 0x070f, BN},
606 +        {0x0710, 0x0710, AL},
607 +        {0x0711, 0x0711, NSM},
608 +        {0x0712, 0x072f, AL},
609 +        {0x0730, 0x074a, NSM},
610 +        {0x074d, 0x074f, AL},
611 +        {0x0780, 0x07a5, AL},
612 +        {0x07a6, 0x07b0, NSM},
613 +        {0x07b1, 0x07b1, AL},
614 +        {0x0901, 0x0902, NSM},
615 +        {0x0903, 0x0939, L},
616 +        {0x093c, 0x093c, NSM},
617 +        {0x093d, 0x0940, L},
618 +        {0x0941, 0x0948, NSM},
619 +        {0x0949, 0x094c, L},
620 +        {0x094d, 0x094d, NSM},
621 +        {0x0950, 0x0950, L},
622 +        {0x0951, 0x0954, NSM},
623 +        {0x0958, 0x0961, L},
624 +        {0x0962, 0x0963, NSM},
625 +        {0x0964, 0x0970, L},
626 +        {0x0981, 0x0981, NSM},
627 +        {0x0982, 0x0983, L},
628 +        {0x0985, 0x098c, L},
629 +        {0x098f, 0x0990, L},
630 +        {0x0993, 0x09a8, L},
631 +        {0x09aa, 0x09b0, L},
632 +        {0x09b2, 0x09b2, L},
633 +        {0x09b6, 0x09b9, L},
634 +        {0x09bc, 0x09bc, NSM},
635 +        {0x09bd, 0x09c0, L},
636 +        {0x09c1, 0x09c4, NSM},
637 +        {0x09c7, 0x09c8, L},
638 +        {0x09cb, 0x09cc, L},
639 +        {0x09cd, 0x09cd, NSM},
640 +        {0x09d7, 0x09d7, L},
641 +        {0x09dc, 0x09dd, L},
642 +        {0x09df, 0x09e1, L},
643 +        {0x09e2, 0x09e3, NSM},
644 +        {0x09e6, 0x09f1, L},
645 +        {0x09f2, 0x09f3, ET},
646 +        {0x09f4, 0x09fa, L},
647 +        {0x0a01, 0x0a02, NSM},
648 +        {0x0a03, 0x0a03, L},
649 +        {0x0a05, 0x0a0a, L},
650 +        {0x0a0f, 0x0a10, L},
651 +        {0x0a13, 0x0a28, L},
652 +        {0x0a2a, 0x0a30, L},
653 +        {0x0a32, 0x0a33, L},
654 +        {0x0a35, 0x0a36, L},
655 +        {0x0a38, 0x0a39, L},
656 +        {0x0a3c, 0x0a3c, NSM},
657 +        {0x0a3e, 0x0a40, L},
658 +        {0x0a41, 0x0a42, NSM},
659 +        {0x0a47, 0x0a48, NSM},
660 +        {0x0a4b, 0x0a4d, NSM},
661 +        {0x0a59, 0x0a5c, L},
662 +        {0x0a5e, 0x0a5e, L},
663 +        {0x0a66, 0x0a6f, L},
664 +        {0x0a70, 0x0a71, NSM},
665 +        {0x0a72, 0x0a74, L},
666 +        {0x0a81, 0x0a82, NSM},
667 +        {0x0a83, 0x0a83, L},
668 +        {0x0a85, 0x0a8d, L},
669 +        {0x0a8f, 0x0a91, L},
670 +        {0x0a93, 0x0aa8, L},
671 +        {0x0aaa, 0x0ab0, L},
672 +        {0x0ab2, 0x0ab3, L},
673 +        {0x0ab5, 0x0ab9, L},
674 +        {0x0abc, 0x0abc, NSM},
675 +        {0x0abd, 0x0ac0, L},
676 +        {0x0ac1, 0x0ac5, NSM},
677 +        {0x0ac7, 0x0ac8, NSM},
678 +        {0x0ac9, 0x0ac9, L},
679 +        {0x0acb, 0x0acc, L},
680 +        {0x0acd, 0x0acd, NSM},
681 +        {0x0ad0, 0x0ad0, L},
682 +        {0x0ae0, 0x0ae1, L},
683 +        {0x0ae2, 0x0ae3, NSM},
684 +        {0x0ae6, 0x0aef, L},
685 +        {0x0af1, 0x0af1, ET},
686 +        {0x0b01, 0x0b01, NSM},
687 +        {0x0b02, 0x0b03, L},
688 +        {0x0b05, 0x0b0c, L},
689 +        {0x0b0f, 0x0b10, L},
690 +        {0x0b13, 0x0b28, L},
691 +        {0x0b2a, 0x0b30, L},
692 +        {0x0b32, 0x0b33, L},
693 +        {0x0b35, 0x0b39, L},
694 +        {0x0b3c, 0x0b3c, NSM},
695 +        {0x0b3d, 0x0b3e, L},
696 +        {0x0b3f, 0x0b3f, NSM},
697 +        {0x0b40, 0x0b40, L},
698 +        {0x0b41, 0x0b43, NSM},
699 +        {0x0b47, 0x0b48, L},
700 +        {0x0b4b, 0x0b4c, L},
701 +        {0x0b4d, 0x0b4d, NSM},
702 +        {0x0b56, 0x0b56, NSM},
703 +        {0x0b57, 0x0b57, L},
704 +        {0x0b5c, 0x0b5d, L},
705 +        {0x0b5f, 0x0b61, L},
706 +        {0x0b66, 0x0b71, L},
707 +        {0x0b82, 0x0b82, NSM},
708 +        {0x0b83, 0x0b83, L},
709 +        {0x0b85, 0x0b8a, L},
710 +        {0x0b8e, 0x0b90, L},
711 +        {0x0b92, 0x0b95, L},
712 +        {0x0b99, 0x0b9a, L},
713 +        {0x0b9c, 0x0b9c, L},
714 +        {0x0b9e, 0x0b9f, L},
715 +        {0x0ba3, 0x0ba4, L},
716 +        {0x0ba8, 0x0baa, L},
717 +        {0x0bae, 0x0bb5, L},
718 +        {0x0bb7, 0x0bb9, L},
719 +        {0x0bbe, 0x0bbf, L},
720 +        {0x0bc0, 0x0bc0, NSM},
721 +        {0x0bc1, 0x0bc2, L},
722 +        {0x0bc6, 0x0bc8, L},
723 +        {0x0bca, 0x0bcc, L},
724 +        {0x0bcd, 0x0bcd, NSM},
725 +        {0x0bd7, 0x0bd7, L},
726 +        {0x0be7, 0x0bf2, L},
727 +        {0x0bf9, 0x0bf9, ET},
728 +        {0x0c01, 0x0c03, L},
729 +        {0x0c05, 0x0c0c, L},
730 +        {0x0c0e, 0x0c10, L},
731 +        {0x0c12, 0x0c28, L},
732 +        {0x0c2a, 0x0c33, L},
733 +        {0x0c35, 0x0c39, L},
734 +        {0x0c3e, 0x0c40, NSM},
735 +        {0x0c41, 0x0c44, L},
736 +        {0x0c46, 0x0c48, NSM},
737 +        {0x0c4a, 0x0c4d, NSM},
738 +        {0x0c55, 0x0c56, NSM},
739 +        {0x0c60, 0x0c61, L},
740 +        {0x0c66, 0x0c6f, L},
741 +        {0x0c82, 0x0c83, L},
742 +        {0x0c85, 0x0c8c, L},
743 +        {0x0c8e, 0x0c90, L},
744 +        {0x0c92, 0x0ca8, L},
745 +        {0x0caa, 0x0cb3, L},
746 +        {0x0cb5, 0x0cb9, L},
747 +        {0x0cbc, 0x0cbc, NSM},
748 +        {0x0cbd, 0x0cc4, L},
749 +        {0x0cc6, 0x0cc8, L},
750 +        {0x0cca, 0x0ccb, L},
751 +        {0x0ccc, 0x0ccd, NSM},
752 +        {0x0cd5, 0x0cd6, L},
753 +        {0x0cde, 0x0cde, L},
754 +        {0x0ce0, 0x0ce1, L},
755 +        {0x0ce6, 0x0cef, L},
756 +        {0x0d02, 0x0d03, L},
757 +        {0x0d05, 0x0d0c, L},
758 +        {0x0d0e, 0x0d10, L},
759 +        {0x0d12, 0x0d28, L},
760 +        {0x0d2a, 0x0d39, L},
761 +        {0x0d3e, 0x0d40, L},
762 +        {0x0d41, 0x0d43, NSM},
763 +        {0x0d46, 0x0d48, L},
764 +        {0x0d4a, 0x0d4c, L},
765 +        {0x0d4d, 0x0d4d, NSM},
766 +        {0x0d57, 0x0d57, L},
767 +        {0x0d60, 0x0d61, L},
768 +        {0x0d66, 0x0d6f, L},
769 +        {0x0d82, 0x0d83, L},
770 +        {0x0d85, 0x0d96, L},
771 +        {0x0d9a, 0x0db1, L},
772 +        {0x0db3, 0x0dbb, L},
773 +        {0x0dbd, 0x0dbd, L},
774 +        {0x0dc0, 0x0dc6, L},
775 +        {0x0dca, 0x0dca, NSM},
776 +        {0x0dcf, 0x0dd1, L},
777 +        {0x0dd2, 0x0dd4, NSM},
778 +        {0x0dd6, 0x0dd6, NSM},
779 +        {0x0dd8, 0x0ddf, L},
780 +        {0x0df2, 0x0df4, L},
781 +        {0x0e01, 0x0e30, L},
782 +        {0x0e31, 0x0e31, NSM},
783 +        {0x0e32, 0x0e33, L},
784 +        {0x0e34, 0x0e3a, NSM},
785 +        {0x0e3f, 0x0e3f, ET},
786 +        {0x0e40, 0x0e46, L},
787 +        {0x0e47, 0x0e4e, NSM},
788 +        {0x0e4f, 0x0e5b, L},
789 +        {0x0e81, 0x0e82, L},
790 +        {0x0e84, 0x0e84, L},
791 +        {0x0e87, 0x0e88, L},
792 +        {0x0e8a, 0x0e8a, L},
793 +        {0x0e8d, 0x0e8d, L},
794 +        {0x0e94, 0x0e97, L},
795 +        {0x0e99, 0x0e9f, L},
796 +        {0x0ea1, 0x0ea3, L},
797 +        {0x0ea5, 0x0ea5, L},
798 +        {0x0ea7, 0x0ea7, L},
799 +        {0x0eaa, 0x0eab, L},
800 +        {0x0ead, 0x0eb0, L},
801 +        {0x0eb1, 0x0eb1, NSM},
802 +        {0x0eb2, 0x0eb3, L},
803 +        {0x0eb4, 0x0eb9, NSM},
804 +        {0x0ebb, 0x0ebc, NSM},
805 +        {0x0ebd, 0x0ebd, L},
806 +        {0x0ec0, 0x0ec4, L},
807 +        {0x0ec6, 0x0ec6, L},
808 +        {0x0ec8, 0x0ecd, NSM},
809 +        {0x0ed0, 0x0ed9, L},
810 +        {0x0edc, 0x0edd, L},
811 +        {0x0f00, 0x0f17, L},
812 +        {0x0f18, 0x0f19, NSM},
813 +        {0x0f1a, 0x0f34, L},
814 +        {0x0f35, 0x0f35, NSM},
815 +        {0x0f36, 0x0f36, L},
816 +        {0x0f37, 0x0f37, NSM},
817 +        {0x0f38, 0x0f38, L},
818 +        {0x0f39, 0x0f39, NSM},
819 +        {0x0f3e, 0x0f47, L},
820 +        {0x0f49, 0x0f6a, L},
821 +        {0x0f71, 0x0f7e, NSM},
822 +        {0x0f7f, 0x0f7f, L},
823 +        {0x0f80, 0x0f84, NSM},
824 +        {0x0f85, 0x0f85, L},
825 +        {0x0f86, 0x0f87, NSM},
826 +        {0x0f88, 0x0f8b, L},
827 +        {0x0f90, 0x0f97, NSM},
828 +        {0x0f99, 0x0fbc, NSM},
829 +        {0x0fbe, 0x0fc5, L},
830 +        {0x0fc6, 0x0fc6, NSM},
831 +        {0x0fc7, 0x0fcc, L},
832 +        {0x0fcf, 0x0fcf, L},
833 +        {0x1000, 0x1021, L},
834 +        {0x1023, 0x1027, L},
835 +        {0x1029, 0x102a, L},
836 +        {0x102c, 0x102c, L},
837 +        {0x102d, 0x1030, NSM},
838 +        {0x1031, 0x1031, L},
839 +        {0x1032, 0x1032, NSM},
840 +        {0x1036, 0x1037, NSM},
841 +        {0x1038, 0x1038, L},
842 +        {0x1039, 0x1039, NSM},
843 +        {0x1040, 0x1057, L},
844 +        {0x1058, 0x1059, NSM},
845 +        {0x10a0, 0x10c5, L},
846 +        {0x10d0, 0x10f8, L},
847 +        {0x10fb, 0x10fb, L},
848 +        {0x1100, 0x1159, L},
849 +        {0x115f, 0x11a2, L},
850 +        {0x11a8, 0x11f9, L},
851 +        {0x1200, 0x1206, L},
852 +        {0x1208, 0x1246, L},
853 +        {0x1248, 0x1248, L},
854 +        {0x124a, 0x124d, L},
855 +        {0x1250, 0x1256, L},
856 +        {0x1258, 0x1258, L},
857 +        {0x125a, 0x125d, L},
858 +        {0x1260, 0x1286, L},
859 +        {0x1288, 0x1288, L},
860 +        {0x128a, 0x128d, L},
861 +        {0x1290, 0x12ae, L},
862 +        {0x12b0, 0x12b0, L},
863 +        {0x12b2, 0x12b5, L},
864 +        {0x12b8, 0x12be, L},
865 +        {0x12c0, 0x12c0, L},
866 +        {0x12c2, 0x12c5, L},
867 +        {0x12c8, 0x12ce, L},
868 +        {0x12d0, 0x12d6, L},
869 +        {0x12d8, 0x12ee, L},
870 +        {0x12f0, 0x130e, L},
871 +        {0x1310, 0x1310, L},
872 +        {0x1312, 0x1315, L},
873 +        {0x1318, 0x131e, L},
874 +        {0x1320, 0x1346, L},
875 +        {0x1348, 0x135a, L},
876 +        {0x1361, 0x137c, L},
877 +        {0x13a0, 0x13f4, L},
878 +        {0x1401, 0x1676, L},
879 +        {0x1680, 0x1680, WS},
880 +        {0x1681, 0x169a, L},
881 +        {0x16a0, 0x16f0, L},
882 +        {0x1700, 0x170c, L},
883 +        {0x170e, 0x1711, L},
884 +        {0x1712, 0x1714, NSM},
885 +        {0x1720, 0x1731, L},
886 +        {0x1732, 0x1734, NSM},
887 +        {0x1735, 0x1736, L},
888 +        {0x1740, 0x1751, L},
889 +        {0x1752, 0x1753, NSM},
890 +        {0x1760, 0x176c, L},
891 +        {0x176e, 0x1770, L},
892 +        {0x1772, 0x1773, NSM},
893 +        {0x1780, 0x17b6, L},
894 +        {0x17b7, 0x17bd, NSM},
895 +        {0x17be, 0x17c5, L},
896 +        {0x17c6, 0x17c6, NSM},
897 +        {0x17c7, 0x17c8, L},
898 +        {0x17c9, 0x17d3, NSM},
899 +        {0x17d4, 0x17da, L},
900 +        {0x17db, 0x17db, ET},
901 +        {0x17dc, 0x17dc, L},
902 +        {0x17dd, 0x17dd, NSM},
903 +        {0x17e0, 0x17e9, L},
904 +        {0x180b, 0x180d, NSM},
905 +        {0x180e, 0x180e, WS},
906 +        {0x1810, 0x1819, L},
907 +        {0x1820, 0x1877, L},
908 +        {0x1880, 0x18a8, L},
909 +        {0x18a9, 0x18a9, NSM},
910 +        {0x1900, 0x191c, L},
911 +        {0x1920, 0x1922, NSM},
912 +        {0x1923, 0x1926, L},
913 +        {0x1927, 0x192b, NSM},
914 +        {0x1930, 0x1931, L},
915 +        {0x1932, 0x1932, NSM},
916 +        {0x1933, 0x1938, L},
917 +        {0x1939, 0x193b, NSM},
918 +        {0x1946, 0x196d, L},
919 +        {0x1970, 0x1974, L},
920 +        {0x1d00, 0x1d6b, L},
921 +        {0x1e00, 0x1e9b, L},
922 +        {0x1ea0, 0x1ef9, L},
923 +        {0x1f00, 0x1f15, L},
924 +        {0x1f18, 0x1f1d, L},
925 +        {0x1f20, 0x1f45, L},
926 +        {0x1f48, 0x1f4d, L},
927 +        {0x1f50, 0x1f57, L},
928 +        {0x1f59, 0x1f59, L},
929 +        {0x1f5b, 0x1f5b, L},
930 +        {0x1f5d, 0x1f5d, L},
931 +        {0x1f5f, 0x1f7d, L},
932 +        {0x1f80, 0x1fb4, L},
933 +        {0x1fb6, 0x1fbc, L},
934 +        {0x1fbe, 0x1fbe, L},
935 +        {0x1fc2, 0x1fc4, L},
936 +        {0x1fc6, 0x1fcc, L},
937 +        {0x1fd0, 0x1fd3, L},
938 +        {0x1fd6, 0x1fdb, L},
939 +        {0x1fe0, 0x1fec, L},
940 +        {0x1ff2, 0x1ff4, L},
941 +        {0x1ff6, 0x1ffc, L},
942 +        {0x2000, 0x200a, WS},
943 +        {0x200b, 0x200d, BN},
944 +        {0x200e, 0x200e, L},
945 +        {0x200f, 0x200f, R},
946 +        {0x2028, 0x2028, WS},
947 +        {0x2029, 0x2029, B},
948 +        {0x202a, 0x202a, LRE},
949 +        {0x202b, 0x202b, RLE},
950 +        {0x202c, 0x202c, PDF},
951 +        {0x202d, 0x202d, LRO},
952 +        {0x202e, 0x202e, RLO},
953 +        {0x202f, 0x202f, WS},
954 +        {0x2030, 0x2034, ET},
955 +        {0x2044, 0x2044, CS},
956 +        {0x205f, 0x205f, WS},
957 +        {0x2060, 0x2063, BN},
958 +        {0x206a, 0x206f, BN},
959 +        {0x2070, 0x2070, EN},
960 +        {0x2071, 0x2071, L},
961 +        {0x2074, 0x2079, EN},
962 +        {0x207a, 0x207b, ET},
963 +        {0x207f, 0x207f, L},
964 +        {0x2080, 0x2089, EN},
965 +        {0x208a, 0x208b, ET},
966 +        {0x20a0, 0x20b1, ET},
967 +        {0x20d0, 0x20ea, NSM},
968 +        {0x2102, 0x2102, L},
969 +        {0x2107, 0x2107, L},
970 +        {0x210a, 0x2113, L},
971 +        {0x2115, 0x2115, L},
972 +        {0x2119, 0x211d, L},
973 +        {0x2124, 0x2124, L},
974 +        {0x2126, 0x2126, L},
975 +        {0x2128, 0x2128, L},
976 +        {0x212a, 0x212d, L},
977 +        {0x212e, 0x212e, ET},
978 +        {0x212f, 0x2131, L},
979 +        {0x2133, 0x2139, L},
980 +        {0x213d, 0x213f, L},
981 +        {0x2145, 0x2149, L},
982 +        {0x2160, 0x2183, L},
983 +        {0x2212, 0x2213, ET},
984 +        {0x2336, 0x237a, L},
985 +        {0x2395, 0x2395, L},
986 +        {0x2488, 0x249b, EN},
987 +        {0x249c, 0x24e9, L},
988 +        {0x2800, 0x28ff, L},
989 +        {0x3000, 0x3000, WS},
990 +        {0x3005, 0x3007, L},
991 +        {0x3021, 0x3029, L},
992 +        {0x302a, 0x302f, NSM},
993 +        {0x3031, 0x3035, L},
994 +        {0x3038, 0x303c, L},
995 +        {0x3041, 0x3096, L},
996 +        {0x3099, 0x309a, NSM},
997 +        {0x309d, 0x309f, L},
998 +        {0x30a1, 0x30fa, L},
999 +        {0x30fc, 0x30ff, L},
1000 +        {0x3105, 0x312c, L},
1001 +        {0x3131, 0x318e, L},
1002 +        {0x3190, 0x31b7, L},
1003 +        {0x31f0, 0x321c, L},
1004 +        {0x3220, 0x3243, L},
1005 +        {0x3260, 0x327b, L},
1006 +        {0x327f, 0x32b0, L},
1007 +        {0x32c0, 0x32cb, L},
1008 +        {0x32d0, 0x32fe, L},
1009 +        {0x3300, 0x3376, L},
1010 +        {0x337b, 0x33dd, L},
1011 +        {0x33e0, 0x33fe, L},
1012 +        {0x3400, 0x4db5, L},
1013 +        {0x4e00, 0x9fa5, L},
1014 +        {0xa000, 0xa48c, L},
1015 +        {0xac00, 0xd7a3, L},
1016 +        {0xd800, 0xfa2d, L},
1017 +        {0xfa30, 0xfa6a, L},
1018 +        {0xfb00, 0xfb06, L},
1019 +        {0xfb13, 0xfb17, L},
1020 +        {0xfb1d, 0xfb1d, R},
1021 +        {0xfb1e, 0xfb1e, NSM},
1022 +        {0xfb1f, 0xfb28, R},
1023 +        {0xfb29, 0xfb29, ET},
1024 +        {0xfb2a, 0xfb36, R},
1025 +        {0xfb38, 0xfb3c, R},
1026 +        {0xfb3e, 0xfb3e, R},
1027 +        {0xfb40, 0xfb41, R},
1028 +        {0xfb43, 0xfb44, R},
1029 +        {0xfb46, 0xfb4f, R},
1030 +        {0xfb50, 0xfbb1, AL},
1031 +        {0xfbd3, 0xfd3d, AL},
1032 +        {0xfd50, 0xfd8f, AL},
1033 +        {0xfd92, 0xfdc7, AL},
1034 +        {0xfdf0, 0xfdfc, AL},
1035 +        {0xfe00, 0xfe0f, NSM},
1036 +        {0xfe20, 0xfe23, NSM},
1037 +        {0xfe50, 0xfe50, CS},
1038 +        {0xfe52, 0xfe52, CS},
1039 +        {0xfe55, 0xfe55, CS},
1040 +        {0xfe5f, 0xfe5f, ET},
1041 +        {0xfe62, 0xfe63, ET},
1042 +        {0xfe69, 0xfe6a, ET},
1043 +        {0xfe70, 0xfe74, AL},
1044 +        {0xfe76, 0xfefc, AL},
1045 +        {0xfeff, 0xfeff, BN},
1046 +        {0xff03, 0xff05, ET},
1047 +        {0xff0b, 0xff0b, ET},
1048 +        {0xff0c, 0xff0c, CS},
1049 +        {0xff0d, 0xff0d, ET},
1050 +        {0xff0e, 0xff0e, CS},
1051 +        {0xff0f, 0xff0f, ES},
1052 +        {0xff10, 0xff19, EN},
1053 +        {0xff1a, 0xff1a, CS},
1054 +        {0xff21, 0xff3a, L},
1055 +        {0xff41, 0xff5a, L},
1056 +        {0xff66, 0xffbe, L},
1057 +        {0xffc2, 0xffc7, L},
1058 +        {0xffca, 0xffcf, L},
1059 +        {0xffd2, 0xffd7, L},
1060 +        {0xffda, 0xffdc, L},
1061 +        {0xffe0, 0xffe1, ET},
1062 +        {0xffe5, 0xffe6, ET},
1063 +    };
1064 +
1065 +    int i, j, k;
1066 +
1067 +    i = -1;
1068 +    j = lenof(lookup);
1069 +
1070 +    while (j - i > 1) {
1071 +       k = (i + j) / 2;
1072 +       if (ch < lookup[k].first)
1073 +           j = k;
1074 +       else if (ch > lookup[k].last)
1075 +           i = k;
1076 +       else
1077 +           return (unsigned char)lookup[k].type;
1078 +    }
1079 +
1080 +    /*
1081 +     * If we reach here, the character was not in any of the
1082 +     * intervals listed in the lookup table. This means we return
1083 +     * ON (`Other Neutrals'). This is the appropriate code for any
1084 +     * character genuinely not listed in the Unicode table, and
1085 +     * also the table above has deliberately left out any
1086 +     * characters _explicitly_ listed as ON (to save space!).
1087 +     */
1088 +    return ON;
1089 +}
1090 +
1091 +unsigned char getPreviousLevel(unsigned char* types, unsigned char* level, int from)
1092 +{
1093 +   int skip = 0;
1094 +
1095 +   while(--from > 0)
1096 +   {
1097 +
1098 +          switch(types[from])
1099 +          {
1100 +          case LRE:
1101 +          case LRO:
1102 +          case RLE:
1103 +          case RLO:
1104 +                  if(skip>0)
1105 +                  {
1106 +                          skip--;
1107 +                          break;
1108 +                  }else
1109 +                          return level[from-1];
1110 +          case PDF:
1111 +                  skip++;
1112 +                  break;
1113 +          }
1114 +   }
1115 +   return 0;           /* Compiler Nag-Stopper */
1116 +}
1117 +
1118 +unsigned char getPreviousOverride(unsigned char* types, unsigned char* level, int from)
1119 +{
1120 +   int skip = 1;
1121 +
1122 +   from--;
1123 +   while(from-- > 0)
1124 +   {
1125 +          switch(types[from])
1126 +          {
1127 +          case LRE:
1128 +          case RLE:
1129 +                  skip++;
1130 +                  break;
1131 +
1132 +          case LRO:
1133 +                  if(skip>0)
1134 +                  {
1135 +                          skip--;
1136 +                          break;
1137 +                  }else
1138 +                          return L;
1139 +          case RLO:
1140 +                  if(skip>0)
1141 +                  {
1142 +                          skip--;
1143 +                          break;
1144 +                  }else
1145 +                          return R;
1146 +          case PDF:
1147 +                  skip++;
1148 +                  break;
1149 +          }
1150 +   }
1151 +   return ON;
1152 +}
1153 +
1154 +
1155 +
1156 +/* The Main shaping function, and the only one to be used
1157 + * by the outside world.
1158 + *
1159 + * line: buffer to apply shaping to. this must be passed by doBidi() first
1160 + * to: output buffer for the shaped data
1161 + * from: start bidi at this index
1162 + * count: number of characters in line
1163 + */
1164 +int doShape(BLOCKTYPE line, CHARTYPE* to, int from, int count)
1165 +{
1166 +       int i, j, ligFlag;
1167 +       unsigned char prevTemp, nextTemp;
1168 +       CHARTYPE tempChar;
1169 +
1170 +       ligFlag = 0;
1171 +       prevTemp = SU;
1172 +       nextTemp = SU;
1173 +       for(i=from; i<count; i++)
1174 +       {
1175 +               /* Get Previous and next Characters type */
1176 +               j=i;
1177 +               while(--j >= 0)
1178 +               {
1179 +                 //assert(j<count);
1180 +                 //assert(i<count);
1181 +                 if(GetType(GETCHAR(line, j)) != NSM)
1182 +                       {
1183 +                               prevTemp = STYPE(GETCHAR(line, j));
1184 +                               break;
1185 +                       }
1186 +               }
1187 +               j=i;
1188 +               while(++j < count)
1189 +               {
1190 +                 //assert(j<count);
1191 +                 //assert(i<count);
1192 +                       if(GetType(GETCHAR(line, j)) != NSM)
1193 +                       {
1194 +                               nextTemp = STYPE(GETCHAR(line, j));
1195 +                               break;
1196 +                               //HAQ
1197 +                       } else if(j == count-1) {
1198 +                               nextTemp = SU;
1199 +                               break;
1200 +                       }
1201 +               }
1202 +
1203 +               switch(STYPE(GETCHAR(line, i)))
1204 +               {
1205 +               case SC:
1206 +               case SU:
1207 +                       to[i] = GETCHAR(line, i);
1208 +                       break;
1209 +
1210 +               case SR:
1211 +                       if(prevTemp == SD || prevTemp == SC)
1212 +                               to[i] = SFINAL(SISOLATED(GETCHAR(line, i)));
1213 +                       else
1214 +                               to[i] = SISOLATED(GETCHAR(line, i));
1215 +                       break;
1216 +
1217 +               case SD:
1218 +      /* Make Ligatures */
1219 +                       if(GETCHAR(line, i) == 0x644)
1220 +                       {
1221 +                               j=i;
1222 +                               while(j++<count)
1223 +                               {
1224 +                                       if(GetType(GETCHAR(line, j)) != NSM)
1225 +                                       {
1226 +                                               tempChar = GETCHAR(line, j);
1227 +                                               break;
1228 +                                       }
1229 +                               }
1230 +                               switch(tempChar)
1231 +                               {
1232 +                               case 0x622:
1233 +                                       ligFlag = 1;
1234 +                                       if(prevTemp == SD || prevTemp == SC)
1235 +                                               to[i] = 0xFEF6;
1236 +                                       else
1237 +                                               to[i] = 0xFEF5;
1238 +                                       break;
1239 +                               case 0x623:
1240 +                                       ligFlag = 1;
1241 +                                       if(prevTemp == SD || prevTemp == SC)
1242 +                                               to[i] = 0xFEF8;
1243 +                                       else
1244 +                                               to[i] = 0xFEF7;
1245 +                                       break;
1246 +                               case 0x625:
1247 +                                       ligFlag = 1;
1248 +                                       if(prevTemp == SD || prevTemp == SC)
1249 +                                               to[i] = 0xFEFA;
1250 +                                       else
1251 +                                               to[i] = 0xFEF9;
1252 +                                       break;
1253 +                               case 0x627:
1254 +                                       ligFlag = 1;
1255 +                                       if(prevTemp == SD || prevTemp == SC)
1256 +                                               to[i] = 0xFEFC;
1257 +                                       else
1258 +                                               to[i] = 0xFEFB;
1259 +                                       break;
1260 +                               }
1261 +                               if(ligFlag)
1262 +                               {
1263 +                                       to[j] = 0x20;
1264 +                                       i = j;
1265 +                                       ligFlag = 0;
1266 +                                       break;
1267 +                               }
1268 +                               }
1269 +                 //assert(j<count);
1270 +                 //assert(i<count);
1271 +                       if((prevTemp == SD) || (prevTemp == SC))
1272 +                       {
1273 +                               if(nextTemp == SR || nextTemp == SD || nextTemp == SC)
1274 +                                       to[i] = SMEDIAL(SISOLATED(GETCHAR(line, i)));
1275 +                               else 
1276 +                                       to[i] = SFINAL(SISOLATED(GETCHAR(line, i)));
1277 +                               break;
1278 +                       }else
1279 +                       {
1280 +                               if(nextTemp == SR || nextTemp == SD || nextTemp == SC)
1281 +                                       to[i] = SINITIAL(SISOLATED(GETCHAR(line, i)));
1282 +                               else
1283 +                                       to[i] = SISOLATED(GETCHAR(line, i));
1284 +                               break;
1285 +                       }
1286 +
1287 +               }
1288 +               nextTemp = SU;
1289 +       }
1290 +       return 1;
1291 +}
1292 +
1293 +/* Rule (X1), (X2), (X3), (X4), (X5), (X6), (X7), (X8), (X9) */
1294 +void doTypes(BLOCKTYPE line, unsigned char paragraphLevel, unsigned char* types,
1295 +                        unsigned char* levels, int count, int fX)
1296 +{
1297 +
1298 +       unsigned char tempType;
1299 +       unsigned char currentEmbedding = paragraphLevel;
1300 +       unsigned char currentOverride = ON;
1301 +       int i;
1302 +
1303 +   if(fX)
1304 +   {
1305 +   for( i=0; i<count; i++)
1306 +   {
1307 +      tempType = GetType(GETCHAR(line, i));
1308 +      switch(tempType)
1309 +      {
1310 +        case RLE:
1311 +           currentEmbedding = levels[i] = leastGreaterOdd(currentEmbedding);
1312 +           currentOverride = ON;
1313 +               types[i] = BN;
1314 +           break;
1315 +
1316 +        case LRE:
1317 +           currentEmbedding = levels[i] = leastGreaterEven(currentEmbedding);
1318 +           currentOverride = ON;
1319 +               types[i] = BN;
1320 +           break;
1321 +
1322 +        case RLO:
1323 +           currentEmbedding = levels[i] = leastGreaterOdd(currentEmbedding);
1324 +               currentOverride = R;
1325 +               types[i] = BN;
1326 +           break;
1327 +
1328 +        case LRO:
1329 +           currentEmbedding = levels[i] = leastGreaterEven(currentEmbedding);
1330 +               currentOverride = L;
1331 +               types[i] = BN;
1332 +           break;
1333 +
1334 +        case PDF:
1335 +               levels[i] = currentEmbedding;
1336 +               currentEmbedding = getPreviousLevel(types, levels, i);
1337 +               currentOverride = getPreviousOverride(types, levels, i);
1338 +               types[i] = BN;
1339 +           break;
1340 +
1341 +           /* Whitespace is treated as neutral for now */
1342 +        case WS:
1343 +        case B:
1344 +        case S:
1345 +           levels[i] = currentEmbedding;
1346 +           tempType = ON;
1347 +           if(currentOverride != ON)
1348 +              tempType = currentOverride;
1349 +           break;
1350 +
1351 +        default:
1352 +           levels[i] = currentEmbedding;
1353 +           if(currentOverride != ON)
1354 +              tempType = currentOverride;
1355 +           break;
1356 +
1357 +      }
1358 +      types[i] = tempType;
1359 +   }
1360 +   }else
1361 +   {
1362 +      for( i=0; i<count; i++)
1363 +         {
1364 +                 tempType = GetType(GETCHAR(line, i));
1365 +                 switch(tempType)
1366 +                 {
1367 +        case WS:
1368 +        case B:
1369 +        case S:
1370 +           levels[i] = currentEmbedding;
1371 +           tempType = ON;
1372 +           if(currentOverride != ON)
1373 +              tempType = currentOverride;
1374 +           break;
1375 +
1376 +        default:
1377 +           levels[i] = currentEmbedding;
1378 +           if(currentOverride != ON)
1379 +              tempType = currentOverride;
1380 +           break;
1381 +
1382 +                 }
1383 +               types[i] = tempType;
1384 +         }
1385 +
1386 +   }
1387 +
1388 +}
1389 +
1390 +/* Rule (W3) */
1391 +void doALtoR(unsigned char* types, int count)
1392 +{
1393 +       int i=0;
1394 +       for(; i<count; i++)
1395 +       {
1396 +               if(types[i] == AL)
1397 +                       types[i] = R;
1398 +       }
1399 +
1400 +}
1401 +/*
1402 + * The Main Bidi Function, and the only function that should
1403 + * be used by the outside world.
1404 + *
1405 + * line: a buffer of size count containing text to apply
1406 + * the Bidirectional algorithm to.
1407 + */
1408 +int doBidi(BLOCKTYPE line, int count, int applyShape, int reorderCombining, int removeMarks)
1409 +{
1410 +   unsigned char* types;
1411 +   unsigned char* levels;
1412 +   unsigned char paragraphLevel;
1413 +   unsigned char tempType, tempTypeSec;
1414 +   int i, j, imax, fX, fAL, fET, fNSM;
1415 +   CHARTYPE* shapeTo;
1416 +
1417 +
1418 +       fX = fAL = fET = fNSM = 0;
1419 +       for(i=0; i<count; i++)
1420 +       {
1421 +               switch(GetType(line[i]))
1422 +               {
1423 +               case AL:
1424 +               case R:
1425 +                       fAL = 1;
1426 +                       break;
1427 +               case LRE:
1428 +               case LRO:
1429 +               case RLE:
1430 +               case RLO:
1431 +               case PDF:
1432 +               case BN:
1433 +                       fX = 1;
1434 +                       break;
1435 +               case ET:
1436 +                       fET = 1;
1437 +                       break;
1438 +               case NSM:
1439 +                       fNSM = 1;
1440 +                       break;
1441 +               }
1442 +       }
1443 +
1444 +       if(!fAL && !fX)
1445 +               return 0;
1446 +
1447 +   /* Initialize types, levels */
1448 +   types = (unsigned char*)malloc(sizeof(unsigned char) * count);
1449 +   levels = (unsigned char*)malloc(sizeof(unsigned char) * count);
1450 +   if(applyShape)
1451 +          shapeTo = (CHARTYPE*)malloc(sizeof(CHARTYPE) * count);
1452 +
1453 +   /* Rule (P1)  NOT IMPLEMENTED
1454 +    * P1. Split the text into separate paragraphs. A paragraph separator is
1455 +    * kept with the previous paragraph. Within each paragraph, apply all the
1456 +    * other rules of this algorithm.
1457 +    */
1458 +
1459 +   /* Rule (P2), (P3)
1460 +    * P2. In each paragraph, find the first character of type L, AL, or R.
1461 +    * P3. If a character is found in P2 and it is of type AL or R, then set
1462 +    * the paragraph embedding level to one; otherwise, set it to zero.
1463 +    */
1464 +   paragraphLevel = GetParagraphLevel(line, count);
1465 +
1466 +   /* Rule (X1), (X2), (X3), (X4), (X5), (X6), (X7), (X8), (X9)
1467 +    * X1. Begin by setting the current embedding level to the paragraph
1468 +       *     embedding level. Set the directional override status to neutral.
1469 +    * X2. With each RLE, compute the least greater odd embedding level.
1470 +    * X3. With each LRE, compute the least greater even embedding level.
1471 +    * X4. With each RLO, compute the least greater odd embedding level.
1472 +    * X5. With each LRO, compute the least greater even embedding level.
1473 +    * X6. For all types besides RLE, LRE, RLO, LRO, and PDF:
1474 +    *          a. Set the level of the current character to the current
1475 +    *              embedding level.
1476 +    *          b.  Whenever the directional override status is not neutral,
1477 +    *               reset the current character type to the directional
1478 +    *               override status.
1479 +    * X7. With each PDF, determine the matching embedding or override code.
1480 +    * If there was a valid matching code, restore (pop) the last
1481 +    * remembered (pushed) embedding level and directional override.
1482 +    * X8. All explicit directional embeddings and overrides are completely
1483 +    * terminated at the end of each paragraph. Paragraph separators are not
1484 +    * included in the embedding. (Useless here) NOT IMPLEMENTED
1485 +    * X9. Remove all RLE, LRE, RLO, LRO, PDF, and BN codes.
1486 +    * Here, they're converted to BN.
1487 +    */
1488 +
1489 +       doTypes(line, paragraphLevel, types, levels, count, fX);
1490 +
1491 +
1492 +   /* Rule (W1)
1493 +    * W1. Examine each non-spacing mark (NSM) in the level run, and change
1494 +    * the type of the NSM to the type of the previous character. If the NSM
1495 +    * is at the start of the level run, it will get the type of sor.
1496 +    */
1497 +       
1498 +       /*
1499 +       * Clear BNs first
1500 +       */
1501 +       if(fX)
1502 +       {
1503 +               for(i=0; i<count; i++)
1504 +               {
1505 +                       if(types[i] == BN)
1506 +                       {
1507 +                               j=i;
1508 +                               while(types[--j] == ON);
1509 +                               levels[i] = levels[j];
1510 +                               
1511 +                               j=i;
1512 +                               while(types[++j] == BN);
1513 +                               
1514 +                               if(levels[j] > levels[i])
1515 +                                       levels[i] = levels[j];
1516 +                               
1517 +                               
1518 +                               
1519 +                               if((levels[i] % 2) == 0)
1520 +                               {
1521 +                                       types[i] = L;
1522 +                               }
1523 +                               else
1524 +                               {
1525 +                                       types[i] = R;
1526 +                               }
1527 +                               
1528 +                       }
1529 +               }
1530 +       }
1531 +
1532 +       
1533 +       if(fNSM)
1534 +       {
1535 +               if(types[0] == NSM)
1536 +                       types[0] = paragraphLevel;
1537 +               
1538 +               for(i=1; i<count; i++)
1539 +               {
1540 +                       if(types[i] == NSM)
1541 +                               types[i] = types[i-1];
1542 +                               /* Is this a safe assumption? 
1543 +                               * I assumed the previous, IS a character.
1544 +                       */
1545 +               }
1546 +       }
1547 +       
1548 +   /* BN TYPES !!!! */
1549 +       
1550 +       if(fX)
1551 +       {
1552 +               for(i=0; i<count; i++)
1553 +               {
1554 +                       if(types[i] == BN)
1555 +                       {
1556 +                               j=i;
1557 +                               while(--j>=0 && types[j] == ON);
1558 +                               tempType = types[j];
1559 +                               j=i;
1560 +                               while(++j<count && types[j] == BN || types[j] == ON);
1561 +                               if(tempType != types[j])
1562 +                                       types[i] = tempType;
1563 +                               
1564 +                       }
1565 +               }
1566 +       }
1567 +
1568 +
1569 +   /* Rule (W2)
1570 +    * W2. Search backwards from each instance of a European number until the
1571 +    * first strong type (R, L, AL, or sor) is found.  If an AL is found,
1572 +    * change the type of the European number to Arabic number.
1573 +    */
1574 +       for(i=0; i<count; i++)
1575 +       {
1576 +               if(types[i] == EN)
1577 +               {
1578 +                       j=i;
1579 +                       while(--j >= 0)
1580 +                       {
1581 +                               if(types[j] == AL)
1582 +                               {
1583 +                                       types[i] = AN;
1584 +                                       break;
1585 +                               }
1586 +                               else if(types[j] == R || types[j] == L)
1587 +                               {
1588 +                                       break;
1589 +                               }
1590 +                       }
1591 +               }
1592 +       }
1593 +
1594 +   /* Rule (W3)
1595 +    * W3. Change all ALs to R.
1596 +    * 
1597 +    * Optimization: on Rule Xn, we might set a flag on AL type
1598 +    * to prevent this loop in L R lines only...
1599 +    */
1600 +       doALtoR(types, count);
1601 +
1602 +   /* Rule (W4)
1603 +    * W4. A single European separator between two European numbers changes
1604 +    * to a European number. A single common separator between two numbers
1605 +    * of the same type changes to that type.
1606 +    */
1607 +       for( i=0; i<(count-1); i++)
1608 +       {
1609 +               if(types[i] == ES)
1610 +               {
1611 +                       if(types[i-1] == EN && types[i+1] == EN)
1612 +                               types[i] = EN;
1613 +               }else if(types[i] == CS)
1614 +               {
1615 +                       if(types[i-1] == EN && types[i+1] == EN)
1616 +                               types[i] = EN;
1617 +                       else if(types[i-1] == AN && types[i+1] == AN)
1618 +                               types[i] = AN;
1619 +               }
1620 +       }
1621 +
1622 +   /* Rule (W5)
1623 +    * W5. A sequence of European terminators adjacent to European numbers
1624 +    * changes to all European numbers.
1625 +    *
1626 +    * Optimization: lots here... else ifs need rearrangement
1627 +    */
1628 +       if(fET)
1629 +       {
1630 +               for(i=0; i<count; i++)
1631 +               {
1632 +                       if(types[i] == ET)
1633 +                       {
1634 +                               if(types[i-1] == EN)
1635 +                               {
1636 +                                       types[i] = EN;
1637 +                                       continue;
1638 +                               }else if(types[i+1] == EN)
1639 +                               {
1640 +                                       types[i] = EN;
1641 +                                       continue;
1642 +                               }else if(types[i+1] == ET)
1643 +                               {
1644 +                                       j=i;
1645 +                                       while(j <count && types[j] == ET)
1646 +                                       {
1647 +                                               j++;
1648 +                                       }
1649 +                                       if(types[j] == EN)
1650 +                                               types[i] = EN;
1651 +                               }
1652 +                       }
1653 +               }
1654 +       }
1655 +
1656 +   /* Rule (W6)
1657 +    * W6. Otherwise, separators and terminators change to Other Neutral:
1658 +    */
1659 +       for(i=0; i<count; i++)
1660 +       {
1661 +               switch(types[i])
1662 +               {
1663 +               case ES:
1664 +               case ET:
1665 +               case CS:
1666 +                       types[i] = ON;
1667 +                       break;
1668 +               }
1669 +       }
1670 +
1671 +   /* Rule (W7)
1672 +    * W7. Search backwards from each instance of a European number until
1673 +    * the first strong type (R, L, or sor) is found. If an L is found,
1674 +    * then change the type of the European number to L.
1675 +    */
1676 +       
1677 +       for(i=0; i<count; i++)
1678 +       {
1679 +               if(types[i] == EN)
1680 +               {
1681 +                       j=i;
1682 +                       while(--j >= 0)
1683 +                       {
1684 +                               if(types[j] == L)
1685 +                               {
1686 +                                       types[i] = L;
1687 +                                       break;
1688 +                               }
1689 +                               else if(types[j] == R || types[j] == AL)
1690 +                               {
1691 +                                       break;
1692 +                               }
1693 +                               
1694 +                       }
1695 +               }
1696 +       }
1697 +       
1698 +       
1699 +   /* Rule (N1)
1700 +    * N1. A sequence of neutrals takes the direction of the surrounding
1701 +    * strong text if the text on both sides has the same direction. European
1702 +    * and Arabic numbers are treated as though they were R.
1703 +    */
1704 +       tempType = paragraphLevel;
1705 +       for(i=0; i<count; i++)
1706 +       {
1707 +               if(types[i] == ON)
1708 +               {
1709 +                       if(types[i-1] == R || types[i-1] == EN || types[i-1] == AN)
1710 +                               tempType = R;
1711 +                       else
1712 +                               tempType = L;
1713 +                       j=i;
1714 +                       
1715 +                       while(j < count)
1716 +                       {
1717 +                               tempTypeSec = types[j];
1718 +                               if(tempTypeSec == ON || tempTypeSec == BN)
1719 +                                       j++;
1720 +                               else
1721 +                                       break;
1722 +                       }
1723 +                       
1724 +                       if(((types[j] == L || types[j] == LRE) && (tempType == L)) ||
1725 +                               (((types[j] == R) || (types[j] == EN) || (types[j] == AN)) && (tempType == R)))
1726 +                       {
1727 +                               while(i<j)
1728 +                               {
1729 +                                       types[i++] = tempType;
1730 +                               }
1731 +                       }
1732 +               }
1733 +       }
1734 +       
1735 +
1736 +   /* Rule (N2)
1737 +    * N2. Any remaining neutrals take the embedding direction.
1738 +    */
1739 +   for(i=0; i<count; i++)
1740 +   {
1741 +      if(types[i] == ON || types[i] == BN)
1742 +      {
1743 +        if((levels[i] % 2) == 0)
1744 +           types[i] = L;
1745 +        else
1746 +           types[i] = R;
1747 +      }
1748 +   }
1749 +
1750 +   /* Rule (I1)
1751 +    * I1. For all characters with an even (left-to-right) embedding
1752 +    * direction, those of type R go up one level and those of type AN or
1753 +    * EN go up two levels.
1754 +    */
1755 +   for(i=0; i<count; i++)
1756 +   {
1757 +      if((levels[i] % 2) == 0)
1758 +      {
1759 +                if(types[i] == R)
1760 +                       levels[i] += 1;
1761 +                else if((types[i] == AN) || (types[i] == EN))
1762 +                       levels[i] += 2;
1763 +      }else
1764 +         {
1765 +                 if((types[i] == L) ||
1766 +                         (types[i] == EN) ||
1767 +                         (types[i] == AN))
1768 +                         levels[i] += 1;
1769 +         }
1770 +   }
1771 +
1772 +   /* Rule (I2)
1773 +    * I2. For all characters with an odd (right-to-left) embedding direction,
1774 +    * those of type L, EN or AN go up one level.
1775 +    */
1776 +/*
1777 +   for(i=0; i<count; i++)
1778 +   {
1779 +      if((levels[i] % 2) == 1)
1780 +      {
1781 +        if(types[i] == L || types[i] == EN || types[i] == AN)
1782 +           levels[i] += 1;
1783 +      }
1784 +   }
1785 +*/
1786 +   /* Rule (L1)
1787 +    * L1. On each line, reset the embedding level of the following characters
1788 +    * to the paragraph embedding level:
1789 +    *          (1)segment separators, (2)paragraph separators,
1790 +    *           (3)any sequence of whitespace characters preceding
1791 +    *           a segment separator or paragraph separator,
1792 +    *           (4)and any sequence of white space characters
1793 +    *           at the end of the line.
1794 +    * The types of characters used here are the original types, not those
1795 +    * modified by the previous phase. 
1796 +    */
1797 +
1798 +
1799 +
1800 +   j=count-1;
1801 +   while(j>0 && (GetType(GETCHAR(line, j)) == WS))
1802 +   {
1803 +      j--;
1804 +   }
1805 +   if(j < (count-1))
1806 +   {
1807 +      for(j++; j<count; j++)
1808 +        levels[j] = paragraphLevel;
1809 +   }
1810 +
1811 +   for(i=0; i<count; i++)
1812 +   {
1813 +      tempType = GetType(GETCHAR(line, i));
1814 +      if(tempType == WS)
1815 +      {
1816 +                j=i;
1817 +                while((++j < count) && ((tempType == WS) || (tempType == RLE)) )
1818 +                {
1819 +                        tempType = GetType(line[j]);
1820 +                }
1821 +
1822 +                if(GetType(GETCHAR(line, j)) == B || GetType(GETCHAR(line, j)) == S)
1823 +                {
1824 +                       for(j--; j>=i ; j--)
1825 +                       {
1826 +                          levels[j] = paragraphLevel;
1827 +                       }
1828 +                }
1829 +         }else if(tempType == B || tempType == S)
1830 +                levels[i] = paragraphLevel;
1831 +   }
1832 +
1833 +   /* Rule (L4)
1834 +    * L4. A character that possesses the mirrored property as specified by
1835 +    * Section 4.7, Mirrored, must be depicted by a mirrored glyph if the
1836 +    * resolved directionality of that character is R.
1837 +    */
1838 +   /* Note: this is implemented before L2 for efficiency */
1839 +       for(i=0; i<count; i++)
1840 +       {
1841 +               if((levels[i] % 2) == 1)
1842 +                       doMirror(&line[i]);
1843 +       }
1844 +
1845 +
1846 +
1847 +   /* Rule (L3)
1848 +    * L3. Combining marks applied to a right-to-left base character will at
1849 +    * this point precede their base character. If the rendering engine
1850 +    * expects them to follow the base characters in the final display
1851 +    * process, then the ordering of the marks and the base character must
1852 +    * be reversed.
1853 +       * Combining marks are reordered to the right of each character on an
1854 +       * odd level.
1855 +    */
1856 +
1857 +   if(fNSM && reorderCombining)
1858 +   {
1859 +          CHARTYPE temp;
1860 +          int it;
1861 +          for(i=0; i<count; i++)
1862 +          {
1863 +                  if(GetType(GETCHAR(line, i)) == NSM && odd(levels[i]))
1864 +                  {
1865 +                          j=i;
1866 +                          while((++j < count) && (GetType(GETCHAR(line, j)) == NSM));
1867 +                          j--; i--;
1868 +                          for(it=j; j>i; i++, j--)
1869 +                          {
1870 +                                        temp = GETCHAR(line, i);
1871 +                                        GETCHAR(line, i) = GETCHAR(line, j);
1872 +                                        GETCHAR(line, j) = temp;
1873 +                          }
1874 +                          i=it+1;
1875 +                  }
1876 +          }
1877 +   }
1878 +
1879 +       /* Shaping 
1880 +        * Shaping is Applied to each run of levels separately....
1881 +        */
1882 +
1883 +       if(applyShape)
1884 +       {
1885 +               
1886 +               for(i=0; i<count; i++)
1887 +               {
1888 +                       shapeTo[i] = GETCHAR(line, i);
1889 +               }
1890 +
1891 +               j=i=0;
1892 +               while(j < count)
1893 +               {
1894 +                       if(GetType(GETCHAR(line, j)) == AL)
1895 +                       {
1896 +                               if(j<count && j >= i )
1897 +                               {
1898 +                                       tempType = levels[j];
1899 +                                       i=j;
1900 +                                       while((i++ < count) && (levels[i] == tempType));
1901 +                                       doShape(line, shapeTo, j, i);
1902 +                                       j=i;
1903 +                                       tempType = levels[j];
1904 +                               
1905 +                               }
1906 +                       }
1907 +                       j++;
1908 +               }
1909 +               for(i=0; i<count; i++)
1910 +               {
1911 +                       GETCHAR(line, i) = shapeTo[i];
1912 +               }
1913 +               free(shapeTo);          
1914 +       }
1915 +
1916 +
1917 +
1918 +   /* Rule (L2)
1919 +    * L2. From the highest level found in the text to the lowest odd level on
1920 +    * each line, including intermediate levels not actually present in the
1921 +    * text, reverse any contiguous sequence of characters that are at that
1922 +    * level or higher
1923 +    */
1924 +   /* we flip the character string and leave the level array */
1925 +   imax = 0;
1926 +   i=0;
1927 +   tempType = levels[0];
1928 +   while(i < count)
1929 +   {
1930 +      if(levels[i] > tempType)
1931 +      {
1932 +        tempType = levels[i];
1933 +        imax=i;
1934 +      }
1935 +      i++;
1936 +   }
1937 +   /* maximum level in tempType, its index in imax. */
1938 +   while(tempType > 0)         /* loop from highest level to the least odd, */
1939 +   {                           /* which i assume is 1 */
1940 +      flipThisRun(line, levels, tempType, count);
1941 +      tempType--;                                              
1942 +   }
1943 +
1944 +   /* The line should be reordered correctly, check for Explicits marks
1945 +    * and remove them if removeMarks
1946 +    */
1947 +   if(fX && removeMarks)
1948 +   {
1949 +          if(!GetParagraphLevel(line, count))
1950 +          {
1951 +                  for(i=0, j=0; i<count; i++)
1952 +                  {
1953 +                          tempType = GetType(GETCHAR(line, i));
1954 +                          if(tempType != RLE &&
1955 +                                  tempType != LRE &&
1956 +                                  tempType != RLO &&
1957 +                                  tempType != LRO &&
1958 +                                  tempType != PDF)
1959 +                          GETCHAR(line, j++) = GETCHAR(line, i);
1960 +                  }
1961 +                  for(i=j; j<count; j++)
1962 +                          GETCHAR(line, j) = 0x20;
1963 +          }else
1964 +          {
1965 +                  for(j=i=count-1; i>=0; i--)
1966 +                  {
1967 +                          tempType = GetType(GETCHAR(line, i));
1968 +                          if(tempType != RLE &&
1969 +                                  tempType != LRE &&
1970 +                                  tempType != RLO &&
1971 +                                  tempType != LRO &&
1972 +                                  tempType != PDF)
1973 +                          GETCHAR(line, j--) = GETCHAR(line, i);
1974 +                  }
1975 +                  for(i=j; j>=0; j--)
1976 +                          GETCHAR(line, j) = 0x20;
1977 +          }
1978 +   }
1979 +
1980 +
1981 +   free(types);
1982 +   free(levels);
1983 +   /* if removeMarks is 1 and there were actual marks then return the new size */
1984 +   if(fX && removeMarks) return i;
1985 +   return count;
1986 +}
1987 +
1988 +
1989 +/*
1990 + * Bad, Horrible function
1991 + * takes a pointer to a character that is checked for
1992 + * having a mirror glyph.
1993 + */
1994 +void doMirror(CHARTYPE* ch)
1995 +{
1996 +    if ((*ch & 0xFF00) == 0) {
1997 +       switch (*ch) {
1998 +         case 0x0028: *ch = 0x0029; break;
1999 +         case 0x0029: *ch = 0x0028; break;
2000 +         case 0x003C: *ch = 0x003E; break;
2001 +         case 0x003E: *ch = 0x003C; break;
2002 +         case 0x005B: *ch = 0x005D; break;
2003 +         case 0x005D: *ch = 0x005B; break;
2004 +         case 0x007B: *ch = 0x007D; break;
2005 +         case 0x007D: *ch = 0x007B; break;
2006 +         case 0x00AB: *ch = 0x00BB; break;
2007 +         case 0x00BB: *ch = 0x00AB; break;
2008 +       }
2009 +    } else if ((*ch & 0xFF00) == 0x2000) {
2010 +       switch (*ch) {
2011 +         case 0x2039: *ch = 0x203A; break;
2012 +         case 0x203A: *ch = 0x2039; break;
2013 +         case 0x2045: *ch = 0x2046; break;
2014 +         case 0x2046: *ch = 0x2045; break;
2015 +         case 0x207D: *ch = 0x207E; break;
2016 +         case 0x207E: *ch = 0x207D; break;
2017 +         case 0x208D: *ch = 0x208E; break;
2018 +         case 0x208E: *ch = 0x208D; break;
2019 +       }
2020 +    } else if ((*ch & 0xFF00) == 0x2200) {
2021 +       switch (*ch) {
2022 +         case 0x2208: *ch = 0x220B; break;
2023 +         case 0x2209: *ch = 0x220C; break;
2024 +         case 0x220A: *ch = 0x220D; break;
2025 +         case 0x220B: *ch = 0x2208; break;
2026 +         case 0x220C: *ch = 0x2209; break;
2027 +         case 0x220D: *ch = 0x220A; break;
2028 +         case 0x2215: *ch = 0x29F5; break;
2029 +         case 0x223C: *ch = 0x223D; break;
2030 +         case 0x223D: *ch = 0x223C; break;
2031 +         case 0x2243: *ch = 0x22CD; break;
2032 +         case 0x2252: *ch = 0x2253; break;
2033 +         case 0x2253: *ch = 0x2252; break;
2034 +         case 0x2254: *ch = 0x2255; break;
2035 +         case 0x2255: *ch = 0x2254; break;
2036 +         case 0x2264: *ch = 0x2265; break;
2037 +         case 0x2265: *ch = 0x2264; break;
2038 +         case 0x2266: *ch = 0x2267; break;
2039 +         case 0x2267: *ch = 0x2266; break;
2040 +         case 0x2268: *ch = 0x2269; break;
2041 +         case 0x2269: *ch = 0x2268; break;
2042 +         case 0x226A: *ch = 0x226B; break;
2043 +         case 0x226B: *ch = 0x226A; break;
2044 +         case 0x226E: *ch = 0x226F; break;
2045 +         case 0x226F: *ch = 0x226E; break;
2046 +         case 0x2270: *ch = 0x2271; break;
2047 +         case 0x2271: *ch = 0x2270; break;
2048 +         case 0x2272: *ch = 0x2273; break;
2049 +         case 0x2273: *ch = 0x2272; break;
2050 +         case 0x2274: *ch = 0x2275; break;
2051 +         case 0x2275: *ch = 0x2274; break;
2052 +         case 0x2276: *ch = 0x2277; break;
2053 +         case 0x2277: *ch = 0x2276; break;
2054 +         case 0x2278: *ch = 0x2279; break;
2055 +         case 0x2279: *ch = 0x2278; break;
2056 +         case 0x227A: *ch = 0x227B; break;
2057 +         case 0x227B: *ch = 0x227A; break;
2058 +         case 0x227C: *ch = 0x227D; break;
2059 +         case 0x227D: *ch = 0x227C; break;
2060 +         case 0x227E: *ch = 0x227F; break;
2061 +         case 0x227F: *ch = 0x227E; break;
2062 +         case 0x2280: *ch = 0x2281; break;
2063 +         case 0x2281: *ch = 0x2280; break;
2064 +         case 0x2282: *ch = 0x2283; break;
2065 +         case 0x2283: *ch = 0x2282; break;
2066 +         case 0x2284: *ch = 0x2285; break;
2067 +         case 0x2285: *ch = 0x2284; break;
2068 +         case 0x2286: *ch = 0x2287; break;
2069 +         case 0x2287: *ch = 0x2286; break;
2070 +         case 0x2288: *ch = 0x2289; break;
2071 +         case 0x2289: *ch = 0x2288; break;
2072 +         case 0x228A: *ch = 0x228B; break;
2073 +         case 0x228B: *ch = 0x228A; break;
2074 +         case 0x228F: *ch = 0x2290; break;
2075 +         case 0x2290: *ch = 0x228F; break;
2076 +         case 0x2291: *ch = 0x2292; break;
2077 +         case 0x2292: *ch = 0x2291; break;
2078 +         case 0x2298: *ch = 0x29B8; break;
2079 +         case 0x22A2: *ch = 0x22A3; break;
2080 +         case 0x22A3: *ch = 0x22A2; break;
2081 +         case 0x22A6: *ch = 0x2ADE; break;
2082 +         case 0x22A8: *ch = 0x2AE4; break;
2083 +         case 0x22A9: *ch = 0x2AE3; break;
2084 +         case 0x22AB: *ch = 0x2AE5; break;
2085 +         case 0x22B0: *ch = 0x22B1; break;
2086 +         case 0x22B1: *ch = 0x22B0; break;
2087 +         case 0x22B2: *ch = 0x22B3; break;
2088 +         case 0x22B3: *ch = 0x22B2; break;
2089 +         case 0x22B4: *ch = 0x22B5; break;
2090 +         case 0x22B5: *ch = 0x22B4; break;
2091 +         case 0x22B6: *ch = 0x22B7; break;
2092 +         case 0x22B7: *ch = 0x22B6; break;
2093 +         case 0x22C9: *ch = 0x22CA; break;
2094 +         case 0x22CA: *ch = 0x22C9; break;
2095 +         case 0x22CB: *ch = 0x22CC; break;
2096 +         case 0x22CC: *ch = 0x22CB; break;
2097 +         case 0x22CD: *ch = 0x2243; break;
2098 +         case 0x22D0: *ch = 0x22D1; break;
2099 +         case 0x22D1: *ch = 0x22D0; break;
2100 +         case 0x22D6: *ch = 0x22D7; break;
2101 +         case 0x22D7: *ch = 0x22D6; break;
2102 +         case 0x22D8: *ch = 0x22D9; break;
2103 +         case 0x22D9: *ch = 0x22D8; break;
2104 +         case 0x22DA: *ch = 0x22DB; break;
2105 +         case 0x22DB: *ch = 0x22DA; break;
2106 +         case 0x22DC: *ch = 0x22DD; break;
2107 +         case 0x22DD: *ch = 0x22DC; break;
2108 +         case 0x22DE: *ch = 0x22DF; break;
2109 +         case 0x22DF: *ch = 0x22DE; break;
2110 +         case 0x22E0: *ch = 0x22E1; break;
2111 +         case 0x22E1: *ch = 0x22E0; break;
2112 +         case 0x22E2: *ch = 0x22E3; break;
2113 +         case 0x22E3: *ch = 0x22E2; break;
2114 +         case 0x22E4: *ch = 0x22E5; break;
2115 +         case 0x22E5: *ch = 0x22E4; break;
2116 +         case 0x22E6: *ch = 0x22E7; break;
2117 +         case 0x22E7: *ch = 0x22E6; break;
2118 +         case 0x22E8: *ch = 0x22E9; break;
2119 +         case 0x22E9: *ch = 0x22E8; break;
2120 +         case 0x22EA: *ch = 0x22EB; break;
2121 +         case 0x22EB: *ch = 0x22EA; break;
2122 +         case 0x22EC: *ch = 0x22ED; break;
2123 +         case 0x22ED: *ch = 0x22EC; break;
2124 +         case 0x22F0: *ch = 0x22F1; break;
2125 +         case 0x22F1: *ch = 0x22F0; break;
2126 +         case 0x22F2: *ch = 0x22FA; break;
2127 +         case 0x22F3: *ch = 0x22FB; break;
2128 +         case 0x22F4: *ch = 0x22FC; break;
2129 +         case 0x22F6: *ch = 0x22FD; break;
2130 +         case 0x22F7: *ch = 0x22FE; break;
2131 +         case 0x22FA: *ch = 0x22F2; break;
2132 +         case 0x22FB: *ch = 0x22F3; break;
2133 +         case 0x22FC: *ch = 0x22F4; break;
2134 +         case 0x22FD: *ch = 0x22F6; break;
2135 +         case 0x22FE: *ch = 0x22F7; break;
2136 +       }
2137 +    } else if ((*ch & 0xFF00) == 0x2300) {
2138 +        switch (*ch) {
2139 +          case 0x2308: *ch = 0x2309; break;
2140 +          case 0x2309: *ch = 0x2308; break;
2141 +          case 0x230A: *ch = 0x230B; break;
2142 +          case 0x230B: *ch = 0x230A; break;
2143 +          case 0x2329: *ch = 0x232A; break;
2144 +          case 0x232A: *ch = 0x2329; break;
2145 +        }
2146 +    } else if ((*ch & 0xFF00) == 0x2700) {
2147 +       switch (*ch) {
2148 +         case 0x2768: *ch = 0x2769; break;
2149 +         case 0x2769: *ch = 0x2768; break;
2150 +         case 0x276A: *ch = 0x276B; break;
2151 +         case 0x276B: *ch = 0x276A; break;
2152 +         case 0x276C: *ch = 0x276D; break;
2153 +         case 0x276D: *ch = 0x276C; break;
2154 +         case 0x276E: *ch = 0x276F; break;
2155 +         case 0x276F: *ch = 0x276E; break;
2156 +         case 0x2770: *ch = 0x2771; break;
2157 +         case 0x2771: *ch = 0x2770; break;
2158 +         case 0x2772: *ch = 0x2773; break;
2159 +         case 0x2773: *ch = 0x2772; break;
2160 +         case 0x2774: *ch = 0x2775; break;
2161 +         case 0x2775: *ch = 0x2774; break;
2162 +         case 0x27D5: *ch = 0x27D6; break;
2163 +         case 0x27D6: *ch = 0x27D5; break;
2164 +         case 0x27DD: *ch = 0x27DE; break;
2165 +         case 0x27DE: *ch = 0x27DD; break;
2166 +         case 0x27E2: *ch = 0x27E3; break;
2167 +         case 0x27E3: *ch = 0x27E2; break;
2168 +         case 0x27E4: *ch = 0x27E5; break;
2169 +         case 0x27E5: *ch = 0x27E4; break;
2170 +         case 0x27E6: *ch = 0x27E7; break;
2171 +         case 0x27E7: *ch = 0x27E6; break;
2172 +         case 0x27E8: *ch = 0x27E9; break;
2173 +         case 0x27E9: *ch = 0x27E8; break;
2174 +         case 0x27EA: *ch = 0x27EB; break;
2175 +         case 0x27EB: *ch = 0x27EA; break;
2176 +       }
2177 +    } else if ((*ch & 0xFF00) == 0x2900) {
2178 +       switch (*ch) {
2179 +         case 0x2983: *ch = 0x2984; break;
2180 +         case 0x2984: *ch = 0x2983; break;
2181 +         case 0x2985: *ch = 0x2986; break;
2182 +         case 0x2986: *ch = 0x2985; break;
2183 +         case 0x2987: *ch = 0x2988; break;
2184 +         case 0x2988: *ch = 0x2987; break;
2185 +         case 0x2989: *ch = 0x298A; break;
2186 +         case 0x298A: *ch = 0x2989; break;
2187 +         case 0x298B: *ch = 0x298C; break;
2188 +         case 0x298C: *ch = 0x298B; break;
2189 +         case 0x298D: *ch = 0x2990; break;
2190 +         case 0x298E: *ch = 0x298F; break;
2191 +         case 0x298F: *ch = 0x298E; break;
2192 +         case 0x2990: *ch = 0x298D; break;
2193 +         case 0x2991: *ch = 0x2992; break;
2194 +         case 0x2992: *ch = 0x2991; break;
2195 +         case 0x2993: *ch = 0x2994; break;
2196 +         case 0x2994: *ch = 0x2993; break;
2197 +         case 0x2995: *ch = 0x2996; break;
2198 +         case 0x2996: *ch = 0x2995; break;
2199 +         case 0x2997: *ch = 0x2998; break;
2200 +         case 0x2998: *ch = 0x2997; break;
2201 +         case 0x29B8: *ch = 0x2298; break;
2202 +         case 0x29C0: *ch = 0x29C1; break;
2203 +         case 0x29C1: *ch = 0x29C0; break;
2204 +         case 0x29C4: *ch = 0x29C5; break;
2205 +         case 0x29C5: *ch = 0x29C4; break;
2206 +         case 0x29CF: *ch = 0x29D0; break;
2207 +         case 0x29D0: *ch = 0x29CF; break;
2208 +         case 0x29D1: *ch = 0x29D2; break;
2209 +         case 0x29D2: *ch = 0x29D1; break;
2210 +         case 0x29D4: *ch = 0x29D5; break;
2211 +         case 0x29D5: *ch = 0x29D4; break;
2212 +         case 0x29D8: *ch = 0x29D9; break;
2213 +         case 0x29D9: *ch = 0x29D8; break;
2214 +         case 0x29DA: *ch = 0x29DB; break;
2215 +         case 0x29DB: *ch = 0x29DA; break;
2216 +         case 0x29F5: *ch = 0x2215; break;
2217 +         case 0x29F8: *ch = 0x29F9; break;
2218 +         case 0x29F9: *ch = 0x29F8; break;
2219 +         case 0x29FC: *ch = 0x29FD; break;
2220 +         case 0x29FD: *ch = 0x29FC; break;
2221 +       }
2222 +    } else if ((*ch & 0xFF00) == 0x2A00) {
2223 +       switch (*ch) {
2224 +         case 0x2A2B: *ch = 0x2A2C; break;
2225 +         case 0x2A2C: *ch = 0x2A2B; break;
2226 +         case 0x2A2D: *ch = 0x2A2C; break;
2227 +         case 0x2A2E: *ch = 0x2A2D; break;
2228 +         case 0x2A34: *ch = 0x2A35; break;
2229 +         case 0x2A35: *ch = 0x2A34; break;
2230 +         case 0x2A3C: *ch = 0x2A3D; break;
2231 +         case 0x2A3D: *ch = 0x2A3C; break;
2232 +         case 0x2A64: *ch = 0x2A65; break;
2233 +         case 0x2A65: *ch = 0x2A64; break;
2234 +         case 0x2A79: *ch = 0x2A7A; break;
2235 +         case 0x2A7A: *ch = 0x2A79; break;
2236 +         case 0x2A7D: *ch = 0x2A7E; break;
2237 +         case 0x2A7E: *ch = 0x2A7D; break;
2238 +         case 0x2A7F: *ch = 0x2A80; break;
2239 +         case 0x2A80: *ch = 0x2A7F; break;
2240 +         case 0x2A81: *ch = 0x2A82; break;
2241 +         case 0x2A82: *ch = 0x2A81; break;
2242 +         case 0x2A83: *ch = 0x2A84; break;
2243 +         case 0x2A84: *ch = 0x2A83; break;
2244 +         case 0x2A8B: *ch = 0x2A8C; break;
2245 +         case 0x2A8C: *ch = 0x2A8B; break;
2246 +         case 0x2A91: *ch = 0x2A92; break;
2247 +         case 0x2A92: *ch = 0x2A91; break;
2248 +         case 0x2A93: *ch = 0x2A94; break;
2249 +         case 0x2A94: *ch = 0x2A93; break;
2250 +         case 0x2A95: *ch = 0x2A96; break;
2251 +         case 0x2A96: *ch = 0x2A95; break;
2252 +         case 0x2A97: *ch = 0x2A98; break;
2253 +         case 0x2A98: *ch = 0x2A97; break;
2254 +         case 0x2A99: *ch = 0x2A9A; break;
2255 +         case 0x2A9A: *ch = 0x2A99; break;
2256 +         case 0x2A9B: *ch = 0x2A9C; break;
2257 +         case 0x2A9C: *ch = 0x2A9B; break;
2258 +         case 0x2AA1: *ch = 0x2AA2; break;
2259 +         case 0x2AA2: *ch = 0x2AA1; break;
2260 +         case 0x2AA6: *ch = 0x2AA7; break;
2261 +         case 0x2AA7: *ch = 0x2AA6; break;
2262 +         case 0x2AA8: *ch = 0x2AA9; break;
2263 +         case 0x2AA9: *ch = 0x2AA8; break;
2264 +         case 0x2AAA: *ch = 0x2AAB; break;
2265 +         case 0x2AAB: *ch = 0x2AAA; break;
2266 +         case 0x2AAC: *ch = 0x2AAD; break;
2267 +         case 0x2AAD: *ch = 0x2AAC; break;
2268 +         case 0x2AAF: *ch = 0x2AB0; break;
2269 +         case 0x2AB0: *ch = 0x2AAF; break;
2270 +         case 0x2AB3: *ch = 0x2AB4; break;
2271 +         case 0x2AB4: *ch = 0x2AB3; break;
2272 +         case 0x2ABB: *ch = 0x2ABC; break;
2273 +         case 0x2ABC: *ch = 0x2ABB; break;
2274 +         case 0x2ABD: *ch = 0x2ABE; break;
2275 +         case 0x2ABE: *ch = 0x2ABD; break;
2276 +         case 0x2ABF: *ch = 0x2AC0; break;
2277 +         case 0x2AC0: *ch = 0x2ABF; break;
2278 +         case 0x2AC1: *ch = 0x2AC2; break;
2279 +         case 0x2AC2: *ch = 0x2AC1; break;
2280 +         case 0x2AC3: *ch = 0x2AC4; break;
2281 +         case 0x2AC4: *ch = 0x2AC3; break;
2282 +         case 0x2AC5: *ch = 0x2AC6; break;
2283 +         case 0x2AC6: *ch = 0x2AC5; break;
2284 +         case 0x2ACD: *ch = 0x2ACE; break;
2285 +         case 0x2ACE: *ch = 0x2ACD; break;
2286 +         case 0x2ACF: *ch = 0x2AD0; break;
2287 +         case 0x2AD0: *ch = 0x2ACF; break;
2288 +         case 0x2AD1: *ch = 0x2AD2; break;
2289 +         case 0x2AD2: *ch = 0x2AD1; break;
2290 +         case 0x2AD3: *ch = 0x2AD4; break;
2291 +         case 0x2AD4: *ch = 0x2AD3; break;
2292 +         case 0x2AD5: *ch = 0x2AD6; break;
2293 +         case 0x2AD6: *ch = 0x2AD5; break;
2294 +         case 0x2ADE: *ch = 0x22A6; break;
2295 +         case 0x2AE3: *ch = 0x22A9; break;
2296 +         case 0x2AE4: *ch = 0x22A8; break;
2297 +         case 0x2AE5: *ch = 0x22AB; break;
2298 +         case 0x2AEC: *ch = 0x2AED; break;
2299 +         case 0x2AED: *ch = 0x2AEC; break;
2300 +         case 0x2AF7: *ch = 0x2AF8; break;
2301 +         case 0x2AF8: *ch = 0x2AF7; break;
2302 +         case 0x2AF9: *ch = 0x2AFA; break;
2303 +         case 0x2AFA: *ch = 0x2AF9; break;
2304 +       }
2305 +    } else if ((*ch & 0xFF00) == 0x3000) {
2306 +       switch (*ch) {
2307 +         case 0x3008: *ch = 0x3009; break;
2308 +         case 0x3009: *ch = 0x3008; break;
2309 +         case 0x300A: *ch = 0x300B; break;
2310 +         case 0x300B: *ch = 0x300A; break;
2311 +         case 0x300C: *ch = 0x300D; break;
2312 +         case 0x300D: *ch = 0x300C; break;
2313 +         case 0x300E: *ch = 0x300F; break;
2314 +         case 0x300F: *ch = 0x300E; break;
2315 +         case 0x3010: *ch = 0x3011; break;
2316 +         case 0x3011: *ch = 0x3010; break;
2317 +         case 0x3014: *ch = 0x3015; break;
2318 +         case 0x3015: *ch = 0x3014; break;
2319 +         case 0x3016: *ch = 0x3017; break;
2320 +         case 0x3017: *ch = 0x3016; break;
2321 +         case 0x3018: *ch = 0x3019; break;
2322 +         case 0x3019: *ch = 0x3018; break;
2323 +         case 0x301A: *ch = 0x301B; break;
2324 +         case 0x301B: *ch = 0x301A; break;
2325 +       }
2326 +    } else if ((*ch & 0xFF00) == 0xFF00) {
2327 +       switch (*ch) {
2328 +         case 0xFF08: *ch = 0xFF09; break;
2329 +         case 0xFF09: *ch = 0xFF08; break;
2330 +         case 0xFF1C: *ch = 0xFF1E; break;
2331 +         case 0xFF1E: *ch = 0xFF1C; break;
2332 +         case 0xFF3B: *ch = 0xFF3D; break;
2333 +         case 0xFF3D: *ch = 0xFF3B; break;
2334 +         case 0xFF5B: *ch = 0xFF5D; break;
2335 +         case 0xFF5D: *ch = 0xFF5B; break;
2336 +         case 0xFF5F: *ch = 0xFF60; break;
2337 +         case 0xFF60: *ch = 0xFF5F; break;
2338 +         case 0xFF62: *ch = 0xFF63; break;
2339 +         case 0xFF63: *ch = 0xFF62; break;
2340 +       }
2341 +    }
2342 +}
2343 Index: qt-2.3.10/src/qt.pro
2344 ===================================================================
2345 --- qt-2.3.10.orig/src/qt.pro   2005-01-23 15:00:39.000000000 +0100
2346 +++ qt-2.3.10/src/qt.pro        2005-05-13 22:22:13.000000000 +0200
2347 @@ -182,6 +182,7 @@
2348                   $$KERNEL_H/qasyncimageio.h \
2349                   $$KERNEL_H/qasyncio.h \
2350                   $$KERNEL_H/qbitmap.h \
2351 +                 $$KERNEL_H/qbidi.h \
2352                   $$KERNEL_H/qbrush.h \
2353                   $$KERNEL_H/qclipboard.h \
2354                   $$KERNEL_H/qcolor.h \
2355 @@ -527,6 +528,8 @@
2356                   kernel/qapplication.cpp \
2357                   kernel/qasyncimageio.cpp \
2358                   kernel/qasyncio.cpp \
2359 +                 kernel/qbidi.cpp \
2360 +                 kernel/minibidi.cpp \
2361                   kernel/qbitmap.cpp \
2362                   kernel/qclipboard.cpp \
2363                   kernel/qcolor.cpp \
2364 Index: qt-2.3.10/src/Makefile.in
2365 ===================================================================
2366 --- qt-2.3.10.orig/src/Makefile.in      2005-05-13 22:22:11.000000000 +0200
2367 +++ qt-2.3.10/src/Makefile.in   2005-05-13 22:29:52.000000000 +0200
2368 @@ -168,6 +168,8 @@
2369                 kernel/qabstractlayout.o \
2370                 kernel/qaccel.o \
2371                 kernel/qapplication.o \
2372 +               kernel/qbidi.o        \
2373 +               kernel/minibidi.o     \
2374                 kernel/qasyncimageio.o \
2375                 kernel/qasyncio.o \
2376                 kernel/qbitmap.o \
2377 @@ -4107,6 +4109,12 @@
2378                 kernel/qthread.h \
2379                 tools/qvaluestack.h
2380  
2381 +kernel/qbidi.o: kernel/qbidi.cpp \
2382 +               kernel/qbidi.h   \
2383 +               tools/qstring.h
2384 +
2385 +kernel/minibidi.o: kernel/minibidi.c
2386 +
2387  kernel/qasyncimageio.o: kernel/qasyncimageio.cpp \
2388                 kernel/qasyncimageio.h \
2389                 kernel/qimage.h \