Is it possible to use alternate characters when creating text with TMP (e.g. a typeface might have 3 different versions of the letter ‘S’, and a random one is chosen each time)?
Sort of …
Support for the OpenType Layout feature called Alternate is not currently available. However, provided you know the index of those alternate glyphs in the font file, you could access these by manually creating ligatures using version 3.2.0-pre.3 of the TMP package for Unity 2020.3 or newer or version 2.2.0-preview.3 for Unity 2019.4.
For example, I am using the font called Alegreya-Black which does contain some alternate forms of glyphs. In this font, there is an alternate for the letter “C” which is the glyph with index #249 as seen below.
Although we can add glyphs by index in this current release, we can indirectly do so by creating a Ligature that references the glyph index as seen below.
Once the glyph has been added to the glyph table, I created a new character using a Unicode in the Private Area Range which is E000 to F8FF and pointed it to the desired glyph index as seen below.
I then deleted the Ligature because I didn’t want to always replace “C” by this new alternate.
To access these alternates, I could repeat this process assigning each alternate to some custom private area Unicode.
Alternatively, I could setup some Ligatures where the input would be something like “C” + “_” + “0” = Ligature as seen below.
Note that when using Ligatures, the sorting order matters where as soon as we have a match the ligature is applied. This means that if “ff” is before “ffi” the “ff” will always be substituted and you won’t ever get the “ffi”. As such, the 3 component ligature “ffi” needs to be first then followed by “ff”.
Proper support for stylistic alternate is in the works but this should enable you to still access them for the time being.
OK that’s great @Stephan_B - thanks for the detailed reply, much appreciated.
Is this only possible in the old pre-releases? Cause I can’t seem to find the “Ligature table” option on the TMPro-font settings. As you can see in the image below.
I did find that I can mark my ligatures as ligature in the “Glyph Table” tho.
I also can’t seem to be able to find the pre-release versions in the package manager (pre-release packages is on in the settings). The only thing that shows is version 3.0.6.
And I was wondering where I should be able to find the version your talking about in your original explanation.
Or if I do something dumb and need to look somewhere else entirely.
If you need any more information from me please let me know!