Creating / updating TextMesh Pro font assets from editor scripts

AFAIK it’s currently not possible to create / update a font asset from script. But it would be a very useful feature.
Let me explain with an example based on our current game and its workflow.

Our game is localized to several languages. Some of them are part of CJK-family and require distinct fonts. These font files are relatively big (about 5MB each). So since we can prebuild font atlases we don’t need these fonts and can save some space of the final build (quite important on mobile and some console platforms).
To make font atlases more optimized we use only those characters which are present in localization data. For this purpose we have a separate tool which extracts all unique characters into separate text files. The only dynamic text we have contains digits, so we add all 10 digits to each of these groups of unique characters.

However during development we use a dynamic population mode to save time on constant updating of the font assets after each update of localization data.

And here comes the part I’d wanted to automate. When the build is started:

  1. extract all unique symbols to text files;
  2. use these text files as a source for rebuilding existing font assets;
  3. switch from dynamic mode to static mode for each of these font assets;
  4. remove reference to the source font from each font asset to make these fonts not get into final build and save some space;
    After the build revert changes in items 3 and 4 to original “development” state to make version control system happy for having no changes.
    Items 1, 3, 4 are feasible now, but not item 2 (at least I did not manage to find related code).
1 Like

Hmm… it looks like item 4 is not required since reference to original font is stored only in the Editor.
However I still would like to automate updating of font atlases.