Search code examples
cssiosencryptionuiwebviewfont-face

Protecting custom fonts in UIWebVIew


In my app I display HTML content in a UIWebView. The HTML content is downloaded from a server and stored in the iPad's file system to enable offline usage. The HTML uses custom fonts via @font-face in it's CSS file:

@font-face {font-family: 'CustomFont'; src: url(Custom-Font.otf);}

To make this work, the font .otf file is also downloaded and stored in the iPad's filesystem.

The problem is, that now the font is available to anyone who can access his iPad's file system (which is really easy if you use something like IExplorer).

This leads to some legal problems, as most font providers do not allow that their fonts are freely distributed (which they practically are when I use this method).

My question: Is there any way, how I could keep the fonts encrypted in the filesystem and decrypt them when the UIWebView tries to load them?


Solution

  • I found a solution that works really well: Robin Summerhill wrote a great tutorial on how to protect resources in your iOS App using Apple's CommonCrypto API and Custom URL protocols. You can use that to encrypt all your embedded resources and it works with fonts, too.