Search Unity

TMP and word spacing with justified align

Discussion in 'UGUI & TextMesh Pro' started by kumade, Jul 11, 2020.

  1. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    tmpro-bug.png
    Hi everyone. On the image above you might see 3 samples of TMP text using different Wrap settings for having nicely looking spaces in text. But none of them shows good result. If wrapping is set towards W - words looks super nice and unified but all spaces between long words are annihilated (see red marks). If the setting is default - it's not much better. If it's set towards C - spaces look better but some words become too wide. Why there's no nice way (or I'm just unaware of it) to have nicely looking words (with almost equal spacing between characters) and at the same time words wrap to another line if there's clearly not enough space to fill them in a single line instead of eliminating spaces between?
    If I'm missing something - please enlighten me, but I really can't make a unified setting for all my TMP texts so they show any content nicely. And I wonder - why is that. Browsers and text processors seem to be doing this pretty well, aren't they?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The Wrap Mix controls the blend between using word or character spacing to fill the empty space when using Justified or Flush alignment modes. Depending on the content of the text, the results will vary.

    How does the same text given the same contain width compare when using Justified alignment in Microsoft Word or Google Docs?
     
    kumade likes this.
  3. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Hi Stephan! Thank you for reply. Not sure how can I measure if it's the same width exactly but here's what I've got in Google Docs:
    tmpro-bug2.png
    Words look consistent and spaces between those long words are very distinct.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    As you can see, Google Docs only uses word spacing to fill the line gap. As such you end up with lots of space between words on the second line.

    By contrast using the Wrap Mix to some value like 0.5, TMP will add extra spacing between characters as well as words to try to make the line look better. However, if a line is made up of only 3 words, it can still end up looking strange.
     
  5. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    I'm ok with lots of space between words but seems like I can't get this result with TMP, can I? After all humanity got used to the way browsers make word spacing so TMP's way seems a bit awry no matter what I set in Wrap Mix (no offence ;) , great job anyway! )
    If I set it to 0.5 it's not much better than 0.4 on the screenshot I provided.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide me with the exact text you are using along with the font file.

    I'll take a look at that 6th line which I suspect is the result of the slight potential compress of the spacing between words.

    Basically, in order to avoid wrapping the last word to the next line because the width of the container doesn't allow all 3 to fit, the space between words can be compressed by up to 5%. If it didn't do that, you would have a lot of spacing on this line just like on line 2. You can visualize this in Google Docs by slightly reducing the margin width where the last word wraps.

    This is not an issue related to TMP but simply the result of what your text happens to be on the particular line given the width of the text container. The same behavior would be observed in Google Docs for the same width. I can verify this if you provide me with the exact text and font.
     
    Last edited: Jul 12, 2020
    kumade likes this.
  7. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Thank you Stephan for looking into my issue! It'd be ok if spacing would have been compressed by 5% but it completely eliminates spaces with WrapMix = 0 , seems the spaces between words become even smaller than between characters as words start overlapping each other.

    As I said it'd be totally fine to me if I had lots of spacing between words but equal spacing between characters in any word. Is that possible to achieve with any set of settings?

    And here's the text:
    https://docs.google.com/document/d/1-AZVYEX8K-hZNbo4YZKstctNK9pHiowChHtJOk-a5sQ/edit?usp=sharing
    (the forum doesn't allow to post cyr characters for some reason)

    And the file is attached to the comment. Thanks again for your attention.
     

    Attached Files:

    B-Erolskiy likes this.
  8. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Hey @Stephan_B , just checking if there's any updates on my case?
     
    B-Erolskiy likes this.