View Full Version : Epub & fonts


Nate the great
07-26-2009, 08:58 PM
My current ebook project has a couple of fonts specified. I'd like to make sure they're included in the Epub version.

I have fonts and the html source properly names them. Do I just copy the fonts into the epub or is there a more complicated process involved?

Thanks.

zelda_pinwheel
07-26-2009, 09:01 PM
you have to make sure the fonts are listed in the manifest as well of course, and it's probably best to keep them in a specific fonts folder, but after that, yes, you just copy them in. make sure all your references (html / css, and manifest) give the precise location (including name of subdirectory : case matters). you can take a look at how they're referenced in one of jellby's epubs (i believe the prince and the pauper has embedded fonts) or my epub of three men and a boat.

Nate the great
07-26-2009, 09:19 PM
Would this be correct? I'm not quite certain what the id is for.

<item id="Tahoma" href="Tahoma_KOI8.ttf" media-type="application/x-truetype-font" />

zelda_pinwheel
07-26-2009, 09:23 PM
i used this :

<item id="fontinbold_font" href="fonts/Fontin-Bold.ttf" media-type="application/x-truetype-font" />
<item id="fontinitalic_font" href="fonts/Fontin-Italic.ttf" media-type="application/x-truetype-font" />
<item id="fontinregular_font" href="fonts/Fontin-Regular.ttf" media-type="application/x-truetype-font" />

with more descriptive ids, so i could differentiate between the various fonts (since i have 3 from the same family).

other than that, i don't see a font folder, are your fonts at the root of the epub file ? if not, don't forget the path.

Jellby
07-27-2009, 06:34 AM
Would this be correct? I'm not quite certain what the id is for.

<item id="Tahoma" href="Tahoma_KOI8.ttf" media-type="application/x-truetype-font" />

That would be fine if Tahoma_KOI8.ttf sits at the same directory as the .opf file. The "id" is only a label you have to give to the file, as you have to do with every other file you include in the ePUB, images included. As far as I know the "id" is only really used in the <spine>, though.

In the .css files, you need the @font-face statement, and in the src property the url must be relative to where the .css sits. Like this:

@font-face {
font-family: "Dearest";
src: url("../fonts/Dearest.ttf") format("truetype");
}

The .css is in OEBPS/css, and the .ttf in OEBPS/fonts.

As examples, of my ePUBs, "The Prince and the Pauper", "Savage Stories of Conan", "Don Quijote" and "Novelas Ejemplares" use embedded fonts.

Nate the great
07-27-2009, 08:30 AM
That would be fine if Tahoma_KOI8.ttf sits at the same directory as the .opf file. The "id" is only a label you have to give to the file, as you have to do with every other file you include in the ePUB, images included. As far as I know the "id" is only really used in the <spine>, though.

In the .css files, you need the @font-face statement, and in the src property the url must be relative to where the .css sits. Like this:

@font-face {
font-family: "Dearest";
src: url("../fonts/Dearest.ttf") format("truetype");
}

The .css is in OEBPS/css, and the .ttf in OEBPS/fonts.

As examples, of my ePUBs, "The Prince and the Pauper", "Savage Stories of Conan", "Don Quijote" and "Novelas Ejemplares" use embedded fonts.

Hmm. I think is going to finally push me into using a separate css file.

Will that @font-face declaration work if it's between the style tags in the header of an html file? If so, then becuase calibre will extract the data this means I can continue to use MobiCreator.

Abecedary
07-27-2009, 08:43 AM
Zelda and Jellby seem to have you squared away on the technical aspects, but I wanted to mention that Tahoma can't legally be included in an epub for redistribution. To the best of my knowledge, only Microsoft can distribute that typeface.

Jellby
07-27-2009, 10:37 AM
Will that @font-face declaration work if it's between the style tags in the header of an html file? If so, then becuase calibre will extract the data this means I can continue to use MobiCreator.

I don't see why it shouldn't... you could always wrap all the style between <![CDATA[ and ]]> if it gives problems with XHTML (see "Dealing with XHTML" here (http://www.howtocreate.co.uk/tutorials/css/combinedpage)).

pdurrant
07-28-2009, 06:13 AM
I wanted to mention that Tahoma can't legally be included in an epub for redistribution.

Many font foundaries haven't really come to terms with ebooks yet. I just asked Monotype how much a licence for including a roman and italic of one of their fonts in an ebook would be.

1500. For a five year licence.

To be fair, this fee covers up to five fonts, and in up to five different ebooks. I suppose if you were publishing lots of popular ebooks, 60/book/year wouldn't be completely out of the question. But it still seems very high to me.

And they did also say they're "in the process of reviewing" their ebook strategy.