Font Embedding and Font Obfuscation/Mangling

The Sigil font obfuscation menu
  • Sumo

There has as been a lot a talk at #ePrdctn Hour recently about font embedding and font obfuscation/mangling. I wanted to provide some resources in case anyone is struggling with the same issues.

Embedding Fonts

Liza Daley has a great post on her Threepress Consulting blog titled “How to embed fonts in ePub files” that explains how to embed fonts but also examines the issues around choosing fonts, font licenses, and how to actually embed a font.

Liz Castro has a post on her Pig, Gourds, and Wikis blog titled “Embedding Fonts in ePUB—iPad, iPhone AND Nook”  that will walk you through embedding fonts for those devices and stores.

Font Obfuscation

When you embed a font in an ePUB, the font files are included in the ePUB itself. This potentially means that someone could open an ePUB file, take the font files out, and use them without license or permission. This would make you a potential distributor of the font, and would likely violate your font license. To avoid this, fonts can be obfuscated or mangled, making it impossible to remove the font from the ePUB and use it anywhere else.

As Liza Daley notes in her post, Adobe has open-source code in epub-tools to enable this, and provides detailed documentation on how to use it.

The International Digital Publishing Forum (IDPF), the institution responsible for the ePUB spec, also has information on font embedding and obfuscation/mangling, including an obfuscation algorithm on their page “Font Embedding for Open Container Format Files.”

I’ve also found a python script that encodes the fonts found in an ePUB. This script encodes the fonts according to the method Adobe uses in ADE, but it does not use the IDPF method.

Adobe InDesign will obfuscate embedded fonts when converting to ePUB. There is some question about issues surrounding validation, however, as described in the posts “InDesign CS5.5, Embedded Fonts and Validation”. and “Best Practice: Embed Fonts??” on the Mobile Read forum.

Sigil now has a font obfuscation menu as an option for embedded fonts in ePUBs. It was added at this update: “Sigil v0.3.1 2010.11.07 – added a new ‘Font Obfuscation’ context menu for font files in the Book Browser; the user can now select (or de-select) the use of Adobe’s or the IDPF’s font obfuscation methods; this also resolves the problem where Sigil refused to open epub files that use such obfuscated fonts with the message that the epub has DRM.” Here’s what it looks like:

The Sigil font obfuscation menu

The Sigil font obfuscation menu

The font obfuscation issue is one area where it appears there isn’t really a best practice established yet, at least not with respect to licensed fonts that require obfuscation if you are going to include them in an ePUB. If you are embedding licensed fonts in your ePUBs, you may want to speak with the foundry licensing the font to see what their recommendations are for obfuscating the font. You might also consider free, open-source fonts like you’ll find at Google Web Fonts.

What have your experiences with embedding fonts been? Do you obfuscate or mangle your embedded fonts? Is so, how do you obfuscate the fonts?

16 Responses to “Font Embedding and Font Obfuscation/Mangling”

  1. @aarontroia says:

    Great post! I have been looking for a way to obfuscate/encrypt/mangle fonts in my ePubs for the last few weeks, and this post really nailed it. the python script (now that I figured out the opf:scheme is not needed in content.opf and will throw errors in ePubCheck1.2 if included) will work wonderfully in my workflow. Thank you!

  2. @aarontroia says:

    A little follow up on my last post on using the Python script.

    In reading the first post on the forum, the author gives the impression that you need to include opf:scheme=”UUID” inside the dc:identifier tag in your content.opf file. But once you read down further in the threads you see that it is not needed in the newest version of the script (he mentions 1.2, if you open the script its says 1.1, but im pretty sure its 1.2), and from my experimenting with the script found, including the opf:scheme will throw errors in ePubCheck1.2 (ex: The prefix “ofp” for attribute “ofp:scheme” associated with an element type “dc:identifier” is not bound.). That being said, you will need to use urn:UUID:(>16 digit hex identifier code) in between the dc:identifier tags for the script to work.

  3. chrxr says:

    So has anyone actually managed to find a tool that obfuscates to IDPF spec, and the resulting file works in iBooks? I can’t get the Adobe one on Google Code to work at all, and files created using Sigil’s IDPF setting don’t work in iBooks (the fonts are replaced). Any help would be much appreciated.

  4. If you obfuscate, do you need any documented rights from the foundry? Or is it enough to obf. And if the foundry questions, tell them what you’ve done?

  5. Matthew says:

    Kevin, check your license with the foundry. First, determine if your license covers the use of the font in ePUBs and other eBooks. If it does, it probably includes a clause on font obfuscation, and may even state the method that the foundry expects you to use for obfuscation. If it is not in the font license agreement, I would ask the foundry directly. You do not want to use a font in violation of your font license agreement.

  6. We are trying to do something similar and I wanted to see if someone here had some advice. Our digital books are all in HTML5. Rather than creating an ePub, which is being read in one of the popular E-Readers, we have our own iOS app, which renders the pages using webkit (iOS Safari) within our app. So, we are looking for a way to obfuscate the fonts and embed them within our HTML5 documents. Any thoughts how one could do this?

  7. […] Auch schon etwas älter ist diese schöne Übersicht von ePubSecrets mit Links und Hinweisen, wie du Schriftarten in ePub einbetten kannst. Ich werde mich demnächst […]

  8. Stephanie says:

    Thank you SO MUCH for this. I know it’s an old post but I have been struggling to embed fonts through Sigil for a couple of weeks now and had no clue that I had to turn on the obfuscation option. It worked immediately.

  9. This was enlightening, but I still don’t quite understand what font obfuscation is. I could read the specs but… is there any high-level description available?

    I tested obfuscation, both methods, in Sigil. It does not really seem to be doing anything. After saving the .epub file, I can open it in Sigil and extract the font using “Save As” on it, and I seem to get the font as-is. It opens in Windows font viewer and in DTL OTMaster Light without difficulties. So how would be obfuscation prevent anyone from grabbing the font from the .epub and using it wherever he likes?

  10. Sheogorath says:

    Personally, I hate distributing epubs with any form of Digital Restrictions Malware, goes against my beliefs. That’s why I always use fonts that are under an open font licence or similar, so if someone does strip them for their own purposes, I’m in the clear.

  11. incblot says:

    I was hunting around for an easy-to-follow tutorial for embedding open-source fonts, in a way which would still validate. In case it helps others looking for a similar resource, this nails it: “Embedding unencrypted fonts into an EPUB” http://youtu.be/_bWXfFsdSYw

  12. […] Diener, “Font Embedding and Font Obfuscation/Mangling,” ePUBSecrets, December 5, 2011, http://epubsecrets.com/font-embedding-and-font-obfuscationmangling.php (accessed July 19, […]

  13. Makanan enak yang ditawarkan ke pria yang sedang marah akan memedam amarahnya

  14. Sheogorath says:

    Yeah, you could go to all the time and effort required to obfuscate the fonts you use, or you could just do what I do. You see, I like to use serif fonts for aesthetic purposes (high similarity to the fonts in print books), so I use Google’s Droid Serif. Looks just the way I want it to, and if someone does rip the font out of the epub? No problem, they already have a licence.

  15. […] Diener, “Font Embedding and Font Obfuscation/Mangling,” ePUBSecrets, December 5, 2011, http://epubsecrets.com/font-embedding-and-font-obfuscationmangling.php (accessed July 19, […]