View Full Version : How to embed fonts in ePub after Calibre


fiery
11-07-2009, 06:12 PM
This is my simple step by step guide how to embed fonts in epub files after Calibre convertion. For me the most important advantage is that ADE and my reader device finally show readable Cyrillic letters instead of ???.

1. When you convert with Calibre turn on "No default cover" available at EPUB Output!

2. Open the epub file using 7-zip (or other zip utility). Add the fonts bellow and edit the files directly in the archive through the 7-zip explorer (you may need to change the default editor for .css/.opf/.xhtml files to WordPad for example (I use SciTE)).

---------------
3. Add the following Serif fonts to the epub file. Fonts are available at C:\Program Files\Calibre2\resources\fonts\liberation:
---------------
LiberationSerif-Regular.ttf
LiberationSerif-Italic.ttf
LiberationSerif-BoldItalic.ttf
LiberationSerif-Bold.ttf

---------------
4. content.opf - insert the <item... lines after the <manifest>
---------------
<manifest>
<item href="LiberationSerif-Regular.ttf" media-type="application/octet-stream" id="id1"/>
<item href="LiberationSerif-Italic.ttf" media-type="application/octet-stream" id="id2"/>
<item href="LiberationSerif-BoldItalic.ttf" media-type="application/octet-stream" id="id3"/>
<item href="LiberationSerif-Bold.ttf" media-type="application/octet-stream" id="id4"/>


---------------
5. stylesheet.css - insert the following text after the first line
---------------
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(LiberationSerif-Italic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(LiberationSerif-Regular.ttf);
}
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(LiberationSerif-BoldItalic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(LiberationSerif-Bold.ttf);
}



-----------------------------------------------------------------
Cybook Opus users - if you want to use these fonts only on your device - first copy all Liberation fonts to your Cybook Opus Fonts folder. Then edit the stylesheet.css file (or enter it at Calibre -> Look & Feel -> External CSS field):
----------------
1. stylesheet.css - insert the following text after the first line
----------------
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(res:///mnt/fat/Fonts/LiberationSerif-Italic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(res:///mnt/fat/Fonts/LiberationSerif-Regular.ttf);
}
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(res:///mnt/fat/Fonts/LiberationSerif-BoldItalic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(res:///mnt/fat/Fonts/LiberationSerif-Bold.ttf);
}

wallcraft
11-07-2009, 08:07 PM
For embedded fonts:

Many ePubs with embedded fonts do not include them in the manifest. I don't know what the standard says, but it is presumably safe to skip step 4.

Steps 3,4,5 assume the fonts go in the same folder as the content.opf and stylesheet.css. I have more often seen the fonts in their own sub-folder of this folder. If this is called "Fonts" then use (step 5):
src: url(Fonts/LiberationSerif-Italic.ttf);


For on-device user fonts:

This also works on Sonys (ePub custom Fonts on 700, 505, 300, 600 (http://www.mobileread.com/forums/showthread.php?t=36361)) and Hanlins ( Fonts and Epub - What works on Sony, Works for Pocket Pro too! (http://www.mobileread.com/forums/showthread.php?t=58901)). All that differs between the Cybooks, Sonys and Hanlins is the location of the user provided font directory (e.g. SD card vs internal memory) and how it is named in the src: line.

brewt
11-09-2009, 03:45 PM
Liked the plan here, but wow, am I ever doing this wrong.

I can get it to embed it so that the calibre viewer can see it, but not adobe's. Even after re-installing adobe. Nor Sony.
Zulu doesn't do it, neither does fbreader (but I'm not sure they handle embedded fonts anyway).

Ideas? I keep hoping epub will be come more universalized in the viewings, but the different readers are vastly different in their interpretations of pretty much anything I produce - maybe I'm just bad at it.

-bjc

pdurrant
11-09-2009, 04:59 PM
This file doesn't pass epubcheck, but none of the errors are significant for your problem.

Your @font-face CSS for Perpetua and Broadway seem to be over-ridden by file-specific CSS, which no longer defines the URL for the font.

Your BROADW.TFF font file is missing from the manifest

I believe that in @font-face declarations, non-generic font-family: attributes should be enclosed in "", as should the path in the url part of the src attribute. See the example in

http://www.w3.org/TR/1998/REC-CSS2-19980512/fonts.html#font-selection

Perhaps fixing these problem will improve consistency of rendering

Liked the plan here, but wow, am I ever doing this wrong.

I can get it to embed it so that the calibre viewer can see it, but not adobe's. Even after re-installing adobe. Nor Sony.
Zulu doesn't do it, neither does fbreader (but I'm not sure they handle embedded fonts anyway).

Ideas? I keep hoping epub will be come more universalized in the viewings, but the different readers are vastly different in their interpretations of pretty much anything I produce - maybe I'm just bad at it.

