Index: configure.in
===================================================================
RCS file: /cvs/gnome/pango/configure.in,v
retrieving revision 1.208
diff -u -p -r1.208 configure.in
--- configure.in	15 Aug 2005 22:45:13 -0000	1.208
+++ configure.in	25 Sep 2005 23:39:00 -0000
@@ -205,13 +205,27 @@ else
 fi
 AM_CONDITIONAL(HAVE_X, $have_x) 
 
-#
-# Check for fontconfig
-#
 have_fontconfig=false
 have_freetype=false
 have_xft=false
+have_fribidi=false
+
+#
+# Check for fribidi
+#
+AC_ARG_WITH(fribidi,
+	    AC_HELP_STRING([--with-fribidi],
+	    		   [use GNU FriBidi installed on the system]),
+	    test $withval = "yes" && have_fribidi=true, :)
 
+if $have_fribidi ; then
+  PKG_CHECK_MODULES(FRIBIDI, fribidi >= 0.10.4)
+  AC_DEFINE(HAVE_FRIBIDI, 1, [Using GNU FriBidi installed on the system])
+fi
+
+#
+# Check for fontconfig
+#
 PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 1.0.1, have_fontconfig=true, :)
 
 if $have_fontconfig ; then
@@ -296,6 +310,7 @@ if $have_cairo ; then
   LDFLAGS=$pango_save_ldflags
 fi
 
+AM_CONDITIONAL(HAVE_FRIBIDI, $have_fribidi)
 AM_CONDITIONAL(HAVE_CAIRO, $have_cairo)
 AM_CONDITIONAL(HAVE_CAIRO_WIN32, $have_cairo_win32 && $have_win32)
 AM_CONDITIONAL(HAVE_CAIRO_FREETYPE, $have_cairo_freetype && $have_freetype)
Index: docs/tmpl/main.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/main.sgml,v
retrieving revision 1.36
diff -u -p -r1.36 main.sgml
--- docs/tmpl/main.sgml	21 Jul 2005 13:55:18 -0000	1.36
+++ docs/tmpl/main.sgml	25 Sep 2005 23:39:00 -0000
@@ -296,18 +296,6 @@ The GObject type for #PangoDirection.
 @Returns: 
 
 
-<!-- ##### FUNCTION pango_unichar_direction ##### -->
-<para>
-Determines the direction of a character; either
-%PANGO_DIRECTION_LTR, %PANGO_DIRECTION_RTL, or
-%PANGO_DIRECTION_NEUTRAL.
-</para>
-
-@ch: character to examine
-@Returns:  the direction of a character, as used in the
-  Unicode bidirectional algorithm.
-
-
 <!-- ##### FUNCTION pango_find_base_dir ##### -->
 <para>
 
Index: pango/Makefile.am
===================================================================
RCS file: /cvs/gnome/pango/pango/Makefile.am,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile.am
--- pango/Makefile.am	22 Sep 2005 15:00:39 -0000	1.123
+++ pango/Makefile.am	25 Sep 2005 23:39:00 -0000
@@ -8,7 +8,12 @@ if HAVE_FREETYPE
 OPENTYPE_SUBDIR=opentype
 endif
 
-SUBDIRS = $(OPENTYPE_SUBDIR) mini-fribidi
+if HAVE_FRIBIDI
+else
+FRIBIDI_SUBDIR=mini-fribidi
+endif
+
+SUBDIRS = $(OPENTYPE_SUBDIR) $(FRIBIDI_SUBDIR)
 
 DIST_SUBDIRS = mini-fribidi opentype
 
@@ -42,8 +47,16 @@ endif
 lib_LTLIBRARIES = libpango-1.0.la
 
 libpango_1_0_la_LDFLAGS = $(LIBRARY_LIBTOOL_OPTIONS)
