Index: firmware/bidi.c =================================================================== --- firmware/bidi.c (revision 25039) +++ firmware/bidi.c (working copy) @@ -30,6 +30,7 @@ #include "arabjoin.h" #include "scroll_engine.h" #include "bidi.h" +#include "diacritic.h" /* #define _HEB_BUFFER_LENGTH (MAX_PATH + LCD_WIDTH/2 + 3 + 2 + 2) * 2 */ #define _HEB_BLOCK_TYPE_ENG 1 @@ -61,30 +62,43 @@ { bool connected = false; unsigned short * writeprt = stringprt; - + short is_diac = 0; + unsigned short * diac_ptr = 0; const arab_t * prev = 0; const arab_t * cur; const arab_t * ligature = 0; short uchar; - int i; + int i,j; for (i = 0; i <= length; i++) { cur = arab_lookup(uchar = *stringprt++); - /* Skip non-arabic chars */ + /* Skip non-arabic chars */ /* (actually this skips diacritics too as they are commented in arabjoin.c) */ if (cur == 0) { - if (prev) { + if (is_diacritic(uchar, NULL)) { /* skip diacritics without affecting the shaping algorithm (apply joining as if there is no diacritics) */ + if(!is_diac) + diac_ptr = stringprt - 1; + is_diac++; + } + else if (prev) /* non-arabic characters */ + { /* Finish the last char */ if (connected) { *writeprt++ = prev->final; connected = false; - } else + } + else *writeprt++ = prev->isolated; prev = 0; + if (is_diac) { /* write the skipped diacritics */ + for (j = 0; j < is_diac; j++) + *writeprt++ = *diac_ptr++; + is_diac = 0; + } *writeprt++ = uchar; - } else { + } + else *writeprt++ = uchar; - } continue; } @@ -129,6 +143,11 @@ } else *writeprt++ = prev->isolated; } + if (is_diac) { /* write the skipped diacritics */ + for (j = 0; j < is_diac; j++) + *writeprt++ = *diac_ptr++; + is_diac = 0; + } prev = cur; } }