-bjc

FizzyWater
11-09-2009, 09:12 PM
If I made epubs like this, and later put them on a new reader that doesn't have a "Fonts" folder (or have the fonts saved into it), would the ebooks be unreadable, or would it simply display them in the default fonts?

pdurrant
11-10-2009, 09:01 AM
The books being discussed here have the fonts inside the ePub, so should display the font on any ePub reader that handles custom fonts.

If you made an ePub with references to fonts inside a particular reader's fonts folder, one a reader without the fonts installed the ePub reader should just use its default fonts.

If I made epubs like this, and later put them on a new reader that doesn't have a "Fonts" folder (or have the fonts saved into it), would the ebooks be unreadable, or would it simply display them in the default fonts?

brewt
11-10-2009, 12:40 PM
Thanks for lookin'. God, mybad on typo.

In my original html, the styles and @fontface calls were in a real css, not at the top of the html - did calibre re-embed? (Built with Word, hand-excised styles references)

Not in original html, in calibre-rendered html's:
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }
@font-face {
font-family: Tahoma;
panose-1: 2 11 6 4 3 5 4 4 2 4
}

@font-face {
font-family: "Ocean Sans Std Bold Ext"
}

@font-face {
font-family: Inconsolata
}

@font-face {
font-family: Perpetua
}

@font-face {
font-family: Broadway
}


Also, in the calibre-built epub's css, there are calibre styles that I didn't have in the original.....
<link rel="Stylesheet" type="text/css" media="all" href="styles.css"/>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/><link href="stylesheet.css" type="text/css"

.calibre4 {
display: block;
font-family: Perpetua;
font-size: 1.125em;
font-weight: bold;
margin-bottom: 3pt;
margin-left: 0;
margin-right: 0;
margin-top: 12pt;
page-break-after: avoid
}
etc


Are these just the styles I had in my original css that I didn't use?

...understanding fading.....

-bjc

FizzyWater
11-10-2009, 10:21 PM
The books being discussed here have the fonts inside the ePub, so should display the font on any ePub reader that handles custom fonts.

:smack:

So sorry! I just read on another thread to include the generic "serif" and/or "sanserif" in the font declaration so that if the font you declare is unavailable, the book will use the default serif or sanserif (depending on which you declare).

padman
11-22-2009, 04:58 AM
2. Open the epub file using 7-zip (or other zip utility). Add the fonts bellow and edit the files directly in the archive through the 7-zip explorer (you may need to change the default editor for .css/.opf/.xhtml files to WordPad for example (I use SciTE)).

@fiery,
Thanks for your guide. You're suggesting editing files through an archive editor. Can you first unzip the epub, make the changes and then compile again? I couldn't find any tool that would make this compilation.

pdurrant
11-22-2009, 06:49 AM
Yes, you can unzip, edit and then zip again.

When zipping, the mimetype file must be the first file in the zip, and it must be zipped uncompressed. The other files must follow.

I wrote an Applescript for Mac OS X that does this zipping. I'm sure a batch file for Windows could be written too.

@fiery,
Thanks for your guide. You're suggesting editing files through an archive editor. Can you first unzip the epub, make the changes and then compile again? I couldn't find any tool that would make this compilation.

fiery
11-22-2009, 05:24 PM
@padman,
Instead of editing files directly in the epub file, you can change its extension from .epub to .zip and then extract the files. On Windows XP and later you can do this very easily through the explorer contextual menu command "Extract All". After file editing, zip first the mimetype file (use the explorer "Send to" -> "Compressed (zipped) folder" command). Then add all other files in the zip (just drag and drop them over the zip file). Finally, change the .zip extension to .epub.

