9c3bf46
--- src/yfontxft.cc.old	2009-09-25 00:07:51.000000000 +0300
9c3bf46
+++ src/yfontxft.cc	2009-09-25 00:18:09.000000000 +0300
9c3bf46
@@ -6,6 +6,11 @@
9c3bf46
 #include "ypaint.h"
9c3bf46
 #include "yxapp.h"
9c3bf46
 #include "intl.h"
9c3bf46
+#include <stdio.h>
9c3bf46
+
9c3bf46
+#ifdef CONFIG_FRIBIDI
9c3bf46
+    #include <fribidi/fribidi.h>
9c3bf46
+#endif
9c3bf46
 
9c3bf46
 /******************************************************************************/
9c3bf46
 
9c3bf46
@@ -68,10 +73,45 @@
9c3bf46
                            char_t * str, size_t len)
9c3bf46
     {
9c3bf46
         XftColor *c = *g.color();
9c3bf46
+
9c3bf46
+#ifdef CONFIG_FRIBIDI
9c3bf46
+
9c3bf46
+#define STATIS_STRING_SIZE	256
9c3bf46
+
9c3bf46
+		// Based around upstream (1.3.2) patch with some optimization
9c3bf46
+		//   on my end. (reduce unnecessary memory allocation)
9c3bf46
+		// - Gilboa
9c3bf46
+
9c3bf46
+		char_t static_str[STATIS_STRING_SIZE];
9c3bf46
+		char_t *vis_str = static_str;
9c3bf46
+
9c3bf46
+		if (len >= STATIS_STRING_SIZE)
9c3bf46
+		{
9c3bf46
+			vis_str = new char_t[len+1];
9c3bf46
+			if (!vis_str)
9c3bf46
+				return;
9c3bf46
+		}
9c3bf46
+
9c3bf46
+		FriBidiCharType pbase_dir = FRIBIDI_TYPE_N;
9c3bf46
+		fribidi_log2vis(str, len, &pbase_dir, //input
9c3bf46
+						vis_str, // output
9c3bf46
+						NULL, NULL, NULL // "statistics" that we don't need
9c3bf46
+						);
9c3bf46
+		str = vis_str;
9c3bf46
+#endif
9c3bf46
+
9c3bf46
         XftDrawString(g.handleXft(), c, font,
9c3bf46
                       x - g.xorigin(),
9c3bf46
                       y - g.yorigin(),
9c3bf46
                       str, len);
9c3bf46
+
9c3bf46
+#ifdef CONFIG_FRIBIDI
9c3bf46
+
9c3bf46
+		if (vis_str != static_str)
9c3bf46
+			delete[] str;
9c3bf46
+
9c3bf46
+#endif
9c3bf46
+
9c3bf46
     }
9c3bf46
 
9c3bf46
     static void textExtents(XftFont * font, char_t * str, size_t len,
9c3bf46
--- configure.in.old	2009-09-25 00:05:08.000000000 +0300
9c3bf46
+++ configure.in	2009-09-25 00:07:14.000000000 +0300
9c3bf46
@@ -307,6 +307,20 @@
9c3bf46
       features="${features} i18n"
9c3bf46
 fi
9c3bf46
 
9c3bf46
+dnl =================================================== Right to left support ===
9c3bf46
+dnl
9c3bf46
+AC_ARG_ENABLE(fribidi,
9c3bf46
+  [  --disable-fribidi       Disable right to left support])
9c3bf46
+      
9c3bf46
+if test "$enable_fribidi" != "no" && test "$enable_i18n" != "no"; then
9c3bf46
+  PKG_CHECK_MODULES(FRIBIDI, fribidi)
9c3bf46
+
9c3bf46
+  AC_DEFINE(CONFIG_FRIBIDI,1, [Define to enable fribidi support])
9c3bf46
+        
9c3bf46
+  CORE_CFLAGS="${CORE_CFLAGS} ${FRIBIDI_CFLAGS}"
9c3bf46
+  CORE_LIBS="${CORE_LIBS} ${FRIBIDI_LIBS}"
9c3bf46
+fi
9c3bf46
+
9c3bf46
 dnl ============================================================ NLS Support ===
9c3bf46
 dnl
9c3bf46
 AC_ARG_ENABLE(nls,