How to implement flexible spacing between words with textmeshpro

Hello Stephan,

I want to know if there is anyway to SEPARATE groups of words to simulate “cells” of a table.
I experienced a good result using “align=flush” but the “cell” must only have 1 word (so i must replace spaces to another character)

Any tip to implement this feature? (i just need a “flexible space between words”)

in this case i want to separate the word group “cell1 word1” and the word group"cell2 word1" without convert to
“cell-word1” and “cell2-word1”

maybe something like “cell1 word1cell2 word1”?

Try the following with Flush mode as you have with the text below:

“Example\u00A0One Example\u00A0Two”

A few months ago, I made a change to the non-breaking space \u00A0 where it is excluded from consideration with regards to Justified or Flush alignment.

1 Like

Perfect!! thank you very much

1 Like

Thanks for the solution Stephan.

I wanted to ask though, could there be a way to have a single flexible space character? Something like a ‘super tab’ char? eg key column: \T value column

It would be an immensely useful feature to have.

Cheers

Just to follow up, I implemented a ‘supertab’ parsing method here to create something with the functionality I mentioned. It’s a bit janky, but it does work:

public static string ParseSuperTab(string src, string superTab = "«»")
{
    if (!src.Contains(superTab))
        return src;

    string[] lines = src.Split('\n');
    string dst = string.Empty;
    for (int i = 0; i < lines.Length; i++)
    {
     
        if (lines[i].Contains(superTab))
        {
            dst += "<align=flush>" + lines[i].Replace(' ', '\u00A0').Replace(superTab, " ") + "</align>";
        }
        else
        {
            dst += lines[i];
        }
        if (i < lines.Length - 1)
            dst += "\n";
    }


    return dst;
}

This will replace normal spaces with non-breaking spaces and set up flush align on any lines that use the “«»” supertab.

So, something like this:
Column one:«»Value
becomes this:
Column one: Value

Works well enough for now. :slight_smile:

Cheers

2 Likes