09-19-2009, 05:47 PM | #1 |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
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.] Last edited by pdurrant; 10-20-2009 at 01:39 PM. |
09-24-2009, 12:22 PM | #2 | |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
What I'm trying to understand is what requirements are needed for the scheme to work in ADE and what are needed only for your script... |
|
09-24-2009, 11:58 PM | #3 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
You know - you're completely right. I got this wrong because the IDPF method is to identify the dc:identifier by id, and the one sample I had of the Adobe version also worked like this (but also did the urn:uuid: on the same dc_identifier)
So yes, it's possible for my script to not work if the ePub contains /two/ dc:identifier elements, both with urn:uuid:, and the second linked from the unique id attribute. And it would also fail if there was no unique id attribute. I'll fix it and upload a new version. Thanks! Quote:
|
|
10-20-2009, 01:36 PM | #4 |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
02-09-2010, 12:51 PM | #5 |
Boo-Frickety-Hoo-Erizer
Posts: 251
Karma: 686
Join Date: Oct 2007
Device: Kobo Glo HD!
|
Does the latest version of ADE break this? I thought I had this working until I upgraded to 1.7.2, now the epubs I had before with embedded/encrypted fonts don't show the fonts - they revert to system fonts. To say nothing about fresh ones.
Not to say I'm doing everything right; it just seemed odd. -bjc |
02-09-2010, 03:16 PM | #6 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
|
|
02-14-2010, 01:16 PM | #7 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
What the latest ADE (1.7.2) breaks is the key getting process. But I have a way around it that now works using a beta version of the key getter. But you may need to edit it to get it to work. What we need to do is get it so it just runs as is without needing to be edited.
|
02-14-2010, 01:47 PM | #8 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
|
|
02-14-2010, 02:23 PM | #9 | |
Boo-Frickety-Hoo-Erizer
Posts: 251
Karma: 686
Join Date: Oct 2007
Device: Kobo Glo HD!
|
Quote:
Dagnab you adobe, making it all hard and all. -bjc |
|
02-14-2010, 03:20 PM | #10 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Hmm... I'll try updating to 1.7.2 and see if I can spot the problem. But not tonight.
Quote:
|
|
02-14-2010, 09:12 PM | #11 |
Boo-Frickety-Hoo-Erizer
Posts: 251
Karma: 686
Join Date: Oct 2007
Device: Kobo Glo HD!
|
Indesign-embedded fonts still seem to work in 1.7.2. Embedded font tests from indesign in
https://www.mobileread.com/forums/showthread.php?t=66594 -bjc |
02-15-2010, 10:06 AM | #12 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
If you upload a sample ePub that's failing for you, perhaps I can spot the difference that's causing the problem. |
|
04-06-2010, 05:38 AM | #13 | |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
<dc:identifier id="BookID" opf:scheme="UUID">c2ff824c-f984-4efc-844d-47875c302ba5</dc:identifier> I'm certainly now seeing that the encryption key is only read if the urn:uuid: prefix is applied, and whether there's an opf:scheme="UUID" is unimportant. So: make sure your have that urn:uuid: prefix on the identifier. Last edited by pdurrant; 10-15-2013 at 09:16 AM. |
|
10-15-2013, 09:12 AM | #14 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jul 2013
Device: Kindle Fire
|
Hi pdurrent
Do you have script using IDPF encryption method or advise me where to find? |
10-15-2013, 09:16 AM | #15 |
The Grand Mouse 高貴的老鼠
Posts: 71,510
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
iPad iBooks, ePub, embedded fonts & encryption | pdurrant | Apple Devices | 37 | 06-08-2010 01:24 PM |
Fonts in Adobe Digital Editions | odt2epub | ePub | 4 | 03-24-2010 01:54 AM |
Adobe epub or Adobe Digital Edition? | Davimee | Astak EZReader | 11 | 01-17-2010 08:15 PM |
how to SAFELY add fonts ? | etherspin | Bookeen | 3 | 03-16-2009 11:01 AM |
not able to add fonts | julia | Bookeen | 9 | 09-27-2008 09:42 AM |