Blame SOURCES/icu.8198.revert.icu5431.patch

f9b135
Index: icu/trunk/source/layout/IndicReordering.cpp
f9b135
===================================================================
f9b135
--- icu/trunk/source/layout/IndicReordering.cpp	(revision 25772)
f9b135
+++ icu/trunk/source/layout/IndicReordering.cpp	(revision 26090)
f9b135
@@ -126,4 +126,8 @@
f9b135
     FeatureMask fSMFeatures;
f9b135
 
f9b135
+    LEUnicode   fPreBaseConsonant;
f9b135
+    LEUnicode   fPreBaseVirama;
f9b135
+    le_int32    fPBCIndex;
f9b135
+    FeatureMask fPBCFeatures;
f9b135
 
f9b135
     void saveMatra(LEUnicode matra, le_int32 matraIndex, IndicClassTable::CharClass matraClass)
f9b135
@@ -172,5 +176,6 @@
f9b135
           fMatraFeatures(0), fMPreOutIndex(-1), fMPreFixups(mpreFixups),
f9b135
           fVMabove(0), fVMpost(0), fVMIndex(0), fVMFeatures(0),
f9b135
-          fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0)
f9b135
+          fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0),
f9b135
+          fPreBaseConsonant(0), fPreBaseVirama(0), fPBCIndex(0), fPBCFeatures(0)
f9b135
     {
f9b135
         // nothing else to do...
f9b135
@@ -191,4 +196,6 @@
f9b135
         fVMabove = fVMpost  = 0;
f9b135
         fSMabove = fSMbelow = 0;
f9b135
+
f9b135
+        fPreBaseConsonant = fPreBaseVirama = 0;
f9b135
     }
f9b135
 
f9b135
@@ -386,4 +393,12 @@
f9b135
     }
f9b135
 
f9b135
+    void notePreBaseConsonant(le_uint32 index,LEUnicode PBConsonant, LEUnicode PBVirama, FeatureMask features)
f9b135
+    {
f9b135
+        fPBCIndex = index;
f9b135
+        fPreBaseConsonant = PBConsonant;
f9b135
+        fPreBaseVirama = PBVirama;
f9b135
+        fPBCFeatures = features;
f9b135
+    }
f9b135
+
f9b135
     void noteBaseConsonant()
f9b135
     {
f9b135
@@ -465,4 +480,20 @@
f9b135
     }
f9b135
     
f9b135
+    void writePreBaseConsonant()
f9b135
+    {
f9b135
+        // The TDIL spec says that consonant + virama + RRA should produce a rakar in Malayalam.  However,
f9b135
+        // it seems that almost none of the fonts for Malayalam are set up to handle this.
f9b135
+        // So, we're going to force the issue here by using the rakar as defined with RA in most fonts.
f9b135
+
f9b135
+        if (fPreBaseConsonant == 0x0d31) { // RRA
f9b135
+            fPreBaseConsonant = 0x0d30; // RA
f9b135
+        }
f9b135
+        
f9b135
+        if (fPreBaseConsonant != 0) {
f9b135
+            writeChar(fPreBaseConsonant, fPBCIndex, fPBCFeatures);
f9b135
+            writeChar(fPreBaseVirama,fPBCIndex-1,fPBCFeatures);
f9b135
+        }
f9b135
+    }
f9b135
+
f9b135
     le_int32 getOutputIndex()
f9b135
     {
f9b135
@@ -723,4 +754,5 @@
f9b135
             }
f9b135
 
f9b135
+            
f9b135
             IndicClassTable::CharClass charClass = CC_RESERVED;
f9b135
             IndicClassTable::CharClass nextClass = CC_RESERVED;
f9b135
@@ -730,7 +762,9 @@
f9b135
             le_bool  seenVattu = FALSE;
f9b135
             le_bool  seenBelowBaseForm = FALSE;
f9b135
+            le_bool  seenPreBaseForm = FALSE;
f9b135
             le_bool  hasNukta = FALSE;
f9b135
             le_bool  hasBelowBaseForm = FALSE;
f9b135
             le_bool  hasPostBaseForm = FALSE;
f9b135
+            le_bool  hasPreBaseForm = FALSE;
f9b135
 
f9b135
             if (postBase < markStart && classTable->isNukta(chars[postBase])) {
f9b135
@@ -746,12 +780,20 @@
f9b135
                 hasBelowBaseForm = IndicClassTable::hasBelowBaseForm(charClass) && !hasNukta;
f9b135
                 hasPostBaseForm  = IndicClassTable::hasPostBaseForm(charClass)  && !hasNukta;
f9b135
+                hasPreBaseForm = IndicClassTable::hasPreBaseForm(charClass) && !hasNukta;
f9b135
 
f9b135
                 if (IndicClassTable::isConsonant(charClass)) {
f9b135
                     if (postBaseLimit == 0 || seenVattu ||
f9b135
                         (baseConsonant > baseLimit && !classTable->isVirama(chars[baseConsonant - 1])) ||
f9b135
-                        !(hasBelowBaseForm || hasPostBaseForm)) {
f9b135
+                        !(hasBelowBaseForm || hasPostBaseForm || hasPreBaseForm)) {
f9b135
                         break;
f9b135
                     }
f9b135
 
f9b135
+                    // Note any pre-base consonants
f9b135
+                    if ( baseConsonant == lastConsonant && lastConsonant > 0 && 
f9b135
+                         hasPreBaseForm && classTable->isVirama(chars[baseConsonant - 1])) {
f9b135
+                        output.notePreBaseConsonant(lastConsonant,chars[lastConsonant],chars[lastConsonant-1],tagArray2);
f9b135
+                        seenPreBaseForm = TRUE;
f9b135
+   
f9b135
+                    }
f9b135
                     // consonants with nuktas are never vattus
f9b135
                     seenVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
f9b135
@@ -786,10 +828,12 @@
f9b135
 
f9b135
             // write any pre-base consonants
f9b135
+            output.writePreBaseConsonant();
f9b135
+
f9b135
             le_bool supressVattu = TRUE;
f9b135
 
f9b135
             for (i = baseLimit; i < baseConsonant; i += 1) {
f9b135
                 LEUnicode ch = chars[i];
f9b135
-                // Don't put 'blwf' on first consonant.
f9b135
-                FeatureMask features = (i == baseLimit? tagArray2 : tagArray1);
f9b135
+                // Don't put 'pstf' or 'blwf' on anything before the base consonant.
f9b135
+                FeatureMask features = tagArray1 & ~( pstfFeatureMask | blwfFeatureMask );
f9b135
 
f9b135
                 charClass = classTable->getCharClass(ch);
f9b135
@@ -842,5 +886,5 @@
f9b135
 
f9b135
             // write below-base consonants
f9b135
-            if (baseConsonant != lastConsonant) {
f9b135
+            if (baseConsonant != lastConsonant && !seenPreBaseForm) {
f9b135
                 for (i = bcSpan + 1; i < postBase; i += 1) {
f9b135
                     output.writeChar(chars[i], i, tagArray1);
f9b135
@@ -872,5 +916,5 @@
f9b135
             // write post-base consonants
f9b135
             // FIXME: does this put the right tags on post-base consonants?
f9b135
-            if (baseConsonant != lastConsonant) {
f9b135
+            if (baseConsonant != lastConsonant && !seenPreBaseForm) {
f9b135
                 if (postBase <= lastConsonant) {
f9b135
                     for (i = postBase; i <= lastConsonant; i += 1) {