Revert "lib/gdi/font.cpp: try to fix wrong reordering of some characters"
[enigma2.git] / lib / gdi / font.cpp
index 6a6007eebfb35f923f8b20cf7a4bcac167d4cf10..2fd9fb691331efbeb316e8b9f2e33777e9368620 100644 (file)
@@ -511,17 +511,6 @@ int eTextPara::renderString(const char *string, int rflags)
        if (!current_font)
                return -1;
 
        if (!current_font)
                return -1;
 
-       if (!current_face)
-               eFatal("eTextPara::renderString: no current_face");
-       if (!current_face->size)
-               eFatal("eTextPara::renderString: no current_face->size");
-
-       if (cursor.y()==-1)
-       {
-               cursor=ePoint(area.x(), area.y()+(current_face->size->metrics.ascender>>6));
-               left=cursor.x();
-       }
-               
 #ifdef HAVE_FREETYPE2
        if ((FTC_Manager_LookupFace(fontRenderClass::instance->cacheManager,
                                    current_font->scaler.face_id,
 #ifdef HAVE_FREETYPE2
        if ((FTC_Manager_LookupFace(fontRenderClass::instance->cacheManager,
                                    current_font->scaler.face_id,
@@ -544,7 +533,18 @@ int eTextPara::renderString(const char *string, int rflags)
                cache_current_font=&current_font->font.font;
        }
 #endif
                cache_current_font=&current_font->font.font;
        }
 #endif
-       
+
+       if (!current_face)
+               eFatal("eTextPara::renderString: no current_face");
+       if (!current_face->size)
+               eFatal("eTextPara::renderString: no current_face->size");
+
+       if (cursor.y()==-1)
+       {
+               cursor=ePoint(area.x(), area.y()+(current_face->size->metrics.ascender>>6));
+               left=cursor.x();
+       }
+
        std::vector<unsigned long> uc_string, uc_visual;
        if (string)
                uc_string.reserve(strlen(string));
        std::vector<unsigned long> uc_string, uc_visual;
        if (string)
                uc_string.reserve(strlen(string));
@@ -595,22 +595,59 @@ int eTextPara::renderString(const char *string, int rflags)
        shape(uc_shape, uc_string);
        
                // now do the usual logical->visual reordering
        shape(uc_shape, uc_string);
        
                // now do the usual logical->visual reordering
-#ifdef HAVE_FRIBIDI    
+       int size=uc_shape.size();
+#ifdef HAVE_FRIBIDI
        FriBidiCharType dir=FRIBIDI_TYPE_ON;
        FriBidiCharType dir=FRIBIDI_TYPE_ON;
+       int lines=1;
+       int pos=0, spos=0;
+       uc_visual.resize(size);
+       // gaaanz lahm, aber anders geht das leider nicht, sorry.
+       FriBidiChar array[size], target[size];
+       std::copy(uc_shape.begin(), uc_shape.end(), array);
+
+       bool line_open = false;
+       while(pos < size)
        {
        {
-               int size=uc_shape.size();
-               uc_visual.resize(size);
-               // gaaanz lahm, aber anders geht das leider nicht, sorry.
-               FriBidiChar array[size], target[size];
-               std::copy(uc_shape.begin(), uc_shape.end(), array);
-               fribidi_log2vis(array, size, &dir, target, 0, 0, 0);
-               uc_visual.assign(target, target+size);
+               int incr=1;
+               bool line_end = false;
+               if (!line_open)
+                       line_open = true;
+               switch((unsigned long)array[pos])
+               {
+               case '\\':
+                       if (pos+1 == size || (unsigned long)array[pos+1] != 'n')
+                               break;
+                       ++incr;
+               case 0x8A:
+               case 0xE08A:
+               case '\n':
+                       line_end = true;
+               default:
+                       break;
+               }
+               if (line_end || pos+incr >= size) {
+                       int len = pos - spos;
+                       if (len)
+                               fribidi_log2vis(array+spos, len, &dir, target+spos, 0, 0, 0);
+                       target[pos] = array[pos];
+                       if (incr > 1)
+                               target[pos+1] = array[pos+1];
+                       spos = pos+incr;
+                       ++lines;
+                       line_open = false;
+               }
+               pos += incr;
        }
        }
+
+       if (lines < 2)
+               fribidi_log2vis(array, size, &dir, target, 0, 0, 0);
+
+       uc_visual.assign(target, target+size);
 #else
        uc_visual=uc_shape;
 #endif
 
 #else
        uc_visual=uc_shape;
 #endif
 
-       glyphs.reserve(uc_visual.size());
+       glyphs.reserve(size);
        
        int nextflags = 0;
        
        
        int nextflags = 0;