It is technically possible to add custom fonts to your Kindle ebook, though Amazon will not be pleased. Not to mention: Embedding a font not only adds to your delivery fee, those spiffy new characters will only be available for kf8 applications (Kindle Fire and Paperwhite).
Furthermore, there may be legal implications. Using the image of a letter is probably safe, but inserting the actual code for a font into your mobi file is tantamount to the redistribution of that font – which may be expressly forbidden by the font’s creator. You may owe a licensing fee, at the very least. Or you might end up in court.
Finally, embedding a font could disrupt the reader’s ability to toggle the “Published fonts” switch on his or her device. In reality, this might be more of a problem if you attempt to switch out the font for the entire text of your book.
If you’re still determined to add a font to your book, I suggest you search for “open source” fonts on sites like Da Font and Font Squirrel. The listings on Font Squirrel contain icons representing the categories of permitted use available. That’s certainly helpful, but you still need to read the license agreement carefully. And don’t forget to acknowledge the font’s author on your copyright page.
That said, here’s how you embed a font. At the top of the <style> section add these lines:
@font-face
{font-family:"Name of Font", sans-serif;
src:url(Font-file-name.ttf);}
The name of the font is in quotes because it’s more than one word. The source of the file mentions no path because you’ve placed the font file in the same folder as the book’s HTML file. The second listing (following the comma) is a fall-back font – in case the new font is somehow unavailable. You can add a second fall-back font if you want. Some coders suggest you place this listing beneath a media call for kf8 (@media amzn-kf8). I haven’t found this to be necessary, but if you run into trouble, try it.
Now you need to add code for the actual application of the font. If, for instance, you want all your h2 headers to use the new font, add this code to the <style> section:
h2
{font-family:"Name of Font";}
If you’re using the new font for the big capital at the beginning of a chapter, add the font-family code to the span listing for initial capitals:
span.initial-cap
{font-family:"Name of Font";
font-weight:bold;
font-size:2em;}
And apply it in the usual way:
<p class="start"><span class="initial-cap">T</span><b>his is the first sentence</b> of the rest of [etc]</p>
You could add the font-family listing to your “dropcaps” or “bigcaps” span code. Kindle Fire and Paperwhite will sparkle; Mobi apps will revert to the machine’s default font.
No comments:
Post a Comment
Comments are welcome -- and moderated by me. Please be patient.