We recently upgraded from Unity 2018 LTS to 2020 LTS. Likewise TMP package was updated to the latest 2020 version (3.0.6) from the latest 2018 version. Unfortunately it looks like some stuff didn’t properly convert over.
Background: I’ve been doing some memory analysis using the new Memory Profiler preview package. When I load my game in English, I noticed that my two Japanese font atlases (1MB each) are residing in memory even though no text references these fonts directly. As a side note, no Chinese or Korean atlases are loading, just the Japanese ones. This seemed odd, but I recalled using these as a fallback at one point. Sure enough, the Memory Profiler indicated that there was a reference from my latin FontAssets.
However, when I opened the inspector on those latin fonts, the fallback list is empty. So I switch the inspector to debug mode and then I notice that there are two fallback lists. It seems the UpgradeFontAsset should have copied it over. Somehow that didn’t happen because the font assets are all marked as version 1.1.0. Also I noticed the UpgradeFontAsset code wouldn’t have removed the old (hidden) list anyway because that’s commented out. So even if I created a new fallback table without that reference, the old one would be hanging around, keeping the reference.
Correction - I realized that this wasn’t an issue with copying during the upgrade at all but in fact we did make a change to remove the fallbacks and so then this legacy list was sitting there still referencing old fonts. So I guess the take-away is that the TMP code needs to be sure to null-out or Clear this hidden legacy fallback list!
I will need to revisit the font asset upgrade process to make sure the old data (as you are reporting) does result in font assets still referenced in there getting added to builds and loaded into memory.
I will try to look into this over the next few days.
As usual feel free to bump the thread if I fail to follow up as I am still totally swamped on my end where it is pretty easy to end up having stuff fall through the cracks. These bumps are nice reminders for me
P.S. I have a new preview available which is version 3.2.0-pre.1 which now includes support for accessing font faces in TTC files as well as the new Dynamic OS Font Assets with manual support for Diacritical Marks as well. This is a preview but I thought these new features would be of interest to you.
Thanks, I appreciate it. It’s not a high priority now that we figured out what was going on, it was easy to fix. I can’t emphasize enough how helpful it’s been to have full access to the TMP source code for debugging things like this.
This sounds pretty cool. I’m not familiar with TTC files but reading about them I’m kind of confused. Sounds like multiple fonts can share the same glyphs, but wouldn’t a collection typically contain different font weights and styles? Seems like these would not likely share glyphs since the thickness would affect the glyph vector art?
Regarding being able to build Dynamic font atlases from an OS font does sound good, especially for CJK fonts. I’m already using NotoSans for these, so I could save a lot of app and memory size if I could just build my fonts from the system’s copy of NotoSans CJK, which has been available since Android 2.2.
I’d like to know more about Diacritical Marks, that sounds like it could combine glyphs to make more space in the atlases?
TrueType Collections were initially designed to reduce potential file size as many CJK fonts for instance had many glyphs in common. Then at some point companies began using TTC to pack font families in a single font file instead of having to potentially manage and ship 18 different font files. This was then taken to another step where we have font s like PingFang.ttc which contains local specific fonts and families as seen below.
Diacritical Marks are essential for several non Latin languages like Thai.
Thanks for the info. I found the preview in the Package Manager and as usually the release notes had a lot of information. The notes refer to a video…perhaps that was from a forum post? Thanks!