It is certainly possible to embed custom fonts and have them be used in iBooks, as well as on other EPUB
reading systems. The process is known as embedding. Embedded fonts are simply included in the .zip
archive that comprises the EPUB
file, and then referenced properly in all the relevant content files. Places you will need to reference them include:
CSS file
This is just like using fonts on the web: the first thing you need to do is define @font-face
:
@font-face {
font-family: roboto;
src: url('fonts/Roboto/Roboto-Regular.ttf')
}
and then use that declaration in for whichever styles you'd like to use that font:
p.intro {
font-family: roboto;
font-weight: normal;
font-style: normal;
}
content.opf file
Just like all the other files in your EPUB
, you'll need to include any font files you're embedding in the <manifest>
of your .opf
file:
<item id="Roboto-Regular_ttf" href="fonts/Roboto-Regular.ttf" media-type="application/x-font-truetype" />
The above steps are sufficient for most reading systems, but iBooks has one more hoop to jump through:
com.apple.ibooks.display-options.xml
This is a file that goes in the META-INF
folder of the EPUB
, rather than the OEBPS folder, and as the name suggests it's iBooks-specific. Neither this file nor the container.xml
file need to be declared in the <manifest>
, so don't worry about that. Here is the file in its entirety:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<display_options>
<platform name="*">
<option name="specified-fonts">true</option>
</platform>
</display_options>
A more in-depth writeup can be found on Liz Castro's excellent blog. As noted elsewhere, be aware that there are some potential hurdles, both legal and practical, to embedding fonts.