Re: Pango Khmer



Here is the patch for Pango-1.3.1 (latest CVS
checkout).

I had to "break" a few things to get Khmer working.
The flags was one of them. Maybe there is a better way
to implement this. I haven't had time to really figure
that out as my first priority was to get a working
implementation, period.

The lazy route would be to implement a separate
module, but Khmer does share 99% of the Indic module
code, with some minor changes.

- Lin

--- Owen Taylor <otaylor redhat com> wrote:
> On Tue, 2003-12-30 at 21:29, Lin Chear wrote:
> > On Wed, 2003-12-31 at 09:29, Lin Chear wrote:
> > > Hi all,
> > > 
> > > I've added Khmer support to Pango by adapting
> the
> > > existing Indic module. I've tested it with gEdit
> and
> > > it works for the most part.
> > > 
> > > I had to add a few features to the feature flags
> but
> > > as a result, I also had to remove some Indic
> feature
> > > flags (as there was no more room for any Khmer
> bit
> > > flags).
> > > 
> > > As a result, I need to incorporate Khmer as a
> > separate
> > > module. Anyone able to assist me in that matter?
> 
> What in particular do you need help with? 
> 
> I'd also be interested in seeing what your patch
> looks like;
> if you are sharing lots of code with the Indic
> module, it's
> possible we can find some other way to extend the
> feature
> flags without having to create an entirely separate
> module.
> 
> 					Owen
> 
> (BTW, it's great that someone is working on this)
> 
> 


diff -Naur pango/modules/indic/CVS/Entries
pango-new/modules/indic/CVS/Entries
--- pango/modules/indic/CVS/Entries	2004-01-05
17:56:46.000000000 -0500
+++ pango-new/modules/indic/CVS/Entries	2004-01-05
17:55:52.000000000 -0500
@@ -1,10 +1,10 @@
 /.cvsignore/1.1/Wed Nov  8 06:07:46 2000//
-/Makefile.am/1.23/Mon Jan  5 22:56:45 2004//
-/indic-fc.c/1.10/Mon Jan  5 22:56:45 2004//
-/indic-ot-class-tables.c/1.3/Mon Jan  5 22:56:46
2004//
-/indic-ot.c/1.5/Mon Jan  5 22:56:46 2004//
-/indic-ot.h/1.7/Mon Jan  5 22:56:46 2004//
-/mprefixups.c/1.1/Mon Jan  5 22:56:46 2004//
-/mprefixups.h/1.1/Mon Jan  5 22:56:46 2004//
-/pango-indic-script.h/1.4/Mon Jan  5 22:56:46 2004//
+/Makefile.am/1.23/Mon Jan  5 22:00:53 2004//
+/indic-fc.c/1.10/Mon Jan  5 22:00:53 2004//
+/indic-ot-class-tables.c/1.3/Mon Jan  5 22:00:54
2004//
+/indic-ot.c/1.5/Mon Jan  5 22:00:54 2004//
+/indic-ot.h/1.7/Mon Jan  5 22:00:54 2004//
+/mprefixups.c/1.1/Mon Jan  5 22:00:55 2004//
+/mprefixups.h/1.1/Mon Jan  5 22:00:55 2004//
+/pango-indic-script.h/1.4/Mon Jan  5 22:00:55 2004//
 D
diff -Naur pango/modules/indic/indic-fc.c
pango-new/modules/indic/indic-fc.c
--- pango/modules/indic/indic-fc.c	2004-01-05
17:56:45.000000000 -0500
+++ pango-new/modules/indic/indic-fc.c	2004-01-05
17:55:52.000000000 -0500
@@ -65,6 +65,7 @@
 #define OT_TAG_telu FT_MAKE_TAG('t','e','l','u')
 #define OT_TAG_knda FT_MAKE_TAG('k','n','d','a')
 #define OT_TAG_mlym FT_MAKE_TAG('m','l','y','m')
+#define OT_TAG_khmr FT_MAKE_TAG('k','h','m','r')
 
 static PangoEngineScriptInfo deva_scripts[] = {
   { PANGO_SCRIPT_DEVANAGARI, "*" }
@@ -102,10 +103,16 @@
   { PANGO_SCRIPT_MALAYALAM, "*" }
 };
 
+static PangoEngineScriptInfo khmr_scripts[] = {
+  { PANGO_SCRIPT_KHMER, "*" }
+};
+
+
 static PangoEngineInfo script_engines[] = {
   INDIC_ENGINE_INFO(deva), INDIC_ENGINE_INFO(beng),
INDIC_ENGINE_INFO(guru),
   INDIC_ENGINE_INFO(gujr), INDIC_ENGINE_INFO(orya),
INDIC_ENGINE_INFO(taml),
-  INDIC_ENGINE_INFO(telu), INDIC_ENGINE_INFO(knda),
INDIC_ENGINE_INFO(mlym)
+  INDIC_ENGINE_INFO(telu), INDIC_ENGINE_INFO(knda),
INDIC_ENGINE_INFO(mlym),
+  INDIC_ENGINE_INFO(khmr)
 };
 
 /*
@@ -119,7 +126,8 @@
 static PangoIndicInfo indic_info[] = {
   PANGO_INDIC_INFO(deva), PANGO_INDIC_INFO(beng),
PANGO_INDIC_INFO(guru),
   PANGO_INDIC_INFO(gujr), PANGO_INDIC_INFO(orya),
PANGO_INDIC_INFO(taml),
-  PANGO_INDIC_INFO(telu), PANGO_INDIC_INFO(knda),
PANGO_INDIC_INFO(mlym)
+  PANGO_INDIC_INFO(telu), PANGO_INDIC_INFO(knda),
PANGO_INDIC_INFO(mlym),
+  PANGO_INDIC_INFO(khmr)
 };
 
 static void
@@ -198,6 +206,8 @@
 	  maybe_add_GSUB_feature (ruleset, info,
script_index, FT_MAKE_TAG ('a','b','v','s'), abvs);
 	  maybe_add_GSUB_feature (ruleset, info,
script_index, FT_MAKE_TAG ('p','s','t','s'), psts);
 	  maybe_add_GSUB_feature (ruleset, info,
script_index, FT_MAKE_TAG ('h','a','l','n'), haln);
+          maybe_add_GSUB_feature (ruleset, info,
script_index, FT_MAKE_TAG ('p','r','e','f'), pref);
+          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,
@@ -232,6 +242,7 @@
 	  maybe_add_GPOS_feature (ruleset, info,
script_index, FT_MAKE_TAG ('b','l','w','m'), blwm);
 	  maybe_add_GPOS_feature (ruleset, info,
script_index, FT_MAKE_TAG ('a','b','v','m'), abvm);
 	  maybe_add_GPOS_feature (ruleset, info,
script_index, FT_MAKE_TAG ('d','i','s','t'), dist);
+          maybe_add_GPOS_feature (ruleset, info,
script_index, FT_MAKE_TAG ('m','k','m','k'), mkmk);
 	}
 
       g_object_set_qdata_full (G_OBJECT (info),
ruleset_quark, ruleset,
@@ -309,6 +320,10 @@
   PangoIndicInfo *indic_info = NULL;
   PangoFcFont *fc_font;
   MPreFixups *mprefixups;
+  glong cnt;                    // Khmer
+  gunichar tmp1, tmp2, tmp3;	// Khmer - swap
+  gulong tag1, tag2, tag3;	// Khmer - tag swap
+  gboolean fixro = FALSE;	// whether RO was reordered
or not.
 
   g_return_if_fail (font != NULL);
   g_return_if_fail (text != NULL);
@@ -332,6 +347,29 @@
   tags    = g_new (gulong,   n_glyphs);
 
   n_glyphs  = indic_ot_reorder (wc_in, utf8_offsets,
n_chars, indic_info->classTable, wc_out, indices,
tags, &mprefixups);
+
+  for (cnt = 0; cnt < n_glyphs; cnt++)
+    {                           // Khmer Ro
Re-Odering
+      if (cnt - 2 >= 0)
+        {
+          fixro = TRUE;
+          if (wc_out[cnt] == 0x179A && wc_out[cnt -
1] == 0x17D2)
+            {
+              tmp1 = wc_out[cnt - 2];
+              tag1 = tags[cnt - 2];     // Consonant
+              tmp2 = wc_out[cnt - 1];
+              tag2 = tags[cnt - 1];     // COENG
+              tmp3 = wc_out[cnt];
+              tag3 = tags[cnt]; // Ro
+              wc_out[cnt - 2] = tmp2;
+              tags[cnt - 2] = tag2;
+              wc_out[cnt - 1] = tmp3;
+              tags[cnt - 1] = tag3;
+              wc_out[cnt] = tmp1;
+              tags[cnt] = tag1;
+            }
+        }
+    }
   
   pango_glyph_string_set_size (glyphs, n_glyphs);
   set_glyphs(font, face, wc_out, n_glyphs, glyphs);
@@ -344,7 +382,7 @@
     }
 
   /* Fix pre-modifiers for some scripts before base
consonant */
-  if (mprefixups)
+  if (mprefixups && !fixro) // Does not apply to
Khmer
     {
       indic_mprefixups_apply (mprefixups, glyphs);
       indic_mprefixups_free (mprefixups);
diff -Naur pango/modules/indic/indic-ot.c
pango-new/modules/indic/indic-ot.c
--- pango/modules/indic/indic-ot.c	2004-01-05
17:56:46.000000000 -0500
+++ pango-new/modules/indic/indic-ot.c	2004-01-05
17:55:52.000000000 -0500
@@ -68,6 +68,8 @@
         output->fMpost = matra;
     } else if (IS_LENGTH_MARK(matraClass)) {
         output->fLengthMark = matra;
+    } else {
+        output->fMpost = matra; // for Khmer Split
     }
 }
 
