Index: ie_imp_MSWrite.cpp
===================================================================
--- ie_imp_MSWrite.cpp	(revision 30387)
+++ ie_imp_MSWrite.cpp	(working copy)
@@ -284,6 +284,7 @@
 IE_Imp_MSWrite::IE_Imp_MSWrite (PD_Document *pDocument)
 	: IE_Imp(pDocument),
 	  default_codepage("CP1252"),
+	  isRTL(false),
 	  hasHeader(false),
 	  hasFooter(false),
 	  wri_fonts(0),
@@ -424,10 +425,23 @@
  * MSWrite Importer (font handling)                                   *
  **********************************************************************/
 
+void fixup_me_font(wri_font *fnt)
+{
+	if (fnt->charset == 178 ||		/* ARABIC_CHARSET  */
+		fnt->charset == 179 ||		/* some win16 value*/
+		fnt->charset == 180) {		/*     --  "  --   */
+			fnt->codepage = "CP1256";
+	} else if (fnt->charset == 177 ||	/* HEBREW_CHARSET  */
+				fnt->charset == 181) {	/* some win16 value*/
+			fnt->codepage = "CP1255";
+	}
+}
+
 bool IE_Imp_MSWrite::read_ffntb ()
 {
 	int pnFfntb, pnMac, fonts_count = 0, cbFfn, fflen;
-	unsigned char buf[2], ffid;
+	unsigned char buf[2], ffid, chset;
+	bool extft = false;
 	wri_font *fonts;
 	char *ffn;
 
@@ -510,6 +524,23 @@
 			return false;
 		}
 
+		wri_fonts[fonts_count].charset = 0;
+		/* I have no idea about actual method to know */
+		if (ffid & 0x80) {
+			chset = ffid;
+			extft = true;
+			isRTL = true;
+			wri_fonts[fonts_count].charset = chset;
+		}
+		if (extft) {
+			/* re-read font family */
+			if (!gsf_input_read (mFile, 1, &ffid)) {
+				perror ("wri_file");
+				return 1;
+			}
+			cbFfn--;
+		}
+
 		wri_fonts[fonts_count].ffid = ffid;
 
 		cbFfn--;   // we've already read ffid
@@ -533,6 +564,8 @@
 		}
 
 		wri_fonts[fonts_count].codepage = get_codepage(ffn, &fflen);
+		if (extft)
+			fixup_me_font(&wri_fonts[fonts_count]);
 
 		ffn[fflen] = 0;
 		wri_fonts[fonts_count].name = ffn;
