fix empty strings
[enigma2.git] / lib / gdi / font.cpp
index 2ff5fbf7f5a2fef7d19c5829149950d01c2e1078..77c8de94e373682106f487257cc6d59ae61829f7 100644 (file)
@@ -443,7 +443,7 @@ void eTextPara::setFont(Font *fnt, Font *replacement)
 void
 shape (std::vector<unsigned long> &string, const std::vector<unsigned long> &text);
 
-int eTextPara::renderString(const std::string &string, int rflags)
+int eTextPara::renderString(const char *string, int rflags)
 {
        singleLock s(ftlock);
        
@@ -467,11 +467,12 @@ int eTextPara::renderString(const std::string &string, int rflags)
        }
        
        std::vector<unsigned long> uc_string, uc_visual;
-       uc_string.reserve(string.length());
+       if (string)
+               uc_string.reserve(strlen(string));
        
-       std::string::const_iterator p(string.begin());
+       const char *p = string ? string : "";
 
-       while(p != string.end())
+       while (*p)
        {
                unsigned int unicode=(unsigned char)*p++;
 
@@ -481,28 +482,28 @@ int eTextPara::renderString(const std::string &string, int rflags)
                        {
                                unicode&=0x1F;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                        } else if ((unicode & 0xF0)==0xE0) // three bytes
                        {
                                unicode&=0x0F;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                        } else if ((unicode & 0xF8)==0xF0) // four bytes
                        {
                                unicode&=0x07;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                                unicode<<=6;
-                               if (p != string.end())
+                               if (p)
                                        unicode|=(*p++)&0x3F;
                        }
                }