fontencrypt.py - Add Adobe encryption to fonts in ePub
Here is my python script for encoding the fonts found in an ePub file. And also, for those on Mac OS X 10.5 (& probably 10.6), an AppleScript that turns using the python script into a drag&drop experience.
This script encodes the fonts according to the method Adobe uses in ADE. It does not use the IDPF method, as ADE doesn't seem to support than encoding method yet. EPubs with fonts encoded with the script /do/ work on the Sony PRS-505
Fonts must be declared in the manifest (in content.opf) of the ePub
The metadata element in content.opf must have contain a dc:identifier
The text of that element must start with the characters "urn:uuid:" or must have an ofp:scheme="UUID" attribute
The text of the dc:identifier (apart from any "urn:uuid:" prefix) must be at least 16 (preferably 32) hexadecimal digits, optionally spaced by dashes, and no other characters.
The first dc:identifier in the file meeting the above requirements is used, as per the Adobe spec.
Also attached is a sample content.opf showing the above requirements.
usage:
python fontencrypt.py infile.epub outfile.epub
(or just drag&drop an ePub onto the AppleScript)
Feedback welcome.
[Update: Now version 1.1 that correctly selects the first appropriate dc:identifier as per the adobe spec.]
[Update: Now version 1.2 that handles that case of a dc:identifier with both a UUID attribute and a urn:uuid: prefix.]
Last edited by pdurrant; 10-20-2009 at 01:39 PM.
|