Comment 16 for bug 1425387

Revision history for this message
poju (popjussi) wrote :

This shouldn't break the old hack. By caching the language pointer in _buildSpansForPara() (May be better exporting it right after getting pango context). For testing all shapings. Or it should rather try to detect the Telugu "te" language instead of "th" then allows the ligature sorting.

--- Layout-TNG-Compute.cpp.orig 2015-07-05 20:42:45.256153018 +0700
+++ Layout-TNG-Compute.cpp 2015-07-05 22:10:38.469670749 +0700
@@ -1099,6 +1099,8 @@
     TRACE(("build spans\n"));
     para->free_sequence(para->unbroken_spans);

+ PangoLanguage* cache_pango_language_th = pango_language_from_string("th"); //Cache the pointer.
+
     for(input_index = para->first_input_index ; input_index < _flow._input_stream.size() ; input_index++) {
         if (_flow._input_stream[input_index]->Type() == CONTROL_CODE) {
             Layout::InputStreamControlCode const *control_code = static_cast<Layout::InputStreamControlCode const *>(_flow._input_stream[input_index]);
@@ -1248,6 +1250,7 @@
                             If ligatures other than with Mark, nonspacing are ever implemented in Pango this will screw up, for instance
                             changing "fi" to "if".
                             */
+
                             if(j - i){
                                 std::sort(&(new_span.glyph_string->glyphs[i]), &(new_span.glyph_string->glyphs[j+1]), compareGlyphWidth);
                             }
@@ -1263,6 +1266,7 @@
                     }
                     else { // ltr sections are in order but glyphs in a log_cluster following a ligature may not be. Sort, but no block swapping.
                         const unsigned nglyphs = new_span.glyph_string->num_glyphs;
+ const PangoLanguage* item_lang = para->pango_items[pango_item_index].item->analysis.language;
                         unsigned i, j;
                         for (i = 0 ; i < nglyphs ; i++)new_span.glyph_string->glyphs[i].attr.is_cluster_start = 0;
                         for (i = 0 ; i < nglyphs ; i++) {
@@ -1271,7 +1275,8 @@
                                     (new_span.glyph_string->log_clusters[j+1] == new_span.glyph_string->log_clusters[i])
                             )j++;
                             /* see note in preceding section */
- if(j - i){
+
+ if( item_lang && item_lang != cache_pango_language_th && j - i){
                                 std::sort(&(new_span.glyph_string->glyphs[i]), &(new_span.glyph_string->glyphs[j+1]), compareGlyphWidth);
                             }
                             new_span.glyph_string->glyphs[i].attr.is_cluster_start = 1;