Index: thai-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/thai/thai-fc.c,v
retrieving revision 1.11
diff -u -r1.11 thai-fc.c
--- thai-fc.c	20 Apr 2004 15:15:34 -0000	1.11
+++ thai-fc.c	30 Sep 2004 11:41:35 -0000
@@ -34,6 +34,7 @@
 #include "pangofc-font.h"
 
 #include "thai-shaper.h"
+#include "thai-ot.h"
 
 /* No extra fields needed */
 typedef PangoEngineShape      ThaiEngineFc;
@@ -152,8 +153,10 @@
       font_info = g_new (ThaiFontInfo, 1);
       font_info->font = font;
   
-      /* detect font set by determining availibility of glyphs */
-      if (contain_glyphs(font, tis620_2))
+      /* detect font set by determining availibility of OT ruleset & glyphs */
+      if (thai_ot_get_ruleset (font))
+        font_info->font_set = THAI_FONT_TIS;
+      else if (contain_glyphs(font, tis620_2))
         font_info->font_set = THAI_FONT_TIS_WIN;
       else if (contain_glyphs(font, tis620_1))
         font_info->font_set = THAI_FONT_TIS_MAC;
Index: thai-ot.c
===================================================================
RCS file: /cvs/gnome/pango/modules/thai/thai-ot.c,v
retrieving revision 1.1
diff -u -r1.1 thai-ot.c
--- thai-ot.c	7 Jun 2004 08:06:44 -0000	1.1
+++ thai-ot.c	30 Sep 2004 11:41:36 -0000
@@ -44,71 +44,63 @@
     }
 }
 
-static PangoOTRuleset *
-get_gsub_ruleset (FT_Face face)
+PangoOTRuleset *
+thai_ot_get_ruleset (PangoFont *font)
 {
-  PangoOTInfo    *info = pango_ot_info_get (face);
-  GQuark          ruleset_quark = g_quark_from_string ("thai-gsub-ruleset");
-  PangoOTRuleset *ruleset;
+  PangoFcFont    *fc_font;
+  FT_Face         face;
+  PangoOTInfo    *info;
+  PangoOTRuleset *ruleset = NULL;
 
-  if (!info)
-    return NULL;
+  g_return_if_fail (font != NULL);
 
-  ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
+  fc_font = PANGO_FC_FONT (font);
+  face = pango_fc_font_lock_face (fc_font);
+  g_assert (face != NULL);
 
-  if (!ruleset)
+  info = pango_ot_info_get (face);
+  if (info != NULL)
     {
-      PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
-      guint      script_index;
-
-      ruleset = pango_ot_ruleset_new (info);
-
-     if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
-				     thai_tag, &script_index))
-	{
-	  maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','c','m','p'), 0xFFFF);
-	  maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('l','i','g','a'), 0xFFFF);
-	}
-
-      g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
-			       (GDestroyNotify)g_object_unref);
-    }
-
-  return ruleset;
-}
-
-
-static PangoOTRuleset *
-get_gpos_ruleset (FT_Face face)
-{
-  PangoOTInfo    *info = pango_ot_info_get (face);
-  GQuark          ruleset_quark = g_quark_from_string ("thai-gpos-ruleset");
-  PangoOTRuleset *ruleset;
-
-  if (!info)
-    return NULL;
+      static GQuark ruleset_quark = 0;
 
-  ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
+      if (!ruleset_quark)
+        ruleset_quark = g_quark_from_string ("thai-ot-ruleset");
 
-  if (!ruleset)
-    {
-      PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
-      guint      script_index;
+      ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
+      if (!ruleset)
+        {
+          PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
+          guint      script_index;
 
-      ruleset = pango_ot_ruleset_new (info);
+          ruleset = pango_ot_ruleset_new (info);
 
-      if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
-				     thai_tag, &script_index))
-	{
-	  maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('k','e','r','n'), 0xFFFF);
-	  maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','a','r','k'), 0xFFFF);
-	  maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), 0xFFFF);
-	}
+          if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
+				         thai_tag, &script_index))
+	    {
+	      maybe_add_gsub_feature (ruleset, info, script_index,
+			              FT_MAKE_TAG ('c','c','m','p'), 0xFFFF);
+	      maybe_add_gsub_feature (ruleset, info, script_index,
+			              FT_MAKE_TAG ('l','i','g','a'), 0xFFFF);
+	    }
+
+          if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
+				         thai_tag, &script_index))
+	    {
+	      maybe_add_gpos_feature (ruleset, info, script_index,
+			              FT_MAKE_TAG ('k','e','r','n'), 0xFFFF);
+	      maybe_add_gpos_feature (ruleset, info, script_index,
+			              FT_MAKE_TAG ('m','a','r','k'), 0xFFFF);
+	      maybe_add_gpos_feature (ruleset, info, script_index,
+			              FT_MAKE_TAG ('m','k','m','k'), 0xFFFF);
+	    }
 
