Re: khmer modul for Pango



On Sat, 2005-02-05 at 16:14 -0500, Owen Taylor wrote:

> The comments I do have:
> 
>  - It's not actually necessary to use separate rulesets for GPOS and
>    GSUB .. other modules do that, but that's just a carry over
>    from older versions of Pango where you couldn't separately apply
>    the GSUB and GPOS rules if you needed to do processing in-between.

Turns out that this was important.

> All this is handled in the pango/opentype so it's strange that you'd
> have problems with Pango and not in Qt since they share almost identical
> code. 
> 
> If you can give a test case of:
> 
>  - Input string (and what font you are using)
>  - Image of output you get
>  - Image of what output you expect
> 
> I can take a look.

I actually had such a test string around, which was the "90 Years"
string that Javier Sola sent me in response to the request I sent out
a while ago. I debugged that a bit and the problem turned out to
be quite simple .. both your get_gsub_ruleset() and get_gpos_ruleset()
calls were using the same quark to cache the ruleset on the PangoOTInfo,
"pango-khmer-ruleset". So, the ruleset with only the GSUB rules
was being reused for GPOS positioning.

Once I fixed that, by simply combining the two rulesets, things seemed
to work better. (On the one test string...) I've attached a diff
against your version. 

One other thing I noticed is that in addition to the C99/C++ comments,
the code also mixes declarations and code, which is also only C++
or C99. So, that needs to be fixed as well.

Regards,
						Owen

PNG image

--- khmer-fc.c.bak	2005-01-17 03:30:38.000000000 -0500
+++ khmer-fc.c	2005-02-05 17:49:16.267143176 -0500
@@ -411,7 +411,7 @@
 }
 
 static PangoOTRuleset *
-get_gsub_ruleset (FT_Face face)
+get_ruleset (FT_Face face)
 {
   PangoOTRuleset *ruleset;
   static GQuark ruleset_quark = 0;
@@ -448,37 +448,6 @@
       maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','l','i','g'), clig);
     }
 
-    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)
-{
-  PangoOTRuleset *ruleset;
-  static GQuark ruleset_quark = 0;
-
-  PangoOTInfo *info = pango_ot_info_get (face);
-
-  if (!ruleset_quark)
-    ruleset_quark = g_quark_from_string ("pango-khmer-ruleset");
-
-  if (!info)
-    return NULL;
-
-  ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
-
-  if (!ruleset)
-  {
-    PangoOTTag khmer_tag = FT_MAKE_TAG ('k', 'h', 'm', 'r');
-    guint script_index;
-
-    ruleset = pango_ot_ruleset_new (info);
-
     if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
                                     khmer_tag, &script_index))
     {
@@ -687,14 +656,12 @@
   } // while
     
   /* do gsub processing */
-  PangoOTRuleset *gsub_ruleset = get_gsub_ruleset (face);
-  if (gsub_ruleset != NULL)
-    pango_ot_ruleset_substitute (gsub_ruleset, buffer);
-
-  /* do gpos processing */
-  PangoOTRuleset *gpos_ruleset = get_gpos_ruleset (face);
-  if (gpos_ruleset != NULL)
-    pango_ot_ruleset_position (gpos_ruleset, buffer);
+  PangoOTRuleset *ruleset = get_ruleset (face);
+  if (ruleset != NULL)
+    {
+      pango_ot_ruleset_substitute (ruleset, buffer);
+      pango_ot_ruleset_position (ruleset, buffer);
+    }
   
   pango_ot_buffer_output (buffer, glyphs);
   

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]