Due to my weak and undisciplined nature I have succumbed to "more shinies syndrome" and now I have a Kobo Touch. I have a large collection of O'Reilly books in ePub format, which work just fine on the iPad, but crash the Kobo. So I set out to massage my O'Reilly books to the point that they are usable on the Kobo.
The first suspect in my list of things to cull was the collection of OTF fonts. They add bulk, and I don't know whether they slow the Kobo down or not. So I excised the Liberation font variants from the ePub, and removed any reference to the font from any file in the ePub (global search and replace).
Then I stripped out the entire content of the core.css file. At this point, the ePub loaded in 5s with no "Please wait" screen.
So I started adding CSS components back into the core.css file until the book was usable and readable. Here is the CSS file content:
a.ulink, a.xref, a.email {
text-decoration: none;
color: #8e0012;
}
h1 {
font: bold 1.5em sans-serif;
}
h2 {
font: bold 1.3em sans-serif;
}
h3 {
font: bold 1.1em sans-serif;
}
h4 {
font: bold 1em sans-serif;
}
.programlisting {
white-space: pre-wrap;
}
img {
max-width: 95%;
}
div.figure {
page-break-inside: avoid;
}
I then stripped down the table of contents from over 100 pages to about 32, using this regex in BBEdit:
^\s+\r
\s+(Problem|Solution|Discussion|See Also)\r
\s+\r
\s+\r
Note that I specifically cut out only the Problem/Solution/Discussion/See Also headings. You'll need to combine those lines into one and remove all the spaces, I had to break it up to fit into LiveJournal's fixed-width non-scrollable layout.
Other changes that I'd like to automate include:
- Rotating all landscape images wider than 500px to be portrait orientation
- Resizing all images to fit within 500x600 pixels
The Kobo can scale images, but I don't see why it should need to waste its scant processing power on that task. Since I'm mangling the book for 6" eInk devices to start with, I may as well pre-process the images to suit!
NB: I am working from that bare-bones CSS towards a more complete CSS to see which elements are causing the Kobo some headaches. At present I've added back some of the Liberation fonts: the Liberation Mono font is much nicer than the Kobo's default monospace font. I also want to change the colour of comments in the code: all the code wraps around, setting the comments to be a paler colour will help distinguish the comments from code.
A huge THANK YOU to O'Reilly for being sensible and releasing their publications with no DRM, which allows me to edit my copy as I see fit. This is why I buy your books (in addition to them being technically excellent).