View Full Version : Embedding fonts


AprilHare
12-21-2009, 05:42 PM
Is it possible to embed fonts in EPUBs? If so, how do I practically do it?
Will such embedded fonts work with Sony Readers, specifically my PRS-500?

JSWolf
12-21-2009, 07:51 PM
Is it possible to embed fonts in EPUBs? If so, how do I practically do it?
Will such embedded fonts work with Sony Readers, specifically my PRS-500?
Yes, embedded will work on the 500. They work the same as they do on the 505 and 600.

See http://www.mobileread.com/forums/showthread.php?t=36361 for more information.

erik5000
12-22-2009, 05:17 AM
sure you can. You can put them anywhere in the directory structure, as long as you tell the .opf file where they are.
Use .otf fonts.
Here is a CSS entry in one of my epubs (the font file is in the fonts directory):

@font-face {
font-weight: bold;
font-style: normal;
font-family: "MyriadProBold" ;
src: url(fonts/MyriadPro-Bold.otf) ;
}
h1
{
font-size:20pt;
margin-bottom:20px;
font-weight: bold;
font-family: "MyriadProBold" ;
text-align: right;
}

This is the entry in content.opf:

<item id="MyriadProBold" href="fonts/MyriadPro-Bold.otf" media-type="application/vnd-ms-opentype"/>

frabjous
12-25-2009, 12:03 AM
Well, legally speaking, you can't embed Myriad Pro (unencrypted) if you're going to distribute the PDFs to others. There are many free fonts you can legally embed however. Look at fontsquirrel.com or kernest.com.

AprilHare
12-31-2009, 02:13 AM
I'm trying to remember if files need to be stored not compressed, and in a specific order?

erik5000
01-02-2010, 05:50 AM
Not fonts: they just have to be zipped into the epub, in the exact place where you say they must be (youe "say" that in the content.opf file AND in the .CSS file of course), eg. in a .\font folder.
Only the container.xml has a pre-defined place AND name: .\META-INF\container.xml.

As it is a real nuisance to have to tell the reader IN TWO PLACES, where a file must be found, I am currently building a little program to automatically make an epub FROM JUST THE HTML AND CSS files. Nothing more, nothing less. If you make valid XHTML "pages" and adhere to some easy extra rules when writing the XHTML, you need not be concerned with difficulties like building an .opf or .ncx or even an TableOfContents.html file yourself. The idea behind the program will be: if you can write XHTML and CSS, you get an epub for free.
I have Perl and ANT scripts that do just this, but i want to make a Windows program. That may be even easier to install. To get Perl, ANT and the XHTML/XML/CSS validation programs working is a little bit cumbersome for some.
If there is any interest in the two scripts, I may publish them on my site.

DaleDe
01-02-2010, 11:42 AM
Not fonts: they just have to be zipped into the epub, in the exact place where you say they must be (youe "say" that in the content.opf file AND in the .CSS file of course), eg. in a .\font folder.
Only the container.xml has a pre-defined place AND name: .\META-INF\container.xml.

As it is a real nuisance to have to tell the reader IN TWO PLACES, where a file must be found, I am currently building a little program to automatically make an epub FROM JUST THE HTML AND CSS files. Nothing more, nothing less. If you make valid XHTML "pages" and adhere to some easy extra rules when writing the XHTML, you need not be concerned with difficulties like building an .opf or .ncx or even an TableOfContents.html file yourself. The idea behind the program will be: if you can write XHTML and CSS, you get an epub for free.
I have Perl and ANT scripts that do just this, but i want to make a Windows program. That may be even easier to install. To get Perl, ANT and the XHTML/XML/CSS validation programs working is a little bit cumbersome for some.
If there is any interest in the two scripts, I may publish them on my site.

Do you know that this already exists? If you zip your html and css in a file it can be used in Calibre to generate the ePUB and many other formats.