Skip to main content

Font obfuscation in EPUBs and why you shouldn't change the dc:identifier after exporting from InDesign


Font obfuscation

Font obfuscation (otherwise known as font mangling) is a two-way process for which there is a set algorithm recorded by the IDPF. The reason for this algorithm and the very specific instructions that accompany it are because fonts once obfuscated need to be de-obfuscated in order to be used by a reader app. And in order for this reversal of the obfuscation process to occur there needs to be a set of open rules to enable compatibility for this open standard.

EPUB font embedding in InDesign

In this post I am not going to enter into the technical details of obfuscation but instead focus on the typical person creating EPUBs using InDesign to embed fonts in an EPUB. So let's begin there: when you choose to embed fonts in an EPUB from the InDesign export panel, the app subsets and obfuscates the fonts included in your document as long as no digital restrictions exist to prevent this.

The reason for this post is that it is common once you have created an EPUB from InDesign to review it and make changes by unzipping/re-zipping the EPUB. And so here I provide information on which parts of the EPUB should be left alone so as not to break the font obfuscation (and a guide for how you might fix things if they've gone wrong).

The role of the dc:identifier

Font obfuscation relies on a key which makes the obfuscation of fonts unique to the EPUB they are contained within. If it weren't for this key all fonts would be obfuscated identically and be interchangeable between books.

Note: A book's ISBN makes a great dc:identifier value in the opf because it is unique.

Don't change the dc:identifier

Now the important part. If you've chosen to embed fonts using InDesign or some other app that obfuscates fonts, any change to the dc:identifier value will make the fonts unreadable unless they are are first de-obsfuscated. This is because once you change the key, it no longer fits the lock. And unless you have the same key that was used to lock the fonts (i.e. obfuscate them) then your key will be useless. Therefore, if you've changed the dc:identifier and broken the font obfuscation, change it back. If you don't have the original value then nothing can be done except to re-export.

It is important to note here that where a key is prefixed by letters like "urn:uuid", for example in urn:uuid:9A6376C9-9E0A-4BA4-87CE-667AA91A70DE, that all of the characters are part of the key not just the string of numbers and capitalized letters. So don't be tempted to tidy the string up at all.

Don't reorder the container.xml 

Most of the time an EPUB contains only one package, but it is possible for a single container to contain multiple packages. And if your book has multiple packages outlined in the container.xml file (listed between the <rootfiles></rootfiles> tags) then it is important that you do not reorder these.

The reason for this is because where multiple packages exist, the dc:identifier for all the packages are joined together (or concatenated), in the order they are presented, and together provide a single key.

Don't delete or amend the encryption.xml file

If you've embedded fonts in an EPUB then an encryption.xml file will be generated by InDesign and contain a reference to every obfuscated font. So if you changed the location of a font within the package, not only would you need  to update the content.opf file with this information but you'd also need to update the encryption.xml file, so the best advice here is that unless you really have to change the location don't move fonts around into different folders (or change the file names).

The encryption.xml file is required where font obfuscation has taken place, so don't delete it (unless all obfuscated fonts are being removed, and no other encrypted content is contained in your EPUB). And if you decide to remove a font then it will also need to have its reference removed from the encryption.xml file (as well as the manifest of the content.opf file).

A final word: subsetting

A final word on things that might happen when embedding fonts in EPUBs: InDesign subsets fonts, as noted above, embedding only the glyphs that are required by the book, changes to the text might result in a lack of glyphs. So you may need to re-export in order to fix this.


Endorse on Coderwall

Comments