Search Unity

Question No Line Breaks in Japanese After 、Character

Discussion in 'UGUI & TextMesh Pro' started by MichaelNicoletti, Sep 14, 2022.

  1. MichaelNicoletti

    MichaelNicoletti

    Joined:
    Aug 23, 2016
    Posts:
    3
    We are currently working on localization for our game and have run into an issue where TextMeshPro seems to be inserting a line break in the middle of a word instead of after the 、character even though it is found in the "Line breaking for Asian languages" section of our TMP Settings.

    Is there something that we have to toggle on the settings or the actual TextMesh object to enable this functionality?

    This is the line in question:
    '特定の属性攻撃を受けたり、危険な場所で戦っていると、<color=#DE2F7B>浸食</color>、<color=#FF5F00>火傷</color>、<color=#B6A925>感電</color>、<color=#30B2A2>浸水</color>
    といった状態異常を引き起こすことがある

    Attached is a picture of how it is broken in the actual editor:
    upload_2022-9-14_9-47-39.png

    Any help would be greatly appreciated!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,486
    Just so you know, posts containing these characters on this forum will cause it to go for moderation because of the sheer amount of spam that is filtered. Also, people quoting you will do the same. I just approved this from moderation because of it.

    I know, it's not ideal but thought it worth mentioning to you to save your posts being delayed. :)
     
  3. MichaelNicoletti

    MichaelNicoletti

    Joined:
    Aug 23, 2016
    Posts:
    3

    Thank you for the heads up! I will make sure to not do this in the future!
     
    MelvMay likes this.
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    For CJK languages where spaces are not typically used. Line breaking is based on the Leading and Following character rules which define where breaking is allowed. These rules list characters that are not allowed at the start of a line or characters not allowed at the end of a line. Line breaking is allowed on all other CJK characters not restricted by these rules. The asset files that contains those rule are defined in the TMP Settings.

    As per the above, the Japanese text would break on characters before the " 、" as it is legal to do so.

    Just for testing, copy / paste the same line of text in Microsoft Word and observe how it breaks the line which should be the same as TMP.

    Having said that, you can control line breaking by using a combination of the <nobr> and <zwsp> markup tags as seen below.

    "<nobr>特定の属性攻撃を受けたり、</nobr><zwsp><nobr>危険な場所で戦っていると、</nobr><zwsp><nobr><color=#DE2F7B>浸食</color>、</nobr><zwsp><nobr><color=#FF5F00>火傷</color>、</nobr><zwsp><nobr><color=#B6A925>感電</color>、</nobr><zwsp><nobr><color=#30B2A2>浸水</color></nobr>
    といった状態異常を引き起こすことがある"
     
  5. MichaelNicoletti

    MichaelNicoletti

    Joined:
    Aug 23, 2016
    Posts:
    3

    Thank you for the very in depth answer! We will move forward with this information thank you!