mirror of
https://github.com/glest/glest-source.git
synced 2025-08-23 16:32:53 +02:00
- added unit tests for arabic handling in fribidi
- added default property value for right to left mixed in english.lng - fixed bug in arabic.lng file
This commit is contained in:
@@ -370,8 +370,8 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_FRIBIDI
|
#ifdef HAVE_FRIBIDI
|
||||||
|
const bool debugFribidi = false;
|
||||||
//printf("BEFORE: [%s]\n",str_.c_str());
|
if(debugFribidi == true) printf("BEFORE: [%s]\n",str_.c_str());
|
||||||
|
|
||||||
string new_value = "";
|
string new_value = "";
|
||||||
bool hasSoftNewLines = false;
|
bool hasSoftNewLines = false;
|
||||||
@@ -390,7 +390,7 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
lines.push_back(str_);
|
lines.push_back(str_);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("Lines: %d\n",(int)lines.size());
|
if(debugFribidi == true) printf("Lines: %d\n",(int)lines.size());
|
||||||
|
|
||||||
for(int lineIndex = 0; lineIndex < (int)lines.size(); ++lineIndex) {
|
for(int lineIndex = 0; lineIndex < (int)lines.size(); ++lineIndex) {
|
||||||
if(lineIndex > 0) {
|
if(lineIndex > 0) {
|
||||||
@@ -402,7 +402,7 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
str_ = lines[lineIndex];
|
str_ = lines[lineIndex];
|
||||||
//printf("Line: %d [%s]\n",lineIndex,str_.c_str());
|
if(debugFribidi == true) printf("Line: %d [%s] Font::fontSupportMixedRightToLeft = %d\n",lineIndex,str_.c_str(),Font::fontSupportMixedRightToLeft);
|
||||||
|
|
||||||
vector<string> words;
|
vector<string> words;
|
||||||
if(Font::fontSupportMixedRightToLeft == true) {
|
if(Font::fontSupportMixedRightToLeft == true) {
|
||||||
@@ -424,12 +424,9 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
nonASCIIWordList.reserve(words.size());
|
nonASCIIWordList.reserve(words.size());
|
||||||
|
|
||||||
for(int wordIndex = 0; wordIndex < (int)words.size(); ++wordIndex) {
|
for(int wordIndex = 0; wordIndex < (int)words.size(); ++wordIndex) {
|
||||||
//if(wordIndex > 0) {
|
|
||||||
// new_value += " ";
|
|
||||||
//}
|
|
||||||
str_ = words[wordIndex];
|
str_ = words[wordIndex];
|
||||||
|
|
||||||
//printf("Word: %d [%s]\n",wordIndex,str_.c_str());
|
if(debugFribidi == true) printf("Word: %d [%s]\n",wordIndex,str_.c_str());
|
||||||
|
|
||||||
//FriBidi C string holding the original text (that is probably with logical hebrew)
|
//FriBidi C string holding the original text (that is probably with logical hebrew)
|
||||||
FriBidiChar *logical = NULL;
|
FriBidiChar *logical = NULL;
|
||||||
@@ -499,14 +496,7 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
//Insert the output string into the result
|
//Insert the output string into the result
|
||||||
str_ = op;
|
str_ = op;
|
||||||
|
|
||||||
//printf("LOG2VIS: [%s]\n",str_.c_str());
|
if(debugFribidi == true) printf("LOG2VIS: [%s]\n",str_.c_str());
|
||||||
|
|
||||||
// if(ascii_char_map.empty() == false) {
|
|
||||||
// for (int index = 0; index < (int)ascii_char_map.size(); ++index) {
|
|
||||||
// str_.insert(ascii_char_map[index].second,1,ascii_char_map[index].first);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//printf("AFTER: [%s]\n",str_.c_str());
|
|
||||||
}
|
}
|
||||||
//printf("AFTER: [%s]\n",str_.c_str());
|
//printf("AFTER: [%s]\n",str_.c_str());
|
||||||
|
|
||||||
@@ -552,18 +542,18 @@ void Font::bidi_cvt(string &str_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("Building New Line: %d [%s]\n",lineIndex,new_value.c_str());
|
if(debugFribidi == true) printf("Building New Line: %d [%s]\n",lineIndex,new_value.c_str());
|
||||||
for(int wordIndex = 0; wordIndex < (int)wordList.size(); ++wordIndex) {
|
for(int wordIndex = 0; wordIndex < (int)wordList.size(); ++wordIndex) {
|
||||||
//printf("wordIndex: %d [%s]\n",wordIndex,wordList[wordIndex].c_str());
|
if(debugFribidi == true) printf("wordIndex: %d [%s]\n",wordIndex,wordList[wordIndex].c_str());
|
||||||
if(wordIndex > 0) {
|
if(wordIndex > 0) {
|
||||||
new_value += " ";
|
new_value += " ";
|
||||||
}
|
}
|
||||||
new_value += wordList[wordIndex];
|
new_value += wordList[wordIndex];
|
||||||
}
|
}
|
||||||
//printf("New Line: %d [%s]\n",lineIndex,new_value.c_str());
|
if(debugFribidi == true) printf("New Line: %d [%s]\n",lineIndex,new_value.c_str());
|
||||||
}
|
}
|
||||||
str_ = new_value;
|
str_ = new_value;
|
||||||
//printf("NEW: [%s]\n",str_.c_str());
|
if(debugFribidi == true) printf("NEW: [%s]\n",str_.c_str());
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ class FontTest : public CppUnit::TestFixture {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void test_bidi_newline_handling() {
|
void test_bidi_newline_handling() {
|
||||||
|
|
||||||
string text = "\n\nHP: 9000/9000\nArmor: 0 (Stone)\nSight: 15\nProduce Slave";
|
string text = "\n\nHP: 9000/9000\nArmor: 0 (Stone)\nSight: 15\nProduce Slave";
|
||||||
string expected = text;
|
string expected = text;
|
||||||
#ifdef HAVE_FRIBIDI
|
#ifdef HAVE_FRIBIDI
|
||||||
@@ -46,6 +47,7 @@ public:
|
|||||||
//printf("Expected: [%s] result[%s]\n",expected.c_str(),text.c_str());
|
//printf("Expected: [%s] result[%s]\n",expected.c_str(),text.c_str());
|
||||||
CPPUNIT_ASSERT_EQUAL( expected,text );
|
CPPUNIT_ASSERT_EQUAL( expected,text );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
void test_LTR_RTL_Mixed() {
|
void test_LTR_RTL_Mixed() {
|
||||||
Font::fontSupportMixedRightToLeft = true;
|
Font::fontSupportMixedRightToLeft = true;
|
||||||
@@ -120,7 +122,6 @@ public:
|
|||||||
CPPUNIT_ASSERT_EQUAL( expected_result4,FactionName_indian );
|
CPPUNIT_ASSERT_EQUAL( expected_result4,FactionName_indian );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This test still failing: xx IP xx
|
|
||||||
string LanIP = "כתובות IP מקומי:192.168.0.150 ( 61357 / 61357 )";
|
string LanIP = "כתובות IP מקומי:192.168.0.150 ( 61357 / 61357 )";
|
||||||
string expected5 = LanIP;
|
string expected5 = LanIP;
|
||||||
//printf("LanIP [%s]\n",LanIP.c_str());
|
//printf("LanIP [%s]\n",LanIP.c_str());
|
||||||
@@ -135,6 +136,39 @@ public:
|
|||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL( expected_result5,LanIP );
|
CPPUNIT_ASSERT_EQUAL( expected_result5,LanIP );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
string IntroText1_ar = "مبني على الحاصلة على جائزة Glest الكلاسيكية";
|
||||||
|
//printf("START IntroText1_ar [%s]\n",IntroText1_ar.c_str());
|
||||||
|
string expected6 = IntroText1_ar;
|
||||||
|
//printf("LanIP [%s]\n",LanIP.c_str());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 75,(int)IntroText1_ar.size() );
|
||||||
|
|
||||||
|
#ifdef HAVE_FRIBIDI
|
||||||
|
//printf("Before IntroText1_ar [%s]\n",IntroText1_ar.c_str());
|
||||||
|
Font::bidi_cvt(IntroText1_ar);
|
||||||
|
//printf("After IntroText1_ar [%s]\n",IntroText1_ar.c_str());
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 104,(int)IntroText1_ar.size() );
|
||||||
|
string expected_result6 = "ﺓﺰﺋﺎﺟ ﻰﻠﻋ ﺔﻠﺻﺎﺤﻟﺍ ﻰﻠﻋ ﻲﻨﺒﻣ Glest ﺔﻴﻜﻴﺳﻼﻜﻟﺍ";
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( expected_result6,IntroText1_ar );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
string IntroText2 = "فريق MegaGlest يقدم";
|
||||||
|
string expected7 = IntroText2;
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 27,(int)IntroText2.size() );
|
||||||
|
|
||||||
|
#ifdef HAVE_FRIBIDI
|
||||||
|
Font::bidi_cvt(IntroText2);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 35,(int)IntroText2.size() );
|
||||||
|
string expected_result7 = "ﻖﻳﺮﻓ MegaGlest ﻡﺪﻘﻳ";
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( expected_result7,IntroText2 );
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user