The sticky announcement post is mentioning some upcoming improvements to the way TMP is handling line breaking. I searched but I haven’t been able to find the relevant forum posts about it. Does anyone knows what improvements are expected and when?
Right now, TMP doesn’t handle line breaking very well. For example, with French language, it sends the exclamation and interrogation marks to the next line even thought this is not typographically correct.
This is what TMP does:
This is what it should do:
The Unicode Line Breaking Algorithm handles these cases pretty well for most languages. Would it be feasible to integrate it to TMP?
The above example is using the following text “Toto veut-il du gateau?”
It is possible that you are using some alternative form of ? which is handled differently for CJK. Can you copy paste the exact text that you are using?
I’m writing French. The typographic rules aren’t the same as English. In French, spaces are required before interrogation and exclamation marks. So TMP is breaking on the space before the ‘?’.
For information I tested both TMP 2.0.1 with Unity 2019.2.19 and TMP 2.1.0 preview with Unity 2019.3, but the behaviour is the same.
As I said, the Unicode Line Breaking Algorithm works fine for this. I’m currently working on using it to wrap my text before feeding it to TMP, but I think it would be much simpler and more efficient if it was implemented inside TMP.
I am french and we do not use / add a space before “.”, “?” or “!” at the end of a line just like English. Pretty much all Latin based language use the same rules for line breaking. For testing, Microsoft Word or Outlook or Google Docs behave the same way.
Having said the above … you can add a non-breaking space \u00A0 between the last character and “?” this will prevent line breaking at “?”.
You’re right that it should be a non breakable space instead of a normal space (actually it should be a thin space). But I would rather let the algorithm handle that kind of stuff for me rather than checking the spaces in every sentences of my game. Also, I have no idea what the rules are for other languages. Judging by how insanely long the list of rules regarding line breaking is in Unicode (see here), I would guess different languages must have many different rules.
I will take a look at improving the line breaking handling of some of those special characters. No ETA on that but I’ll see what I can do.
Until then, I suggest using a non-breaking space in the text. I did add in the previous release support for which is easier to read / less error prone in the text. Internally, this tag gets replaced by \u00A0.
Hey there! I am trying to solve this exact problem while adding French localization to our game. I tried the tag but it wasn’t recognized… do I have to set a flag for it somewhere? Tags like work fine.
Ah I suppose it may be because we are on Unity 2018.4.26f, so we are limited to TMP 1.4.1 (I believe?), and maybe that tag was added in a later version?
Huh I just updated TMP to 1.5.6, even though the package manager said we were already “up to date”… and it worked! the tag is recognized now. I’m a little worried we’re gonna run into problems though since the package manager was telling us we were already up to date though?
I know that when I open the latest Unity 2018.4 or close to the latest, it will show me that a new package is available. Now perhaps if I was to open a version of Unity that predates this release, it might not show the latest package but I am speculating here as this is package manager stuff.