diff -w -r -up pango-1.2.1/pango/break.c pango-1.2.1.dov/pango/break.c
--- pango-1.2.1/pango/break.c	2001-12-06 14:51:49.000000000 -0500
+++ pango-1.2.1.dov/pango/break.c	2003-04-21 07:29:03.000000000 -0400
@@ -1528,4 +1528,3 @@ pango_get_log_attrs (const char    *text
                  log_attrs + chars_broken,
                  attrs_len - chars_broken);
 }
-
diff -w -r -up pango-1.2.1/pango/mini-fribidi/fribidi.c pango-1.2.1.dov/pango/mini-fribidi/fribidi.c
--- pango-1.2.1/pango/mini-fribidi/fribidi.c	2002-01-10 16:28:47.000000000 -0500
+++ pango-1.2.1.dov/pango/mini-fribidi/fribidi.c	2003-04-21 07:16:48.000000000 -0400
@@ -1068,7 +1068,20 @@ pango_log2vis_get_embedding_levels (	/* 
 
   DBG ("Entering fribidi_log2vis_get_embedding_levels()\n");
 
-  fribidi_base_dir = (*pbase_dir == PANGO_DIRECTION_LTR) ? FRIBIDI_TYPE_L : FRIBIDI_TYPE_R;
+  switch (*pbase_dir) {
+  case PANGO_DIRECTION_LTR:
+    fribidi_base_dir = FRIBIDI_TYPE_L;
+    break;
+  case PANGO_DIRECTION_RTL:
+    fribidi_base_dir = FRIBIDI_TYPE_R;
+    break;
+  case PANGO_DIRECTION_WEAK_RTL:
+    fribidi_base_dir = FRIBIDI_TYPE_WR;
+    break;
+  default:
+    fribidi_base_dir = FRIBIDI_TYPE_WL;
+    break;
+  }
 
   if (len == 0)
     {
@@ -1097,3 +1110,23 @@ pango_log2vis_get_embedding_levels (	/* 
   DBG ("Leaving fribidi_log2vis_get_embedding_levels()\n");
   return TRUE;
 }
+
+/**
+ * pango_unichar_direction:
+ * @ch: character to examine
+ *
+ * Returns the BiDi direction of a unicode character.
+ */
+PangoDirection
+pango_unichar_direction (gunichar ch)
+{
+  FriBidiCharType fribidi_ch_type = _pango_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;
+}
+
diff -w -r -up pango-1.2.1/pango/pango-context.h pango-1.2.1.dov/pango/pango-context.h
--- pango-1.2.1/pango/pango-context.h	2001-11-18 18:23:14.000000000 -0500
+++ pango-1.2.1.dov/pango/pango-context.h	2003-02-27 21:01:07.000000000 -0500
@@ -77,6 +77,7 @@ void                      pango_context_
 void                      pango_context_set_base_dir         (PangoContext               *context,
 							      PangoDirection              direction);
 PangoDirection            pango_context_get_base_dir         (PangoContext               *context);
+PangoDirection            pango_context_get_resolved_base_dir(PangoContext               *context);
 
 /* Break a string of Unicode characters into segments with
  * consistent shaping/language engine and bidrectional level.
diff -w -r -up pango-1.2.1/pango/pango-enum-types.c pango-1.2.1.dov/pango/pango-enum-types.c
--- pango-1.2.1/pango/pango-enum-types.c	2003-01-29 12:50:40.000000000 -0500
+++ pango-1.2.1.dov/pango/pango-enum-types.c	2003-04-21 07:20:05.000000000 -0400
@@ -224,6 +224,9 @@ pango_direction_get_type (void)
       { PANGO_DIRECTION_RTL, "PANGO_DIRECTION_RTL", "rtl" },
       { PANGO_DIRECTION_TTB_LTR, "PANGO_DIRECTION_TTB_LTR", "ttb-ltr" },
       { PANGO_DIRECTION_TTB_RTL, "PANGO_DIRECTION_TTB_RTL", "ttb-rtl" },
+      { PANGO_DIRECTION_WEAK_LTR, "PANGO_DIRECTION_WEAK_LTR", "weak-ltr" },
+      { PANGO_DIRECTION_WEAK_RTL, "PANGO_DIRECTION_WEAK_RTL", "weak-rtl" },
+      { PANGO_DIRECTION_NEUTRAL, "PANGO_DIRECTION_NEUTRAL", "neutral" },
       { 0, NULL, NULL }
     };
     etype = g_enum_register_static ("PangoDirection", values);
diff -w -r -up pango-1.2.1/pango/pango-types.h pango-1.2.1.dov/pango/pango-types.h
--- pango-1.2.1/pango/pango-types.h	2001-09-18 16:05:17.000000000 -0400
+++ pango-1.2.1.dov/pango/pango-types.h	2003-02-27 20:37:56.000000000 -0500
@@ -73,7 +73,10 @@ typedef enum {
   PANGO_DIRECTION_LTR,
   PANGO_DIRECTION_RTL,
   PANGO_DIRECTION_TTB_LTR,
-  PANGO_DIRECTION_TTB_RTL
+  PANGO_DIRECTION_TTB_RTL,
+  PANGO_DIRECTION_WEAK_LTR,
+  PANGO_DIRECTION_WEAK_RTL,
+  PANGO_DIRECTION_NEUTRAL
 } PangoDirection;
 
 #define PANGO_TYPE_LANGUAGE (pango_language_get_type ())
diff -w -r -up pango-1.2.1/pango/pango-utils.c pango-1.2.1.dov/pango/pango-utils.c
--- pango-1.2.1/pango/pango-utils.c	2002-12-06 19:00:53.000000000 -0500
+++ pango-1.2.1.dov/pango/pango-utils.c	2003-04-21 08:10:35.000000000 -0400
@@ -1244,7 +1244,20 @@ 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:
+    fribidi_base_dir = FRIBIDI_TYPE_L;
+    break;
+  case PANGO_DIRECTION_RTL:
+    fribidi_base_dir = FRIBIDI_TYPE_R;
+    break;
+  case PANGO_DIRECTION_WEAK_RTL:
+    fribidi_base_dir = FRIBIDI_TYPE_WR;
+    break;
+  default:
+    fribidi_base_dir = FRIBIDI_TYPE_WL;
+    break;
+  }
 
   result = fribidi_log2vis_get_embedding_levels (str, len, &fribidi_base_dir,
 						 embedding_level_list);
@@ -1254,7 +1267,6 @@ pango_log2vis_get_embedding_levels (guni
   return result;
 }
 
-
 gboolean 
 pango_get_mirror_char (gunichar        ch,
 		       gunichar       *mirrored_ch)
@@ -1495,3 +1507,44 @@ pango_lookup_aliases (const char   *font
       *n_families = 0;
     }
 }
+
+/**
+ * pango_find_base_dir:
+ * @text:      the text to process
+ * @length:    length of @text in bytes (may be -1 if @text is nul-terminated)
+ *
+ * Searches a string the first character that has a strong and
+ * BiDi property. 
+ *
+ * Return value: The direction corresponding to the first strong character.
+ * If no such character is found, then PANGO_DIRECTION_NEUTRAL is returned.
+ */
+PangoDirection
+pango_find_base_dir(const gchar *text,
+		    gint         length
+		    )
+{
+  const gchar *p = text;
+  const gchar *end;
+  PangoDirection dir = PANGO_DIRECTION_NEUTRAL;
+
+  if (length < 0)
+    length = strlen (text);
+  
+  end = text + length;
+
+  while (p != end)
+    {
+      gunichar wc = g_utf8_get_char (p);
+
+      dir = pango_unichar_direction (wc);
+
+      if (dir != PANGO_DIRECTION_NEUTRAL)
+	break;
+
+      p = g_utf8_next_char (p);
+    }
+
+  return dir;
+}
+
diff -w -r -up pango-1.2.1/pango/pango-utils.h pango-1.2.1.dov/pango/pango-utils.h
--- pango-1.2.1/pango/pango-utils.h	2001-11-18 11:06:01.000000000 -0500
+++ pango-1.2.1.dov/pango/pango-utils.h	2003-04-21 07:44:25.000000000 -0400
@@ -91,5 +91,15 @@ gboolean pango_log2vis_get_embedding_lev
 gboolean pango_get_mirror_char              (gunichar        ch,
 					     gunichar       *mirrored_ch);
 
+
 G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language);
 
+PangoDirection pango_unichar_direction      (gunichar ch);
+
+
+/* Resolve and find the base direction of a string according to the
+   Bidi algorithm. */
+
+PangoDirection pango_find_base_dir          (const gchar *text,
+					     gint         length);
+