The epub format requires that mimetype file should be put first without compression (don't worry Windows will not compress it due to its size) in the epub file. However, ADE as well as my device read epub files even if the mimetype file is not first. In fact, if you do direct editing through the 7-zip utility, it will put edited files above mimetype file and an epub verification would complain about this. So, if you want to produce a strict epub file you should unzip it, edit files and zip it again as explained above.

JSWolf
11-22-2009, 05:38 PM
Yes, you can unzip, edit and then zip again.

When zipping, the mimetype file must be the first file in the zip, and it must be zipped uncompressed. The other files must follow.

I wrote an Applescript for Mac OS X that does this zipping. I'm sure a batch file for Windows could be written too.
What I do is unzip the ePub, and then make the changes and put back just the files that I've changed. Works quite easily.

Valloric
11-22-2009, 07:23 PM
What I do is unzip the ePub, and then make the changes and put back just the files that I've changed. Works quite easily.

If the mimetype file is not the first file and/or is not uncompressed, your epub might not work in all epub-supporting software. Calibre, ADE and Sigil can still handle this, but your epub is still non-conformant and may not work elsewhere.

JSWolf
11-22-2009, 08:23 PM
If the mimetype file is not the first file and/or is not uncompressed, your epub might not work in all epub-supporting software. Calibre, ADE and Sigil can still handle this, but your epub is still non-conformant and may not work elsewhere.
I am using WinRAR to do this. So when I update the changed files, does it changes things enough to be out of spec?

pdurrant
11-23-2009, 04:48 AM
I don't know - but a quick run through epubcheck will tell you.

I am using WinRAR to do this. So when I update the changed files, does it changes things enough to be out of spec?

JSWolf
11-23-2009, 01:02 PM
I just ran epubcheck on one of the edited ePub files and it did not have any issue with mimetype.

padman
11-27-2009, 05:08 AM
Does the compression have to be zip? What if I use another software – eg. 7-zip? And what software do you use for compression on mac?

pdurrant
11-27-2009, 06:39 AM
Any zip program that produces a valid zip file should be fine - provided it doesn't add extraneous stuff between filename and file contents.

On the Mac I use the built-in zip command, controlled with an AppleScript to make it a drag&drop operation.

Does the compression have to be zip? What if I use another software eg. 7-zip? And what software do you use for compression on mac?

charleski
11-30-2009, 06:49 AM
What I do is unzip the ePub, and then make the changes and put back just the files that I've changed. Works quite easily.
I use WinRAR, with the external editor set to Notepad++ in the options. This allows me to open an epub in WinRAR, click on a file and have it open in Notepad++. When I save the file after editing, WinRAR automatically asks if I want to insert the changed version back into the archive. This way all the zipping and unzipping is handled behind the scenes.

Lloyd Simcoe
11-30-2009, 02:25 PM
I use WinRAR, with the external editor set to Notepad++ in the options. This allows me to open an epub in WinRAR, click on a file and have it open in Notepad++. When I save the file after editing, WinRAR automatically asks if I want to insert the changed version back into the archive. This way all the zipping and unzipping is handled behind the scenes.

Thanks for the tip. I gave it a go and it worked nicely.

JSWolf
12-01-2009, 12:29 PM
I use WinRAR, with the external editor set to Notepad++ in the options. This allows me to open an epub in WinRAR, click on a file and have it open in Notepad++. When I save the file after editing, WinRAR automatically asks if I want to insert the changed version back into the archive. This way all the zipping and unzipping is handled behind the scenes.
I do the exact same thing with WinRAR and Notepad++. Works very well and is a very easy setup.

teodorp
02-02-2010, 08:05 PM
Any chance for *.bat file which will make all this quckly?

P.T
02-14-2010, 04:52 PM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.

brewt
02-14-2010, 09:37 PM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.

Apparently, my plugin adding/using ability is lacking.

er, how to use? I can get the epub built with what looks like the font embedded in the file, but it sure don't look like it in the viewers I have (calibre and ade[attached]).

-bjc

kovidgoyal
02-14-2010, 09:46 PM
@PT: You can find the font file path like this


font_dir = P('fonts/liberation')


This is guaranteed to work on all platforms. It will give you the platform dependent location of the directory containing the liberation fonts.

padman
02-20-2010, 11:54 AM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.
I have added the plugin to Calibre, but apparently I do not know how to activate it. Generated ePUBs are still without fonts. Any hint how to use this plugin?

brewt
02-21-2010, 11:12 AM
I have added the plugin to Calibre, but apparently I do not know how to activate it. Generated ePUBs are still without fonts. Any hint how to use this plugin?

The plugin seems to be built for Liberation Fonts - if you have them in C:\Program Files\Calibre2\resources\fonts\liberation, and then open the epub as zip, you should see those in it.

I just can't figure out how to call them in my css/xhtml to make it work.

This is a grand idea - any chance of getting a) some more guidance, and b) the encryption scripts in it too?

-bjc

charleski
02-23-2010, 10:08 PM
Ok, I took a look at the css in the epub you posted. I don't use Calibre to produce ePubs (apart from a few very rough conversions), so I can't help you with that, but I can point out why you aren't seeing the fonts.

Firstly, the ePub has only got Liberation Serif embedded in it, so you aren't going to see the sans font at all, this may be an issue with how you've configured this plugin.
Secondly, the css code for the fonts is mangled. I don't know if this is an issue with the plugin code, but that seems a possibility.

Here are the edits I needed to make to get Liberation Serif to show up in the viewer:
Original:

@font-face {font-style: normal;font-family: 'Liberation', serif, sans-serif;font-weight: normal;src: url(LiberationSerif-Regular.ttf);}

Modified:

