Hiya, i wanna do some cool effects with my text that requires i use images for the characters instead of an actual font file. Does TextMeshPro support this?
Yes.
First, create a font asset and then mark it as Static. Assign the atlas texture that you want to use to the default material of the font asset.
Then edit the font face metrics to have the desired Ascender, Descender, Line height, etc. Lastly, add / edit the character and glyph tables to point to the glyph images contained in your atlas texture.
The glyphRects are the UV coordinates of the glyphs in the texture.
P.S. Just to get a better feel for how font assets are structures, create a font asset using the Font Asset Creator and add only the digits to it. Then look at the character and glyph table to learn how these related to each other.
How do I create a font asset? it’s saying i have to have a font file selected, but i’ve only got a PNG atlas.
Just pick the LiberationSans font file and then assign the your texture instead and then edit the metrics for the font face, characters and glyphs.
The texture slot for the atlas is greyed out (im assuming this is what you meant by assigning my texture)
Yes. It is greyed out because it is a sub asset part of the font asset and cannot be changed. However, the material which is also a sub asset of the font asset which currently references the atlas texture of the font asset can be edited to reference your texture. You would change this reference in the debug section of the material inspector.
Alright, So i’ve changed the texture. I previously did some slicing earlier with my font with the sprite editor, could I just take the dimensions from each slice there and use it for TMPro?
Also, when editing each letter, it doesn’t seem to change the actual display font. I’ve changed what the texture is on the material’s debug settings, but it’s still showing the old font.
Any help with this @Stephan_B ?
Create a text object using this new font asset that you created. Make sure the material used by this font asset does reference your texture. Then type the letter A for instance, and then edit the glyphRect to match the position of the letter A in the texture. Then edit the glyph metrics. Repeat for all other characters and glyphs.
I did type that, but the result was just the original texture stretched. I couldn’t see the new texture, which should’ve been green as that’s the main letter color
Update: Manage to get it going and can make out the outlines of the letters. Problem is, editing the glyphRect nor the glyph metrics doesn’t change anything. What’s more, I can’t make out the colors in the font, as it’s all white
@Stephan_B any idea on how to fix this?
Can you detail the steps you took to get to the point that your characters could display? I’m trying to do something similar but I’m unable to get my glyphs to appear in the side menu. I seem to be stuck at the point you were here:
Thank you!
Can you provide me the texture that you are using? I’ll create a font asset and edit the relevant data for two of the characters and glyphs and then export it out for you so that you can then mirror these changes for the other characters and glyphs.
If needed, you can provide me with the texture via private message.
Here it is:
https://media.discordapp.net/attachments/85593628650504192/923987625885438012/Silly_Font.png
The main thing I need to keep is the colour in the texture, as I’m hoping to use some shader trickery to colour each side differently.
To keep the color, you will need to use the TMP Sprite Shader. All the other shaders are for textures that are 8 bit alpha.
Thank you for providing the font texture, I will try to take a look on monday.
Ahh, alrighty. I’d have to make my own anyway to get the color changing working.
Also thanks.
Any update?