View Single Post
Old 09-19-2009, 05:47 PM   #1
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 71,612
Karma: 306652114
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
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.]
Attached Files
File Type: zip content.opf.zip (1.2 KB, 689 views)
File Type: zip Font Encrypt.app.zip (28.2 KB, 664 views)
File Type: zip fontencrypt.py.zip (2.5 KB, 724 views)

Last edited by pdurrant; 10-20-2009 at 01:39 PM.
pdurrant is online now   Reply With Quote