Index: pango/opentype/ftxgpos.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgpos.c,v
retrieving revision 1.26
diff -u -p -r1.26 ftxgpos.c
--- pango/opentype/ftxgpos.c	22 Sep 2004 18:14:55 -0000	1.26
+++ pango/opentype/ftxgpos.c	15 Mar 2005 09:33:54 -0000
@@ -1032,16 +1032,27 @@
     Free_Coverage( &sp->Coverage, memory );
   }
 
+  static FT_Error  Lookup_DefaultPos(  GPOS_Instance*    gpi,
+				       TTO_GPOS_SubTable* st,
+				       OTL_Buffer        buffer,
+				       FT_UShort         flags,
+				       FT_UShort         context_length,
+				       int               nesting_level )
+  {
+    return TTO_Err_Not_Covered;
+  }
 
   static FT_Error  Lookup_SinglePos( GPOS_Instance*    gpi,
-                                     TTO_SinglePos*    sp,
+                                     TTO_GPOS_SubTable* st,
 				     OTL_Buffer        buffer,
                                      FT_UShort         flags,
-                                     FT_UShort         context_length )
+                                     FT_UShort         context_length,
+                                     int               nesting_level )
   {
     FT_UShort        index, property;
     FT_Error         error;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_SinglePos*   sp = &st->single;
 
 
     if ( context_length != 0xFFFF && context_length < 1 )
@@ -1593,14 +1604,16 @@
 
 
   static FT_Error  Lookup_PairPos( GPOS_Instance*    gpi,
-                                   TTO_PairPos*      pp,
+                                   TTO_GPOS_SubTable* st,
 				   OTL_Buffer        buffer,
                                    FT_UShort         flags,
-                                   FT_UShort         context_length )
+                                   FT_UShort         context_length,
+                                   int               nesting_level )
   {
     FT_Error         error;
     FT_UShort        index, property, first_pos;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_PairPos*     pp = &st->pair;
 
 
     if ( buffer->in_pos >= buffer->in_length - 1 )
@@ -1799,14 +1812,16 @@
 
 
   static FT_Error  Lookup_CursivePos( GPOS_Instance*    gpi,
-                                      TTO_CursivePos*   cp,
+                                      TTO_GPOS_SubTable* st,
 				      OTL_Buffer        buffer,
                                       FT_UShort         flags,
-                                      FT_UShort         context_length )
+                                      FT_UShort         context_length,
+                                      int               nesting_level )
   {
     FT_UShort        index, property;
     FT_Error         error;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_CursivePos*  cp = &st->cursive;
 
     TTO_EntryExitRecord*  eer;
     FT_Pos                entry_x, entry_y;
@@ -2224,15 +2239,17 @@
 
 
   static FT_Error  Lookup_MarkBasePos( GPOS_Instance*    gpi,
-                                       TTO_MarkBasePos*  mbp,
+                                       TTO_GPOS_SubTable* st,
 				       OTL_Buffer        buffer,
                                        FT_UShort         flags,
-                                       FT_UShort         context_length )
+                                       FT_UShort         context_length,
+                                       int               nesting_level )
   {
     FT_UShort        i, j, mark_index, base_index, property, class;
     FT_Pos           x_mark_value, y_mark_value, x_base_value, y_base_value;
     FT_Error         error;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_MarkBasePos* mbp = &st->markbase;
 
     TTO_MarkArray*   ma;
     TTO_BaseArray*   ba;
@@ -2631,16 +2648,18 @@
 
 
   static FT_Error  Lookup_MarkLigPos( GPOS_Instance*    gpi,
-                                      TTO_MarkLigPos*   mlp,
+                                      TTO_GPOS_SubTable* st,
 				      OTL_Buffer        buffer,
                                       FT_UShort         flags,
-                                      FT_UShort         context_length )
+                                      FT_UShort         context_length,
+                                      int               nesting_level )
   {
     FT_UShort        i, j, mark_index, lig_index, property, class;
     FT_UShort        mark_glyph;
     FT_Pos           x_mark_value, y_mark_value, x_lig_value, y_lig_value;
     FT_Error         error;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_MarkLigPos*  mlp = &st->marklig;
 
     TTO_MarkArray*        ma;
     TTO_LigatureArray*    la;
@@ -2970,16 +2989,18 @@
 
 
   static FT_Error  Lookup_MarkMarkPos( GPOS_Instance*    gpi,
-                                       TTO_MarkMarkPos*  mmp,
+                                       TTO_GPOS_SubTable* st,
 				       OTL_Buffer        buffer,
                                        FT_UShort         flags,
-                                       FT_UShort         context_length )
+                                       FT_UShort         context_length,
+                                       int               nesting_level )
   {
     FT_UShort        j, mark1_index, mark2_index, property, class;
     FT_Pos           x_mark1_value, y_mark1_value,
                      x_mark2_value, y_mark2_value;
     FT_Error         error;
     TTO_GPOSHeader*  gpos = gpi->gpos;
+    TTO_MarkMarkPos* mmp = &st->markmark;
 
     TTO_MarkArray*    ma1;
     TTO_Mark2Array*   ma2;
@@ -4060,12 +4081,14 @@
 
 
   static FT_Error  Lookup_ContextPos( GPOS_Instance*    gpi,
-                                      TTO_ContextPos*   cp,
+                                      TTO_GPOS_SubTable* st,
 				      OTL_Buffer        buffer,
                                       FT_UShort         flags,
                                       FT_UShort         context_length,
                                       int               nesting_level )
   {
+    TTO_ContextPos*   cp = &st->context;
+
     switch ( cp->PosFormat )
     {
     case 1:
@@ -5548,12 +5571,14 @@
 
   static FT_Error  Lookup_ChainContextPos(
                      GPOS_Instance*        gpi,
-                     TTO_ChainContextPos*  ccp,
+		     TTO_GPOS_SubTable* st,
 		     OTL_Buffer            buffer,
                      FT_UShort             flags,
                      FT_UShort             context_length,
                      int                   nesting_level )
   {
+    TTO_ChainContextPos*  ccp = &st->chain;
+
     switch ( ccp->PosFormat )
     {
     case 1:
@@ -5868,6 +5893,25 @@
   }
 
 
+  typedef FT_Error  (*Lookup_Func_Type)  ( GPOS_Instance*    gpi,
+					   TTO_GPOS_SubTable* st,
+					   OTL_Buffer        buffer,
+					   FT_UShort         flags,
+					   FT_UShort         context_length,
+					   int               nesting_level );
+  static const Lookup_Func_Type Lookup_Call_Table[] = {
+    Lookup_DefaultPos,
+    Lookup_SinglePos,		/* GPOS_LOOKUP_SINGLE     1 */
+    Lookup_PairPos,		/* GPOS_LOOKUP_PAIR       2 */
+    Lookup_CursivePos,		/* GPOS_LOOKUP_CURSIVE    3 */
+    Lookup_MarkBasePos,		/* GPOS_LOOKUP_MARKBASE   4 */
+    Lookup_MarkLigPos,		/* GPOS_LOOKUP_MARKLIG    5 */
+    Lookup_MarkMarkPos,		/* GPOS_LOOKUP_MARKMARK   6 */
+    Lookup_ContextPos,		/* GPOS_LOOKUP_CONTEXT    7 */
+    Lookup_ChainContextPos,	/* GPOS_LOOKUP_CHAIN      8 */
+    Lookup_DefaultPos,		/* GPOS_LOOKUP_EXTENSION  9 */
+  };
+
   /* Do an individual subtable lookup.  Returns TT_Err_Ok if positioning
      has been done, or TTO_Err_Not_Covered if not.                        */
 
@@ -5881,6 +5925,8 @@
     FT_UShort        i, flags;
     TTO_GPOSHeader*  gpos = gpi->gpos;
     TTO_Lookup*      lo;
+    int		     lt;
+    Lookup_Func_Type Lookup_Func;
 
 
     nesting_level++;
@@ -5890,69 +5936,18 @@
 
     lo    = &gpos->LookupList.Lookup[lookup_index];
     flags = lo->LookupFlag;
+    lt = lo->LookupType;
+    if (lt >= sizeof Lookup_Call_Table / sizeof Lookup_Call_Table[0])
+      lt = 0;
+    Lookup_Func = Lookup_Call_Table[lt];
 
     for ( i = 0; i < lo->SubTableCount; i++ )
     {
-      switch ( lo->LookupType )
-      {
-      case GPOS_LOOKUP_SINGLE:
-        error = Lookup_SinglePos( gpi,
-                                  &lo->SubTable[i].st.gpos.single,
-                                  buffer,
-                                  flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_PAIR:
-        error = Lookup_PairPos( gpi,
-                                &lo->SubTable[i].st.gpos.pair,
-                                buffer,
-                                flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_CURSIVE:
-        error = Lookup_CursivePos( gpi,
-                                   &lo->SubTable[i].st.gpos.cursive,
-                                   buffer,
-                                   flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_MARKBASE:
-        error = Lookup_MarkBasePos( gpi,
-                                    &lo->SubTable[i].st.gpos.markbase,
-                                    buffer,
-                                    flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_MARKLIG:
-        error = Lookup_MarkLigPos( gpi,
-                                   &lo->SubTable[i].st.gpos.marklig,
-                                   buffer,
-                                   flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_MARKMARK:
-        error = Lookup_MarkMarkPos( gpi,
-                                    &lo->SubTable[i].st.gpos.markmark,
-                                    buffer,
-                                    flags, context_length );
-        break;
-
-      case GPOS_LOOKUP_CONTEXT:
-        error = Lookup_ContextPos( gpi,
-                                   &lo->SubTable[i].st.gpos.context,
-                                   buffer,
-                                   flags, context_length,
-                                   nesting_level );
-        break;
-
-      case GPOS_LOOKUP_CHAIN:
-        error = Lookup_ChainContextPos( gpi,
-                                        &lo->SubTable[i].st.gpos.chain,
-                                        buffer,
-                                        flags, context_length,
-                                        nesting_level );
-        break;
-      }
+      error = Lookup_Func ( gpi,
+			    &lo->SubTable[i].st.gpos,
+			    buffer,
+			    flags, context_length,
+			    nesting_level );
 
       /* Check whether we have a successful positioning or an error other
          than TTO_Err_Not_Covered                                         */
Index: pango/opentype/ftxgsub.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxgsub.c,v
retrieving revision 1.27
diff -u -p -r1.27 ftxgsub.c
--- pango/opentype/ftxgsub.c	22 Sep 2004 18:14:55 -0000	1.27
+++ pango/opentype/ftxgsub.c	15 Mar 2005 09:33:54 -0000
@@ -214,6 +214,16 @@
    * SubTable related functions
    *****************************/
 
+  static FT_Error  Lookup_DefaultSubst(  TTO_GSUBHeader*   gsub,
+					 TTO_GSUB_SubTable* st,
+					 OTL_Buffer        buffer,
+					 FT_UShort         flags,
+					 FT_UShort         context_length,
+					 int               nesting_level )
+  {
+    return TTO_Err_Not_Covered;
+  }
+
 
   /* LookupType 1 */
 
@@ -317,14 +327,17 @@
   }
 
 
-  static FT_Error  Lookup_SingleSubst( TTO_SingleSubst*  ss,
+  static FT_Error  Lookup_SingleSubst( TTO_GSUBHeader*   gsub,
+				       TTO_GSUB_SubTable* st,
 				       OTL_Buffer        buffer,
                                        FT_UShort         flags,
                                        FT_UShort         context_length,
-                                       TTO_GDEFHeader*   gdef )
+				       int               nesting_level )
   {
     FT_UShort index, value, property;
     FT_Error  error;
+    TTO_SingleSubst*  ss = &st->single;
+    TTO_GDEFHeader*   gdef = gsub->gdef;
 
 
     if ( context_length != 0xFFFF && context_length < 1 )
@@ -520,15 +533,18 @@
   }
 
 
-  static FT_Error  Lookup_MultipleSubst( TTO_MultipleSubst*  ms,
+  static FT_Error  Lookup_MultipleSubst( TTO_GSUBHeader*   gsub,
+					 TTO_GSUB_SubTable* st,
 					 OTL_Buffer          buffer,
                                          FT_UShort           flags,
                                          FT_UShort           context_length,
-                                         TTO_GDEFHeader*     gdef )
+					 int               nesting_level )
   {
     FT_Error  error;
     FT_UShort index, property, n, count;
     FT_UShort*s;
+    TTO_MultipleSubst*  ms = &st->multiple;
+    TTO_GDEFHeader*     gdef = gsub->gdef;
 
 
     if ( context_length != 0xFFFF && context_length < 1 )
@@ -717,14 +733,17 @@
 
 
   static FT_Error  Lookup_AlternateSubst( TTO_GSUBHeader*      gsub,
-                                          TTO_AlternateSubst*  as,
+					  TTO_GSUB_SubTable*   st,
 					  OTL_Buffer           buffer,
                                           FT_UShort            flags,
                                           FT_UShort            context_length,
-                                          TTO_GDEFHeader*      gdef )
+					  int                  nesting_level )
   {
     FT_Error          error;
     FT_UShort         index, alt_index, property;
+    TTO_AlternateSubst*  as = &st->alternate;
+    TTO_GDEFHeader*     gdef = gsub->gdef;
+
 
     TTO_AlternateSet  aset;
 
@@ -996,16 +1015,19 @@
   }
 
 
-  static FT_Error  Lookup_LigatureSubst( TTO_LigatureSubst*  ls,
+  static FT_Error  Lookup_LigatureSubst( TTO_GSUBHeader*     gsub,
+					 TTO_GSUB_SubTable* st,
 					 OTL_Buffer          buffer,
                                          FT_UShort           flags,
                                          FT_UShort           context_length,
-                                         TTO_GDEFHeader*     gdef )
+					 int                 nesting_level )
   {
     FT_UShort      index, property;
     FT_Error       error;
     FT_UShort      numlig, i, j, is_mark, first_is_mark = FALSE;
     FT_UShort*     c;
+    TTO_LigatureSubst*  ls = &st->ligature;
+    TTO_GDEFHeader*     gdef = gsub->gdef;
 
     TTO_Ligature*  lig;
 
@@ -2118,12 +2140,14 @@
 
 
   static FT_Error  Lookup_ContextSubst( TTO_GSUBHeader*    gsub,
-                                        TTO_ContextSubst*  cs,
+					TTO_GSUB_SubTable* st,
 					OTL_Buffer         buffer,
                                         FT_UShort          flags,
                                         FT_UShort          context_length,
                                         int                nesting_level )
   {
+    TTO_ContextSubst*  cs = &st->context;
+
     switch ( cs->SubstFormat )
     {
     case 1:
@@ -3610,12 +3634,14 @@
 
   static FT_Error  Lookup_ChainContextSubst(
                      TTO_GSUBHeader*         gsub,
-                     TTO_ChainContextSubst*  ccs,
+		     TTO_GSUB_SubTable*      st,
 		     OTL_Buffer              buffer,
                      FT_UShort               flags,
                      FT_UShort               context_length,
                      int                     nesting_level )
   {
+    TTO_ChainContextSubst*  ccs = &st->chain;
+
     switch ( ccs->SubstFormat )
     {
     case 1:
@@ -3936,6 +3962,23 @@
   }
 
 
+  typedef FT_Error  (*Lookup_Func_Type)  ( TTO_GSUBHeader*   gsub,
+					   TTO_GSUB_SubTable* st,
+					   OTL_Buffer        buffer,
+					   FT_UShort         flags,
+					   FT_UShort         context_length,
+					   int               nesting_level );
+  static const Lookup_Func_Type Lookup_Call_Table[] = {
+    Lookup_DefaultSubst,
+    Lookup_SingleSubst,		/* GSUB_LOOKUP_SINGLE     1 */
+    Lookup_MultipleSubst,	/* GSUB_LOOKUP_MULTIPLE   2 */
+    Lookup_AlternateSubst,	/* GSUB_LOOKUP_ALTERNATE  3 */
+    Lookup_LigatureSubst,	/* GSUB_LOOKUP_LIGATURE   4 */
+    Lookup_ContextSubst,	/* GSUB_LOOKUP_CONTEXT    5 */
+    Lookup_ChainContextSubst,	/* GSUB_LOOKUP_CHAIN      6 */
+    Lookup_DefaultSubst,	/* GSUB_LOOKUP_EXTENSION  7 */
+  };
+
   /* Do an individual subtable lookup.  Returns TT_Err_Ok if substitution
      has been done, or TTO_Err_Not_Covered if not.                        */
 
@@ -3948,6 +3991,8 @@
     FT_Error     error = TT_Err_Ok;
     FT_UShort    i, flags;
     TTO_Lookup*  lo;
+    int          lt;
+    Lookup_Func_Type Lookup_Func;
 
 
     nesting_level++;
@@ -3957,50 +4002,18 @@
 
     lo    = &gsub->LookupList.Lookup[lookup_index];
     flags = lo->LookupFlag;
+    lt = lo->LookupType;
+    if (lt >= sizeof Lookup_Call_Table / sizeof Lookup_Call_Table[0])
+      lt = 0;
+    Lookup_Func = Lookup_Call_Table[lt];
 
     for ( i = 0; i < lo->SubTableCount; i++ )
     {
-      switch ( lo->LookupType )
-      {
-      case GSUB_LOOKUP_SINGLE:
-        error = Lookup_SingleSubst( &lo->SubTable[i].st.gsub.single,
-                                    buffer,
-                                    flags, context_length, gsub->gdef );
-        break;
-
-      case GSUB_LOOKUP_MULTIPLE:
-        error = Lookup_MultipleSubst( &lo->SubTable[i].st.gsub.multiple,
-                                      buffer,
-                                      flags, context_length, gsub->gdef );
-        break;
-
-      case GSUB_LOOKUP_ALTERNATE:
-        error = Lookup_AlternateSubst( gsub,
-                                       &lo->SubTable[i].st.gsub.alternate,
-                                       buffer,
-                                       flags, context_length, gsub->gdef );
-        break;
-
-      case GSUB_LOOKUP_LIGATURE:
-        error = Lookup_LigatureSubst( &lo->SubTable[i].st.gsub.ligature,
-				      buffer,
-                                      flags, context_length, gsub->gdef );
-        break;
-
-      case GSUB_LOOKUP_CONTEXT:
-        error = Lookup_ContextSubst( gsub, &lo->SubTable[i].st.gsub.context,
-                                     buffer,
-                                     flags, context_length, nesting_level );
-        break;
-
-      case GSUB_LOOKUP_CHAIN:
-        error = Lookup_ChainContextSubst( gsub,
-                                          &lo->SubTable[i].st.gsub.chain,
-					  buffer,
-                                          flags, context_length,
-                                          nesting_level );
-        break;
-      }
+      error = Lookup_Func ( gsub,
+			    &lo->SubTable[i].st.gsub,
+			    buffer,
+			    flags, context_length,
+			    nesting_level );
 
       /* Check whether we have a successful substitution or an error other
          than TTO_Err_Not_Covered                                          */
