The TMP FontAsset inspector allows you to modify font metrics (FaceInfo) such as baseline, ascentLine, underlineOffset, lineHeight, etc. so that you can manually tune the font metrics as needed. We use this a lot with Chinese, Japanese, and Korean fonts especially.
We recently upgraded from TMP version 1.0.56 to Unity 2018.4 with TMP package 1.5.0-preview.4 It’s nice that the font creation information is preserved when you click [Update Atlas Texture]. However, as before, when you save the new atlas, the font asset metrics (FaceInfo) always get overwritten from the default in the source OTF font.
To solve this in the past, we wrote a script to preserve the font metrics after regenerating a static font. It even handles the case when the point size changes. For example, say we had created a FontAsset with point size 40 and a manually-tuned line height of 50. After regenerating the atlas with added glyphs, the auto point sizing has to be smaller to make the new glyphs fit: in this example it becomes 35. Since the line height and other metrics are proportional to point size, we wrote a script that fixes up the font metrics after going from 40 to 35. In this case the new line height would be set to 43.75 = 50 * 35 / 40:
NewMetric = OldMetric * NewPointSize / OldPointSize
Now after upgrading TMP, while you can still edit the metrics from the UI, it appears as if you’re no longer able to modify the FontAsset faceInfo from a custom editor script. Is there an API exposed to do this?
We would love it if this editor script we wrote to fix the metrics wasn’t needed any more; there are two solutions to achieve this. The first and best solution would be if TextMeshPro automatically preserve the metrics when regenerating existing fonts, as described above, when the point size changes and the source font is the same.
The second (less ideal) solution is if we could keep the point size fixed at, say, 40 and just dynamically create as many smaller atlases as needed to build the font. This is supported in the new 1.5.0 preview! However, we cannot use dynamic fonts for Chinese at runtime because the Noto Sans OTF fonts for CJK would take up 110MB, which is larger than our entire APK right now on Android! What we really need is an “Atlas Population Mode” of “Dynamic In Editor, Static at Runtime” which would ensure that the original OTF file is not referenced in the builds. With this solution, the metrics could also be manually tuned and presumable with Dynamic font generation, the metrics would not get overwritten.
Thanks so much @Stephan_B