Index: modules/arabic/arabic-fc.c
===================================================================
RCS file: /usr/local/cvsroot/pango/modules/arabic/arabic-fc.c,v
retrieving revision 1.3
diff -d -u -b -B -r1.3 arabic-fc.c
--- modules/arabic/arabic-fc.c	28 Dec 2003 12:08:39 -0000	1.3
+++ modules/arabic/arabic-fc.c	27 Jan 2004 14:09:58 -0000
@@ -48,6 +47,51 @@
   }
 };
 
+static PangoGlyph has_dotted_circle ( PangoFcFont* fc_font )
+{
+  gunichar dotted_circle = 0x25CC;
+  return pango_fc_font_get_glyph (fc_font, dotted_circle);
+}
+
+#define IS_ARABIC(wc) ((wc) >= 0x0600 && (wc) < 0x0700)
+
+static int count_dotted_circle(gunichar* text, 
+                               int length, 
+                               int dotted_circle_index, 
+                               gushort *a)
+{
+  int i, j, is_orphan = 1, dotted_circle_count = 0;
+
+  if(!text)
+	return 0;
+
+  for ( i = 0; i < length ; i++)
+    {
+      a[i] = 0;
+      if ( dotted_circle_index &&
+           IS_ARABIC(text[i]) && 
+           ARABIC_GET_MARKCLASS (text[i]) && 
+           (i == 0 || (IS_ARABIC(text[i-1]) && 
+                       ARABIC_GET_MARKCLASS (text[i-1]))))
+        {
+          if ( is_orphan || 
+               ( i != 0 && Arabic_Is_Confilicting(text[i], text[i-1])))
+            {
+              dotted_circle_count++;
+              a[i] = is_orphan ? 2 : 1;
+            }
+            else if (i > 2 && ARABIC_GET_MARKCLASS (text[i-2]) && !a[i-1])
+	           {
+                     dotted_circle_count++;
+	             a[i] = 1;
+                   }
+        }
+      else if (is_orphan) is_orphan = 0;
+    }
+  a[i]= a[i+1] = 0;
+  return dotted_circle_count;
+}
+
 static void
 maybe_add_gsub_feature (PangoOTRuleset *ruleset,
 			PangoOTInfo    *info,
 static void
 
@@ -175,12 +215,16 @@
 {
   int n_chars;
   int i;
+  int is_orphan = 1;
   const char *p;
+  gushort *a;
   gulong *properties = NULL;
   gunichar *wcs = NULL;
   FT_Face face;
   PangoOTRuleset *ruleset;
   PangoFcFont *fc_font;
+  PangoGlyph dotted_circle_index;
+  gulong dotted_circle_count = 0;
 
   g_return_if_fail (font != NULL);
   g_return_if_fail (text != NULL);
@@ -192,19 +234,25 @@
   face = pango_fc_font_lock_face (fc_font);
   g_assert (face);
 
+  dotted_circle_index = has_dotted_circle(fc_font);
   n_chars = g_utf8_strlen (text, length);
-  pango_glyph_string_set_size (glyphs, n_chars);
-
+  //pango_glyph_string_set_size (glyphs, n_chars * 2 + 16);
   ruleset = get_ruleset (face);
   if (ruleset)
     {
       wcs = g_utf8_to_ucs4_fast (text, length, NULL);
-      properties = g_new0 (gulong, n_chars);
+      a = g_new0(gushort, n_chars + 2);
+      dotted_circle_count = count_dotted_circle(wcs, n_chars, dotted_circle_index, a);
       
-      Arabic_Assign_Properties (wcs, properties, n_chars);
+      properties = g_new0 (gulong, n_chars + dotted_circle_count);
+  
+      Arabic_Assign_Properties (wcs, properties, n_chars, a);
     }
+  pango_glyph_string_set_size (glyphs, n_chars + dotted_circle_count);
   
   p = text;
+  dotted_circle_count = 0;
+
   for (i=0; i < n_chars; i++)
     {
       gunichar wc;
@@ -225,9 +272,13 @@
 	    input = buf;
 	  }
 
+      if ( a[i]) 
+        set_glyph (font, glyphs, i + dotted_circle_count++, 
+                   p - text, dotted_circle_index);
+   
       if (wc >= 0x200B && wc <= 0x200F)	/* Zero-width characters */
 	{
-	  set_glyph (font, glyphs, i, p - text, 0);
+	  set_glyph (font, glyphs, i + dotted_circle_count, p - text, 0);
 	}
       else
 	{
@@ -243,20 +294,19 @@
 #endif	  
 	  
 	  index = pango_fc_font_get_glyph (fc_font, wc);
-
 	  if (!index)
 	    {
-	      set_glyph (font, glyphs, i, p - text,
+	      set_glyph (font, glyphs, i + dotted_circle_count, p - text,
 			 pango_fc_font_get_unknown_glyph (fc_font, wc));
 	    }
 	  else
 	    {
-	      set_glyph (font, glyphs, i, p - text, index);
+	      set_glyph (font, glyphs, i + dotted_circle_count, p - text, index);
 	      
 	      if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK)
 		{
-		  if (i > 0)
-		    glyphs->log_clusters[i] = glyphs->log_clusters[i-1];
+		  if (i + dotted_circle_count > 0)
+		    glyphs->log_clusters[i + dotted_circle_count] = glyphs->log_clusters[i + dotted_circle_count -1];
 		}
 	    }
 	}
@@ -268,13 +318,13 @@
 
   if (ruleset)
     {
-      printf("begin\n");
       pango_ot_ruleset_substitute (ruleset, glyphs, properties);
 
       pango_ot_ruleset_position (ruleset, font, glyphs, properties,
 				 analysis->level % 2 != 0);
 
       g_free (wcs);
+      g_free(a);
       g_free (properties);
     }
   else
@@ -302,7 +352,6 @@
 	  swap_range (glyphs, 0, glyphs->num_glyphs);
 	}
     }
-  
   pango_fc_font_unlock_face (fc_font);
 }
 
Index: modules/arabic/arabic-ot.c
===================================================================
RCS file: /usr/local/cvsroot/pango/modules/arabic/arabic-ot.c,v
retrieving revision 1.2
diff -d -u -b -B -r1.2 arabic-ot.c
--- modules/arabic/arabic-ot.c	17 Dec 2003 10:55:38 -0000	1.2
+++ modules/arabic/arabic-ot.c	27 Jan 2004 14:12:25 -0000
@@ -251,7 +251,8 @@
 static joining_class  Get_Joining_Class (gunichar*   string,
 					 int         pos,
 					 int         length,
-					 int         direction)
+					 int         direction,
+                                         gushort       *a)
 {
   joining_class  j;
 
@@ -277,34 +278,53 @@
       else
         j =  arabic[string[pos] - 0x0620];
       
-      if (!direction || j != transparent)
+      if (!direction || (j != transparent))
         return j;
+      else if (direction == 1 ? a[pos+1]: a[pos])
+		return none;
     }
 }
 
 
+int Arabic_Is_Confilicting (gunichar wc1, gunichar wc2)
+{
+  if ( ARABIC_GET_MARKCLASS(wc1) == ARABIC_GET_MARKCLASS(wc2) ||
+       (ARABIC_GET_MARKCLASS(wc1) == 1 && ARABIC_GET_MARKCLASS(wc2) == 2) ||
+       (ARABIC_GET_MARKCLASS(wc2) == 1 && ARABIC_GET_MARKCLASS(wc1) == 2) )
+       return 1;
+  else return 0;
+
+}
+
 FT_Error  Arabic_Assign_Properties (gunichar    *string,
 				    gulong      *properties,
-				    int          length)
+				    int          length,
+                                    gushort       *a)
 {
   joining_class  previous, current, next;
 
   int      i;
-
+  int	   dotted_circle_count = 0;
+  int 	   is_orphan = 1;
+  int      is_after_dotted_circle = 0;
   if (!string || !properties || length == 0)
     return FT_Err_Invalid_Argument;
 
-  for (i = 0; i < length; i++)
+  for (i = 0; i < length ; i++)
     {
-      previous = Get_Joining_Class (string, i, length, -1);
-      current  = Get_Joining_Class (string, i, length,  0);
-      next     = Get_Joining_Class (string, i, length,  1);
+
+      if( a[i] )
+	properties[i + dotted_circle_count++] = isolated_p;
+  
+      previous = Get_Joining_Class (string, i, length, -1, a);
+      current  = Get_Joining_Class (string, i, length,  0, a);
+      next     = Get_Joining_Class (string, i, length,  1, a);
 
       /* R1 */
 
       if (current == transparent)
 	{
-	  properties[i] |= isolated_p;
+	  properties[i + dotted_circle_count] |= isolated_p;
 	  continue;
 	}
 
@@ -315,7 +335,7 @@
 	  previous == dual   )
         if (current == right)
 	  {
-	    properties[i] |= final_p;
+	    properties[i + dotted_circle_count] |= final_p;
 	    continue;
 	  }
 
@@ -326,7 +346,7 @@
 	    next == right   ||
 	    next == dual   )
 	  {
-	    properties[i] |= initial_p;
+	    properties[i + dotted_circle_count] |= initial_p;
 	    continue;
 	  }
 