@@ -206,7 +208,7 @@
 
         case CC_DEPENDENT_VOWEL:
             writeMpre(&output);
-            writeChar(&output, C_DOTTED_CIRCLE, prev,
blwf_p);
+            // writeChar(&output, C_DOTTED_CIRCLE,
prev, blwf_p); // for Khmer -- ignore this rule for
some vowel/marks 
             writeMbelow(&output);
             writeMabove(&output);
             writeMpost(&output);
diff -Naur pango/modules/indic/indic-ot-class-tables.c
pango-new/modules/indic/indic-ot-class-tables.c
--- pango/modules/indic/indic-ot-class-tables.c
2004-01-05 17:56:46.000000000 -0500
+++ pango-new/modules/indic/indic-ot-class-tables.c
2004-01-05 17:55:52.000000000 -0500
@@ -180,6 +180,17 @@
     _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx,
_xx, _xx, _xx, _xx, _xx, _xx  /* 0D60 - 0D6F */
 };
 
+static IndicOTCharClass khmrCharClasses[] = {
+  _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct,
_ct, _ct, _ct, _ct, _ct, _ct,       /* 1780 - 178F */
+  _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct,
_ct, _ct, _ct, _ct, _ct, _ct,       /* 1790 - 179F */
+  _ct, _ct, _ct, _iv, _iv, _iv, _iv, _iv, _iv, _iv,
_iv, _iv, _iv, _iv, _iv, _iv,       /* 17A0 - 17AF */
+  _iv, _iv, _iv, _iv, _iv, _iv, _dr, _da, _da, _da,
_da, _db, _db, _db, _s1, _s2,       /* 17B0 - 17BF */
+  _s3, _dl, _dl, _dl, _s4, _s5, _ma, _mp, _mp, _ma,
_ma, _ma, _ma, _ma, _ma, _ma,       /* 17C0 - 17CF */
+  _ma, _ma, _vr, _ma, _xx, _xx, _xx, _mp, _xx, _xx,
_xx, _xx, _xx, _xx, _xx, _xx,       /* 17D0 - 17EF */
+  _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx,
_xx, _xx, _xx, _xx, _xx, _xx        /* 17F0 - 17FF */
+};
+
+
 /*
  * Split matra tables
  */
