Long URL breaks link tag

Hello,

Seems odd that I might be the first to find about this, but I simply can’t have “long” links in TMPro.
Using v3.0.6

Text: <link="https://res.cloudinary.com/cloudinary-marketing/cloudinary-marketing/images//blog/WebP_2000x1100_v1a/WebP_2000x1100_v1a-jpg?_i=AA">@@@@</link>
Expected render: @@@@
Actual render: <link="https://res.cloudinary.com/cloudinary-marketing/cloudinary-marketing/images//blog/WebP_2000x1100_v1a/WebP_2000x1100_v1a-jpg?_i=AA">@@@@

Edit:

  • Happens in v3.2.0-pre.4 too
  • Using Unity 2022.1.24f1

@Stephan_B any thoughts on this?
Thanks

Alright, I’ve found the culprit, links over ~120 chars are not supported out of the box, it’s a pretty huge limitation.
I understand that links can be shorter and you can have a mapping in code, but that’s seems unnecessarily complicated.

I’ve added this code to my current project to increase it to 1024 chars:

    private const int RICH_TEXT_TAG_LENGTH_OVERRIDE = 1024;
#if UNITY_EDITOR
    [UnityEditor.InitializeOnLoadMethod]
#else
    [RuntimeInitializeOnLoadMethod]
#endif
    static void TryFixTMProTagLength()
    {
        // Fixing TMPro to have a bigger tag length. Currently it's just 128 which is peanuts - links can be very long.
        // More specifically, the link tag breaks if the text inside the tag is longer than 128 chars, eg:
        // For <link="http://..">
        // <whatever_is_here_has_to_be_shorter_than_128_chars>
        var fi = typeof(TMP_Text).GetField("m_htmlTag", BindingFlags.NonPublic | BindingFlags.Static);
        var arr = fi.GetValue(null) as char[];
        if (arr.Length < RICH_TEXT_TAG_LENGTH_OVERRIDE)
        {
            Array.Resize(ref arr, RICH_TEXT_TAG_LENGTH_OVERRIDE);
            fi.SetValue(null, arr);
        }
    }

Link to the latest revision: github