Sinhala support patch for pango-1.5.1



Hi Owen,
I am sending a patch to add support for sinhala script in pango-1.5.1. Please, consider applying this patch to the pango source.

The original patch was by Harsha Senanayake for pango-1.2.5. This is just a port of that to 1.5.1. Harsha has sent you that earlier patch last year, but it seems that it has never made it into the pango source.
http://mail.gnome.org/archives/gtk-i18n-list/2003-October/msg00000.html

I cannot test this thoroughly yet, because the the only sinhala unicode font available so far does not have GPOS and GSUB tables. That font is available at http://cvs.linux.lk/cgi-bin/cvsweb/sinhala/ The patch seems to be working except for the fact that it seems to ignore spaces in sinhala texts.

Thanks

chamath


diff -rup pango-1.5.1/modules/indic/indic-fc.c pango-1.5.1.sinh-patch/modules/indic/indic-fc.c
--- pango-1.5.1/modules/indic/indic-fc.c	2004-02-29 07:44:47.000000000 -0800
+++ pango-1.5.1.sinh-patch/modules/indic/indic-fc.c	2004-07-25 18:33:40.313132128 -0700
@@ -65,6 +65,7 @@ struct _PangoIndicInfo
 #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_sinh FT_MAKE_TAG('s','i','n','h')
 
 static PangoEngineScriptInfo deva_scripts[] = {
   { PANGO_SCRIPT_DEVANAGARI, "*" }
@@ -102,10 +103,15 @@ static PangoEngineScriptInfo mlym_script
   { PANGO_SCRIPT_MALAYALAM, "*" }
 };
 
+static PangoEngineScriptInfo sinh_scripts[] = {
+  { PANGO_SCRIPT_SINHALA, "*" }
+};
+
 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(sinh)
 };
 
 /*
@@ -119,7 +125,8 @@ static PangoEngineInfo script_engines[] 
 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(sinh)
 };
 
 static void
diff -rup pango-1.5.1/modules/indic/indic-ot-class-tables.c pango-1.5.1.sinh-patch/modules/indic/indic-ot-class-tables.c
--- pango-1.5.1/modules/indic/indic-ot-class-tables.c	2004-03-05 12:49:51.000000000 -0800
+++ pango-1.5.1.sinh-patch/modules/indic/indic-ot-class-tables.c	2004-07-25 18:33:40.271138512 -0700
@@ -192,6 +192,19 @@ static IndicOTCharClass mlymCharClasses[
     _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  /* 0D60 - 0D6F */
 };
 
+static IndicOTCharClass sinhCharClasses[] =
+{
+    _xx, _xx, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, /* 0D80 - 0D8F */
+    _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct, _ct, /* 0D90 - 0D9F */
+    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0DA0 - 0DAF */
+    _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _xx, _xx, /* 0DB0 - 0DBF */
+    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _vr, _xx, _xx, _xx, _xx, _dr, /* 0DC0 - 0DCF */
+    _dr, _dr, _da, _da, _db, _xx, _db, _xx, _dr, _dl, _s1, _dl, _s2, _s3, _s4, _dr, /* 0DD0 - 0DDF */
+    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0DE0 - 0DEF */
+    _xx, _xx, _dr, _dr, _xx                                                         /* 0DF0 - 0DF4 */
+};
+
+
 /*
  * Split matra tables
  */
@@ -208,6 +221,9 @@ static const IndicOTSplitMatra kndaSplit
 
 static const IndicOTSplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}};
 
+static const IndicOTSplitMatra sinhSplitTable[] = {{0x0DD9, 0x0DCA}, {0x0DD9, 0x0DCF}, {0x0DD9, 0x0DCF,0x0DCA}, {0x0DD9, 0x0DF3} };
+
+
 /*
  * Script Flags
  */
