A few months ago I tweeted this:
iOS PSA: as of at least iOS 14, apps support the compressed .woff font format. This isn’t documented anywhere as far as I know. Shave some kb off your installed app size! pic.twitter.com/CudCS8VfM4
— Joel Kin (@myunderpants) March 15, 2022
Now that this change has actually been in my company’s app for a while, and nothing has blown up, I thought I’d expand on it a little.
The important takeaway–the tl;dr, if you will–is that you can simply compress your ttf fonts into woff, drop them into your app, change the file name in your plist, and you’re off to the races. Our app only has a few fonts, but it’s fairly small overall, so that savings is proportionally significant. If you have a small app, or if you have a lot of fonts, well, there’s no downside that I can see.
How did I figure this out? I wish I had a story about digging around in Hopper looking for optimizations. (And indeed my Hopper license is paid up.) But in this case it was just deductive reasoning.
- Using Emerge, I saw that the installed size of the app was fairly heavy on fonts.
- I googled “how to compress fonts” or something along those lines.
- I learned that Safari supports modern compressed font formats.
- I reasoned that it was unlikely WebKit had its own font code path, so if Safari can do it, maybe other parts of the system can too. (I could have verified this, since WebKit is open source.)
- I fucked around and found out.
If there’s a lesson here, it’s not to let received wisdom limit you. The documentation doesn’t mention this, and it’s very possible the right confluence of engineers within Apple has not come together–it might be that no one is in a position to write that documentation! But so what? Give it a try and see what happens! Coding is all about exploration, right?Tweet