View Full Version : How to Embed a font after the ePub is created.


Adjust
07-24-2011, 09:55 PM
Hi Guys,
This it the first time I need to embed a font. I having some issues as to what elements I need and where.

I have an ePub already made and lost its macrons and turned them into ? marks. So the solution is to embed a Free font which contains those characters.

I've chosen GentiumPlus-I.ttf and GentiumPlus-R.ttf.

I unziped the epub. I made a "Fonts" Folder and copied in the fonts.:

http://i41.photobucket.com/albums/e276/marcusstringer/Picture4-6.png

I then inserted the Itemref code into the manifest section like so :
http://i41.photobucket.com/albums/e276/marcusstringer/Picture2-28.png

I then added this to the META-INF folder:
http://i41.photobucket.com/albums/e276/marcusstringer/Picture3-9.png

But when I validate it, its give this error:
http://i41.photobucket.com/albums/e276/marcusstringer/Picture5-6.png

Does anyone know
1. what I'm missing?
2. where it goes?
3. what's the extact line of code I need?

Thanks
Adjust

Toxaris
07-25-2011, 02:54 AM
Try in the first line: <item href ="META-INF/...

You must also include the fonts in the OPF file. Then make the correct reference to it in the stylesheet.

Adjust
07-25-2011, 07:20 PM
How do I declare fonts in the OPF file?

Also I took the / out of the <item href ="META-INF/... It didn't make a difference.
I'm getting this error now:

http://i41.photobucket.com/albums/e276/marcusstringer/Picture2-29.png


Is someone able to list the exact code I need to get this working please

pholy
07-25-2011, 07:55 PM
I'm not sure, but I don't think that your display-options.xml file needs to be included in the manifest within the opf file because it is part of the META-INF directory. Remember, the directory the opf file is in is considered the 'root' of the manifest's file system.

And it looks like (in the manifest section of the opf) the item hrefs for the fonts have left out the Fonts in the path. That would clear up both the other two errors. they should look like <item href="Fonts/GentiumPlus..." ...can't remember how to declare font files here />

Hope this helps a little.

JSWolf
07-25-2011, 07:58 PM
Even if you get it working, it won't validate as the way to get embedded fonts to display with iBooks is non-standard.

Adjust
07-25-2011, 08:03 PM
So what's the solution to getting Macron Characters to display:
http://www.fileformat.info/info/unicode/char/14d/index.htm

All the other accents display fine except the macrons (any character with a straight line above it)

JSWolf
07-25-2011, 08:05 PM
Have you actually tried loading the ePub into iBooks and using any of the fonts iBooks gives you access to?

It won't validate in ePubCheck, but done correctly, it's valid for iBooks.

Adjust
07-25-2011, 08:11 PM
It won't validate in ePubCheck

It needs to validate ePubCheck

I haven't checked whether it view in iBook, But it becomes a ? in ADE...

JSWolf
07-25-2011, 08:12 PM
It needs to validate ePubCheck

I haven't checked whether it view in iBook, But it becomes a ? in ADE...

iBooks is not ADE. iBooks uses a different font. So maybe it will work as is without the need to embed any fonts.

Adjust
07-25-2011, 08:21 PM
It needs to be viewed over multiple devices

JSWolf
07-25-2011, 09:53 PM
It needs to be viewed over multiple devices

You'll then have to do it for iBooks and a separate one for ADE.

Adjust
07-25-2011, 10:09 PM
"surely you can't be serious"

So ePubCheck, no matter what, simply doesn't validate embedded fonts?

Yet the ereading devices can access them fine?

Does Kindle recognise embedded fonts? because this will be converted to .mobi as well?

TBH I keep banging my head against my desk in disbelieving that although the IDPF is supposed to be the "industry standard" which all the major players are members of, and I'm assuming all sit around in their ivory tower...

Yet they ignore everything and do what they want and we're stuck here picking up the pieces...