-libpango_1_0_la_LIBADD = $(GLIB_LIBS) mini-fribidi/libmini-fribidi.la $(libm)
-libpango_1_0_la_DEPENDENCIES = mini-fribidi/libmini-fribidi.la
+libpango_1_0_la_LIBADD = $(GLIB_LIBS) $(libm)
+libpango_1_0_la_DEPENDENCIES = 
+
+if HAVE_FRIBIDI
+libpango_1_0_la_LIBADD += $(FRIBIDI_LIBS)
+INCLUDES += $(FRIBIDI_CFLAGS)
+else
+libpango_1_0_la_LIBADD += mini-fribidi/libmini-fribidi.la
+libpango_1_0_la_DEPENDENCIES += mini-fribidi/libmini-fribidi.la
+endif
 
 if OS_WIN32
 libpango_1_0_la_LDFLAGS += -export-symbols $(srcdir)/pango.def -Wl,pango-win32-res.o
Index: pango/pango-utils.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-utils.c,v
retrieving revision 1.59
diff -u -p -r1.59 pango-utils.c
--- pango/pango-utils.c	27 Jul 2005 22:14:46 -0000	1.59
+++ pango/pango-utils.c	25 Sep 2005 23:39:00 -0000
@@ -32,7 +32,9 @@
 #include <glib/gstdio.h>
 
 #ifdef HAVE_FRIBIDI
-#include <fribidi/fribidi.h>
+#  include <fribidi/fribidi.h>
+#else
+#  include <mini-fribidi/fribidi.h>
 #endif
 
 #ifndef HAVE_FLOCKFILE
@@ -1402,8 +1404,6 @@ pango_language_get_sample_string (PangoL
   return result;
 }
 
-#ifdef HAVE_FRIBIDI
-
 gboolean
 pango_log2vis_get_embedding_levels (gunichar       *str,
 				    int             len,
@@ -1413,17 +1413,63 @@ pango_log2vis_get_embedding_levels (guni
   FriBidiCharType fribidi_base_dir;
   gboolean result;
 
-  fribidi_base_dir = (*pbase_dir == PANGO_DIRECTION_LTR) ? FRIBIDI_TYPE_L : FRIBIDI_TYPE_R;
+  switch (*pbase_dir)
+    {
+    case PANGO_DIRECTION_LTR:
+    case PANGO_DIRECTION_TTB_RTL:
+      fribidi_base_dir = FRIBIDI_TYPE_L;
+      break;
+    case PANGO_DIRECTION_RTL:
+    case PANGO_DIRECTION_TTB_LTR:
+      fribidi_base_dir = FRIBIDI_TYPE_R;
+      break;
+    case PANGO_DIRECTION_WEAK_RTL:
+      fribidi_base_dir = FRIBIDI_TYPE_WR;
+      break;
+    /*
+    case PANGO_DIRECTION_WEAK_LTR:
+    case PANGO_DIRECTION_NEUTRAL:
+    */
+    default:
+      fribidi_base_dir = FRIBIDI_TYPE_WL;
+      break;
+    }
+
+  /* make sure fribidi does not go insane */
+  if (sizeof (gunichar) != sizeof (FriBidiChar))
+    g_assert_not_reached ();
 
-  result = fribidi_log2vis_get_embedding_levels (str, len, &fribidi_base_dir,
-						 embedding_level_list);
+  result = fribidi_log2vis_get_embedding_levels ((FriBidiChar*)str, len, &fribidi_base_dir,
+						 (gint8*)embedding_level_list);
   
   *pbase_dir = (fribidi_base_dir == FRIBIDI_TYPE_L) ?  PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
 
   return result;
 }
 
-#endif /* HAVE_FRIBIDI */
+/**
+ * pango_unichar_direction:
+ * @ch: a unicode character
+ *
+ * Determines the direction of a character; either
+ * %PANGO_DIRECTION_LTR, %PANGO_DIRECTION_RTL, or
+ * %PANGO_DIRECTION_NEUTRAL.
+ *
+ * Return value: the direction of the character, as used in the
+ * Unicode bidirectional algorithm.
+ */
+PangoDirection
+pango_unichar_direction (gunichar ch)
+{
+  FriBidiCharType fribidi_ch_type = fribidi_get_type (ch);
+
+  if (!FRIBIDI_IS_LETTER (fribidi_ch_type))
+    return PANGO_DIRECTION_NEUTRAL;
+  else if (FRIBIDI_IS_RTL (fribidi_ch_type))
+    return PANGO_DIRECTION_RTL;
+  else
+    return PANGO_DIRECTION_LTR;
+}
 
 /**
  * pango_get_mirror_char:
