diff -rdu pango-head-040727-0020/pango/opentype/ftxgpos.c patchedPango/pango/opentype/ftxgpos.c
--- pango-head-040727-0020/pango/opentype/ftxgpos.c	2004-07-26 23:29:02.000000000 +0430
+++ patchedPango/pango/opentype/ftxgpos.c	2004-07-27 13:01:12.000000000 +0430
@@ -6060,6 +6060,11 @@
          feature_index >= gpos->FeatureList.FeatureCount )
       return TT_Err_Invalid_Argument;
 
+    /* 
+	Filling feature list ApplyCount by order of features listed in the RuleSet
+    */
+    gpos->FeatureList.ApplyOrder[gpos->FeatureList.ApplyCount++] = feature_index;
+
     properties = gpos->LookupList.Properties;
 
     feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;
@@ -6088,6 +6093,8 @@
     for ( i = 0; i < gpos->LookupList.LookupCount; i++ )
       properties[i] = 0;
 
+    gpos->FeatureList.ApplyCount = 0;
+
     return TT_Err_Ok;
   }
 
@@ -6133,7 +6140,11 @@
     FT_Error       error, retError = TTO_Err_Not_Covered;
     GPOS_Instance  gpi;
 
-    FT_UShort j;
+    FT_UShort index,
+	      i,
+	      j;
+
+    TTO_Feature feature;
 
     FT_UShort* properties;
 
@@ -6149,20 +6160,29 @@
     gpi.load_flags = load_flags;
     gpi.r2l        = r2l;
     gpi.dvi        = dvi;
+    for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ )
+    { 
+      /* index of i'th feature */
+      index = gpos->FeatureList.ApplyOrder[i];
+      
+      if( index >= gpos->FeatureList.FeatureCount )
+        continue;
 
-    for ( j = 0; j < gpos->LookupList.LookupCount; j++ )
-      if ( !properties || properties[j] )
-      {
-        error = Do_String_Lookup( &gpi, j, buffer );
-	if ( error )
-	  {
-	    if ( error != TTO_Err_Not_Covered )
-	      return error;
-	  }
-	else
-	  retError = error;
-      }
+      feature = gpos->FeatureList.FeatureRecord[index].Feature;
 
+      for ( j = 0; j < feature.LookupListCount; j++ )
+        if ( !properties || properties[feature.LookupListIndex[j]] )
+          {
+            error = Do_String_Lookup( &gpi, feature.LookupListIndex[j], buffer );
+            if ( error )
+	      {
+	        if ( error != TTO_Err_Not_Covered )
+	        return error;
+	      }
+              else
+	        retError = error;
+          }
+    }
     error = Position_CursiveChain ( buffer );
     if ( error )
       return error;
diff -rdu pango-head-040727-0020/pango/opentype/ftxgsub.c patchedPango/pango/opentype/ftxgsub.c
--- pango-head-040727-0020/pango/opentype/ftxgsub.c	2004-07-26 23:55:45.000000000 +0430
+++ patchedPango/pango/opentype/ftxgsub.c	2004-07-27 13:54:23.436174874 +0430
@@ -4068,6 +4068,11 @@
          feature_index >= gsub->FeatureList.FeatureCount )
       return TT_Err_Invalid_Argument;
 
+    /* 
+	Filling feature list ApplyCount by order of features listed in the RuleSet
+    */
+    gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index;
+
     properties = gsub->LookupList.Properties;
 
     feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
@@ -4096,6 +4101,8 @@
     for ( i = 0; i < gsub->LookupList.LookupCount; i++ )
       properties[i] = 0;
 
+    gsub->FeatureList.ApplyCount = 0;
+
     return TT_Err_Ok;
   }
 
@@ -4120,33 +4127,43 @@
 				  OTL_Buffer        buffer )
   {
     FT_Error          error, retError = TTO_Err_Not_Covered;
-    FT_UShort         j;
+    FT_UShort         j,
+		      i,
+		      index;
+
+    TTO_Feature feature;
 
     FT_UShort*        properties;
 
     if ( !gsub ||
-         !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length )
+         !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length || !(gsub->FeatureList.ApplyOrder) )
       return TT_Err_Invalid_Argument;
 
     properties = gsub->LookupList.Properties;
-    
-    for ( j = 0; j < gsub->LookupList.LookupCount; j++ )
-      if ( properties[j] )
-      {
-        error = Do_String_Lookup( gsub, j, buffer );
-        if ( error )
-	{
-	  if ( error != TTO_Err_Not_Covered )
+    for ( i = 0; i < gsub->FeatureList.ApplyCount; i++)
+    {
+      index = gsub->FeatureList.ApplyOrder[i];
+      if( index >= gsub->FeatureList.FeatureCount )
+         continue;
+      feature = gsub->FeatureList.FeatureRecord[index].Feature;
+
+      for ( j = 0; j < feature.LookupListCount; j++ )
+        if ( properties[feature.LookupListIndex[j]] )
+        {
+          error = Do_String_Lookup( gsub, feature.LookupListIndex[j], buffer );
+          if ( error )
+	  {
+	      if ( error != TTO_Err_Not_Covered )
+	      goto End;
+          }
+	  else
+	    retError = error;
+        
+	  error = otl_buffer_swap( buffer );
+	  if ( error )
 	    goto End;
-	}
-	else
-	  retError = error;
-	  
-	error = otl_buffer_swap( buffer );
-	if ( error )
-	  goto End;
-      }
-    
+       } 
+    } 
     error = retError;
 
   End:
diff -rdu pango-head-040727-0020/pango/opentype/ftxopen.c patchedPango/pango/opentype/ftxopen.c
--- pango-head-040727-0020/pango/opentype/ftxopen.c	2003-11-01 18:32:17.000000000 +0330
+++ patchedPango/pango/opentype/ftxopen.c	2004-07-27 13:01:12.000000000 +0430
@@ -373,6 +373,10 @@
 
     if ( ALLOC_ARRAY( fl->FeatureRecord, count, TTO_FeatureRecord ) )
       return error;
+    
+    if ( ALLOC_ARRAY( fl->ApplyOrder, count, FT_UShort ) )
+      goto Fail;
+    fl->ApplyCount = 0;
 
     fr = fl->FeatureRecord;
 
@@ -400,6 +404,10 @@
       Free_Feature( &fr[m].Feature, memory );
 
     FREE( fl->FeatureRecord );
+
+    if( fl->ApplyOrder )
+      FREE( fl->ApplyOrder );
+
     return error;
   }
 
diff -rdu pango-head-040727-0020/pango/opentype/ftxopen.h patchedPango/pango/opentype/ftxopen.h
--- pango-head-040727-0020/pango/opentype/ftxopen.h	2004-02-29 19:14:50.000000000 +0330
+++ patchedPango/pango/opentype/ftxopen.h	2004-07-27 13:01:13.000000000 +0430
@@ -117,6 +117,9 @@
   {
     FT_UShort           FeatureCount;   /* number of FeatureRecords */
     TTO_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */
+    FT_UShort*		ApplyOrder;	/* order to apply features */
+    FT_UShort		ApplyCount;	/* number of elements in ApplyOrder */
+
   };
 
   typedef struct TTO_FeatureList_  TTO_FeatureList;

