Dynamic Font - what happens when the atlas runs out of room? How to handle that situation?

If I create a dynamic font with an atlas width/height of 2048x2048 (which Stephan has said in other posts should be the largest size you use) for a Chinese font - what happens if the atlas runs out of room? Chinese has hundreds of characters and from previous experience making non-dynamic fonts, you end up having to make multiple atlas’s and use the font fallbacks in order to get all characters in.

From some limited testing, it seems once the atlas runs out of room the rest of the fonts just fall back to the projects’ default font asset (generally LiberationSans since I never change it…).

Is there some way to know if an atlas is “full” so that another dynamic font can be generated?

As you mentioned, when a glyph is missing from a font asset or when it is no longer possible to add the given glyph to a dynamic font asset, TMP will go through the fallback chain in the following order:

  1. Primary Font Asset (Local fallbacks)
    Recursive search through the fallback list of the primary
  2. Sprite Asset assigned to the text object as sprite may have been assigned a unicode value.
  3. Recursive search through the fallback list assigned in the TMP Setting. (Global Fallbacks)
  4. Default sprite asset assigned in the TMP Settings
  5. Default Font Asset assigned in the TMP Settings
  6. Missing glyph symbol specific in the TMP Settings

All font assets potentially referenced above can be static or dynamic.

It is important to note that changes to font assets in the editor are persistent but not in builds. As such any glyphs and characters added to a dynamic font asset will not be persistent from one play session to another. As such, if you have a primary font asset (for Chinese text) that contains all the known text used in the project (ie, all the characters specifically referenced in the project menus, ui, dialogue, etc.) and assign an empty dynamic fallback to this primary static font asset, it is very unlikely that any user will type enough characters to overflow an empty dynamic fallback of the appropriate size (typically 1024 x 1024 depending on sampling point size and padding) in a single play session.

It is important to understand that although the Chinese language contains over 72,000 characters, the bulk of the Chinese population only understands a small subset of that. Case and point, the Chinese government published the Table of General Standard Chinese Characters. This list includes pretty much everything that has ever been encountered in electronic publications, etc. This list contains a total of 8105 characters which is divided into 3 groups. These are the Common Characters (3500), Less Common (3000) and Rare (1605). As such the likelihood of a user typing more than a few dozen characters outside of this list is unlikely and as such should easily be handled by a single dynamic fallback.

Having said that and to continue to make the dynamic system in TMP more powerful / flexible, a new feature called Multi Atlas Texture will be introduced in the next release. This new feature will enable dynamic font assets to have more than one atlas texture where additional textures are created as needed to handle additional glyph coverage. Atlas textures are now contained in an array. They all have the same settings.

The next release of the TMP package with this new feature should be available within the new few days or so. I am currently going through the steps to get the new package approved / published.

Awesome news - thanks for the info and thanks for this amazing asset :slight_smile:

1 Like

Hi [Stephan_B]( https://discussions.unity.com/t/758857 members/stephan_b.1309638/),
Is the functionality you mentioned above available at version 2.0.0? I can’t find any options named with that.

The above functionality is available in the latest releases which for Unity 2019.x is 2.1.0-preview.12.

You will need to make sure that you have “Show Preview Packages” in the Package Manager where this option is in the Advance menu option as seen below.

5840623--619993--upload_2020-5-13_0-33-37.png