Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 03-07-2009, 10:14 AM   #16
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
this method works on the 505 as well (tested by JSWolf) so i'm moving it to the epub forum where it seems more appropriate.
zelda_pinwheel is offline   Reply With Quote
Old 03-10-2009, 04:56 PM   #17
deadringer
Enthusiast
deadringer began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Feb 2009
Device: Sony PRS700BC
I can't seem to make this work. My epub files , which I make from .lit files using Calibre, never change fonts. I put the font files in a fonts dir which I made in the Sony Reader directory. Also in there are directories called sync,database,books etc. Is this the correct place?

Thanks

John
deadringer is offline   Reply With Quote
Old 03-11-2009, 12:21 PM   #18
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
since i've had a few questions about this procedure i decided to add some screen caps to make the process clearer to people who are less experienced. detailed instructions (including all the css code needed) are in post 9 of this thread (thanks llasram !!).

(click three times in a row on the image to see it at full size)
1. connect the 505 / 700, and open the folder
Click image for larger version

Name:	1openfolder.png
Views:	2175
Size:	10.2 KB
ID:	25429

2. create a new folder called "fonts"
Click image for larger version

Name:	2fontsfolder.png
Views:	2191
Size:	23.7 KB
ID:	25430

3. put the font files inside this folder
Click image for larger version

Name:	3fonts.png
Views:	2135
Size:	31.0 KB
ID:	25431

4. add the css rules indicating where the fonts are, and to use them
Click image for larger version

Name:	4cssrules.png
Views:	2981
Size:	47.9 KB
ID:	25432

5. (very important) output in epub format.

TUTORIAL

