173a174
> 		/*arjun printf("U+%04x: glyph %d (0x%x) tag 0x%x Cluster %d\n", wcs[i],glyph,glyph,tags[i],i); */
222,223c223,226
<   PangoOTBuffer *buffer;
<   glong i, n_chars, n_glyphs;
---
> 
>   PangoOTBuffer *buffer, *buffer_temp;
>   glong i, n_chars, n_glyphs_sy, syllable, char_count, prev = 0, n_glyphs = 0,n_glyphs_sum=0;
> 
225c228,229
<   gunichar *wc_in = NULL, *wc_out = NULL;
---
>   gunichar *wc_in = NULL, *wc_out = NULL, *wc_temp = NULL;
> 
229a234,239
>     
>   PangoOTGlyph *glyphs_temp,glyphele;
>   int n_glyphs_temp;
>   GSList *indices_g = NULL;
>   //These are required to store the intermediate glyphs for the line after processing one syllable.
>   GSList  *glyphseq_glyph=NULL,*glyphseq_properties=NULL,*glyphseq_cluster=NULL;
245,253d254
<   n_glyphs = indic_ot_reorder (wc_in, utf8_offsets, n_chars, indic_shape_engine->classTable, NULL, NULL, NULL, NULL);
< 
<   wc_out  = g_new (gunichar, n_glyphs);
<   indices = g_new (glong,    n_glyphs);
<   tags    = g_new (gulong,   n_glyphs);
< 
<   n_glyphs  = indic_ot_reorder (wc_in, utf8_offsets, n_chars, indic_shape_engine->classTable, wc_out, indices, tags, &mprefixups);
< 
<   pango_glyph_string_set_size (glyphs, n_glyphs);
255,258d255
< 
<   set_glyphs(font, wc_out, tags, n_glyphs, buffer,
< 	     (indic_shape_engine->classTable->scriptFlags & SF_PROCESS_ZWJ) != 0);
< 
271a269
>  
273,280c271,331
<   /* do gsub processing */
<   pango_ot_ruleset_substitute (ruleset, buffer);
< 
<   /* Fix pre-modifiers for some scripts before base consonant */
<   if (mprefixups)
<     {
<       indic_mprefixups_apply (mprefixups, buffer);
<       indic_mprefixups_free (mprefixups);
---
>   while (prev < n_chars) { 
>       syllable = indic_ot_find_syllable(indic_shape_engine->classTable, wc_in, prev, n_chars);
>       char_count = syllable - prev;
>       wc_temp = g_new (gunichar, char_count);
>       for (i = 0; i < char_count; i++) {
> 	          wc_temp[i] = wc_in[i + prev];	  
>       }
> 
>       n_glyphs_sy = indic_ot_reorder (wc_temp, utf8_offsets, char_count, indic_shape_engine->classTable, NULL, NULL, NULL, NULL);
>       wc_out  = g_new (gunichar, n_glyphs_sy);
>       indices = g_new (glong,    n_glyphs_sy);
>       tags    = g_new (gulong,   n_glyphs_sy);
> 
>       n_glyphs_sy  = indic_ot_reorder (wc_temp, utf8_offsets, char_count, indic_shape_engine->classTable, wc_out, indices, tags, &mprefixups);
>       for (i = 0; i < n_glyphs_sy; i++) {
> 	           indices_g=g_slist_append(indices_g, GINT_TO_POINTER(indices[i]));
>       }
> 
>       n_glyphs += n_glyphs_sy;
>       
>       buffer_temp = pango_ot_buffer_new (fc_font);
>       
>       set_glyphs(font, wc_out, tags, n_glyphs_sy, buffer_temp,
>         	(indic_shape_engine->classTable->scriptFlags & SF_PROCESS_ZWJ) != 0);
> 
>       /* do gsub processing */
>       pango_ot_ruleset_substitute (ruleset, buffer_temp);
> 
>       /* Fix pre-modifiers for some scripts before base consonant */
>       if (mprefixups)
>         {
>           indic_mprefixups_apply (mprefixups, buffer_temp);
>           indic_mprefixups_free (mprefixups);
>         }
> 
>       /* do gpos processing */
>       pango_ot_ruleset_position (ruleset, buffer_temp);
> 
>      pango_ot_buffer_get_glyphs (buffer_temp, &glyphs_temp, &n_glyphs_temp);
>         n_glyphs_sum+=n_glyphs_temp;
>       for (i = 0; i < n_glyphs_temp; i++) {
> 		        glyphseq_glyph=g_slist_append(glyphseq_glyph, GINT_TO_POINTER(glyphs_temp[i].glyph));
> 		        glyphseq_properties=g_slist_append(glyphseq_properties, GINT_TO_POINTER(glyphs_temp[i].glyph));
> 		        glyphseq_cluster=g_slist_append(glyphseq_cluster, GINT_TO_POINTER(glyphs_temp[i].glyph));
> 	      }
>  //         pango_ot_buffer_add_glyph (buffer, glyphs_temp[i].glyph, glyphs_temp[i].properties, glyphs_temp[i].cluster);
>        
>       prev = syllable;     
>       
>       pango_ot_buffer_destroy (buffer_temp);
>       g_free (wc_temp);
>       g_free (tags);
>       g_free (indices);
>       g_free (wc_out);
>  }
> 
> 	    for (i=0; i< n_glyphs_sum; i++) {
> 		      glyphele.glyph= g_slist_nth_data(glyphseq_glyph,i);
> 		      glyphele.properties=g_slist_nth_data(glyphseq_properties,i);
> 	      glyphele.cluster= g_slist_nth_data(glyphseq_properties,i);
> 														pango_ot_buffer_add_glyph (buffer,glyphele.glyph , glyphele.properties, glyphele.cluster);
281a333
> 									pango_glyph_string_set_size (glyphs, n_glyphs);
283,290c335
<   /* do gpos processing */
<   pango_ot_ruleset_position (ruleset, buffer);
< 
<   pango_ot_buffer_output (buffer, glyphs);
< 
<   /* Get the right log_clusters values */
<   for (i = 0; i < glyphs->num_glyphs; i += 1)
<     glyphs->log_clusters[i] = indices[glyphs->log_clusters[i]];
---
>      pango_ot_buffer_output (buffer, glyphs); 
291a337,340
>      /* Get the right log_clusters values */
>      for (i = 0; i < glyphs->num_glyphs; i += 1)
>          glyphs->log_clusters[i] = g_slist_nth_data( indices_g, glyphs->log_clusters[i]);
>  
295,297c344
<   g_free (tags);
<   g_free (indices);
<   g_free (wc_out);
---
>   g_slist_free(indices_g);
299a347,349
> 	 g_slist_free(glyphseq_glyph);
> 	 g_slist_free(glyphseq_properties);
> 	 g_slist_free(glyphseq_cluster);