@font-face {font-style: normal;font-family: "Liberation Serif";font-weight: normal;src: url(LiberationSerif-Regular.ttf);}

1) The font is referred to as "Liberation Serif" in the class definition, but is called 'Liberation' in the @font-face definition. The font-face defn. needed to be changed to Liberation Serif.
2) The font name is surrounded by single quotes in the font-face defn. These needed to be changed to double quotes.
3) I'm at a loss as to what the ancillary names are doing in the font-face definition ('Liberation', serif, sans-serif). These needed to be deleted.
All three changes had to be made for the font to show up correctly.

I'd suspect this is an issue with the plugin code needing to be tweaked a bit.

JaneFancher
04-05-2010, 01:40 PM
This is exactly what I was looking for.

Thanks so much!

frabjous
04-12-2010, 06:00 PM
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(LiberationSerif-Italic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: normal;
src: url(LiberationSerif-Regular.ttf);
}
@font-face {
font-style: italic;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(LiberationSerif-BoldItalic.ttf);
}
@font-face {
font-style: normal;
font-family: 'Liberation', serif, sans-serif;
font-weight: bold;
src: url(LiberationSerif-Bold.ttf);
}


I don't really understand putting multiple family names in the @font-face declaration. This makes sense when you're using the fonts: you want a stack so that it moves down to a fallback if need be, but in the font-face, all this can do is screw up the fallbacks, right?

In any case, it appears that calibre's own viewer does not support multiple font weights/styles defined for the same family, which is rather obnoxious. At least others seem to.

