Letter spacing in Text

Hi guys, I’m using the new Unity 4.6 GUI but I noticed a problem with the Text component. I don’t find the option of adding space (in pixels) between a letter and the other. Previously I used NGUI and with it there was the possibility to set a certain space between letters.

I believe that this feature isn’t implemented yet because this is a beta!

Tell me if there’s a solution, thanks,

Marco

Character Spacing ins’t available in Unity 4.6 GUI. However, if you need control over character spacing, check out TextMesh Pro which gives you control over Character, Line and Paragraph spacing as well as Kerning.

TextMesh Pro does a lot more than that so to learn more about it see the links in my signature or check out this video.

1 Like

I made a simple component to solve this exact problem within the new 4.6 UI environment.

Check it out here, if you’re still struggling with this.

3 Likes

Thanks you so much, your free script works really nice.

Thank you very much! :slight_smile:

We released an asset to solve kerning for Unity UI, it inherits from the Text element creating a new element called KernedText: Unity Asset Store - The Best Assets for Game Making

Here is tutorial and code for the letter spacing.

Here is the fix and updated latest code for unity 5.2 +.

A quick update here from this code:

In 5.3.X (and further) it’s not compiling anymore, but you will have to modify only one line
(41) “#if UNITY_5_2”
to
(41) “#if UNITY_5_2 || UNITY_5_3”

Of course you will have to do the same modification with all next versions of the engine.

Cheers !

If you do
#if UNITY_5_2 || UNITY_5_3_OR_NEWER’
then you don’t have to change it in the next versions (unless you really have to change the code itself).

Still from this code:

It works well, except I get an error while I’m using it with a text containing more than 2 lines :
2914073--214942--upload_2017-1-9_10-1-34.png

I fixed it by replacing line 125 :

//lines[i] = this.text.text.Substring(lineInfos[i].startCharIdx, lineInfos[i + 1].startCharIdx - 1);
  lines[i] = this.text.text.Substring(lineInfos[i].startCharIdx, (lineInfos[i + 1].startCharIdx - lineInfos[i].startCharIdx) - 1);
1 Like