@@ -196,6 +207,9 @@
 
 static const IndicOTSplitMatra mlymSplitTable[] =
{{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46,
0x0D57}};
 
+static const IndicOTSplitMatra khmrSplitTable[] =
+  { {0x17C1, 0x17B8}, {0x17C1, 0x17BF}, {0x17C1,
0x17C0},{0x17C1, 0x17C4}, {0x17C1, 0x17C5}};
+
 /*
  * Script Flags
  */
@@ -214,6 +228,7 @@
 #define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
 #define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
 #define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP |
SF_NO_POST_BASE_LIMIT)
+#define KHMR_SCRIPT_FLAGS (SF_MPRE_FIXUP |
SF_NO_POST_BASE_LIMIT)
 
 /*
  * Indic Class Tables
@@ -236,6 +251,8 @@
 
 IndicOTClassTable mlym_class_table = {0x0D00, 0x0D6F,
3, MLYM_SCRIPT_FLAGS, mlymCharClasses,
mlymSplitTable};
 
+IndicOTClassTable khmr_class_table = {0x1780, 0x17FF,
4, KHMR_SCRIPT_FLAGS, khmrCharClasses, khmrSplitTable
};
+
 const IndicOTSplitMatra
*indic_ot_get_split_matra(const IndicOTClassTable
*class_table, IndicOTCharClass char_class)
 {
     gint32 index = (char_class & CF_INDEX_MASK) >>
CF_INDEX_SHIFT;
diff -Naur pango/modules/indic/indic-ot.h
pango-new/modules/indic/indic-ot.h
--- pango/modules/indic/indic-ot.h	2004-01-05
17:56:46.000000000 -0500
+++ pango-new/modules/indic/indic-ot.h	2004-01-05
17:55:52.000000000 -0500
@@ -22,7 +22,8 @@
 {
   C_SIGN_ZWNJ     = 0x200C,
   C_SIGN_ZWJ      = 0x200D,
-  C_DOTTED_CIRCLE = 0x25CC
+  C_DOTTED_CIRCLE = 0x25CC,
+  C_KH_RO = 0x179A // Khmer RO
 };
 
 /*
@@ -97,7 +98,8 @@
 /*
  * Bit flags for the indic feature tags
  */
