View Full Version : Is it possible to really embed fonts yet?


LaurelRusswurm
10-25-2011, 03:46 PM
Q: Is it possible to bundle free fonts inside the ePub container so they can work on the ereader?

Backstory: Although I don't actually have an ebook reader, I have been playing around with ebooks on my computer (Calibre Reader). This is a big deal for me as I am a novelist learning about self publishing, and I want my novels to be a perfect as possible.

I played around with Calibre, and it seems I can fairly easily make an ePub but I was having trouble getting the table of contents to do what i want, and most especially to include fonts. I have used markup and CSS making websites, which ought to help me make this work.

So I've been trying to use Sigil, since it has the advantage of allowing me direct access to the code, an easy way to make chapter stops, and a place to load fonts and css. Except I can't actually edit the CSS in Sigil, and no matter what I do, the fonts I include don't work. So it occurred to me to seek expert advice, which is how I found my way here.

Old threads here say first it is not possible, later threads talk about doing the font face thing, but I hate the idea. Just I hated that the only way I could include fonts in my word press blog was to use Google fonts. The essential problem I see is that the existence of the font is in Google's hands, or it depends on the continued existence of the website where the font can be found, and no broken links.

What I want to truly embed my chosen fonts so they are there in the reader, bundled with the book. They don't take up much room. If the ebook sits in the ereader, why can't the publisher's fonts sit there in the epub file too?

There is no reason I can see why this should not be possible, if the markup is done the same way it would be for websites, with the publisher's choice listed first, then alternates, so the reader user can default to their own preferences if they like.

Pablo
10-25-2011, 05:40 PM
Have a look at my ePub tutorial (link in my signature). It covers the basics of html, css and Sigil, including font embedding among other formatting tasks.
I hope you find it useful.
And welcome to MobileRead!!!

