Hi there,
I faced a bug when Label and RT rendered Persian and Arabic text.
A new line is usually in the middle of the word, not a space after or before.
Some screenshots
In these two images the new line is in middle of word
The issue you are facing is because the arabic script has unique features like connected letters and right to left. To resolve this you can use the \n (newline character) or manually shift the word to the next line that is getting cutoff.
Example using \n:
جستجوی\nپمپ بنزین
When you run the game it will be displayed as:
جستجوی
پمپ بنزین
Yes, I know this solution, but there is a lot of text they must get from services that are not hard coded so, this solution is not possible in my case!
In that case you can try using an arabic text shaping library, that will connect the letters correctly for you. I’ve not tested it personally but you can give it a try. Just google and look for a js arabic text shaping library and import it in cocos creator.
Previous versions of CC had reshaping sticky text problem and they’ve solved it.
Reshape is a different issue than mine, it’s related to font glyphs. Beside, using reshapers will throw new bugs for example, no all custom fonts will support all glyps.
The issue you facing is due to incorrect word wrapping for arabic script. You can disable wrapping in your label component and write your own custom solution to handle word wrapping for arabic text. You can try the following:
- store the max width of your label
- split the arabic text into words
- add each word to the label one by one
- after adding each word check if the width exceeds the max label width
- if so then store it as line one
- do this again for remaining words and store them as line two and so on…
- then join all the lines with \n
This is an alternate solution, the con is that it will cause a lot of unnecessary draw calls.
The pipeline or renderer must fixed as solution
I would also like a fix for this. It happens with other cases as well, if you have say “$10,000”, it will split on the $ or , characters. (this could be separate issue)