(P.S. Hmm. Now I'm not entirely sure about this. I need to investigate something.)

wallcraft
04-12-2010, 07:06 PM
I don't really understand putting multiple family names in the @font-face declaration. This makes sense when you're using the fonts: you want a stack so that it moves down to a fallback if need be, but in the font-face, all this can do is screw up the fallbacks, right? It can presumably screw up the fallback if there is something wrong with the font. The reason for doing it is that the fallback (the default serif font) isn't very good. By redefining serif you always get Liberation when no font is specified in the body of the ebook. This should not be necessary if the ePub was designed from the start to use an embedded font, but if it is added later it can be hard to get Liberation to to applied uniformly to all the CSS.

elanamig
12-13-2010, 12:14 PM
Hello,

I'm a newbie on this forum.

I am trying to get cyrillic to display in epub. I used Calibre to create an epub file. The file displays Cyrillic in Calibre without problems.

Now I am trying to use Sigil to embed the fonts. I've added the liberation fonts to the epub file and modified the css. Saved epub.

Now, when I try to open it in Adobe Digital Editions, the ToC on the left displays in Cyrillic, but the text itself is ????????????....

I suspect I need to add or change something else, but what?

Thank you!

elanamig
12-13-2010, 12:27 PM
Hello,

I'm a newbie on this forum.

I am trying to get cyrillic to display in epub. I used Calibre to create an epub file. The file displays Cyrillic in Calibre without problems.

Now I am trying to use Sigil to embed the fonts. I've added the liberation fonts to the epub file and modified the css. Saved epub.

Now, when I try to open it in Adobe Digital Editions, the ToC on the left displays in Cyrillic, but the text itself is ????????????....

I suspect I need to add or change something else, but what?

Thank you!

After spending days trying to figure it out, I got it 10 mins after I made the post. I had to go back to the css file and change every reference in the .calibreX block from Times New Roman serif to Liberation sans-serif...

Works, PHEW

Danger
12-17-2010, 02:23 AM
Well I've been through this again and again. I cannot get embedded Italicized fonts to work no matter what I try. Figured at first something must be screwed with the Charis font files I was working with so I tried the Liberation fonts instead... same result. The regular font works when embedded but I cannot bold or italicize any words. If I remove the embedded font names from the CSS everything shows up as it should. If it matters I have been using Sigil to go the editting.

wannabee
12-17-2010, 06:48 AM
If the mimetype file is not the first file and/or is not uncompressed, your epub might not work in all epub-supporting software. Calibre, ADE and Sigil can still handle this, but your epub is still non-conformant and may not work elsewhere.

I usually work from a mac but had to start a new job using a pc in a new job. I am so glad i did. My new books were all ok with epub check and crew flight.

All were unzipped for editing and zipped back up in windows 7 with a right mouse click. The original epubs were generated from indesign epubs. I have never had a problem. No scripts. I knew that the mimetype file was not to be compressed but they just worked.

JaneFancher
12-24-2010, 06:16 PM
Well I've been through this again and again. I cannot get embedded Italicized fonts to work no matter what I try. Figured at first something must be screwed with the Charis font files I was working with so I tried the Liberation fonts instead... same result. The regular font works when embedded but I cannot bold or italicize any words. If I remove the embedded font names from the CSS everything shows up as it should. If it matters I have been using Sigil to go the editting.

Total sympathy!

I'm no expert and I don't know that this will fix your problem, but if you're going from a Calibre created epub file and editing it in Sigil, you might have an extraneous code that looks like this

p.sgc-1 {font-style: italic}

in your Sigil html. This will be at the head of every file that contains italics and be reflected in a style call around the italicized words themselves.

This actually duplicates the ital CSS code put in by Calibre and seems to screw up the embeded font when viewed in some readers. I found I had to take out all references to this sgc code and then my font ital worked fine.

good luck!

lavomat
12-26-2010, 10:17 AM
http://dl.dropbox.com/u/11045564/VEGESIGNES%20INCL.zip
This is my own built Font. I made an ePub eBook last week and I was questioning myself if I could embed these characters into it afterwards. VEGESIGNES English is the Title.[pirate site]

jackie_w
12-27-2010, 07:42 PM
Well I've been through this again and again. I cannot get embedded Italicized fonts to work no matter what I try. Figured at first something must be screwed with the Charis font files I was working with so I tried the Liberation fonts instead... same result. The regular font works when embedded but I cannot bold or italicize any words. If I remove the embedded font names from the CSS everything shows up as it should. If it matters I have been using Sigil to go the editting.

How were you viewing the EPUB when you decided it wasn't working? I'm not sure about Sigil, but if you try to view an EPUB with embedded fonts in the Calibre Viewer then bold & italic do not display correctly. The same EPUB viewed on my Sony readers displays just fine. I raised a Calibre bug ticket about it and was told it is a known fault. The exact response was:
This is caused by a bug in QtWebKit, see https://bugs.webkit.org/show_bug.cgi?id=29433

I believe that QtWebKit is the cross platform tool kit by Nokia that Calibre uses for various things like the GUI.

In other words fixing it is not possible by the Calibre developers. If Sigil also uses the QtWebKit it will not be fixable by the Sigil developer(s) either. They will be reliant on Nokia fixing it.

artshim
01-04-2011, 10:59 PM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.

P.T,

I put some additional code for some more flexibility. Below are usage,

* To use proper font, the resources folder need to be populated with following rule, please take a look the sample.bmp
- Parent folder for the fonts : Under Calibre installation folder, \resources\fonts
- font folder name : All smaller case, the font name like liberation
- font files in the folder : font family name + -Regular, -Italic, -BoldItalic, -Bold (Should have all 4 with proper name)
-As an example, additional Droid fonts can be located under C:\Program Files\Calibre2\resources\fonts\droid. In this case droid(all smaller case) is the font name. The font files in this folder are DroidSerif-Regular.ttf, DroidSerif-Italic.ttf, DroidSerif-BoldItalic.ttf, DroidSerif-Bold.ttf. In this case DroidSerif is font family name(font name + decal). The font file names are case-sensitive. The plugin will not work if there are no font files.

* The ExtraCss will be like this. Please note that the font-family name is the font name from the file name. So far this is what I can do without making big changes(same naming convention, folder location from liberation font)

body {
font-family: "DroidSerif";
}

* Advanced : You can put DroidSans under same folder. But the font file name should be some like DroidSans-Regular.ttf etc.

* Advanced : You can put any free font from Internet. As an example, if you downloaded SantaSerif, the folder name should be santa. And 4 style fonts need to be saved under the folder as SantaSerif-Regular.ttf, SantaSerif-Italic.ttf, SantaSerif-BoldItalic.ttf, SantaSerif-Bold.ttf. All the remains are change the EXTRA-CSS.

Thank you.

artshim
01-04-2011, 11:10 PM
P.T,
I put some additional code for some more flexibility. Below are usage,


I'd like to make it clear another font naming convention. If the font family name doesn't come with Serif or Sans, font family name and font name can be same except cases.

I just downloaded Arimo font from Google. The folder name is ....\resources\fonts\arimo and all the fonts name is Arimo-Regular.ttf, Arimo-Italic.ttf, Arimo-bold.ttf, Arimo-BoldItalic.ttf.

Thank you.

lavomat
01-07-2011, 05:55 PM
⊥hank you! ⊥hree ⊥imes more ⊥han one!

fiery
01-15-2011, 07:30 PM
I found another free good looking Serif font released recently from ParaType (paratype.com/paratype.ru). Font is free under the OFL (Open Font License). It includes Western, Central European and Cyrillic code pages. There is a Sans Serif version as well.

The advantage over the Liberation font is that the PT Serif Caption font looks bigger and more readable on the same zoom level. It's also a good solution where the last zoom option of the regular fonts is not big enough (most probably limited by the book's css).