jackie_w
10-25-2011, 09:12 PM
Physically embedding fonts inside an epub is easily done, once you know what to do. Publishers do it often (usually with the Charis SIL font in the epubs I've encountered). You still need to do the @font-face statements, but they point to the font files actually inside the epub

If you plan to publish, you would need to read the font copyright carefully to make sure that distributing the fonts was legal.

I guess you'd also need to check that embedded font epubs worked correctly on a good range of the most popular readers. I can vouch for the fact they work on all the readers I own.

JSWolf
10-25-2011, 10:22 PM
Physically embedding fonts inside an epub is easily done, once you know what to do. Publishers do it often (usually with the Charis SIL font in the epubs I've encountered). You still need to do the @font-face statements, but they point to the font files actually inside the epub

If you plan to publish, you would need to read the font copyright carefully to make sure that distributing the fonts was legal.

I guess you'd also need to check that embedded font epubs worked correctly on a good range of the most popular readers. I can vouch for the fact they work on all the readers I own.

Font embedding doesn't work properly on the Kobo. They botched it big time. If you put the font-family directive in body, it doesn't display. That is how most publishers do it to activate the main embedded font(s).

HarryT
10-26-2011, 03:26 PM
This has nothing to do with Calibre; moved to the ePub forum.

LaurelRusswurm
10-28-2011, 04:24 AM
I will take a look this weekend, Pablo, thanks!

LaurelRusswurm
10-28-2011, 04:37 AM
You still need to do the @font-face statements, but they point to the font files actually inside the epub

Am I correct in thinking this will work even if the ebook is offline?

If you plan to publish, you would need to read the font copyright carefully to make sure that distributing the fonts was legal.

I am very much aware of issues of font copyright, and have been at pains to use only free fonts bundled with clear licenses absent contradictory statements.

Thanks very much for your help, jackie_w :D

LaurelRusswurm
10-28-2011, 04:46 AM
Font embedding doesn't work properly on the Kobo. They botched it big time. If you put the font-family directive in body, it doesn't display. That is how most publishers do it to activate the main embedded font(s).

I am too tired to look now, but I assumed that it would be possible to identify the fonts in as you would on a webpage, listing my chosen font, followed by a second common font choice and backing them both up with serif or sans-serif just in case.

I appreciate the heads up about the Kobo reader, JSWolf, thanks. [Especially as I haven't yet had the opportunity to use one.]

Again, thanks to all... I won't have time to try any of this 'til the weekend, but it's fabulous to have some hope of actually succeeding :D

LaurelRusswurm
10-28-2011, 04:53 AM
No worries, HarryT, I'm still finding my way around; I didn't realize there were segments for formats; what actually brought me here were old font threads in the Calibre section. I'll work on it :)

jackie_w
10-28-2011, 06:49 AM
Am I correct in thinking this will work even if the ebook is offline?

I don't understand the question. It will work for an epub loaded onto an ereader, as long as the ereader's epub renderer understands embedded fonts.

JSWolf
10-28-2011, 12:04 PM
In the CSS
@font-face {
font-family: "Charis SIL";
font-weight: normal;
font-style: normal;
src: url(fonts/CharisSILR.ttf)
}
@font-face {
font-family: "Charis SIL";
font-weight: bold;
font-style: normal;
src: url(fonts/CharisSILB.ttf)
}
@font-face {
font-family: "Charis SIL";
font-weight: normal;
font-style: italic;
src: url(fonts/CharisSILI.ttf)
}
@font-face {
font-family: "Charis SIL";
font-weight: bold;
font-style: italic;
src: url(fonts/CharisSILBI.ttf)
}
@font-face {
font-family: "Old Claude LP Oldstyle Figures";
font-weight: normal;
font-style: normal;
src: url(fonts/Old_Claude_LP_Oldstyle_Figures.ttf)
}
body {
font-family: "Charis SIL", serif;
widows: 0;
orphans: 0;
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
text-align: justify;
font-size: 95%;
line-height: 1.04em
}

In the OPF in the manifest section
<item href="fonts/CharisSILB.ttf" id="font1" media-type="application/x-font-ttf"/>
<item href="fonts/CharisSILBI.ttf" id="font2" media-type="application/x-font-ttf"/>
<item href="fonts/CharisSILI.ttf" id="font3" media-type="application/x-font-ttf"/>
<item href="fonts/CharisSILR.ttf" id="font4" media-type="application/x-font-ttf"/>
<item href="fonts/Old_Claude_LP_Oldstyle_Figures.ttf" id="font5" media-type="application/x-font-ttf"/>

Also in the CSS
span.drop-cap {
font-family: "Old Claude LP Oldstyle Figures", serif;
font-weight: normal;
font-style: normal;
font-size: 1.17em;
}

Those are all the relevant bits of code in the CSS and OPF for embedding these fonts. Also, the font files are in the directory fonts which is right under the directory the CSS and OPF are in. /OEBS/fonts/ OEBS has all the other files (in this case) and fonts has the fonts.

I hope this helps. This will mostly work for iBooks but you do have to add some non-standard code elsewhere for this to work. ON the Kobo, they botched things big time and refuse to listen to the bug report I've mentioned to them. The font-family in the body doesn't work on a Kobo. The drop-cap font will work fine. For a Kobo, you'll have to move the font-family from body to all the other CSS styles you use where that font is to be used. But in most cases like Sony, B&N, ADE (desktop), iRiver, Onyx, Boox, Bookeen, etc, this will work as is.

Charis SIL is the font that most publishers embed as it is a good looking font and it's free.

HarryT
10-29-2011, 06:26 AM
Will hard-coding the font in the "body" style not prevent the user from choosing a different font on those reading devices which provide such an option?

pholy
10-29-2011, 10:29 AM
Harry, I think you are probably right, although it depends on the reader of course. Certainly Kobo has chosen to override a 'body' choice; I'm not sure what my new Sony T1 does yet.
In my opinion, having the publisher force a font choice on the user removes one of the nicer features of ebooks. I think the user, not the publisher and not the ereader maker, should have the choice of body font. I'm a hopeless idealist.

dwig
10-29-2011, 10:49 AM
...
In my opinion, having the publisher force a font choice on the user removes one of the nicer features of ebooks. I think the user, not the publisher and not the ereader maker, should have the choice of body font. ...

+1

Using an embedded font for some special text is fine, provided the font is chosen well and that the book will still look decent when the text defaults to the reader's own font instead of the embedded font.

Any use of an embedded font should be made based on actual experience with that particular font on a wide range of devices. Experience with how a particular font looks in print on paper is of absolutely no value is choosing a font for an ebook.

HarryT
10-29-2011, 10:50 AM
I think the user, not the publisher and not the ereader maker, should have the choice of body font. I'm a hopeless idealist.

Exactly - that was precisely my point. By all means use embedded fonts for such things as titles, but please, Mr. Publisher, leave the choice of body font to the reader.

jackie_w
10-29-2011, 11:04 AM
I have been using embedded fonts on my PRST1 and I have been using the generic font-family name rather than the specific for the labels, i.e.
@font-face {font-family: serif; ... etc}
body {font-family: serif; ... etc}
rather than
@font-face {font-family: "Charis"; ... etc}
body {font-family: "Charis"; ... etc}

I have noticed that the PRST1's font override feature DOES work if you do it this way.

Given that the PRST1's font override feature is less than satisfactory (unpredictable loss of italics/bold) I am rather glad that embedded fonts do work correctly.

JSWolf
10-29-2011, 11:45 AM
Exactly - that was precisely my point. By all means use embedded fonts for such things as titles, but please, Mr. Publisher, leave the choice of body font to the reader.

But that's how it's done. Why do you think it's a forcing of an embedded font on the reader? I would think it's harder to override an embedded font if it's placed in all the different paragraph styles. When you look at the default ADE font, you find that it's not all that nice. It has fake italics that in the serif body font doesn't look nice.

HarryT
10-29-2011, 11:48 AM
But that's how it's done. Why do you think it's a forcing of an embedded font on the reader? I would think it's harder to override an embedded font if it's placed in all the different paragraph styles. When you look at the default ADE font, you find that it's not all that nice. It has fake italics that in the serif body font doesn't look nice.

I certainly wasn't suggesting that it be placed in the paragraph styles. What I was saying is that I don't personally like forcing a body font on the user AT ALL.

JSWolf
10-29-2011, 11:49 AM
Harry, I think you are probably right, although it depends on the reader of course. Certainly Kobo has chosen to override a 'body' choice; I'm not sure what my new Sony T1 does yet.
In my opinion, having the publisher force a font choice on the user removes one of the nicer features of ebooks. I think the user, not the publisher and not the ereader maker, should have the choice of body font. I'm a hopeless idealist.

Kobo has created a serious bug and they refuse to fix it. Most publishers and people who create ePub with embedded fonts use the body style to put the main font-family declaration. That won't work on any Kobo eink reader and it's a bug they've been told about and refuse to fix. Kobo users are likely to get a lesser reading experience when the ePub has an embedded font.

The new Star Wars eBooks all have an embedded font and yet Kobo will not display it at all.

As for forcing, it's not forcing a font on the user.

JSWolf
10-29-2011, 11:52 AM
I certainly wasn't suggesting that it be placed in the paragraph styles. What I was saying is that I don't personally like forcing a body font on the user AT ALL.

It's not forcing. You have it all wrong. Besides, if the reader allows one to change the base font, then that embedded font should be changeable. And you may end up liking the font used. But please don't call it forced. It's not.

DiapDealer
10-29-2011, 12:45 PM
And you may end up liking the font used. But please don't call it forced. It's not.
Very strenuously recommended (and difficult to change without deconstruction), then?

There's two things in an ebook that should never be hard-coded: Normal body-text fonts, and normal body-text sizes.

DaleDe
10-29-2011, 01:21 PM
Very strenuously recommended (and difficult to change without deconstruction), then?

There's two things in an ebook that should never be hard-coded: Normal body-text fonts, and normal body-text sizes.

I would agree except in the case where the book requires characters that are not in the default map it may be needed, particularly for some languages.

Dale

DiapDealer
10-29-2011, 02:03 PM
I would agree except in the case where the book requires characters that are not in the default map it may be needed, particularly for some languages.
I can see that necessity, of course.
I should never say never, I guess. :o

Jellby
10-29-2011, 04:15 PM
I would agree except in the case where the book requires characters that are not in the default map it may be needed, particularly for some languages.

I wouldn't say it's needed. For readers that allow setting the text font it's the same situation, because the user can always choose a font with the appropriate glyph coverage. It's only "needed" to work around a "feature" in some readers, that force a default font on you.

Freeshadow
10-30-2011, 02:30 PM
I would agree except in the case where the book requires characters that are not in the default map it may be needed, particularly for some languages.

Dale

absolutely +1 on that

khin99
11-17-2011, 11:25 PM
absolutely +1 on that

Absolutely +3:thumbsup: