Skip to main content
Baldur Bjarnason

The iBooks 2.0 textbook format

Baldur Bjarnason
Today, Apple released both iBooks 2.0 and an authoring app called iBooks Author. The new iBooks, the authoring app, and Apple’s new textbook category are all based on a new ebook format Apple has invented.

I’ve spent a few hours staring at the innards of a file exported from iBooks Author in an attempt to understand what it going on. I still only grasp a fraction of what they are doing, but I figured I might share my theories at this point.

The good

Apple’s new format is mostly ePub3. It has valid NCX and OPF files. The XHTML files are all XHTML5. It uses SVG extensively. Promising.

The meh

The XHTML files all use declarations of the form

<?xml-stylesheet href='*' type='text/css' media='*'?> 

to link to CSS files, instead of the more usual (and certainly more standard way, since they’re using the HTML5 doctype) link element.

The mimetype iBooks uses for these files is application/x-ibooks+zip. In and of itself not bad news, but it is a clear indicator that Apple doesn’t want this to be treated like ePub. That is, they do not want to have to worry about making sure that the output of iBooks Author is readable in ePub reading systems.

Yup, that’s a cue for ominous music.

The bad

The CSS files are full of undocumented extensions to the CSS standard, few of which seem to be from any version of any spec I could find on the W3.org website. Things like:

-ibooks-layout-hint: inline;

and

-ibooks-list-text-indent: 0.0000pt;
-ibooks-strikethru-type: none;
-ibooks-strikethru-width: 1.0000px;
-ibooks-underline-type: none;
-ibooks-underline-width: 1.0000px;

and

-ibooks-gutter-margin-left: 50.0pt;
-ibooks-gutter-margin-right: 25.0pt;
-ibooks-head-height: 660.0pt;

and

-ibooks-line-hints: textShape-0 p url(../hints/content1-landscape.plist) 13 7;

Apple has chosen to use custom properties to define strikethroughs, underlines, margins, and heights in various contexts, with no standards-compliant fallbacks, to get a level of control over the visual design that standard CSS does not offer.

The ugly

A lot of the layout and text-wrapping features of an iBooks 2.0 file are defined in non-standard ways.

The XHTML files contain object elements with types such as application/x-ibooks+flowhead and application/x-ibooks+shape that tie in with the way the file is laid out in undocumented ways. The CSS link to .plist files with properties called -ibooks-line-hints. Your guess as to what that’s for is as good as mine.

They use CSS like this to define some text-wrapping and layout areas:

@page ::nth-instance {
  height: 748pt;
  width: 1024pt;
  ::slot(textShape-122) {
    height: 668pt;
    left: 512pt;
    top: 40pt;
    width: 0pt;
    z-index: 1;
  }
  ::slot(media-7) {
    -ibooks-box-wrap-exterior-path: directional contour both 12pt 0.5 false;
    height: 668pt;
    left: 535pt;
    top: 40pt;
    width: 440pt;
    z-index: 2;
  }
  ::slot(textShape-1) {
    height: 334pt;
    left: 50pt;
    top: 40pt;
    width: 440pt;
    z-index: 3;
  }
  ::slot(textShape-0) {
    height: 300pt;
    left: 50pt;
    top: 408pt;
    width: 440pt;
    z-index: 4;
  }
  -ibooks-positioned-slots: textShape-122, media-7, textShape-1, textShape-0;
}

This CSS is, as far as I can tell, completely non-standard. The only public documentation I can find is an e-mail from an Apple employee to a W3.org mailing list.

This piece of code is going to be gobbledygook to all web browsers and all ePub reading systems. I don’t see an easy or straightforward way of converting this piece of CSS into anything understandable by other apps.

It is one thing to deliver a format that is ePub3 in all but name. The differences between the iBooks 2.0 format and ePub3 seem all but trivial. But when that format is built around non-standard extensions to the CSS rendering model and all of the XHTML and the CSS are built around that extended model, the file is likely to forever be useless and unreadable in other reading systems.

The work involved in converting an iBooks 2.0 file to a standard ePub3 is likely to be easy.

The work involved in converting the iBooks 2.0 CSS to something ePub3 reading systems or browsers, however, is likely to be too great to be worthwhile.

Rewriting the CSS for a complex, intricately designed, book from one layout model to another is also probably impossible. The reason why Apple chose a non-standard layout model is probably because the ones currently standardised and proposed by the W3 cannot deliver the designs Apple is aiming for.

Update: I also wrote a post on “The iBooks 2.0 built-in widgets”.

Update 2: My last thoughts on the subject. “The pros and cons of the iBooks 2.0 textbook format”.