Ebook Formatting – Part 10 – The Last One I Swear
Add Custom fonts
Usually, each ebook reading device already has its own fonts and therefore will have no problem displaying your ePub even if you have not specified which font to use. But in some cases, especially to give a certain emphasis to titles and other things, you can decide to apply your own fonts to some parts of the text.
As with word documents, for ebooks too, fonts can be displayed only if the person opening the file actually has these fonts, i.e. if the fonts are embedded in the document.
First of all, get a font legally. Read the license before using it for commercial purposes (using a font only for printing and embedding the file in an ePub require two different types of license). Now keep at hand the file containing your font, which can have a .ttf (TrueType) or .otf (OpenType) extension, the formats supported by most devices (if in doubt, choose .otf, which is the most compatible).
Font embedding takes place in three steps:
1) Insert the font into the ePub by right-clicking on the Fonts folder and then selecting Add Existing Files…
2) Insert the @font-face code in the CSS, at the beginning of the document, even before the body selector and all the rest of the styling.
The code to add is this (in the example we use a font called Garamond.ttf):
Warning: if you insert only this font, it means that all the text indicated as Garamond will appear in normal format and normal style. If, on the other hand, there are parts of your text that go in bold or italic or both, you’ll need to add two more fonts into the folder, one for bold and one for italic (and if there is one for bold italic, add that too!) and below write this code:
And so on for each font file you are embedding.
Of course, the name of the file under font-family and the path under src: url(‘ ‘) will change based on the name of the font you added.
3) Create a class or edit the existing classes to which you want to apply your font and add this string:
font-family: ‘Garamond’, serif;
It is useful to also add the words “serif” or “sansserif” after the comma because in the event that for some reason the device cannot display your font, it will apply the default font as an alternative.
If when you go to test your ebook you find that the font is not displayed, first of all check that your device has enabled the function to display the fonts and styles of the publisher.
Hang in there, we’re almost done. I promise.
Metadata are the part of the ebook that you don’t see within the text but are important for a whole host of reasons that I won’t list here, but which I think you’ll understand on your own when I tell you what they are.
Metadata can be found listed in the content.opf file and are things such as: author name, book title, publisher, ISBN, keywords, description, other contributors, etc. In short, they are the identity card of your ebook and in some cases they are essential for the correct display on various devices. In fact, if you don’t have the name of the author and the title in the metadata, whoever downloads your book will find in the list of his ebooks a file with no title or with Unknown author and you will understand that it would be quite challenging to sort through a bounce of files with no name.
I know that when I mentioned the content.opf file, a shiver ran down your spine, but don’t worry, we are not going to modify it directly. In fact, Sigil has a special command that allows you to edit your metadata very easily.
Go to the Tools > Metadata Editor… menu and you’ll find a table with two columns called Name and Value.
Name indicates the typical identifier of that metadata, while Value is the space where you can enter your text freely by double-clicking.
To add a new entry just click on the Add Metadata button and select from the existing list of roles the one you need, click ok and then double click in the Value box to type your text.
For example, to add the language, if it is not already present after conversion, just select Language – which will appear in the table as dc:language – and type as value “en” for English, “it” for Italian, etc.
To enter the author, select Author from the list and type the author’s name in the box next to dc:creator.
Optional, but may be important for indexing the book in the various stores, is to enter keywords and a description of the book (the blurb or back cover matter) – just select Subject (dc:subject) for each keyword (so one line for each word or phrase) and Description (dc:description) for the plot of the book.
I put it in all caps because yes, and because it’s really the last chapter and after this we’re really done and let’s face it, we’re all a little exhausted. Me at least.
So now that we’ve seen all the major changes we can make to our ePub and we’ve done everything we can to make it as beautiful and as compliant to standard as possible, it’s finally time to do one last important check.
Validation is used to verify that there are no errors in the code.
Sigil already has an internal validation system, which you can find under Tools > Well-formatted Check ePub.
If you get a message saying “No Problems Found!”, everything is more or less fine.
If, on the other hand, you get error messages, try to read carefully and figure out what’s wrong. Maybe it’s just an oversight, maybe you mistyped some code, or maybe there are some links that don’t work properly, or there are unused files that you need to delete.
Fix the fixable and validate again.
In some cases, however, there are errors that are not detected by Sigil and that can cause problems when you upload the ebook to some stores. To find these evil and treacherous errors, there is another, more precise tool, called ePubCheck, which can be found here: https://github.com/w3c/epubcheck.
But since it can be a bit tricky to use for less experienced users, since it requires Java and to use the Windows command console, I found a simpler alternative, which already has a graphical interface and does everything in a couple of clicks. It is Page ePub Checker (free download at this link: https://www.pagina.gmbh/produkte/epub-checker/), the site is in German and English but is quite intuitive, just click on the “Free Download” button and choose the version that corresponds to your operating system (Windows, Mac or Linux) unzip the .zip file and run EPUB-Checker.exe without any installation.
Even in this case it is likely to require Java, if you do not already have it installed on your computer (since it is also needed for other programs), but you’ll just have to go and download it from the official page of the java.com website (it’s all free, don’t worry).
So, we were saying, click on EPUB-Checker.exe, click on “Chose EPUB file” select your ePub, click “Open” and wait. If the screen turns green and says “No errors”, congratulations! Your ebook is perfectly formatted and ready for new adventures.
If, on the other hand, you get error messages, it should tell you where they are and what the errors are, and you should be able to fix them accordingly (if not, a quick Internet search may help).
Edit the editable and check again.
And if there are no errors this time, you can finally get up on a cliff, puff up your chest and tell the world that you’ve created your perfect ebook.
It was worth it after so much effort, wasn’t it?
Ok, now you’ll say, but I have to publish to Amazon or upload the file to my Kindle that doesn’t support ePubs, how am I supposed to do?
Don’t worry, we can fix that easily.
1) Upload the ePub on Kindle Direct Publishing
Yes, when you go publish your book, the ePub format is actually supported by Amazon, so you can simply upload the ePub file you made, and Amazon will automatically convert it to its own format.
2) Use Kindle Previewer or Kindle Create to import and convert your ebook to mobi or any other fancy format Amazon decided they are using the current year. You can download them for free on the Amazon website (I won’t leave a link because it will probably change but you can find them with a quick search). If the ePub is properly formatted the conversion should be seamless and the end result pretty much perfect.
Aaaand this time it’s really done.
I hope I covered everything there is to know about making ebooks, but if you have any questions or doubts, feel free to ask!
Have a nice writing and formatting! 😀