Your fixed-layout EPUBs can have embedded fonts just like your PDFs can have embedded fonts; however, you can't just throw any font that you have into the EPUB font folder, because it all depends on the rights that the font foundry gives you, as far as embedding. Now when you export to PDF, InDesign and other programs will tear that font apart and embed just the subset of the letters, and there's no way that you can give that PDF to somebody else and they can extract the entire font to use. And Adobe InDesign tries to do that when you export to EPUB.
If we export this to EPUB, and we, say, here under Contents, to include embeddable fonts, well, an embeddable font to Adobe is any font that can be embedded in a PDF. And so they will go ahead and embed encrypted versions of the fonts you used in this, and then there is an encryption file that goes along with it. And the problem that most EPUB designers have found is that it's a crapshoot whether or not iBooks will support it. It seems like in some versions of iBooks, it works fine; in other ones, it ignores it. And it's also the same kind of gamble that you take with getting the EPUB validated.
A lot of times the validation engine, EpubCheck, will kick it out because it will say "doesn't understand that encryption file." And if you toss out the encryption file then the fonts are completely ignored. We're all hoping that Adobe and other font foundries and the idpf.org and iBooks and Apple will all get together and figure out how to make this work for everybody, but in the meantime, you can embed fonts as long as you have the right to embed the entire font. And you don't have that right really with Adobe fonts unless you can encrypt them, which doesn't work. So we're going to embed unencrypted fonts into our EPUB.
Now this document that we're looking at in InDesign uses some Adobe fonts, Chaparral Pro. So you would have to try and find a substitute that sort of matches this if you want to be completely legal. A lot of times people are creating fixed-layout EPUBs from scratch; they are not trying to replicate the print version. So in that case, you have your choice of which fonts to choose, and it's a lot easier than trying to retrofit a public domain or a rights-free sort of font into your beautiful publication. There are lots of places where you can find fonts that you can embed for free, or what you want to look for our public domain or web fonts.
For example, Google web fonts works great. You can use Google web fonts on your web site by making sort of like a link to where they are on the web, but the problem is that you don't want to do that for an EPUB because the person reading your eBook on the iPad might not have a connection at that time, so they don't have a constant connection with the Google server. So you want to be able to download the actual fonts, and you can embed either TrueType or OpenType fonts. All the Google web fonts are available as TrueType. Say that I wanted this one, Grumpy wizard, this Lilita One.
I can say Add to Collection. Then as soon as you start adding things to collection, you can choose to download your collection. So Download Collection, and this says, "You don't have to do it if you're going to use it for web pages," but I actually do one download the collection as a zip file. So it downloads these as TrueType fonts, as a zip file. If you go to this site, scripts.sil.org, a lot of people are using their free fonts. The fonts have been made to be embedded in all sorts of different venues.
The one that you see a lot is Gentium and Gentium Plus, which we'll be using in this project. There is other ones that you can play around with. And if you go to dafont.com, you will see that the Gentium family is there, as well as the other fonts from sil.org. So you can get a better preview of what they'll look like, and then you can download them. So let's say that you've downloaded your fonts. How do you get them into your EPUB? So I've downloaded the Gentium basic fonts into this folder and it comes a little text file explaining how to use them. You need to actually add the physical fonts to the EPUB, and you put them in the OEBPS folder.
Like here is an example of our Lost Highway fixed-layout EPUB and inside the OEBPS, we just have CSS and images in our XHTML files. But in the after one, you can see that I added a little folder called fonts. It doesn't have to go onto a folder called font; they can be loose in here, but why not stay organized? Just the TTF fonts. And every time that you add a file, remember, to your EPUB, you have to include it in the manifest. So open up your OPF file and add them to your manifest.
I made a little organized fonts section here, and you just give it any ID that you like, and then have the link to where it is, the actual file, and the media-type for this is application/x-font-ttf. It'd say otf if it was OpenType font. So number one, add the actual fonts to the OEBPS folder. Number two, add the links to those fonts in your manifest section in content. And then you want to add them to the CSS file as font-face calls.
So let's go to the CSS and go to styles.css. So we we're going to start it out with @font-face. You have a font-family name; this is font-style: normal, font-weight: normal, and then the URL, a link to the URL. Because the CSS file is inside a folder called CSS, we have to say back up one level and then find the fonts folder and then there is the ttf. So I add them one right after the other. You add one for every font that's inside your folder that you want to use. And then finally, you need to include the font-family attribute in the CSS.
So say, for example, in my Header section, h1 font-family Gentium Bold. So I believe I'm using h1 in my page 2. Yeah, there it is, Saguaro Cactus. So you have some text here. Let's take a look at it in the Safari. There is the Gentium Bold being used instead of the default font. Now if you don't call any font, iBooks will just default to its own serif font which, as far as I can tell, is Times New Roman.
It's either that or Georgia. I really spent a lot of time trying to figure that out, but there's no documentation about it. So you don't have to embed a font, but if you want to have control over the fonts, then that is the way that you do it. One last thing is that even if you include all these font calls at the top and you include all these fonts in the fonts folder, you don't have to use them. You might be thinking "Will it fail validation if I include fonts that I don't actually use in my HTML files?" And no, you just have to make sure that the manifest has links to all those fonts. But what you do in your CSS and HTML files is completely up to you.
- Comparing fixed-layout and flowing EPUBs
- Replacing placeholders in the fixed-layout template
- Extracting content from PDFs with Adobe Acrobat Pro and Reader
- Using free scripts to streamline fixed-layout production
- Extracting text and its formatting from InDesign layouts
- Exporting InDesign layouts to single-page HTML files
- Adding viewport and orientation instructions
- Embedding your own fonts
- Creating faux text wraps around background images
- Validating the EPUB
Skill Level Intermediate
Q: What's new in the 11/12/2013 course update?
A: Since this title was first recorded, many commercial third-party solutions have come to the marketplace that help InDesign users convert their print layouts to the fixed-layout EPUB format. We added a video about one of these, Rorohiko's ePubCrawler, to the "Starting with InDesign" chapter.
Q: This course was updated on 7/03/2014. What changed?
A: The author added and revised movies to reflect the June 2014 updates to InDesign's EPUB handling features, including fixed-layout support and EPUB exporting options.