-enum indic_glyph_feature_
+/*enum indic_glyph_feature_ // disable these feature
flags for Khmer 
+// obviously, this will break other Indic languages.
 {
   nukt = 0x0001,
   akhn = 0x0002,
@@ -115,8 +117,34 @@
   abvm = 0x2000,
   dist = 0x4000,
   junk = 0x8000
+};*/
+
+enum indic_glyph_feature_
+{
+  pref = 0x00001,
+  abvf = 0x00002,
+  rphf = 0x00004,
+  blwf = 0x00008,
+  nukt = 0x00010,
+  pstf = 0x00020,
+  clig = 0x00040,
+  pres = 0x00080,
+  blws = 0x00100,
+  abvs = 0x00200,
+  psts = 0x00400,
+  mkmk = 0x00800,
+  blwm = 0x01000,
+  abvm = 0x02000,
+  dist = 0x04000,
+  junk = 0x08000,
+  half = 0x10000,               // FIXME: Extend
flags to support the below.
+  akhn = 0x20000,
+  vatu = 0x40000,
+  haln = 0x80000
 };
 
+
+
 /*
  * Complement of the feature flags that
  * will be assigned to specific glyphs.
@@ -195,6 +223,7 @@
 extern IndicOTClassTable telu_class_table;
 extern IndicOTClassTable knda_class_table;
 extern IndicOTClassTable mlym_class_table;
+extern IndicOTClassTable khmr_class_table;
 
 const IndicOTSplitMatra
*indic_ot_get_split_matra(const IndicOTClassTable
*class_table, IndicOTCharClass char_class);
 



__________________________________
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
http://search.yahoo.com/top2003



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