View Full Version : Problem embedding font into an ePub


mvo
08-31-2011, 06:36 PM
Hi all

I would like to embed a particular font (Old Standard from http://www.thessalonica.org.ru/en/oldstandard.html) in a book.

In Sigil, Calibre, and the EPub reader add-on to Firefox, all looks fine. (Well, in Sigil and Calibre the italics don't display, but that is ok.) But in ADE, (and on my Sony Reader) the font does not show at all.

I have tried the .ttf and .otf versions of the fonts, and checked and double-checked my code in the stylesheet - see below.

The font looks fine in Word and other applications, and I can successfully embed other fonts into the ePub.

Any suggestions? Do some fonts have characteristics that make them unsuitable for embedding?

Any help much appreciated :)


@font-face {
font-family: "OldStandard";
font-weight: normal;
font-style: normal;
src: url(../Fonts/OldStandard-Regular.ttf);
}


@font-face {
font-family: "OldStandard";
font-weight: normal;
font-style: italic;
src: url(../Fonts/OldStandard-Italic.ttf);
}


body {
display: block;
margin-top: 0em;
margin-bottom: 0em;
margin-left: 0em;
margin-right: 0em;
font-family: "OldStandard", serif;
font-size: .90em;
text-align: justify;
widows: 1;
orphans: 1;
}

pholy
08-31-2011, 10:46 PM
In the Kobo (using ADE) a font-family in a body selector gets overridden by the reader software; I wasn't aware of this on the Sony. Try putting the font-family in a p selector, to see if it works there.
OTOH, I seem to recall that if ADE detects any errors in the css file, the entire file gets ignored. I can't think of any css verifiers off-hand, unfortunately.

JSWolf
08-31-2011, 10:50 PM
In the Kobo (using ADE) a font-family in a body selector gets overridden by the reader software; I wasn't aware of this on the Sony. Try putting the font-family in a p selector, to see if it works there.
OTOH, I seem to recall that if ADE detects any errors in the css file, the entire file gets ignored. I can't think of any css verifiers off-hand, unfortunately.

That's a bug in Kobo's implementation of ADE. Most ePub from publishers put the font family selector into the body. This does work fine with Sony Readers.

JSWolf
08-31-2011, 10:52 PM
MVO, the only way to check where the problem may be is for you to post a sample ePub so someone can take a look. The posted code looks OK. But we'd need to see an ePub to help.

mvo
09-01-2011, 12:38 AM
Hi all,

Sample attached. BTW, I am using ADE 1.7.2.1131

Thanks again!

DaleDe
09-01-2011, 02:04 AM
In the Kobo (using ADE) a font-family in a body selector gets overridden by the reader software; I wasn't aware of this on the Sony. Try putting the font-family in a p selector, to see if it works there.
OTOH, I seem to recall that if ADE detects any errors in the css file, the entire file gets ignored. I can't think of any css verifiers off-hand, unfortunately.

Here is a CSS Validator: http://jigsaw.w3.org/css-validator/

Dale

Keroberos
09-01-2011, 02:46 AM
I did a little testing, your fonts show up in ADE 1.8 preview, but not in 1.7.2. I renamed a couple of fonts to the same as in the epub and swapped them in and they work fine. Could it be that the file size of the fonts are too large for ADE (both over 600k each)?

[edit] Yeah, definitely looks like something with the fonts not the css, the css file is loading (if there was something broken ADE wouldn't load any formating at all). It's loading the fall-back font and not the embedded ones.

mvo
09-01-2011, 05:05 AM
I hadn't noticed the size of the true type fonts - they are large! The otf versions are smaller, but still don't show. My css seems to validate, just font errors, which I'd expect...

Odd that the fonts show in ADE 1.8 preview, I hadn't tried that.

Jellby
09-01-2011, 05:23 AM
I suspect the file size might be a problem in some cases, but 600KB doesn't look like too much. If the body override is the problem, you could try with a more specific selector, such as "html body" or "body.text" (and use <body class="text">).

Keroberos
09-01-2011, 10:47 AM
I did some more testing, and it's starting to look like there is something about that font that the ADE 1.7.2 rendering engine does not like. I created a new epub with that font and limited css and it still exhibits the same problem. I also went to font Squirrel and made a limited glyph version of that font and tried that, but it still doesn't load in ADE 1.7.2.

[edit] I also loaded the epub onto my nook and it doesn't load the font, so it's looking like a problem with ADE and that font.

That's about the limit of things I could think of to try, anyone else have any ideas?

Keroberos
09-01-2011, 11:37 AM
I rebuilt the fonts in Font Forge and saved them as otf and now they display in ADE 1.7.2. I've included a zip file with the rebuilt fonts for you to test.

JSWolf
09-01-2011, 11:48 AM
My guess is the font size may be the issue with 1.7.2 ADE.

But as has been said before, ADE 1.8 preview the original fonts work fine.

mvo
09-01-2011, 09:07 PM
Keroberos, that has done the trick! The rebuilt font shows in ADE and my Sony reader. Thank you very, very much.

I am amazed at the wealth of expertise on this site, and very grateful it is so graciously shared.:thanks:

Keroberos
09-02-2011, 12:09 AM
You're quite welcome, I've never seen a problem with embedded fonts like that before. I enjoyed trying to figure it out and learned some new things in the process.

Pipian
01-02-2012, 06:31 AM
I hate reviving all-but-dead threads, but since this is pretty much the only discussion about this issue, I figured I would mention that I am having identical trouble with two other fonts (Linux Libertine (http://www.linuxlibertine.org/) and Symbola (http://users.teilar.gr/~g1951d/)). Although the Bold, Italic, and Bold Italic versions of Libertine will display correctly in ADE, the Normal version of Libertine fails to load and ADE instead falls back on the Bold version, so that all of the text set in Libertine is in Bold rather than Normal type. Similarly, Symbola fails to load and display any characters it supports.

As the above posters found with respect to Old Standard, I have tried (in FontForge) subsetting the fonts (as the Libertine fonts are over 400K and Symbola is 1.6MB), converting Symbola to OpenType (as it originally comes in TrueType), and re-generating the OpenType font from the original SFDs of Libertine, but this was all to no avail, and the fonts still fail to load.

Given the above discussion, Keroberos seems to have found the fix to this issue, but unfortunately it's not clear what needs to be done to make these fonts work.

I've attached another example epub file which exhibits these problems (i.e. Libertine Regular not displaying, and ADE falling back on Libertine Bold, as well as Symbola not displaying the symbol characters) using the subset OpenType versions of Symbola (which includes two non-Latin-1 Unicode symbols which are used in the epub) and Libertine which I generated with FontForge.

It's possible that the second of the symbol characters (U+1F603) won't display in ADE at all (depending on whether or not ADE correctly supports characters outside of the Basic Multilingual Plane that were introduced in Unicode 6.0), but I would expect at least the first (U+263A) to show up normally if Symbola worked correctly. The subset of Libertine used in the epub has no non-Latin-1 characters at all, and would be unaffected by any issues with high-Unicode support.

Knowing the trick to fixing these fonts would be very useful, in case I (or others) run into similar issues with other fonts (and also because I intend to apply some custom kerning tweaks to Libertine that I haven't yet done).

Timur
01-03-2012, 05:11 AM
In case you have not tried it on your Nook touch, Linux Libertine and Symbola display problem in your subsetted.epub file occurs in ADE 1.7.2. ADE 1.8 preview and Nook STR(1.1 updated) display both fonts fine.

Jim Lester
01-03-2012, 08:10 PM
ADE 1.7.2 is using RMSDK 9.1, ADE 1.8 and most of the Nook devices (but not the original) are using RMSDK 9.2 and above. Font rendering was changed drastically between 9.1 and 9.2 (its using a completely separate engine). So it would seem to make sense that this is failing on 9.1 but not on 9.2. You can force RMSDK 9.2 to use the old engine by adding in 'adobe-text-layout: optimizeSpeed;' which may help you with troubleshooting.