View Full Version : Embedded fonts in epub


erik5000
11-26-2009, 06:56 PM
I have made an epub book and it works well. Only I try to embed a Garamond font and it does not show up on the Sony PRS600. The font stays Times New Roman-like.
The underlying HTML file shows up OK in Firefox, CSS and all.
I mentiooned the OTF in the content.opf ok...
Tried ttf and otf font... all NO GO !
Anyone succeeded in embedding fonts on this machine ?
please help !

JSWolf
11-26-2009, 07:57 PM
Have a look at The Secret Adversary by Agatha Christie. It is an ePub with embedded fonts. You can have a look and see how it's done.

http://www.mobileread.com/forums/showthread.php?t=53913

quillaja
12-03-2009, 02:12 AM
did you change the CSS to style the text with the new font? just sticking the file into the epub won't change anything (except the size of the epub). don't forget to reference the font file in the manifest, too.

this post here has some details. it says it's for "after calibre" but the process is exactly the same.

http://www.mobileread.com/forums/showthread.php?t=61587

i've had no problem embedding a font and having it show up on my prs600, even a japanese font (for a japanese text).

erik5000
12-04-2009, 05:58 PM
Yes, I did all those things.
Weird thing is, some <H1> headings show up in the correct font and others do not.
And another thing is, that FireFox (with epub plug-in) shows the embedded font alright, but the Adobe Digital Edition program does not, as does not the PRS600.
I show some parts of relevant files:
the CSS:

@font-face
{
font-weight: normal;
font-family: "TrumpMediaevalLTStd-Roman" ;
src: url(fonts/TrumpMediaevalLTStd-Roman.otf) ;
}

h3.toc_heading
{
margin-left: 24px;
font-family: "TrumpMediaevalLTStd-Roman";
}
h1
{
margin-top:12.0pt;
margin-right:0.5px;
margin-bottom:24.0pt;
margin-left:14.2pt;
text-indent:0pt;
font-size:140%;
font-family: "TrumpMediaevalLTStd-Roman" ;
}

a HTML file (showing the h3 right):

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
<link rel="stylesheet" type="text/css" href="ccjr2.css" />
<title>Table of Contents</title>
</head>
<body>
<h3 class="toc_heading">Table of Contents</h3>

Another HTML file (H1 showing the STANDARD font, not the mediaeval)
FF shows it right, but Adobe and the SOny NOT:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
<link REL="stylesheet" href="ccjr2.css" type="text/css" />
<title>Introduction</title>
</head>
<body>
<p class="Author" style=" ">
Samuel Freeman
</p>
<h1>
Introduction
<br/>
John Rawls - An Overview
</h1>

and a piece of the <manifest> part of the OPF:

<item id="ClassGarmndItBT" href="fonts/ClassicalGaramondItalicBT.ttf" media-type="application/vnd-ms-truetype"/>
<item id="TrumpMediaevalLTStd-Italic" href="fonts/TrumpMediaevalLTStd-Italic.otf" media-type="application/vnd-ms-truetype"/>
<item id="TrumpMediaevalLTStd-Roman" href="fonts/TrumpMediaevalLTStd-Roman.otf" media-type="application/vnd-ms-truetype"/>
<item id="TrajanProBold" href="fonts/TrajanPro-Bold.otf" media-type="application/vnd-ms-truetype"/>
</manifest>

Anybody has a solution ??

jackie_w
12-05-2009, 09:04 PM
Hi Erik,
Does it make a difference if you add
font-style: normal;
to the @font-face in the CSS
i.e.

@font-face
{
font-style: normal;
font-weight: normal;
font-family: "TrumpMediaevalLTStd-Roman" ;
src: url(fonts/TrumpMediaevalLTStd-Roman.otf) ;
}

JSWolf
12-05-2009, 09:31 PM
You don't need font-weight, but you do need font-style.

erik5000
12-08-2009, 11:59 AM
Before assembling HTML files into an epub is is absolutely, unequivocally necessary to VALIDATE THE HTML.
As I just found out.

Adobe Digital Edition and Sony are by far not as easy-going as Firefox is.
Incomplete tag pairs are killing.

DaleDe
12-08-2009, 12:55 PM
Before assembling HTML files into an epub is is absolutely, unequivocally necessary to VALIDATE THE HTML.
As I just found out.

Adobe Digital Edition and Sony are by far not as easy-going as Firefox is.
Incomplete tag pairs are killing.

Exactly, That is the difference between XHTML that ePUB uses and HTML that firefox reads.

Dale