Do we need to manually apply line breaks in cases like these either in the text itself or code so that the linebreakless text fits better within text nodes or is there an option I’m not thinking of?
This could probably be made smarter by detecting non-Japanese chars and not adding zero-width space char after them so they don’t split in half when mixed in but then that would mess up the tracking.
We do nothing special with the zero-width space character except use it when calculating linebreaks. If the zero-width space character has some width it is probably because it’s like that in the font.
So should be possible to detect English words and not add zero width spaces within them. There are still more considerations until this is really good too.
Wow, that is an extensive set of rules! There’s basically two groups: 1) Characters not permitted on the start of a line and 2) Characters not permitted at the end of a line
Right now we only break on space + zero-width space and we never break in the middle of a word. I’m not really sure if we need to do anything else really?
No, nothing is needed by the engine, but we do have to filter text to insert zero-width spaces based on these rules depending on language at the correct places before setting text on nodes / labels to have attractive text that has line breaks as expected.
Here is a wip module meant to address the issues related to this topic. It is a start with following these rules Line breaking rules in East Asian languages - Wikipedia though it would be good if Defold itself was able to handle these rules on labels/text nodes. Maybe RichText would be a good option for implementing the rules since this is already sort of in its domain.
The wip module can for sure be improved to be more efficient / faster / implement more of the rules by someone who knows how to do those well.
This image illustrates the kind of problems the WrapText module is meant to address. Because all characters are connected there is no natural white space to allow line breaks. But there are still situations where you don’t want certain characters to be left at the start/end of a line.
When testing with this specific font with Chinese characters attempting include the zero width space / insert it between Chinese characters does not seem to work.
It’s something the editor is doine changing the extra_characters field. I tried setting it to \xe2\x80\x8b and the editor changed it to extra_characters: “\342\200\213”
And now it seems to be working right, (but only with the modified ttf not the otf) and with the \342\200\213 listed in the extra chars raw text (I don’t understand this, I guess they are Octal UTF-8 bytes).
This is great! I bumped into this a while back with Japanese, but solved it by manually (and possibly incorrectly) inserting spaces. Next time I’ll give the module a spin instead.