JSWolf
07-25-2011, 10:20 PM
Yes, ePubCheck validates embedded fonts. but it does not fully validate embedded fonts done the iBooks way. It validates them the standard way.

Adjust
07-25-2011, 10:29 PM
Yes, ePubCheck validates embedded fonts. but it does not fully validate embedded fonts done the iBooks way. It validates them the standard way.

Colour me confused...

So lets go back a bit...how do I get my epub to validate?

What's the exact lines of codes I need in the manifest

pholy
07-26-2011, 12:41 AM
Well, here are some font refs that validate:
<item id="BNKGOTHM.TTF" href="Fonts/BNKGOTHM.TTF" media-type="application/x-font-truetype"/>
<item id="BRUSHSCI.TTF" href="Fonts/BRUSHSCI.TTF" media-type="application/x-font-truetype"/>
<item id="HANSON-H.TTF" href="Fonts/HANSON-H.TTF" media-type="application/x-font-truetype"/>
<item id="SCHWRZW.TTF" href="Fonts/SCHWRZW.TTF" media-type="application/x-font-truetype"/>
<item id="TrajanPro-Bold.otf" href="Fonts/TrajanPro-Bold.otf" media-type="application/x-font-opentype"/>
<item id="TrajanPro-Regular.otf" href="Fonts/TrajanPro-Regular.otf" media-type="application/x-font-opentype"/>
<item id="Vivaldii.TTF" href="Fonts/Vivaldii.TTF" media-type="application/x-font-truetype"/>


This is with the Fonts directory and the opf file both immediately inside the OEBPS directory.

And here is a font declaration in the stylesheet:
@font-face {
font-family: "Vivaldi";
font-style: normal;
font-weight: normal;
src:url(../Fonts/Vivaldii.TTF) format(truetype);;
}



Note that the stylesheet is inside a directory within the OEBPS directory, so the url is relative to the current directory. I think that is correct, but I'll do more checking soon.

And here is a class reference for the font: {
font-family: "Vivaldi", cursive
}

Note the fallback to cursive if Vivaldi is unavailable.

I hope this helps.

Adjust
07-26-2011, 01:37 AM
Ok that's fixed the font embed, which validates...

What does this file do... I had to remove it to validate the epub

<item href="META-INF/com.apple.ibooks.display-options.xml" id="caido" media-type="application/xhtml+xml"/>

charleski
07-26-2011, 06:18 AM
Ok that's fixed the font embed, which validates...

What does this file do... I had to remove it to validate the epub

<item href="META-INF/com.apple.ibooks.display-options.xml" id="caido" media-type="application/xhtml+xml"/>

The latest epubcheck (v 1.2) doesn't produce an error if that file is present. It's certainly non-standard, and was introduced by Apple for their 'Fixed-Layout' nonsense. You don't really need it, since the default fonts in iBooks have a pretty wide glyph set, but it can be used to force iBooks to respect the fonts that are embedded, see http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-and.html .

brewt
07-26-2011, 10:36 AM
The snag I keep running into is that I want to encrypt the font, to help keep me from embedding a font that is usable outside of the epub, being ever-so-slightly closer to license compliance.
I haven't heard of a case of an epub with an encrypted embedded font which is tagged as "Print and Preview" and still illegal. Has that hit the courts yet? That's how embedded-font pdfs get away with it - the font is unusable if extracted. Yeah-yeah, I know, better safe than stupid, but still...
I've been using the Adobe encryption scheme, which isn't the "official" scheme put forth by the epub committee.
So, does Apple allow for encrypted fonts? ('cause I still can't get that to validate).
And has anybody gotten the blessed encryption scheme to work anywhere?

charleski
07-26-2011, 01:27 PM
Adobe's scheme only produces a warning in epubcheck, so the book still validates. But you can be sure that iBooks won't recognise that method, so you'll need two versions of the file. I suspect that the iTunes store's DRM might cover the fonts as well, but you'd have to check that.

