SaveFontTexture

Author: Eric Haines (Eric5h5)

Description
If you've ever wanted to get at the auto-generated font bitmap that Unity creates when importing vector fonts, now's your chance. SaveFontTexture saves that bitmap as a .png file so you can edit it, add whatever whizbang effects you want to it, and then use it as a colored font, using the TexturedFont shader and a GUIText object.

Note: this script isn't necessary in Unity 4, since in that case you can click on the font and choose "Create Editable Copy" in the gear menu in the inspector.

Usage
Script Setup

You must place the script in a folder named Editor in your project's Assets folder for it to work properly. When this is done, you will then have a Save Font Texture... menu item in the Assets menu. Find the TrueType font you want in Unity and open the root, which reveals the auto-generated material and texture. Click once on the texture (called "font Texture") and select the Save Font Texture menu item. If the texture appears black in the preview window then you must change the Character setting in the inspector from Dynamic to another, such as Unicode. Choose a file name and location in the file dialog, and hit save. (Technically this script will work for any texture in Alpha8 format, if for some reason you wanted to save it as a .png file.) Note that the character set must be something other than dynamic.

Customizing and Using Font Textures

1. Get the TrueType font that you want to modify in Unity at the desired Font Size (so that you can use Pixel Correct in the GUI_Text object that will use it for crisp rendering).

2. Use this script (installed as described above) to save the texture Unity generates automatically for the font.

3. Edit that texture file in Photoshop to use in your project.

4. Create a new Material in Unity.

5. Set the texture of the material to the modified texture.

6. Set the shader of the material to the TexturedFont Shader.

7. In any scene GUI_Text objects that will use the custom font, apply the original font to the object then change its material to the custom material created in steps 4-6.

8. In the Inspector, Wrap Mode: Clamp the texture and set its Texture Type to "GUI" (which disables MIP Maps).