Quote:
Originally Posted by zelda_pinwheel View Post
here is a step-by-step guide :
1. install calibre.
2. choose the font you want to use for your files. i use "Fontin" family (it has a regular, a bold, an italic, and a small-caps version).
3. create a new folder at the top level of your 700 called "fonts" (case is important : it can be called "Fonts", but you'll have to name it that way everywhere you refer to it).
4. put your chosen font files into that folder (there should be more than one, since usually there will be regular, italic, bold, and maybe some others. also, some font families come with serif and sans serif versions).
5. launch calibre, click on the little arrow next to "convert ebooks", then "set defaults for conversion".
6. on the left side of the dialogue box, click on "look & feel".
7. in the "override css" box in the bottom right quarter of the dialogue box, paste the script from the other thread, making sure to follow the renaming instructions. since i'm using Fontin, the script for me looks like this :
Code:
@font-face {
  font-family: "Fontin";
  font-weight: normal;
  font-style: normal;
  src: url(res:///Data/fonts/Fontin-Regular.ttf);
}

@font-face {
  font-family: "Fontin";
  font-weight: bold;
  font-style: normal;
  src: url(res:///Data/fonts/Fontin-Bold.ttf);
}

@font-face {
  font-family: "Fontin";
  font-weight: normal;
  font-style: italic;
  src: url(res:///Data/fonts/Fontin-Italic.ttf);
}

body {
  font-family: "Fontin", serif;
}
notice i named the "font-family" Fontin for clarity, and in the "source" line (src) i specified the exact name of each file, inside the "fonts" folder i created on my 700.

click ok to save these defaults.

all books you convert with calibre should now use the font of your choice.

HOW TO CREATE THE FONTS FOLDER :
connect your 700 to your computer using the usb cable. wait for it to be recognized. if you are using a pc, you should get a prompt asking you what you want windows to do with this new disk ; ask to view it in explorer (or something like that ; i'm translating from french, from memory here. but in windows XP, the icon for the choice you want is an open folder). you'll see a new file explorer window, with some folders already in it. i believe you should have "database" "digital editions" etc. on the side of that window, you'll have options, including "create new folder". click on that, and rename the folder "fonts".
zelda_pinwheel is offline   Reply With Quote
Old 03-11-2009, 12:30 PM   #19
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
Quote:
Originally Posted by deadringer View Post
I can't seem to make this work. My epub files , which I make from .lit files using Calibre, never change fonts. I put the font files in a fonts dir which I made in the Sony Reader directory. Also in there are directories called sync,database,books etc. Is this the correct place?

Thanks

John
i thought it was working for you ? are you having trouble again ?
zelda_pinwheel is offline   Reply With Quote
Old 03-11-2009, 11:49 PM   #20
deadringer
Enthusiast
deadringer began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Feb 2009
Device: Sony PRS700BC
Hello Zelda

I couldn't get Fontin to work but I did just get georgia.ttf to work. I must have a typing error in the css or something. Thanks for all the help!

John
deadringer is offline   Reply With Quote
Old 03-14-2009, 10:07 AM   #21
JSWolf
Suspended
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
Posts: 35,392
Karma: 16147088
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Fontin is actually a nice readable font at small sizes because of the weight. I've also used the sans-serif version to make the headers. That looks good too.
JSWolf is offline   Reply With Quote
Old 03-14-2009, 10:10 AM   #22
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
Quote:
Originally Posted by deadringer View Post
Hello Zelda

I couldn't get Fontin to work but I did just get georgia.ttf to work. I must have a typing error in the css or something. Thanks for all the help!

John
ha okay. well don't forget the filepath of the font must be exactly as it is in the font folder (file name and directory name are case sensitive) ; to get the file name i did a copy-paste directly from the font file.

that said, i have had a couple of failed attempts, which i've not been able to figure out. and when i tried to embed a couple of decorative fonts in a file which i had already put into fontin, one of them worked, but not the other (don't know why).

perhaps not all fonts are created equal... (for info, i've had success both with otf and ttf fonts).

glad you managed to get one of them to work though !
zelda_pinwheel is offline   Reply With Quote
Old 03-14-2009, 11:01 AM   #23
pepak
Fanatic
pepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura about
 
Posts: 594
Karma: 4150
Join Date: Mar 2008
Device: Sony Reader PRS-505
After I have defined the external font-faces:
Code:
@font-face { font-family: "Times"; font-weight: normal; font-style: normal; src: url(res:///Data/fonts/times.ttf); }
@font-face { font-family: "Times bold"; font-weight: bold; font-style: normal; src: url(res:///Data/fonts/timesbd.ttf); }
@font-face { font-family: "Times italic"; font-weight: normal; font-style: italic; src: url(res:///Data/fonts/timesi.ttf); }
@font-face { font-family: "Times bold italic"; font-weight: bold; font-style: italic; src: url(res:///Data/fonts/timesbi.ttf); }
and told body to use the basic font:
Code:
body { font-family: "Times CE", serif; }
do I need to add definitions to use the italic/bold variants as well, or will ADE use them automatically?
Code:
strong, b { font-family: "Times CE bold", serif; }
em, i { font-family: "Times CE italic", serif; }
...
And a second question: I am using "generic" font-families everywhere:
Code:
code { font-family: monospace; }
Is it possible to instruct ADE that my custom font "Courier CE" should be used as a default monospace font, or do I need to update all definitions to:
Code:
code { font-family: "Courier CE", monospace; }
?

Last edited by pepak; 03-14-2009 at 11:05 AM.
pepak is offline   Reply With Quote
Old 03-14-2009, 11:12 AM   #24
pepak
Fanatic
pepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura about
 
Posts: 594
Karma: 4150
Join Date: Mar 2008
Device: Sony Reader PRS-505
Well, answer to question 1 is "apparently yes", since italic sections of a book I tried I rendered using the default font, not my custom font (I did not use the extra definitions for em, i, strong, b, etc.).
pepak is offline   Reply With Quote
Old 03-14-2009, 11:20 AM   #25
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
first question : be careful with your code : for "font family", you should use the name of the font family, not the specific font type, so "Times" instead of "Times bold" (etc.) and it should be the same name for all variants of the font (regular, bold, italic). then you have to give this same font family name in the "body" rule. then, the italic and bold variants should be used automatically when you specify "em" and "strong" in the markup.

second question : i think you need to make new rules for all additional fonts, and define them the same way you did for times, and then try creating a css class (like ".mono" or ".code") which says to use the font ; then use a "span class" selector to specify when you want to use the monospace fonts.
zelda_pinwheel is offline   Reply With Quote
Old 03-14-2009, 11:32 AM   #26
pepak
Fanatic
pepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura about
 
Posts: 594
Karma: 4150
Join Date: Mar 2008
Device: Sony Reader PRS-505
#1: You are correct, my mistake. Fixed it and it works now.
#2: That's not so good, but I guess there is little else to do.

Interesting observation: The new font gets used for regular, bold and italic text, but it does not get used for font-variant: small-caps;. But that is probably an error in ADE, since it renders such sections as font-variant: normal; anyway.
pepak is offline   Reply With Quote
Old 03-14-2009, 11:34 AM   #27
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
Quote:
Originally Posted by pepak View Post
#1: You are correct, my mistake. Fixed it and it works now.
#2: That's not so good, but I guess there is little else to do.
glad the first one worked. sorry about the second one. that's the only way i see. but maybe you can find a simpler one ; if you do, please share it here !

Quote:
Interesting observation: The new font gets used for regular, bold and italic text, but it does not get used for font-variant: small-caps;. But that is probably an error in ADE, since it renders such sections as font-variant: normal; anyway.
well, some fonts actually have a specific "small caps" variant which is a separate font file (Fontin does) ; so if it's not defined, maybe it goes back to the default. you could define "small caps" in your css though.
zelda_pinwheel is offline   Reply With Quote
Old 03-14-2009, 11:58 AM   #28
richardigp
Enthusiast
richardigp began at the beginning.
 
Posts: 27
Karma: 18
Join Date: Dec 2008
Location: Currently living in Pune India
Device: Sony
Xenophon,

We have embedded fonts working on the 505 and use it to test commercial ePubs with embedded fonts nearly every day. The spec says use OTF preferrably, but it is up to the device what it handles. Devices do not have to handle fonts, or any fonts in particular. The mandatory points for embedded fonts if supported are: Font is in the manifest, must use the CSS2 descriptors, font must not map outside Unicode characters, must honor embedding properties.

The idea of the ePub package, if it is going to use embedded fonts, is that the fonts are in the ePub package itself. It is optional that a reader device can then choose to have the ability to use them or not.

Check it out here
You can see an example in the Hound of the Baskervilles downloadable from here. Its on the title page and part separator page after the introduction. Crack it open and have a look. This will work in AZARDI, ADE and the 505. Just a simple decorative effect to set the tone of the book. (the font credit is on the copyright page).

Nervously critical...
I am unsure about the technique of putting the fonts in the ///data/ directory and referring from the ePub stylesheet statement. It's not wrong insofar as there is no prohibition to referencing a font outside the ePub package, but obviously this is then not an embedded font. This effectively hardcodes the font to a device and has the potential of not working in the future, or across new and emerging devices.

It should be as simple as this...
The following example is from a commercial ePub book and has two fonts and the fonts are in a directory in the opf directory fonts/ (it didn't have to be called fonts, but that is moderately sensible). Note that the path is relative from where the stylesheet is in the base book directory along with the pages, etc. We don't really need to worry about anything else:

@font-face {
font-family: "Futura";
font-style: normal;
font-weight: normal;
src:url(fonts/TT0202M_.TTF);
}
@font-face {
font-family: "PizzaDude Pointers";
font-style: normal;
font-weight: normal;
src:url(fonts/PIZZADUDEPOINTERS.ttf);
}
The other font rule that ADE ignores (therefore maybe the 505), unless it has changed, is that fonts must be registered in the OPF manifest. That should look something like:

<item id="font21" href="fonts/PIZZADUDEPOINTERS.ttf" media-type="application/x-font-truetype" />

One manifest statement for each font. Fonts are pretty special in any OS. They have to be running to be used. In a desktop system a reader can pick up fonts through the OS if available. ADE uses Adobe Flash and it starts up the fonts from the CSS statement, which is OK for it, but is only half the answer.

Problems in Reader implementation...
Our AZARDI reference reader is programmed in PyQT and WebKit. It will not find fonts and start them from the CSS statement without programmatic involvement. AZARDI looks in the manifest; If fonts are there, they are started for the reading session. We could program it to look for fonts in the CSS, but that is off-specification and we have the "nasty strict" reference ePub Reader.

In its present version Qt only supports TTF, so that is what we use. It doesn't currently support OTF, but if fallback fonts were used, the bases would be covered - all fallback fonts have to be in the manifest. (ADE/505 support OTF fine because they are clever font people).

Internally, when a book is loaded a Reader supporting fonts should do something like read the manifest specifically looking for fonts it understands. If it finds them it starts them up for the book Reading session, and they are automatically available for the CSS, just like Operating System fonts. When the book is closed so are the internal fonts.

This way reading devices don't have to interprete CSS to know if a font is available, or if they have to start-up a font; reading devices dont have to be loaded up with fonts; and ePubs with embedded fonts are portable across devices that support embedded fonts.

And the rules are....!
So in summary there are just two simple rules for embedding fonts:

1. The font must be in the manifest and the package
2. The CSS reference must point to the font location in the package.

The rest is up to the Reading device or application.

ePub is in early days of development, and with this font issue ADE has not helped by loading fonts from the CSS without being in the manifest. This will get worse as more titles try to utilize in-line and out-of-line XML Islands.

Beware the fonts...
And a final word of caution, there are fonts and fonts. Most fonts from a reputable foundary will work fine; older fonts and free fonts (like we use in our demo products) need to be tested. Suspect the font if some work and one doesn't. To know a font is being handled correctly by a device make sure it is NOT installed on the operating system of your work station.

Maybe that was a bit technical, hope it helps.
richardigp is offline   Reply With Quote
Old 03-15-2009, 04:19 AM   #29
pepak
Fanatic
pepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura aboutpepak has a spectacular aura about
 
Posts: 594
Karma: 4150
Join Date: Mar 2008
Device: Sony Reader PRS-505
Quote:
Originally Posted by pepak View Post
I am using "generic" font-families everywhere:
Code:
code { font-family: monospace; }
Is it possible to instruct ADE that my custom font "Courier CE" should be used as a default monospace font?
Turns out the solution is extremely simple. All you need to do is to add the generic family to your @font-face:
Code:
@font-face { font-family: "Courier CE", monospace; font-weight: normal; font-style: normal; font-variant: all; src: url(res:///Data/fonts/cour.ttf); }
I still haven't solved the problem with font-variant: small-caps, though - font-variant: all should take care of that as per CSS3 specs, but it does not - Calibre complains that such a value is not allowed, but duly puts it in the EPUB, where it is then completely ignored by ADE (on Sony Reader).
pepak is offline   Reply With Quote
Old 03-15-2009, 12:35 PM   #30
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 24,805
Karma: 4369673
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
IIRC ADE only supports CSS2
kovidgoyal is online now   Reply With Quote
Reply

Tags
epub, fonts

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any Reader With Custom Fonts and Full Justification? Loose_Appeal Which one should I buy? 2 07-16-2010 07:16 AM
ePub with custom .css on a 505 dicknskip Sony Reader Dev Corner 3 06-09-2010 11:34 PM
Custom TTF fonts in MOBI books? jpt Astak EZReader 21 11-21-2009 08:24 AM
Test for custom entities in ePUB Jellby ePub 9 05-27-2009 06:45 AM


All times are GMT -4. The time now is 06:34 AM.


MobileRead.com is a privately owned, operated and funded community.