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