@@ -226,6 +242,7 @@ static const IndicOTSplitMatra mlymSplit
 #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 SINH_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
 
 /*
  * Indic Class Tables
@@ -248,6 +265,8 @@ IndicOTClassTable knda_class_table = {0x
 
 IndicOTClassTable mlym_class_table = {0x0D00, 0x0D6F, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable};
 
+IndicOTClassTable sinh_class_table = {0x0D80, 0x0DF4, 3, SINH_SCRIPT_FLAGS, sinhCharClasses, sinhSplitTable};
+
 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 -rup pango-1.5.1/modules/indic/indic-ot.c pango-1.5.1.sinh-patch/modules/indic/indic-ot.c
--- pango-1.5.1/modules/indic/indic-ot.c	2004-02-29 07:44:47.000000000 -0800
+++ pango-1.5.1.sinh-patch/modules/indic/indic-ot.c	2004-07-25 18:33:39.900194904 -0700
@@ -29,6 +29,7 @@ struct _Output
     gunichar fMabove;
     gunichar fMpost;
     gunichar fLengthMark;
+    gunichar fVirama; // to handle virama in sinhala split matras
     glong    fMatraIndex;
     gulong   fMatraTags;
     glong    fMPreOutIndex;
@@ -49,7 +50,7 @@ static void initOutput(Output *output, c
     output->fOutIndex    = 0;
     output->fMatraTags   = 0;
 
-    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = 0;
+    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = output->fVirama = 0;
 
     output->fMPreOutIndex = -1;
     output->fMPreFixups = mpreFixups;
@@ -68,6 +69,8 @@ static void saveMatra(Output *output, gu
         output->fMpost = matra;
     } else if (IS_LENGTH_MARK(matraClass)) {
         output->fLengthMark = matra;
+    } else if(IS_VIRAMA(matraClass)) {
+        output->fVirama = matra;
     }
 }
 
@@ -75,7 +78,7 @@ static void noteMatra(Output *output, co
 {
     IndicOTCharClass matraClass = indic_ot_get_char_class(classTable, matra);
 
-    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = 0;
+    output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = output->fVirama = 0;
     output->fMPreOutIndex = -1;
     output->fMatraIndex = matraIndex;
     output->fMatraTags = matraTags;
@@ -114,6 +117,14 @@ static void writeChar(Output *output, gu
     output->fOutIndex += 1;
 }
 
+//To handle virama in sinhala split matra
+static void writeVirama(Output *output)
+{
+  if(output->fVirama != 0){
+    writeChar(output, output->fVirama, output->fMatraIndex, output->fMatraTags);
+  }
+}
+
 static void writeMpre(Output *output)
 {
     if (output->fMpre != 0) {
@@ -211,6 +222,7 @@ glong indic_ot_reorder(const gunichar *c
             writeMabove(&output);
             writeMpost(&output);
             writeLengthMark(&output);
+	    writeVirama(&output);
             break;
 
         case CC_CONSONANT:
@@ -393,6 +405,7 @@ glong indic_ot_reorder(const gunichar *c
 	    }
 
 	    writeLengthMark(&output);
+	    writeVirama(&output);
 
 	    /* write reph */
 	    if ((class_table->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
diff -rup pango-1.5.1/modules/indic/indic-ot.h pango-1.5.1.sinh-patch/modules/indic/indic-ot.h
--- pango-1.5.1/modules/indic/indic-ot.h	2003-11-01 07:02:15.000000000 -0800
+++ pango-1.5.1.sinh-patch/modules/indic/indic-ot.h	2004-07-25 18:33:39.865200224 -0700
@@ -195,6 +195,7 @@ extern IndicOTClassTable taml_class_tabl
 extern IndicOTClassTable telu_class_table;
 extern IndicOTClassTable knda_class_table;
 extern IndicOTClassTable mlym_class_table;
+extern IndicOTClassTable sinh_class_table;
 
 const IndicOTSplitMatra *indic_ot_get_split_matra(const IndicOTClassTable *class_table, IndicOTCharClass char_class);
 


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