Embedding Fonts

It's an old béte noire of Kindle publishing that Kindle makes it difficult to specify your own fonts. There are arguably sound reasons for this; it allows readers to make the decision of what (Kindle supported) font they find most readable for books.

Nevertheless, sometimes you want to override a font or force a specific font to produce a specific visual effect.

This is actually possible. I am told that even if done correctly, Kindle will sometimes still strip out custom fonts. But it will mostly work, as long as you do it right.

First, choose the right font type. OpenType (fontname.otf) is asserted to be best supported in EPUB3, followed by TrueType (fontname.ttf). You probably should not even try to use Adobe Type 1 fonts. And make sure that either you choose a freely licensed font, or you have a valid license to use it.

Second, your font needs to be embedded in your EPUB3 file. Try putting it under OEBPS/Fonts, and don't forget to add it to the manifest (content.opf):

<item id="oldlondon_otf" href="Fonts/oldlondon.otf" media-type="font/otf"/>

And here lies the crucial “gotcha”. I will not say all of the documentation, but at least, all of the reference CSS documentation that I have found and read says that the proper media-type to declare for an OpenType font is application/opentype.

This is outright WRONG. The correct media-type, the one that ACTUALLY WORKS, is font/otf.

Third, your CSS stylesheet must contain a correctly formatted @font-face record, like this one:

@font-face {
   font-family: "OldLondon";
   src: url(../Fonts/oldlondon.otf);
}

And then finally, when you use the font, you must reference that font-family:

.prophecy {
   font-family: "OldLondon", cursive;
   font-style: italic;
}

And that SHOULD work.

•••••

Note that while I observe here that OpenType (fontname.otf) is asserted to be the best supported vector font type in EPUB3, I have to date ONLY managed to get font embedding to work properly in a Kindle book using TrueType fonts. It is likely that the Amazon documentation that suggests OpenType is the best choice is either outdated or flat-out wrong.

Comments