Mobileread
How to embed fonts in ePub after Calibre
#61  Thasaidon 07-05-2012, 01:56 PM
Quote artshim
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.
Reply 

#62  kevin.pugh 01-04-2013, 06:39 AM
Quote wallcraft
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.
Reply 

#63  Jellby 01-04-2013, 07:07 AM
Quote kevin.pugh
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:

Code
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:

Code
@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.
Reply 

#64  pholy 01-04-2013, 10: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.
Reply 

#65  theducks 01-05-2013, 01: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
Reply 

#66  kevin.pugh 01-05-2013, 12:52 PM
Quote theducks
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
Reply 

#67  JSWolf 01-07-2013, 02:59 PM
Quote kevin.pugh
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.
Reply 

#68  Turtle91 01-30-2013, 10:31 AM
Quote JSWolf
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! Not a plugin, but a standalone.
Reply 

#69  JSWolf 01-30-2013, 01:37 PM
Quote Turtle91
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! 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.
Reply 

#70  Doitsu 01-31-2013, 09:59 AM
You could also use the Font Squirrel's @font-face Generator in expert mode, which offers more settings than Toxaris's standalone app, to subset fonts.
Reply 

 « First  « Prev Next »  Last »  (7/8)
Today's Posts | Search this Thread | Login | Register