@@ -340,7 +360,7 @@
 	      next == right   ||
 	      next == dual   )
 	    {
-	      properties[i] |= medial_p;
+	      properties[i+ dotted_circle_count] |= medial_p;
 	      continue;
 	    }
 
@@ -354,7 +374,7 @@
 		next == right   ||
 		next == dual   ))
 	    {
-	      properties[i] |= final_p;
+	      properties[i + dotted_circle_count] |= final_p;
 	      continue;
 	    }
 
@@ -368,13 +388,13 @@
 	      next == right   ||
 	      next == dual   )
 	    {
-	      properties[i] |= initial_p;
+	      properties[i + dotted_circle_count] |= initial_p;
 	      continue;
 	    }
 
       /* R7 */
 
-      properties[i] |= isolated_p;
+      properties[i + dotted_circle_count] |= isolated_p;
     }
 
   return FT_Err_Ok;
Index: modules/arabic/arabic-ot.h
===================================================================
RCS file: /usr/local/cvsroot/pango/modules/arabic/arabic-ot.h,v
retrieving revision 1.1.1.1
diff -d -u -b -B -r1.1.1.1 arabic-ot.h
--- modules/arabic/arabic-ot.h	17 Dec 2003 10:53:15 -0000	1.1.1.1
+++ modules/arabic/arabic-ot.h	20 Jan 2004 12:10:32 -0000
@@ -17,9 +17,11 @@
 /*                                                                          */
 /****************************************************************************/
 
-
+#ifndef ARABIC_OT_H
+#define ARABIC_OT_H
 #include <pango/pango-ot.h>
 
+#define ARABIC_GET_MARKCLASS(Char) (arabic_mark_class[Char - 0x0610])
 
 enum  joining_type_
 {
@@ -56,17 +58,118 @@
   transparent
 };
 
+static int  arabic_mark_class[] =
+{
+  /* U+0610 */
+  4, 4, 4, 4,
+  4, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+
+  /* U+0620 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0630 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0640 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 1,
+  1, 2, 1, 1,
+  
+  /* U+0650 */
+  2, 3, 1, 7,
+  8, 8, 2, 1,
+  1, 4, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0660 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0670 */
+  6, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0680 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+0690 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+06A0 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+06B0 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+06C0 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+
+  /* U+06D0 */
+  0, 0, 0, 0,
+  0, 0, 4, 4,
+  4, 4, 4, 4,
+  4, 0, 0, 4,
+
+  /* U+06E0 */
+  4, 1, 4, 5,
+  4, 0, 0, 4,
+  4, 0, 5, 4,
+  4, 5, 0, 0,
+
+  /* U+06F0 */
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+  0, 0, 0, 0,
+};
+
+
 typedef enum joining_class_  joining_class;
 
 
 FT_Error  Arabic_Assign_Properties (gunichar   *string,
 				    gulong     *properties,
-				    int         length);
+				    int         length,
+				    gushort    *a);
+
+int Arabic_Is_Confilicting (gunichar wc1, gunichar wc2);
+
+int Arabic_Is_Mark (gunichar wc);
+
 #if 0
 TT_Error  Build_Arabic_Glyph_Properties (TT_CharMap        char_map,
 					 TT_UShort         max_glyphs,
 					 TTO_GDEFHeader**  gdef );
 #endif
 
-
+#endif
 /* End */
