--- indic-ot.c.bak	2006-09-11 14:09:20.000000000 +0800
+++ indic-ot.c	2006-09-11 13:56:29.000000000 +0800
@@ -168,6 +168,27 @@
     }
 }
 
+static void swapChars(Output *output, int a, int b)
+{
+    if (output->fOutChars != NULL) {
+	gunichar temp_char;
+	guint32 temp_index;
+	gulong temp_tag;
+
+	temp_char = output->fOutChars[output->fOutIndex + b];
+	temp_index = output->fCharIndices[output->fOutIndex + b];
+	temp_tag = output->fCharTags[output->fOutIndex + b];
+
+	output->fOutChars[output->fOutIndex + b] = output->fOutChars[output->fOutIndex + a];
+	output->fCharIndices[output->fOutIndex + b] = output->fCharIndices[output->fOutIndex + a];
+	output->fCharTags[output->fOutIndex + b] = pstf_p;	
+
+	output->fOutChars[output->fOutIndex + a] = temp_char;
+	output->fCharIndices[output->fOutIndex + a] = temp_index;
+	output->fCharTags[output->fOutIndex + a] = temp_tag;
+    }
+}
+
 static void writeChar(Output *output, gunichar ch, guint32 charIndex, gulong charTags)
 {
     if (output->fOutChars != NULL) {
@@ -421,6 +442,15 @@
 		writeChar(&output, chars[i], /*i*/ prev, nukt_p);
 	    }
 
+            //for the special conjuction of Cons+0x0d4d+0x0d31 of Malayalam
+	    if ((baseConsonant - 2 >= 0) &&
+		(chars[baseConsonant - 1] == 0x0d4d) &&
+		(chars[baseConsonant] == 0x0d31) &&
+		((chars[baseConsonant - 2] >= 0x0d15) && 
+		 (chars[baseConsonant - 2] <= 0x0d39)))  {
+		swapChars (&output, -1, -3);
+	    }
+
 	    if ((class_table->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
 		writeMbelow(&output);
 		writeMabove(&output);
