Search Unity

TextMesh Pro Textmesh Pro update breaks monospacing

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by FlaxenFlash, Aug 7, 2019.

  1. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    I just updated from Unity 2018.3.10 to 2018.4.4 for xbox build support reasons and at the same time textmeshpro seems to have been updated from 1.3.0 to 1.4.1. This update has completely changed monospacing values and broken a lot of our text. Strings that previous needed 2.5em monospacing now need 0.9em spacing to look the same. Rolling back to 1.3.0 fixes this but seems to cause some other alignment issues.

    Is this expected? I really don't want to have to go through the entire game to update all of our strings.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,312
    Unfortunately, I did make changes in 1.4.0 as the previous implementation was incorrect in the handling of these values. This also made it more difficult for users using external design tools to recreate these designs in TextMesh Pro. See the following post which contains more details.

    If you do have a lot of text to revise, let me see if I can think of a simple way to somehow keep the old behavior.
     
  3. FlaxenFlash

    FlaxenFlash

    Joined:
    Oct 15, 2015
    Posts:
    27
    Thanks, that post is useful and good to at least know that it's intended. Our strings are in a localisation system so I can probably write something to loop through all of them and update them rather than having to do it by hand based on the info you posted about how the spacing was calculated before and after the change. Can I assume the relationship between point size and character size is linear?
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,312
    For the conversion, here is the previous implementation vs. the newer one.

    m_monoSpacing = value * m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize;

    m_fontScale is
    m_fontScale = (m_fontSize / m_fontAsset.fontInfo.PointSize * m_fontAsset.fontInfo.Scale);

    TabWidth is the width of the Space Character (32)
    Tab size is the multiple for the tab defined in the font asset.

    Revised implementation
    m_monoSpacing = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;

    If you are using a normal TMP component then isOrthographic is typically false. For UGUI component it is true.

    The above should allow you to calculate what the previous m_monoSpacing value was vs the newer implementation.
     
    5argon, FlaxenFlash and technicat like this.