Web Open Font Format (WOFF) and UIFont

A few months ago I tweeted this:

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.

  1. Using Emerge, I saw that the installed size of the app was fairly heavy on fonts.
  2. I googled “how to compress fonts” or something along those lines.
  3. I learned that Safari supports modern compressed font formats.
  4. 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.)
  5. 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?

About Joel Kin

Developing on Apple platforms for, holy shit, like twenty years now. Find me on linkedin and twitter. My personal website is joelk.in.
This entry was posted in Uncategorized. Bookmark the permalink.