Search Unity

TextMesh Pro Could we limit wrapping by words

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Jul 23, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hey.
    Is there a way to configure line breaking to keep words in text intact?

    Basically, I'd like to force a single word per line for existing text which is kinda not that hard to set up with single language, but with some localization there is usually different word length, so yes, it's actually requires you to turn wrapping off and modify text to include line breaker("\n") or it's gonna cut some characters to next line when text is too long. Which is a little bit of headache.

    Thoughts?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Line breaking always breaks on words unless the width of the text container cannot fit a particular word on a single line. Ie. by default it does not break words unless the word doesn't fit.

    For Asian language which typically do not use spaces, the list of Line Breaking Leading and Following characters which is referenced in the TMP Setting is used to determine where it is appropriate to break a line.
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    Well, I see that TMP by default does not break words unless the word doesn't fit, but I actually wonder if there a way to not break line even when word does not fit inside provided width.

    Would you be kind to clarify, please - Is list of Line Breaking Leading and Following characters is somehow suitable for not asian languages and if so, could I configure it somehow to break line where is spaces only?

    Thank you for your response.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What behavior / result would you expect when a word cannot be wrapped? Would you expect the remaining characters to go outside the bounds of the text container?

    The Line Breaking rules are specific to East Asian languages. These also only define where it is legal to break lines.
     
  5. Deleted User

    Deleted User

    Guest

    That's right, I do expect remaining characters to go outside of the bounds, since overflow allows to display then words in such manner.
    In fact, when I implemented localization it was little bit of frustrating moment to find out that some characters appeared on next line.

    Here. It's ~kind of what I am talking about.
    In both cases here expected two words, but since in russian words usually a bit longer - "Заданный" here have drop character "й" on next line.

    Аннотация 2019-07-24 004650.png

    Making text object wider will force english text here to be single lined and it's mean that line breaking suppose to be managed manually for each case to keep overall style uniform.
    Also, if there is some user provided localization that might be created by modders - then they're suppose to concern such moments, which is might be a little bit inconvenient.

    Here is what I am looking up to. In this example text bellow has been manually set to wider.

    Аннотация 2019-07-24 011500.png
     
  6. joxdev_pavel_glagolev

    joxdev_pavel_glagolev

    Joined:
    Feb 4, 2020
    Posts:
    8