+static int iso885968x[] = {
+ 0xbc, // 0xa8 = fathatan
+ 0xbd, // 0xa9 = dammatan
+ 0xbe, // 0xaa = kasratan
+ 0xdb, // 0xab = fatha
+ 0xdc, // 0xac = damma
+ 0xdd, // 0xad = kasra
+ 0xde, // 0xae = shadda
+ 0xdf, // 0xaf = sukun
+
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xb0-0xbf
+
+ 0, // 0xc0
+ 0xc1, // 0xc1 = hamza
+ 0xc2, // 0xc2 = ligature madda
+ 0xc3, // 0xc3 = ligature hamza on alef
+ 0xc4, // 0xc4 = ligature hamza on waw
+ 0xc5, // 0xc5 = ligature hamza under alef
+ 0xc0, // 0xc6 = ligature hamza on ya
+ 0xc7, // 0xc7 = alef
+ 0xeb, // 0xc8 = baa
+ 0xc9, // 0xc9 = taa marbuta
+ 0xec, // 0xca = taa
+ 0xed, // 0xcb = thaa
+ 0xee, // 0xcc = jeem
+ 0xef, // 0xcd = haa
+ 0xf0, // 0xce = khaa
+ 0xcf, // 0xcf = dal
+
+ 0xd0, // 0xd0 = thal
+ 0xd1, // 0xd1 = ra
+ 0xd2, // 0xd2 = zain
+ 0xf1, // 0xd3 = seen
+ 0xf2, // 0xd4 = sheen
+ 0xf3, // 0xd5 = sad
+ 0xf4, // 0xd6 = dad
+ 0xd7, // 0xd7 = tah
+ 0xd8, // 0xd8 = zah
+ 0xf5, // 0xd9 = ain
+ 0xf6, // 0xda = ghain
+ 0,0,0,0,0, // 0xdb- 0xdf
+
+ 0, // 0xe0
+ 0xf7, // 0xe1 = fa
+ 0xf8, // 0xe2 = qaf
+ 0xf9, // 0xe3 = kaf
+ 0xfa, // 0xe4 = lam
+ 0xfb, // 0xe5 = meem
+ 0xfc, // 0xe6 = noon
+ 0xfd, // 0xe7 = ha
+ 0xe8, // 0xe8 = waw
+ 0xe9, // 0xe9 = alef maksura
+ 0xfe // 0xea = ya
+};
+
+bool is_arabic(unsigned char c)
+{
+ return 0xa8 <= c && c <= 0xea && iso885968x[c-0xa8];
+}
+
+unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
+{
+ if (is_arabic(c) &&
+ (form == FORM_INITIAL || form == FORM_MEDIAL) )
+ return iso885968x[c-0xa8];
+ else
+ return c;
+}
+
+unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
+ LyXParagraph::size_type pos) const
+{
+ if (!is_arabic(c))
+ return c;
+
+ bool not_first = (pos > 0 && is_arabic(par->GetChar(pos-1)));
+ if (pos < par->Last()-1 && is_arabic(par->GetChar(pos+1)))
+ if (not_first)
+ return TransformChar(c,FORM_MEDIAL);
+ else
+ return TransformChar(c,FORM_INITIAL);
+ else
+ if (not_first)
+ return TransformChar(c,FORM_FINAL);
+ else
+ return TransformChar(c,FORM_ISOLATED);
+}
+
+// This is the comments that some of the warnings below refers to.
+// There are some issues in this file and I don't think they are
+// really related to the FIX_DOUBLE_SPACE patch. I'd rather think that
+// this is a problem that has been here almost from day one and that a
+// larger userbase with differenct access patters triggers the bad
+// behaviour. (segfaults.) What I think happen is: In several places
+// we store the paragraph in the current cursor and then moves the
+// cursor. This movement of the cursor will delete paragraph at the
+// old position if it is now empty. This will make the temporary
+// pointer to the old cursor paragraph invalid and dangerous to use.
+// And is some cases this will trigger a segfault. I have marked some
+// of the cases where this happens with a warning, but I am sure there
+// are others in this file and in text2.C. There is also a note in
+// Delete() that you should read. In Delete I store the paragraph->id
+// instead of a pointer to the paragraph. I am pretty sure this faulty
+// use of temporary pointers to paragraphs that might have gotten
+// invalidated (through a cursor movement) before they are used, are
+// the cause of the strange crashes we get reported often.
+//
+// It is very tiresom to change this code, especially when it is as
+// hard to read as it is. Help to fix all the cases where this is done
+// would be greately appreciated.
+//
+// Lgb
+