Index: ftxgsub.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgsub.c,v
retrieving revision 1.15
diff -u -p -r1.15 ftxgsub.c
--- ftxgsub.c	28 Jul 2003 22:28:37 -0000	1.15
+++ ftxgsub.c	15 Sep 2003 11:24:54 -0000
@@ -4319,11 +4317,14 @@
                                  FT_UShort        feature_index,
                                  FT_UShort        property )
   {
-    FT_UShort    i;
+    FT_UShort    i, j;
 
     TTO_Feature  feature;
     FT_UShort*   properties;
+    FT_UShort*   apply_order;
+    
     FT_UShort*   index;
+    FT_UShort    lookup;
 
 
     if ( !gsub ||
@@ -4331,12 +4332,30 @@
       return TT_Err_Invalid_Argument;
 
     properties = gsub->LookupList.Properties;
+    apply_order = gsub->LookupList.ApplyOrder;
 
     feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
     index   = feature.LookupListIndex;
 
     for ( i = 0; i < feature.LookupListCount; i++ )
-      properties[index[i]] |= property;
+      {
+	lookup = index[i];
+
+	/* We assume here lookup can be applied only once; if features
+	 * could be applied more than once, we'd need to dynamically
+	 * reserve space in ApplyOrder.
+	 */
+	for ( j = 0; j < gsub->LookupList.ApplyCount; j++ )
+	  if ( apply_order[j] == lookup )
+	    goto next_lookup;
+
+	apply_order[j] = lookup;
+	gsub->LookupList.ApplyCount++;
+	
+	properties[lookup] |= property;
+	
+      next_lookup: ;
+      }
 
     return TT_Err_Ok;
   }
@@ -4358,6 +4377,8 @@
     for ( i = 0; i < gsub->LookupList.LookupCount; i++ )
       properties[i] = 0;
 
+    gsub->LookupList.ApplyCount = 0;
+
     return TT_Err_Ok;
   }
 
@@ -4464,6 +4485,8 @@
     TTO_GSUB_String*  t;
 
     FT_UShort*        properties;
+    FT_UShort*        apply_order;
+    FT_UShort         apply_count;
 
 
     if ( !gsub ||
@@ -4471,6 +4494,8 @@
       return TT_Err_Invalid_Argument;
 
     properties = gsub->LookupList.Properties;
+    apply_order = gsub->LookupList.ApplyOrder;
+    apply_count = gsub->LookupList.ApplyCount;
     
     tmp1.memory      = memory;
     tmp1.length      = in->length;
@@ -4516,10 +4541,9 @@
     MEM_Copy( tmp1.logClusters, in->logClusters,
 	      in->length * sizeof( FT_Int ) );
 
-    for ( j = 0; j < gsub->LookupList.LookupCount; j++ )
-      if ( properties[j] )
+    for ( j = 0; j < apply_count; j++ )
       {
-        error = Do_String_Lookup( gsub, j, ptmp1, ptmp2 );
+        error = Do_String_Lookup( gsub, apply_order[j], ptmp1, ptmp2 );
         if ( error )
 	{
 	  if ( error != TTO_Err_Not_Covered )
Index: ftxopen.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxopen.c,v
retrieving revision 1.10
diff -u -p -r1.10 ftxopen.c
--- ftxopen.c	26 Jul 2003 13:20:52 -0000	1.10
+++ ftxopen.c	15 Sep 2003 11:24:54 -0000
@@ -701,7 +701,11 @@
     if ( ALLOC_ARRAY( ll->Lookup, count, TTO_Lookup ) )
       return error;
     if ( ALLOC_ARRAY( ll->Properties, count, FT_UShort ) )
+      goto Fail3;
+    
+    if ( ALLOC_ARRAY( ll->ApplyOrder, count, FT_UShort ) )
       goto Fail2;
+    ll->ApplyCount =0;
 
     l = ll->Lookup;
 
@@ -724,12 +728,16 @@
     return TT_Err_Ok;
 
   Fail1:
-    FREE( ll->Properties );
+    FREE( ll->ApplyOrder );
 
     for ( m = 0; m < n; m++ )
       Free_Lookup( &l[m], type, memory );
 
   Fail2:
+    FREE( ll->Properties );
+    return error;
+    
+  Fail3:
     FREE( ll->Lookup );
     return error;
   }
@@ -745,6 +753,7 @@
 
 
     FREE( ll->Properties );
+    FREE( ll->ApplyOrder );
 
     if ( ll->Lookup )
     {
Index: ftxopen.h
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxopen.h,v
retrieving revision 1.3
diff -u -p -r1.3 ftxopen.h
--- ftxopen.h	26 Jul 2003 03:14:23 -0000	1.3
+++ ftxopen.h	15 Sep 2003 11:24:54 -0000
@@ -150,6 +150,8 @@ extern "C" {
     FT_UShort    LookupCount;           /* number of Lookups       */
     TTO_Lookup*  Lookup;                /* array of Lookup records */
     FT_UShort*   Properties;            /* array of flags          */
+    FT_UShort*   ApplyOrder;            /* order to apply lookups  */
+    FT_UShort    ApplyCount;	        /* number of elements in ApplyOrder */
   };
 
   typedef struct TTO_LookupList_  TTO_LookupList;