Ola Morris
05-13-2011, 10:13 AM
Hello, I have also got a problem with font in epub. I create an epub file in Calibre but the font shows as bold on my reader? Any ideas please? I have spent hours trying to work it out :S.
I use calibre, embedded fonts plug in to display the cyrillic characters, they all show ok, but bold. Please help!
Many thanks,

jackie_w
05-13-2011, 12:02 PM
Hello, I have also got a problem with font in epub. I create an epub file in Calibre but the font shows as bold on my reader? Any ideas please? I have spent hours trying to work it out :S.
I use calibre, embedded fonts plug in to display the cyrillic characters, they all show ok, but bold. Please help!
Many thanks,

Is the problem in all epub files or just one particular one?

If it's one particular epub the problem is probably that bold is specified in the epub's .css file. You can always fix this manually but there is no "magic button". You could try a simple option first, but it may or may not work depending on the css inside the epub.

Simple
Do an epub-to-epub conversion in Calibre with this in the Convert - Look&Feel-ExtraCSS box:
body {font-weight: normal}

Manual - but more reliable

Select the epub in Calibre and choose the Tweak-epub option.
Press the Explode button.
Find the file with extension .css and open it in your standard text editor.
Search for text something like (may not be exact)
font-weight: bold
and change the word bold to normal
You will need to be careful because some of these may be making your headings bold and you may not want to change those. Once you have finished save the changes, close the file and the text editor.
If you are using Calibre v0.8, there is a Preview button which will let you check whether your unwanted bold has gone.
Press the Rebuild button to recreate the edited epub and you are finished.

Ola Morris
05-13-2011, 04:23 PM
This is happening to every single epub I create. I am giving up.

When it displays as normal on my PC (not bold) is displays as bold on my ereader. I Have uploaded fonts into my reader (have created a folder called 'fonts') - still no luck.
Any ideas?

JSWolf
05-13-2011, 04:29 PM
It may not be the CSS. But instead something wrong in the code in the XML files. I had an issue where I had a <h2> and no closing </h2> so the text in that XML came out all bold.

theducks
05-13-2011, 04:47 PM
One tiny error in the CSS and my reader (ADE) ignores that section.

It looked fine on the PC (Sigil and Calibre)

Ola Morris
05-13-2011, 05:22 PM
Any ideas how to sort it out? It's driving me mad!

pholy
05-13-2011, 05:48 PM
I recall a similar problem some time ago. It turned out to be a problem in the @font-face declaration of the embedded font; it had an alternative font given in the declaration, but alternatives should only be used in the font references. Perhaps if you post your css file we can sort out the problem.

Ola Morris
05-14-2011, 12:02 PM
Guys, I have sorted it. Finally.
I seem to be able to covert books ok now. My only concerns is why some books in PDF take aaaages to convert into PDF?

JSWolf
05-14-2011, 09:18 PM
Guys, I have sorted it. Finally.
I seem to be able to covert books ok now. My only concerns is why some books in PDF take aaaages to convert into PDF?

PDF to PDF? Why?

IGOR_G
07-19-2011, 02:59 PM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.

I downloaded and installed this plugin into Calibre. However, the Cyrillic text is still not readable. It replaces Cyrillic characters with other crazy symbols.

Can you advise?

steelart
08-07-2011, 11:26 AM
Here you can get the my program which patch existent epub file by inserting fonts
http://dl.dropbox.com/u/18464173/epub-patch.jar
(also it contains source java file, so you can modify program)

goto
08-07-2011, 04:19 PM
Here you can get the my program which patch existent epub file by inserting fonts
http://dl.dropbox.com/u/18464173/epub-patch.jar
(also it contains source java file, so you can modify program)

It doesn't work for me at all.

