View Full Version : The ePub 2.0.1 specifications and font embedding


Giordano Galli
09-17-2011, 01:10 PM
Hello

I'm having trouble finding where in the ePub specifications they discuss the nuts and bolts of font embedding. I only found a vague treatment of this matter in relation to encryption.

At the very least I need to know:
1) whether all I have to do to embed an unencrypted font is include its file in the package (I'm using the "Add file" command in "oXygen XML Author 13"), reference it in the manifest and use "@font-face" in my stylesheet
2) whether OpenType fonts are supported
3) which value for the "media-type" attribute should be used for OpenType fonts.

I've been happily using OpenType fonts labeled as "application/vnd.ms-opentype" for my tests in Adobe Digital Editions but I have now to ask questions 2) and 3) because a publisher is complaining about my files being rejected by epubcheck 1.2 with a "hyperlink to non-standard resource" error.

I'd be grateful for any links and comments. Thank you very much!


Giordano

LaoTseu
09-17-2011, 01:22 PM
Here's a link that will help you: http://blog.threepress.org/2009/09/16/how-to-embed-fonts-in-epub-files/

1- See the link above

2- OpenType is definitely supported, all the EPub standard doc always refer to OpenType font

3- media-type="font/opentype"/

Hope that helps.

Toxaris
09-17-2011, 02:31 PM
Remember that font embedding seems to be a hit-and-miss for readers. Some readers do honor the specs and use it. Others just plainly ignore it.

Jellby
09-18-2011, 04:43 AM
1. You have to include the font in the package, add a @font-face definition to the CSS and include the reference in the OPF manifest.

2. Actually, OpenType is the only format supported, at least it's the only format suggested by the spec.

3. "application/vnd.ms-opentype", according to the spec.

The message "hyperlink to non-standard resource" probably means that somewhere you have a link to something that is not an XHTML file, it could be a link to an image or something like that. That's not allowed.

LaoTseu
09-18-2011, 10:33 AM
3. "application/vnd.ms-opentype", according to the spec.


You are quite right, my bad. I wonder where Threepress took media-type="font/opentype" from.

pholy
09-18-2011, 08:28 PM
It seems that most readers and browsers don't really check the media type. Which is good, because as far as I can find out, only one obsolete font ever got a assigned media type.
Still, for future compatibility, one needs something, and the most common recommendation seems to be media-type=application/x-font-otf (or ttf, depending on the file type). x is for extension, as there is no assigned type for fonts. While vnd.ms-opentype probably is correct, both otf and ttf are recognized standard types, so I don't think we need to use the vendor specific designation, as long as we use x-font-something.
But font/anything is incorrect, as IANA doesn't have a font mime-type directory.

At least, that's what I'm going to do from now on.

LaoTseu
09-18-2011, 11:11 PM
Thanks pholy, it clarify things. Sigil is using application/x-font-ttf for the TrueType fonts. If I understand what you said, it's as good and anything else for now so I won't mess with it.

Jellby
09-19-2011, 05:23 AM
While vnd.ms-opentype probably is correct, both otf and ttf are recognized standard types, so I don't think we need to use the vendor specific designation, as long as we use x-font-something.

However, the current spec explicitly calls for "application/vnd.ms-opentype", so using something else for opentype is against it.

Giordano Galli
09-24-2011, 11:28 AM
1. The message "hyperlink to non-standard resource" probably means that somewhere you have a link to something that is not an XHTML file, it could be a link to an image or something like that. That's not allowed.

I don't know, I wasn't able to reproduce any error or warning not even when I downloaded the latest version of the command line tool (ePubChecker apparently sticks to ePubCheck version 1.0.5).

Anyway, I'm delighted at the quality of this discussion, it has significantly added to my understanding of the matter and will be of great help in the future.

Thanks to everybody for your interest!