-      g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
-			       (GDestroyNotify)g_object_unref);
+          g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
+			           (GDestroyNotify)g_object_unref);
+        }
     }
 
+  pango_fc_font_unlock_face (fc_font);
+
   return ruleset;
 }
 
@@ -117,27 +109,20 @@
 thai_ot_shape (PangoFont        *font,
                PangoGlyphString *glyphs)
 {
-  FT_Face         face;
-  PangoOTRuleset *gsub_ruleset, *gpos_ruleset;
-  PangoFcFont    *fc_font;
+  PangoOTRuleset *ot_ruleset;
 
   g_return_if_fail (font != NULL);
   g_return_if_fail (glyphs != NULL);
 
-  fc_font = PANGO_FC_FONT (font);
-  face = pango_fc_font_lock_face (fc_font);
-  g_assert (face != NULL);
+  ot_ruleset = thai_ot_get_ruleset (font);
 
-  gsub_ruleset = get_gsub_ruleset (face);
-  gpos_ruleset = get_gpos_ruleset (face);
-
-  if (gsub_ruleset != NULL || gpos_ruleset != NULL)
+  if (ot_ruleset != NULL)
     {
       gint i;
       PangoOTBuffer *buffer;
 
       /* prepare ot buffer */
-      buffer = pango_ot_buffer_new (fc_font);
+      buffer = pango_ot_buffer_new (PANGO_FC_FONT (font));
       for (i = 0; i < glyphs->num_glyphs; i++)
         {
           pango_ot_buffer_add_glyph (buffer,
@@ -146,18 +131,11 @@
 				     glyphs->log_clusters[i]);
         }
 
-      /* do gsub processing */
-      if (gsub_ruleset != NULL)
-        pango_ot_ruleset_substitute (gsub_ruleset, buffer);
-
-      /* do gpos processing */
-      if (gpos_ruleset != NULL)
-        pango_ot_ruleset_position (gpos_ruleset, buffer);
+      pango_ot_ruleset_substitute (ot_ruleset, buffer);
+      pango_ot_ruleset_position (ot_ruleset, buffer);
 
       pango_ot_buffer_output (buffer, glyphs);
       pango_ot_buffer_destroy (buffer);
     }
-
-  pango_fc_font_unlock_face (fc_font);
 }
 
Index: thai-ot.h
===================================================================
RCS file: /cvs/gnome/pango/modules/thai/thai-ot.h,v
retrieving revision 1.1
diff -u -r1.1 thai-ot.h
--- thai-ot.h	7 Jun 2004 08:06:44 -0000	1.1
+++ thai-ot.h	30 Sep 2004 11:41:36 -0000
@@ -10,6 +10,9 @@
 
 #include "pango-ot.h"
 
+PangoOTRuleset *
+thai_ot_get_ruleset (PangoFont *font);
+
 void 
 thai_ot_shape (PangoFont        *font,
                PangoGlyphString *glyphs);