fromrussia
10-03-2011, 07:29 AM
Plugin from artshim (http://www.mobileread.com/forums/showpost.php?p=1314070&postcount=39) works fine on Windows 7, but doesn't work on Mac OS X Lion. Is there any way to make it work on Mac OS X?

Thanks in advance!

vferdman
10-27-2011, 12:31 PM
I created a simple plugin for Calibre that embeds fonts into epub as a part of the conversion process.

Any feedback is welcome.

How does one install this plugin on Calibre?

vferdman
10-27-2011, 12:38 PM
This is my simple step by step guide how to embed fonts in epub files after Calibre convertion. For me the most important advantage is that ADE and my reader device finally show readable Cyrillic letters instead of ???.

1. When you convert with Calibre turn on "No default cover" available at EPUB Output!



I had the ????? problem with (some) Russian epubs and the fonts seemed to be fine in the epub (embedded). As soon as I did a conversion of an epub that caused ???? with "No default cover" (epub to epub) the Russian characters showed up perfectly. Any ideas?

entodoays
11-14-2011, 06:46 PM
Hi,
I managed to embed fonts once in an epub but I'm having problems with a second one.
I followed the instructions and added the extra css body { etc and on Calibre's viewer it seems to be working fine but on my Sony PRS-T1 I'm getting ??? for every greek accented character.

Here's the resulting epub. Could anybody help please?

jackie_w
11-14-2011, 08:01 PM
Hi,
I managed to embed fonts once in an epub but I'm having problems with a second one.
I followed the instructions and added the extra css body { etc and on Calibre's viewer it seems to be working fine but on my Sony PRS-T1 I'm getting ??? for every greek accented character.

Here's the resulting epub. Could anybody help please?

That looks like the same epub someone was having trouble with in this thread (http://www.mobileread.com/forums/showthread.php?t=153778) (post #13). You could see if the same solution suits you.

entodoays
11-15-2011, 06:08 PM
Thank you very much. That worked very well.

Thasaidon
07-05-2012, 02:56 PM
P.T,

I put some additional code for some more flexibility. Below are usage,


Thank you.

I have found a problem with this plugin. If you convert a short atory in mobi format to ePub it damages the OPF. If you then open the ePub produced in Sigil the cover page appears in the list of files but the file containing the text does not. I have not noticed any other source file being affected.

I tried removing the line - font-family: "LiberationSerif" ; - from "Look and Feel" - Extra CSS. I then converted the same mobi file and this time it did not damage the OPF so that all the files could be seen in Sigil.

Thanks must go to Kovid for his helping to sort this out.

If hope someone with more time and knowledge than myself will amend the plugin as I have found it very useful.

kevin.pugh
01-04-2013, 07:39 AM
It can presumably screw up the fallback if there is something wrong with the font. The reason for doing it is that the fallback (the default serif font) isn't very good. By redefining serif you always get Liberation when no font is specified in the body of the ebook. This should not be necessary if the ePub was designed from the start to use an embedded font, but if it is added later it can be hard to get Liberation to to applied uniformly to all the CSS.


Hi there, the comma separated list does give a list of what fonts to use if the 'system' cannot find a particular font. For instance:

In the style.css file you might have:

@font-face {
font-family: "Liberation", Arial, sans-serif;
font-weight: normal;
font-style: normal;
src: url(../Fonts/LiberationSans-Regular.otf);
}

The above means - if you can't find font family "Liberation" then use Arial. If you cannot find Arial then use any font that is sans-serif.

I believe the use of quotes in such declarations is to handle font family names which have spaces in - e.g.: "Liberation Sans".

Note that the fall back strategy is important for those who are testing their ePub document with embed fonts. If your Windows or Linux system has these fonts installed already, then some ePub readers will use those fonts - SIGIL for instance. In contrast, So you assume that the embed fonts are working. However, when you transfer the ePub document to your eReader, the embed font does not work.

From my experience, Calibre uses the embed font.

Jellby
01-04-2013, 08:07 AM
In the style.css file you might have:

@font-face {
font-family: "Liberation", Arial, sans-serif;
font-weight: normal;
font-style: normal;
src: url(../Fonts/LiberationSans-Regular.otf);
}

I don't think you can have several fonts there. It is possible in a "normal" style:

p {
font-family: "Liberation", Arial, sans-serif;
}

But in a @font-face, you are not specifying that a given font should be used, but you are actually defining the font, and to define the font you must give it a name, not a list of names. So with:

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

you say that whenever the "Liberation" family is needed, in normal weight and style, the renderer should use the file in ../Fonts/LiberationSans-Regular.otf.

pholy
01-04-2013, 11:57 PM
I'm quite sure Jelby is right, having found and fixed this sort of problem elsewhere.
The @font-face is a declaration of a font, which can be found in a particular src: url().
The font-family in a style is a reference to a desired font, so the fallback list is appropriate there.

theducks
01-05-2013, 02:02 AM
Jelby is correct:
In the @fontface, you are specifying the definition of a single fonts relationship to a family: "Liberation" (it take 4 font weight/stokes to fully define a full family. normal, bold, italic, bold-italic)

The font-family in the (style) usage, gets the fallbacks

kevin.pugh
01-05-2013, 01:52 PM
Jelby is correct:
In the @fontface, you are specifying the definition of a single fonts relationship to a family: "Liberation" (it take 4 font weight/stokes to fully define a full family. normal, bold, italic, bold-italic)

The font-family in the (style) usage, gets the fallbacks

hi folks, I stand corrected ... this is one more thing I have learned today. Thanks for the information.
Kevin

JSWolf
01-07-2013, 03:59 PM
hi folks, I stand corrected ... this is one more thing I have learned today. Thanks for the information.
Kevin

I can teach you another thing.

The current version of Calibre has font subsetting. Subsetting is where when Calibre converts to ePub (maybe AZW3 as well) it checks which embedded fonts are used and also which characters from which fonts.

So if you embed a 4 family font in your ePub and the bold italic version is not used, Calibre would delete it.

Subsetting also will remove characters from the font(s) that are not used in that specific ePub. So it makes the font files smaller for the used fonts and between cutting out unused fonts/characters, this can make the ePub significantly smaller.

What I do once the ePub is done other then subsetting, I load that into Calibre, convert the ePub > ePub (turning on font subsetting in Look & Feel) and in the converted ePub, extract the font directory to replace the font directory in the finished ePub. Then I edit the CSS & OPF as needed for any fonts that were deleted.

Once that's done and the ePub validates, I delete the two ePub in Calibre and put in the finished ePub to eventually go on my Reader.

Turtle91
01-30-2013, 11:31 AM
I can teach you another thing.

Thanks Jon - that is exactly what I was looking for!

I thought I had seen something on MR that someone was making a plugin for Sigil to do all of that automatically...have you heard/seen anything?

[edit] Found it! (http://www.mobileread.com/forums/showthread.php?t=203163&highlight=font+subsetting) Not a plugin, but a standalone.

JSWolf
01-30-2013, 02:37 PM
Thanks Jon - that is exactly what I was looking for!

I thought I had seen something on MR that someone was making a plugin for Sigil to do all of that automatically...have you heard/seen anything?

[edit] Found it! (http://www.mobileread.com/forums/showthread.php?t=203163&highlight=font+subsetting) Not a plugin, but a standalone.

It's not a plugin. It's Calibre. The standalone is much much harder to use. Use Calibre until the standalone works as well.

Doitsu
01-31-2013, 10:59 AM
You could also use the Font Squirrel's @font-face Generator (http://www.fontsquirrel.com/fontface/generator) in expert mode, which offers more settings than Toxaris's standalone app, to subset fonts.

Turtle91
01-31-2013, 11:23 AM
Does Font Squirrel scan a document and only provide the characters 'used', or do you need to manually delete the un-used?

Doitsu
01-31-2013, 12:26 PM
Font Squirrel doesn't allow you to exclude unused characters. You can only select glyphs by Unicode ranges, languages or character types (uppercase, lowercase, numbers, punctuation etc.)
IMHO, excluding unused glyphs offers only minimal size advantages. Also if you find a font that you like, you'd have to run the subsetter each time you create a new book to make sure that all characters are included in the subset font.

Turtle91
01-31-2013, 12:50 PM
Also if you find a font that you like, you'd have to run the subsetter each time you create a new book to make sure that all characters are included in the subset font.

I don't intend to use embedded fonts/subsetting on a regular basis...that's what user selection is for on the device; I'll let them choose which font THEY like best. The only time I would need an embedded font is if the specific font itself adds to the story of that specific book...HP for example. If a customer wants to pay for a different font in their header, who am I to tell them "no"... Being a professional [cough,cough] I would want to provide the best (smallest/cleanest) product I can - I would just like a tool that makes that easier! ;)

Thanks for the suggestion though!

Toxaris
01-31-2013, 02:55 PM
Keep in mind that Font Squirell will not subset all fonts. Quite a number of fonts are blacklisted.

Also, John, I take some offense to your words. My program was not intended to work as you would like, it works as I wanted. The fact that I am working on a new version that can open ePUB is because I can see some need for it for myself and some others. Quite frankly I don't care if it works better for you. You never ask for something, you demand.

trampino
11-10-2014, 08:14 PM
Hello, could anybody help me?

I make conversion of DOCX to EPUB, using Calibre command line. I use all recomandations, writen in this thread, for using plugin embedfont_plugin.zip

If I use original plugin version form P.T. (http://www.mobileread.com/forums/showpost.php?p=789034&postcount=23) in win7 with Calibre 2.7, it works perfect. If I use the same on Linux server with Calibre 2.7. files with fonts are not placed into epub file and error messages written below are displayed in terminal.

If I used modified version of plugin form artshim (http://www.mobileread.com/forums/showpost.php?p=1314070&postcount=39) it does not work in win7 with Calibre 2.7 and it does not work in Linux with Calibre 2.7 too. In both operation systems terminal displays the same erro as for plugin from P.T.

The error messages are these:
Error: Can't find liberation fonts.
Running file type plugin EPUB Font embedding plugin failed with traceback:
Traceback (most recent call last):
File "site-packages/calibre/customize/ui.py", line 154, in _run_filetype_plugins
File "calibre_plugins.dummy1.__init__", line 88, in run
SystemExit: 0
EPUB output written to /u1/myusername/opt/calibre/KnihaVystup.epub
Output saved to /u1/myusername/opt/calibre/KnihaVystup.epub