Open mynkrthd opened 1 year ago
Hey @mynkrthd , Thanks for your interest. Sorry for the late response; what you need to do is to modify Resources/res/persian_language_support_res/characters.json file and add configuration for characters with issues. Let me know if you have any issues.
Hi @mynkrthd ,
I wanted to know you were able to make any advances on the fix? Any information or insights would be greatly appreciated.
Thanks!
I don't have much time now to make a proper pull request, but here is an arabic characters file and a piece of code that does ligatures replacement as well. @MMaestriIce I guess you don't need this now :D
At the end of the constructor, read the ligatures:
{
const auto& rawLigatures = document[PersianLanguageSupportConstants::JsonKeys::ligatures].GetArray();
assert(rawLigatures.Size() > 0);
std::vector<std::string> rawLigatureArray;
for (auto& rawLigatureString : rawLigatures) {
rawLigatureArray = CommonOperators::split(rawLigatureString.GetString(), ' ');
assert(rawLigatureArray.size() == 2);
ligaturePairs[rawLigatureArray[0]] = rawLigatureArray[1];
}
}
At the beginning of normalizeText:
std::string PersianLanguageSupport::normalizeText(const std::string& rawText) {
std::string parsedText = CommonOperators::trim(rawText);
if (parsedText.length() <= 0) {
return parsedText;
}
{
auto replace_all = [](std::string& str, const std::string& from, const std::string& to) {
if (from.empty ())
return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length (); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
};
for (auto& pair : ligaturePairs) {
if (parsedText.find(pair.first) != std::string::npos) {
replace_all(parsedText, pair.first, pair.second);
}
}
}
std::vector<std::vector<cocos2d::StringUtils::StringUTF8::CharUTF8>> words;
{//Creating words
...
This is the characters file: arabic_characters.json.zip
Hi, I'm trying to fix it for Arabic. I have tried however it's working for some worlds and not for some worlds special for multiple worlds together. could please help out to fix this for Arabic language support.