@@ -704,7 +737,7 @@
 		for (int fod = 0; fod < cfod; fod++)
 		{
 			int bfprop, cch;
-			int jc, dxaRight, dxaLeft, dxaLeft1, dyaLine, fGraphics;
+			int jc, rtl, flag, dxaRight, dxaLeft, dxaLeft1, dyaLine, fGraphics;
 			int rhcPage, rHeaderFooter, rhcFirst;
 			int tabs, dxaTab[14], jcTab[14];
 
@@ -727,13 +760,26 @@
 			rhcPage = rHeaderFooter = rhcFirst = 0;
 			fGraphics = 0;
 			tabs = 0;
+			jc = isRTL ? 2 : 0;
+			flag = isRTL ? 60 : 61;
+			rtl = isRTL ? 1 : 0;
 
 			// if the PAP FPROPs (formatting properties) differ from the defaults, get them
 			if (bfprop != 0xffff && bfprop + (cch = page[bfprop + 4]) < 0x80)
 			{
 				if (process == All) UT_DEBUGMSG(("    cch = %d\n", cch));
 
+				if (cch >= 1) flag = page[bfprop + 5];
+				if (flag == 60) {
+					jc = 2;
+					rtl = 1;
+				} else {
+					jc = 0;
+					rtl = 0;
+				}
+
 				if (cch >= 2) jc = page[bfprop + 6] & 3;
+				if (cch >= 2) rtl = page[bfprop + 6] & 0x10;
 				if (cch >= 6) dxaRight = READ_WORD(page + bfprop + 9);
 				if (cch >= 8) dxaLeft = READ_WORD(page + bfprop + 11);
 				if (cch >= 10) dxaLeft1 = READ_WORD(page + bfprop + 13);
@@ -796,12 +842,18 @@
 				UT_DEBUGMSG(("    rHeaderFooter = %d\n", rHeaderFooter));
 				UT_DEBUGMSG(("    rhcFirst      = %d\n", rhcFirst));
 				UT_DEBUGMSG(("    fGraphics     = %d\n", fGraphics));
+				UT_DEBUGMSG(("    rtl           = %d\n", rtl));
 
 				UT_LocaleTransactor lt(LC_NUMERIC, "C");
 				UT_String_sprintf(properties, "text-align:%s; line-height:%.1f",
 				                              text_align[jc],
 				                              static_cast<float>(dyaLine) / 240.0);
 
+				if (rtl)
+				{
+					properties += "; dom-dir:rtl";
+				}
+
 				if (tabs)
 				{
 					properties += "; tabstops:";
@@ -914,7 +966,8 @@
 		// read all FODs (format descriptors)
 		for (int fod = 0; fod < cfod; fod++)
 		{
-			int bfprop, cch, ftc, hps, fBold, fItalic, fUline, hpsPos;
+			int bfprop, cch, ftc, aftc, fAlt, hps, ahps, fBold, fItalic, 
+				fUline, hpsPos, fABold;
 
 			UT_DEBUGMSG(("       CHP-FOD #%02d:\n", fod + 1));
 
@@ -922,43 +975,62 @@
 			fcLim = READ_DWORD(page + 4 + fod * 6);
 			bfprop = READ_WORD(page + 8 + fod * 6);
 
-			UT_DEBUGMSG(("        fcLim  = %d\n", fcLim));
-			UT_DEBUGMSG((bfprop == 0xffff ? "        bfprop = 0x%04X\n" : "        bfprop = %d\n", bfprop));
+			if (from < fcLim && to >= fcFirst)
+			{
+				UT_DEBUGMSG(("        fcLim  = %d\n", fcLim));
+				UT_DEBUGMSG((bfprop == 0xffff ? "        bfprop = 0x%04X\n" : "        bfprop = %d\n", bfprop));
 
-			// default CHP values
-			ftc = 0;
-			hps = 24;
-			fBold = fItalic = fUline = hpsPos = 0;
+				// default CHP values
+				ftc = 0;
+				aftc = 0;
+				hps = 24;
+				ahps = 24;
+				fBold = fABold = fItalic = fUline = hpsPos = 0;
+				fAlt = 1;
 
-			// if the CHP FPROPs (formatting properties) differ from the defaults, get them
-			if (bfprop != 0xffff && bfprop + (cch = page[bfprop + 4]) < 0x80)
-			{
-				UT_DEBUGMSG(("         cch = %d\n", cch));
+				// if the CHP FPROPs (formatting properties) differ from the defaults, get them
+				if (bfprop != 0xffff && bfprop + (cch = page[bfprop + 4]) < 0x80)
+				{
+					UT_DEBUGMSG(("         cch = %d\n", cch));
 
-				if (cch >= 2) ftc = page[bfprop + 6] >> 2;
-				if (cch >= 5) ftc |= (page[bfprop + 9] & 3) << 6;
-				if (cch >= 3) hps = page[bfprop + 7];
-				if (cch >= 2) fBold = page[bfprop + 6] & 1;
-				if (cch >= 2) fItalic = page[bfprop + 6] & 2;
-				if (cch >= 4) fUline = page[bfprop + 8] & 1;
-				if (cch >= 6) hpsPos = page[bfprop + 10];
-			}
+					if (cch >= 2) ftc = page[bfprop + 6] >> 2;
+					if (cch >= 5) ftc |= (page[bfprop + 9] & 3) << 6;
+					if (cch >= 3) hps = page[bfprop + 7];
+					if (cch >= 2) fBold = page[bfprop + 6] & 1;
+					if (cch >= 2) fItalic = page[bfprop + 6] & 2;
+					if (cch >= 4) fUline = page[bfprop + 8] & 1;
+					if (cch >= 6) hpsPos = page[bfprop + 10];
+					if (cch >= 1) aftc = page[bfprop + 5] >> 2;
+					if (cch >= 1) fAlt = page[bfprop + 5] & 2;
+					if (cch >= 4) fABold = page[bfprop + 8] & 2;
+					if (cch >= 4) ahps = (ahps & 0xF0) | (page[bfprop + 8] >> 2) & 0xf;
+					if (cch >= 5) ahps = (ahps & 0x0F) | page[bfprop + 9] & 0xF0;
+				}
 
-			UT_DEBUGMSG(("         ftc           = %d\n", ftc));
-			UT_DEBUGMSG(("         hps           = %d\n", hps));
-			UT_DEBUGMSG(("         fBold         = %d\n", fBold));
-			UT_DEBUGMSG(("         fItalic       = %d\n", fItalic));
-			UT_DEBUGMSG(("         fUline        = %d\n", fUline));
-			UT_DEBUGMSG(("         hpsPos        = %d\n", hpsPos));
+				UT_DEBUGMSG(("         ftc           = %d\n", ftc));
+				UT_DEBUGMSG(("         aftc          = %d\n", aftc));
+				UT_DEBUGMSG(("         hps           = %d\n", hps));
+				UT_DEBUGMSG(("         ahps          = %d\n", ahps));
+				UT_DEBUGMSG(("         fBold         = %d\n", fBold));
+				UT_DEBUGMSG(("         fItalic       = %d\n", fItalic));
+				UT_DEBUGMSG(("         fUline        = %d\n", fUline));
+				UT_DEBUGMSG(("         fAlt          = %d\n", fAlt));
+				UT_DEBUGMSG(("         fABold        = %d\n", fABold));
+				UT_DEBUGMSG(("         hpsPos        = %d\n", hpsPos));
 
-			if (ftc >= wri_fonts_count)
-			{
-				fprintf(stderr, "read_txt: Wrong font code.\n");
-				ftc = wri_fonts_count - 1;
-			}
+				/* a sort of dirty hack */
+				if (fAlt) {
+					ftc = aftc;
+					hps = ahps;
+					fBold = fABold;
+				}
 
-			if (from < fcLim && to >= fcFirst)
-			{
+				if (ftc >= wri_fonts_count)
+				{
+					fprintf(stderr, "read_txt: Wrong font code.\n");
+					ftc = wri_fonts_count - 1;
+				}
+
 				UT_LocaleTransactor lt(LC_NUMERIC, "C");
 				UT_String_sprintf(properties, "font-weight:%s",
 				                              fBold ? "bold" : "normal");
@@ -1066,8 +1138,7 @@
 	{"\x04 Cyr", "CP1251"},
 	{"\x06 Greek", "CP1253"},
 	{"\x04 Tur", "CP1254"},
-	{"\x09 (Hebrew)", "CP1255"},
-	{"\x09 (Arabic)", "CP1256"},
+	{"\x05 Euro", "CP1252"},
 	{"\x07 Baltic", "CP1257"},
 	{NULL, NULL}
 };
Index: ie_imp_MSWrite.h
===================================================================
--- ie_imp_MSWrite.h	(revision 30387)
+++ ie_imp_MSWrite.h	(working copy)
@@ -31,6 +31,7 @@
 typedef struct
 {
 	short ffid;             // unused
+	short charset;
 	const char *name;
 	const char *codepage;
 } wri_font;
@@ -76,6 +77,7 @@
 	const char *default_codepage;
 	int xaLeft, xaRight;
 	bool hasHeader, hasFooter, page1Header, page1Footer;
+	bool isRTL;
 	wri_font *wri_fonts;
 	int wri_fonts_count;
 	unsigned int pic_nr;
