Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 09-13-2012, 08:52 PM   #1
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
AZW3 (KF8) and embedded fonts

First off... this is no big deal. Everything displays/works as expected in the calibre viewer, kindle devices, and KindePreviewer ... but I've noticed something odd about converting ePubs with embedded fonts to the new MOBI format. Just wondering if it's the intended behavior or something I'm doing wrong/not understanding.

Starting with an ePub that contains unobfuscated, embedded fonts ... when you use calibre to convert to A) an AZW3 or B) a "new" mobi; the fonts seem to be obfuscated when using MobiUnpack to inspect the contents of the calibre produced file.

However when converting that same ePub (with unobfuscated, embedded fonts) to mobi using the "both" mobi output option (combination mobi/KF8) the fonts are un-obfuscated when inspecting the calibre produced file with MobiUnpack.

To recap: all fonts seem to end up obfuscated in the stand-alone KF8 conversions (AZW3 or the "new" mobi output option), but they end up un-obfuscated when converting using the "both" mobi output option (starting with the same ePub with un-obfuscated, embedded fonts).

Sorry if that makes no sense, as I said, it's curiosity more than anything.
DiapDealer is offline   Reply With Quote
Old 09-13-2012, 11:24 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I really cannot recall what the intended behavior is, you'll have to go spelunking in the code.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-14-2012, 08:45 AM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I took a quick look, and for the life of me ... I can't figure out why the embedded fonts would ever be unencrypted when building KF8s with calibre.

The write_font_record function in the utils.py (ebooks/mobi/) has an optional parameter to obfuscate fonts that defaults to 'True'.
Code:
def write_font_record(data, obfuscate=True, compress=True):
That write_font_record function gets called exactly once (in all the scripts in the ebook/mobi/ folder hierarchy), and it's called with only the first mandatory parameter in the resource.py script (ebook/mobi/writer2/).
Code:
self.records.append(write_font_record(item.data))
So I can't determine why the procedure to build the combo MOBI/KF8 file leaves unencrypted fonts unencrypted, but the procedure to build a standalone KF8 always encrypts them.

The Tweak Book feature seems to un-obfuscate them, regardless, when exploding, so nothing really critical is going on, but I'd just like to get my head around it if I can.
DiapDealer is offline   Reply With Quote
Old 09-14-2012, 10:04 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Are you sure that they are unobfuscated in a joint file? Are they compressed?
kovidgoyal is offline   Reply With Quote
Old 09-14-2012, 10:07 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
An easy way to test if they are indeed obfuscated is stick a print statement in read_font_record and try converting the book running tweak book from the command line.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-14-2012, 02:45 PM   #6
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm frankly baffled. According to debug print statements (in read_font_record and write_font_record) when converting via the command-line, calibre is always obfuscating the fonts -- stand-alone KF8 or joint file.

I need to revisit Mobi_Unpack's handling of obfuscated fonts, because it unpacks the joint file's fonts as unobfuscated and the standalone file's fonts as obfuscated (although I know the same font handling routine handles joint vs stand-alone KF8s).

EDIT: I think I'll just change calibre's write_font_record to:
Code:
def write_font_record(data, obfuscate=False, compress=True):
for now. Always unobfuscated in KF8.

I know Kindlegen/KindePreviewer doesn't produce xor'd, obfuscated fonts (I think Amazon only obfuscates them before/upon delivery).

Last edited by DiapDealer; 09-14-2012 at 03:01 PM.
DiapDealer is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AZW3 vs KF8 bhoyt Calibre 4 08-18-2012 01:41 AM
Embedding fonts in AZW3/KF8 pirl8 Calibre 47 07-24-2012 05:25 PM
Add embedded fonts to azw3 arad26 Amazon Kindle 1 07-20-2012 08:19 AM
Calibre has a serious bug with KF8 & embedded fonts JSWolf Conversion 4 07-08-2012 10:26 PM
Embedded fonts on KF8 & Kindle Touch dbh2ppa Amazon Kindle 5 04-27-2012 09:41 PM


All times are GMT -4. The time now is 07:36 PM.


MobileRead.com is a privately owned, operated and funded community.