consortium / transformer

HTML 2 EPUB conversion using the Transpect tool set
1 stars 0 forks source link

Generated epub needs com.apple.ibooks.display-options.xml file for displaying fonts #7

Open codingisacopingstrategy opened 8 years ago

codingisacopingstrategy commented 8 years ago

Hello,

The generated epub now includes the font files, and they are referenced in the css and the manifest file. When I view the epub in Calibre viewer, the font displays as expected. This is not yet the case in iBooks.

It seems that for the viewers in the Apple ecosystem, the ePub needs an extra XML file in the META-INF folder, telling it to use the fonts provided in the EPUB.

It should be called com.apple.ibooks.display-options.xml and have the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<display_options>
<platform name="*">
<option name="specified-fonts">true</option>
</platform>
</display_options>

Cf http://ebooks.stackexchange.com/questions/1037/can-i-make-custom-fonts-show-up-in-ibooks

mkraetke commented 8 years ago

Then @haendwic must store the com.apple.ibooks.display-options.xml in the directory of the HTML source file. The converter checks for this file and include it automatically in the EPUB file.

gimsieke commented 8 years ago

tl;dr Use <epub-config variant="ORIGINAL-CSS" …>

We are processing the /epub-config/@variant attribute that is currently not included in the sample config but is available as per its RNG schema.

Currently there are two variant values that will be processed in create-ocf.xpl, 'FIXED-APPLE' and 'ORIGINAL-CSS'. Both variants use the complete com.apple.ibooks.display-options.xml , but 'ORIGINAL-CSS' strips all but the 'specified-fonts' options. So this is our variant of choice, and I don’t see another place in the epubtools code where 'ORIGINAL-CSS' is being acted upon. From its wording it seems to be meant to do the same as /epub-config[@css-handling='unchanged']. The css-handling options tells the converter not to parse and regenerate the supplied CSS, while variant='ORIGINAL-CSS tells the (Apple-supplied) reading system to use the fonts that were supplied in the publication’s CSS. We probably should rename 'ORIGINAL-CSS' to something more descriptive, such as 'APPLE-USE-FONTS-FROM-CSS', but maybe we have to keep it for all time now because of backwards compatibility.

haendwic commented 8 years ago

The com.apple.ibooks.display-options.xml is located in the epub result now as like as the attribute='ORIGINAL-CSS' is in use. I tested it (IBooks 4.8) but for some reason only the heading is using the custom fonts. Any suggestions?@mkraetke , @gimsieke

codingisacopingstrategy commented 8 years ago

Yes, that is the behaviour on my side as well… I really can’t figure out why iBooks behaves in this way? the Calibre viewer shows everything in the custom fonts.

codingisacopingstrategy commented 8 years ago

Hmm on second thought I think iBooks is just being rather picky—it also justifies all text where I explicitly told it to left-align. I’m finding some contradictory info online on whether it can be forced to listen to the CSS. I think we can leave this open for if it is ever needed to further investigate.