st_albert
07-26-2011, 08:40 PM
"surely you can't be serious"

So ePubCheck, no matter what, simply doesn't validate embedded fonts?

Yet the ereading devices can access them fine?

Does Kindle recognise embedded fonts? because this will be converted to .mobi as well?

TBH I keep banging my head against my desk in disbelieving that although the IDPF is supposed to be the "industry standard" which all the major players are members of, and I'm assuming all sit around in their ivory tower...

Yet they ignore everything and do what they want and we're stuck here picking up the pieces...

I feel your pain, mate.

You see, Apple got beaten over the head so badly with the MS "embrace and extend" tactic that it decided to adopt it. It has been posted many times before, but if you go back and watch carefully that ground-breaking Apple "1984" Superbowl ad (http://www.youtube.com/watch?v=HhsWzJo2sN4), you will see that today, the roles have been precisely reversed. "We have met the enemy, and they are us." -- berkekey breathed, "Bloom County," way back then.

(pedantic note inserted: the original "walled garden" enemy was IBM. not Microsoft. And the bra-less hammer-thrower is now not Apple, but ::cough:: linux ::cough:: )

So, sadly, mate, he's very serious.

Now, as to whether Kindle (mobipocket) respects embedded fonts, I don't know. I suspect not, but I would love to see a definitive answer.

Albert

slm
07-26-2011, 09:11 PM
mobi format (and azw format) do not have any provision for embedded fonts. The Topaz format can "sort-of" embed fonts, but only Amazon can make a Topaz file.

st_albert
07-26-2011, 09:37 PM
mobi format (and azw format) do not have any provision for embedded fonts. The Topaz format can "sort-of" embed fonts, but only Amazon can make a Topaz file.

Thanks for the confirmation. That's what I thought might be the case.

Albert

Adjust
07-26-2011, 10:49 PM
Dammit...

I guess that only way now is to insert this character as an Image

JSWolf
07-29-2011, 11:30 AM
Dammit...

I guess that only way now is to insert this character as an Image

Surely Apple cannot do something non-standard and then expect ePubCheck to validate it?

saskir
08-02-2011, 05:22 PM
Oh Apple will surely hammer all their non-conform "standards" into their product till they are the new standard. So I learned somethign new. Kindle and Apple cannot use embedded fonts? Will there be problems if I have a embedded fonts in it? Will it ignore it or give a big Cahonga and over?


Oh and besides I was also thinking about embedding some characters as pictures but what about the increasing and resizing of the font? The image would not be affected. Also the textflow around the image is problematic.

charleski
08-02-2011, 08:52 PM
Oh Apple will surely hammer all their non-conform "standards" into their product till they are the new standard. So I learned somethign new. Kindle and Apple cannot use embedded fonts? Will there be problems if I have a embedded fonts in it? Will it ignore it or give a big Cahonga and over?

I suspect that the more publishers who send Apple an email saying, "WTF are you trying to do? Fire all your retarded engineers now and hire some who will comply with the clearly-defined standard," the better.

Oh and besides I was also thinking about embedding some characters as pictures but what about the increasing and resizing of the font? The image would not be affected. Also the textflow around the image is problematic.
Doing it as an image is obviously not the solution. Apple has, graciously, decided to allow ePubs to follow The Actual Spec as long as you include a 'magic' bit of nonstandard xml (http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-and.html).

The fact is that all this iPad bullshit is the worst thing that could ever happen to a developing cross-platform standard, and Apple is DIRECTLY TO BLAME.

Adjust
08-03-2011, 01:09 AM
The fact is that all this iPad bullshit is the worst thing that could ever happen to a developing cross-platform standard, and Apple is DIRECTLY TO BLAME.

Agreed... However I am now at an impasse...

I don't know which way to proceed in order to display a macron charater, which will display in iBooks and other epub readers, which can converted to .mobi and which will validate...