-
Notifications
You must be signed in to change notification settings - Fork 354
TextMeshPro Font Asset Creation & Packaging Guide
This is a guide on how to create a new font asset bundle. If you want to know how to use a font asset bundle in game, see the "Font overriding" section in the readme.
This guide is based on a post by vbnshi. Check the original post for a Chinese version. They also posted a video version of this guide on bilibili.
Note: This was generated from the original post with a local LLM. While it was checked it may still contain inconsistencies. If in doubt, reference the original guide.
- Prerequisites
- Create a TextMeshPro Font Asset
- Test the Generated SDF Atlas
- Package the Asset into an AssetBundle
- Assign the AssetBundle to the Font Asset
- Build the AssetBundle
- Troubleshooting
- Ready-to-Use Font Files
This guide assumes that the target game is built in Unity 6.0. If it runs on a different Unity version, you must create the font asset with that same version, otherwise the asset may be incompatible.
| Item | Version / Requirement |
|---|---|
| Unity Hub | Latest |
| Unity Editor | 6000 (or the exact Unity version used by the target game) |
| TextMeshPro | Comes with Unity 6000; will be imported automatically |
| TTF Font File | Any TrueType font you wish to convert (e.g., arialuni.ttf) |
| Basic Unity knowledge | Creating a project, navigating the UI, etc. |
Open Unity Hub → Install → select Unity 6000 → click Install. After installation, click New → give the project a name → Create.
In the Hierarchy window, right-click on empty space → 3D Object → Text - TextMeshPro. The TMP Importer dialog appears. Click both “Import TMP Essential Resources” and “Import TMP Examples & Extras” buttons.
Drag the .ttf file from Explorer into the Assets folder in Unity.
In the top menu bar: Window → TextMeshPro → Font Asset Creator.
| Parameter | Recommended Setting | Remarks |
|---|---|---|
| Source Font | Drag your TTF file here | |
| Sampling Point Size | Auto Sizing |
|
| Padding |
3 (or 5 if you see missing glyphs) |
|
| Packing Method | Fast |
|
| Atlas Resolution | 8192 x 8192 |
Large enough for many characters |
| Character Set | Unicode Range (Hex) |
|
| Unicode Ranges | 0020-007E,00A0-00FF,2000-206F,3000-303F,3040-30FF,2600-26FF,FF00-FFEF,4E00-9FA5 |
Includes basic Latin, Latin-1 Supplement, punctuation, CJK symbols, Hiragana/Katakana, emojis, full-width punctuation, and common Chinese characters. Adjust to fit your needs. |
| Render Mode |
SDFAA or SDF (choose one) |
SDFAA gives slightly sharper edges at the cost of a larger atlas. |
Press Generate Font Atlas. Unity creates a new SDF (or SDFAA) font asset under Assets.
- Drag the newly created font asset onto a TextMeshPro object in the scene.
- Type a variety of characters (including those you listed in the Unicode range).
-
If you see missing glyph boxes (displayed as
□□□), return to the Font Asset Creator and increase Padding or expand the Unicode ranges.
When the test looks correct, proceed to packaging.
In Assets, right-click → Show in Explorer (Windows) / Reveal in Finder (macOS). Inside the opened folder, create a new sub-folder named Editor.
Inside Editor, create a plain text file and rename it to TextAssetBundleBuilder.cs (ensure the extension is .cs). Paste the following code and save:
using System.IO;
using UnityEditor;
/// <summary>
/// Simple AssetBundle builder. Place this script inside an "Editor" folder.
/// </summary>
public static class TextAssetBundleBuilder
{
[MenuItem("Vbntool/AssetsBundlePackage")]
private static void BuildAllAssetBundles()
{
const string folderName = "AssetsBundlePackage";
// Ensure the output folder exists
if (!Directory.Exists(folderName))
Directory.CreateDirectory(folderName);
// Build the bundle for Windows Standalone (adjust BuildTarget if needed)
BuildPipeline.BuildAssetBundles(
folderName,
BuildAssetBundleOptions.None,
BuildTarget.StandaloneWindows);
}
}Return to Unity. The editor will recompile the script and may show a few loading windows.
- Select the SDF/SDFAA font asset you generated earlier in the Project window.
- In the Inspector, locate the AssetBundle field at the bottom right.
- Click the dropdown
None→New.... - Type a name for the bundle, e.g.,
arialuni_sdf_6000, and press Enter.
The asset is now marked to be included in the bundle you will build.
- In the top menu bar, click Vbntool → AssetsBundlePackage (the menu item added by the script).
- Unity will display a progress bar. Wait until it finishes without errors.
The output folder AssetsBundlePackage appears next to your Unity project folder. Inside, you will find a file named exactly as the AssetBundle you set (e.g., arialuni_sdf_6000). This file is the ready-to-use TextMeshPro font asset bundle.
| Symptom | Possible Cause | Fix |
|---|---|---|
Missing glyphs (□□□) |
Padding too low, Unicode range incomplete, or atlas resolution too small. | Increase Padding to 5, add missing Unicode ranges, or raise Atlas Resolution. |
| No text appears at all (blank) | AssetBundle built with a Unity version that differs from the target game's version. | Re-create the font asset using the exact Unity version the game runs on. |
Font still shows □□□ after bundling |
The font asset was not correctly assigned to the AssetBundle, or the bundle wasn’t rebuilt. | Verify the AssetBundle name in the Inspector, then re-run Vbntool → AssetsBundlePackage. |
| XUnity.AutoTranslator does not pick up the font | Config entries missing or wrong. | Add the following lines to your AutoTranslator config: EnableTextMeshPro=True, and OverrideFontTextMeshPro=arialuni_sdf_6000 or FallbackFontTextMeshPro=arialuni_sdf_6000 (adjust the name if you used a different bundle name). |
| Need additional language support | The provided bundles only contain Japanese, Chinese, English, basic symbols, and Chinese punctuation. | Create a new font asset following the steps above, specifying the extra Unicode blocks you need. |
If you simply want a pre-built font bundle for the most common characters, look here:
- The process described here is fully editor-side; you do not need to write any runtime code to load the font.
- Always keep the Unity version consistent between creation and the target game to avoid compatibility problems.
- When working with large atlases (8192 × 8192), expect longer import times and larger bundle files. Adjust resolution according to the number of glyphs you truly need.