I discovered a big and important bug in iBooks on the iPad: if you don't have some text specified as Palatino (in some form or other), no other fonts will be displayed and everything will display in Palatino.
So, imagine you have this for your CSS:
p.palatino {font-family:"Palatino";}
p.other {font-family:"Optima";}
In the XHTML, the first paragraph is styled with the
palatino
class, and the rest is other
.Since Palatino is explicitly called, everything is displayed correctly:
Now, you decide you don't really want Palatino, but would prefer Zapfino. Your CSS now looks like this:
p.palatino {font-family:"Zapfino";}
p.other {font-family:"Optima";}
Here's where the bug kicks in. Since there is no paragraph explicitly or implicitly styled with Palatino, iBooks freaks out and makes everything Palatino:
There are various solutions. As you can see with the first example, if Palatino is called for and used explicitly, everything is fine.
But you don't actually have to call the font explicitly, you can just call no font (which in effect also means Palatino, since that's the default font in iBooks). I've tried this with explicitly font-related styles, like
font-size
, and with less font-related properties like text-align
. As long as there's some selector with at least one rule, and that doesn't specify a font, you're good:p {text-align:left;}
p.other {font-family:"Optima";}
And again, it works fine:
Ah, but what if you don't want Palatino in your ebook at all? If you remove it from the XHTML, even if you leave it in the CSS, iBooks goes nutso again:
The solution is to leave a Palatino style in your CSS, with
display:none
if you like and call that style at least once in your XHTML.CSS:
p.palatino {font-family:"Palatino";display:none;}
p.other {font-family:"Optima";}
XHTML:
<p class="palatino"> </p>
And voilĂ : no Palatino, and the Optima (or whatever other font you want), displays perfectly well!
All that is a bit scary. Shades of doing CSS hacks for ADE. I can see an ePub that is doing more than a novel, having about 5K of device hack CSS just to start the various engines.
ReplyDeleteWithout appearing to order up additional tests Liz, does the same happen with the default font-family: serif; and font-family: sans-serif, and of course faithful old monospace. I noticed some errors on my own books using generic font names after playing with the default font as per your earlier post.
What I like most about my iPad is the possibility to read ebooks on it.
ReplyDeleteHow is the ePub/iBook tomb coming? I hope it will be in iBook format, as I find it difficult to use your HTML book in it's Kindle form: no search capability, for example, and I must go through highlights and notes manually. Awkward. Good writing,
ReplyDeleteSorry. tome. Hope that wasn't some kind of a Freudian slip
ReplyDeleteI hope you've logged this as a bug in iBooks with Apple via Radar (their bug reporting/tracking tool). Otherwise they aren't going to address it ... https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/wa/signIn
ReplyDeleteGood idea. Done.
ReplyDeleteLove all the work you're doing, Liz.
ReplyDeleteIs this still an issue or has it been fixed in iBooks?
ReplyDeleteI'm mucking about with an epub version of one of my favourite books. I converted from it's original .pdb format into .epub with Calibre and now I'm going through it page by page trying to make it resemble the same fonts and page inserts that my original hardback copy has.
However, looking through the files in Sigil, I cannot see Palatino declared anywhere in the css. But when I've specified Zapfino for a "In the beginning..." line at the start, it displays fine.
I shall perform some tests on fresh files tonight after work and let you know.
Yes, as far as I know, it's still an issue. If you have an example that doesn't trigger it, I'd love to see it.
ReplyDeleteNote that Apple will be releasing an update to iBooks at the end of June with the new iPhone. Hopefully, this bug will be fixed then (I'll post it here if so).
ah no, i see where i went wrong. i had a paragraph style in the css that was setting font size and nothing else. but as you say above, that is sufficient to make it think you are specifying palatino as the default font.
ReplyDeleteThat Palatino bug is pretty bad-after reading your blog about it, I checked a book that was saved in Sigil that had that problem...and Sigil breaks up the ePub internally into multiple XML documents...and I think the "palatino" thing has to be put in every XML document in the ePub. Hopefully they fix the issue soon.
ReplyDeleteApple Blog
@faris. Well, in iBooks 1.1.1 it's worse. This solution no longer works. See http://www.pigsgourdsandwikis.com/2010/06/apple-kills-fonts-in-ibooks-strikes.html
ReplyDeleteHello Liz,
ReplyDeletemy name is Theresa, I am a student of book and media production in Leipzig/Germany.Currently I am doing a presentation on Typography on mobile devices. I've been reading all your posts about font-embedding on iBooks and ePub and wanted to ask, if you know whether this problem has been solved in iBooks or if it is still an issue, I could report about in my presentation. It would be wonderful, if you could answer me. Gladly via eMail too (theresa.neubauer@gmail.com)
Thank you very much!
Best, Theresa