Migrate static font assets to Advanced Text Generator
Migrate static font assets to the Advanced Text Generator.
阅读时间3 分钟最后更新于 8 天前
The default Advanced Text Generator doesn't support static font assets. If your existing project uses them, you must migrate them so your UI text elements render correctly.
The recommended way to migrate is to convert the static font asset to dynamic in the Inspector window. The conversion happens in place, so all references to the font asset keep working, and it preserves the optimizations static font assets are commonly used for: the baked atlas is kept, and the source font is subset so only the baked characters ship in builds.
If you prefer to migrate manually, choose your approach based on your original optimization goals for the static assets:
- Reduce memory footprint through character set limitation.
- Optimize startup and first-frame performance through a font atlas pre-populated with commonly used characters.
- Remove static font assets without font-asset-specific optimization preservation.
Convert a static font asset to dynamic
When you select a static font asset, the Inspector window displays a warning that static font assets aren't supported, along with a Convert to Dynamic button.
To convert a static font asset:
- In the Project window, select the static font asset.
- In the window, select Convert to Dynamic.Inspector
?
The font asset switches to the Dynamic atlas population mode and keeps its atlas, material, and references. Unity subsets the source font to the characters baked into the atlas, so builds don't grow by the size of the full font file. You can review or change the subset in the Font Subsetting section of the Inspector.
If the source font file has changed since the atlas was generated, the baked glyphs no longer match it and the Convert to Dynamic button is disabled with a warning. Regenerate the atlas with the Font Asset Creator first, then convert.
Reduce memory footprint
If you created the static font asset mainly to ship a smaller character set, create a dynamic font asset and subset its source font.
This reduces the font file size and can further lower memory usage because it eliminates the need for a pre-populated atlas texture. For reference, an atlas texture in Alpha 8 is approximately:
- 1024 × 1024 → ~1 MB
- 2048 × 2048 (common for CJK) → ~4 MB
To migrate, do the following:
- Identify the characters or scripts required by your UI.
- Create a dynamic font asset from the original font file.
- Subset the source font in the font asset's Font Subsetting section.
- Replace all references to the static font asset (USS/UXML/C#).
Optimize startup or first-frame behavior
If you used a static font asset mainly to pre-populate an atlas (to reduce runtime glyph generation during startup), the equivalent workflow in Advanced Text Generator is to use a dynamic font asset and pre-populate its atlas with a chosen character set.
To migrate, do the following:
- Create or select a dynamic font asset
- In the Font Asset Creator window, load the dynamic font asset.
- Populate the atlas with the desired character set.
- Replace all references to the static font asset (USS/UXML/C#).
Remove static font assets without preserving font-asset-specific optimizations
If you don't need memory reduction nor startup optimization, you can replace static font references directly with the Unity font asset imported from the typeface file, such as or .
.ttf.otfThis requires no font-asset creation step; however, you lose font-asset-specific customization options.
To migrate, do the following:
- Locate the corresponding Unity font asset (the imported typeface) in the project.
- Replace references to the static font asset with the Unity font asset (USS/UXML/C#).
Your UI text elements can now render correctly, and you can take advantage of Advanced Text Generator's enhanced text rendering features going forward.