diff -aur vte-0.16.13_orig/ChangeLog vte-0.16.13/ChangeLog
--- vte-0.16.13_orig/ChangeLog	2008-03-10 22:32:16.000000000 +0200
+++ vte-0.16.13/ChangeLog	2008-06-06 23:15:31.455793700 +0300
@@ -1,3 +1,11 @@
+2008-06-06 Muayyad AlSadi <alsadi@ojuba.org>
+
+	* Bug fixes in the previous BiDi support.
+
+2008-05-17 Muayyad AlSadi <alsadi@ojuba.org>
+
+	* Add primitive support for BiDi and Shapping (needed in Arabic and other Semitic languages) to pango and pangox backends
+
 2008-03-10  Behdad Esfahbod  <behdad@gnome.org>
 
 	Released vte-0.16.13.
diff -aur vte-0.16.13_orig/NEWS vte-0.16.13/NEWS
--- vte-0.16.13_orig/NEWS	2008-03-10 22:23:28.000000000 +0200
+++ vte-0.16.13/NEWS	2008-06-06 23:13:43.953793739 +0300
@@ -1,3 +1,6 @@
+
+- Add primitive support for BiDi and Shapping (needed in Arabic and other Semitic languages) to pango and pangox backends
+
 0.16.13
 =======
 - Minor optimization.
diff -aur vte-0.16.13_orig/src/vtedraw.c vte-0.16.13/src/vtedraw.c
--- vte-0.16.13_orig/src/vtedraw.c	2007-11-27 10:41:31.000000000 +0200
+++ vte-0.16.13/src/vtedraw.c	2008-06-06 23:13:43.954793775 +0300
@@ -36,16 +36,17 @@
 #include "vtexft.h"
 
 static const struct _vte_draw_impl
+
 *_vte_draw_impls[] = {
 #ifndef X_DISPLAY_MISSING
 #ifdef HAVE_XFT2
-	&_vte_draw_xft,
+//	&_vte_draw_xft,
 #endif /* HAVE_XFT2 */
 #endif /* !X_DISPLAY_MISSING */
-	&_vte_draw_ft2,
+//	&_vte_draw_ft2,
 #ifndef X_DISPLAY_MISSING
 #ifdef HAVE_GL
-	&_vte_draw_gl,
+//	&_vte_draw_gl,
 #endif /* HAVE_GL */
 #endif /* !X_DISPLAY_MISSING */
 	&_vte_draw_pango,
diff -aur vte-0.16.13_orig/src/vtepango.c vte-0.16.13/src/vtepango.c
--- vte-0.16.13_orig/src/vtepango.c	2007-11-28 15:55:04.000000000 +0200
+++ vte-0.16.13/src/vtepango.c	2008-06-13 01:29:16.197325874 +0300
@@ -16,7 +16,10 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-
+/*
+ * Copyright (C) 2008, Muayyad Alsadi <Alsadi@ojuba.org>
+ * Adding BiDi and shapping support
+ */
 #include "../config.h"
 
 #include <sys/param.h>
@@ -331,30 +334,40 @@
 {
 	return TRUE;
 }
-
+#define RUN_MAX 512
 static void
 _vte_pango_draw_text(struct _vte_draw *draw,
 		     struct _vte_draw_text_request *requests, gsize n_requests,
 		     GdkColor *color, guchar alpha)
 {
 	struct _vte_pango_data *data = (struct _vte_pango_data*) draw->impl_data;
-	char buf[VTE_UTF8_BPC];
-	guint i;
-	gsize length;
+	char *buf;
+	gunichar text_run[RUN_MAX];
+	guint i,j,k,cw;
+	gshort x,y,expected_x_limit;
+	glong length;
 	GdkColor wcolor;
 
-
 	wcolor = *color;
 	gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
 			   &wcolor);
 	gdk_gc_set_foreground(data->gc, &wcolor);
-
-	for (i = 0; i < n_requests; i++) {
-		length = g_unichar_to_utf8(requests[i].c, buf);
+        cw=_vte_pango_get_text_width(draw);
+        pango_context_set_base_dir(pango_layout_get_context(data->layout),PANGO_DIRECTION_LTR);
+	for (i = 0; i < n_requests;) {
+		k=i;
+		x=requests[i].x; expected_x_limit=x+cw;
+		y=requests[i].y;
+		for (j=0; i<n_requests && y==requests[k+j].y && requests[k+j].x<expected_x_limit && j<RUN_MAX ;) {
+			text_run[j]=requests[k+j].c;
+			expected_x_limit+=cw;
+			++j;
+			++i;
+		}
+		buf=g_ucs4_to_utf8(text_run,j,NULL,&length,NULL);
 		pango_layout_set_text(data->layout, buf, length);
-		gdk_draw_layout(draw->widget->window, data->gc,
-				requests[i].x, requests[i].y,
-				data->layout);
+		gdk_draw_layout(draw->widget->window, data->gc, x, y, data->layout);
+		g_free(buf);
 	}
 }
 
diff -aur vte-0.16.13_orig/src/vtepangox.c vte-0.16.13/src/vtepangox.c
--- vte-0.16.13_orig/src/vtepangox.c	2007-11-28 15:55:16.000000000 +0200
+++ vte-0.16.13/src/vtepangox.c	2008-06-13 01:31:36.617325248 +0300
@@ -16,7 +16,10 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-
+/*
+ * Copyright (C) 2008, Muayyad Alsadi <Alsadi@ojuba.org>
+ * Adding BiDi and shapping support
+ */
 #include "../config.h"
 
 #ifndef X_DISPLAY_MISSING
@@ -379,6 +382,7 @@
 	return FALSE;
 }
 
+#define RUN_MAX 512
 static void
 _vte_pango_x_draw_text(struct _vte_draw *draw,
 		       struct _vte_draw_text_request *requests,
@@ -388,8 +392,11 @@
 	Display *display;
 	GC gc;
 	struct _vte_pango_x_data *data;
-	char buf[VTE_UTF8_BPC];
-	gsize i, length;
+	char *buf;
+	gunichar text_run[RUN_MAX];
+	gshort x,y,expected_x_limit;
+	glong length;
+	gsize i,j,k,cw;
 	GdkColor wcolor;
 
 	data = (struct _vte_pango_x_data*) draw->impl_data;
@@ -400,16 +407,27 @@
 	gdk_gc_set_foreground(data->gc, &wcolor);
 	display = gdk_x11_drawable_get_xdisplay(draw->widget->window);
 	gc = gdk_x11_gc_get_xgc(data->gc);
+        pango_context_set_base_dir(data->ctx,PANGO_DIRECTION_LTR);
+	for (i = 0; i < n_requests;) {
+		k=i;
+		x=requests[i].x; expected_x_limit=x+cw;
+		y=requests[i].y;
+		for (j=0; i<n_requests && y==requests[k+j].y && requests[k+j].x<expected_x_limit && j<RUN_MAX ;) {
+			text_run[j]=requests[k+j].c;
+			expected_x_limit+=cw;
+			++j;
+			++i;
+		}
 
-	for (i = 0; i < n_requests; i++) {
-		length = g_unichar_to_utf8(requests[i].c, buf);
+		buf=g_ucs4_to_utf8(text_run,j,NULL,&length,NULL);
 		pango_layout_set_text(data->layout, buf, length);
 		pango_x_render_layout(display,
 				      data->drawable,
 				      gc,
 				      data->layout,
-				      requests[i].x - data->x_offs,
-				      requests[i].y - data->y_offs);
+				      x - data->x_offs,
+				      y - data->y_offs);
+		g_free(buf);
 	}
 }
 
