Mobileread
ePub custom Fonts on all Sonys
#1  Xenophon 01-14-2009, 01:23 PM
In some earlier post in one of the many fora here on MobileRead, somebody posted instructions on how to use a custom non-embedded(!) font with ePub files on the 500 and 505. Has anyone done this successfully on the 700?

The posted directions were:
Quote
Just put the following script:
@font-face {
font-family: "Freestyle Script";
src:url(res:///Data/FONT/FREESCPT.TTF);
}
in the CSS and put your font at FONT/FREESCPT.TTF of internal storage.
And actually it supports *any* unicode locale. (Fonts on MS is also possible.)
I'm trying to do this on my 700, but I can't find a Data directory in which to place my font. Suggestions, anyone?

Xenophon

EDIT : scroll down to post 9 of this thread for all the css code you will need, and in post 18 i've added some screen caps and a step-by-step guide for people who are less experienced with using css.
--zelda pinwheel
Reply 

#2  kovidgoyal 01-14-2009, 01:25 PM
I haven't tried this, but you should be able to put the font in any directory
Reply 

#3  llasram 01-14-2009, 01:37 PM
Quote Xenophon
I'm trying to do this on my 700, but I can't find a Data directory in which to place my font. Suggestions, anyone?
The '/Data' directory is where the externally-mountable Reader-internal flash partition is mounted from the Reader's perspective. So if you create a file 'foobar.otf' just in the root directory of the Reader-internal memory, the Reader (and the CSS you need to write) sees it at '/Data/foobar.otf'.
Reply 

#4  wallcraft 01-14-2009, 01:38 PM
Quote Xenophon
II'm trying to do this on my 700, but I can't find a Data directory in which to place my font.
My reading of the original posts is that res:///Data/ is the URL of the root of the Reader-internal memory, so you should create the FONT directory (or whatever) there.
Reply 

#5  Xenophon 01-14-2009, 01:57 PM
Quote llasram
The '/Data' directory is where the externally-mountable Reader-internal flash partition is mounted from the Reader's perspective. So if you create a file 'foobar.otf' just in the root directory of the Reader-internal memory, the Reader (and the CSS you need to write) sees it at '/Data/foobar.otf'.
Should I take your use of the '.otf' extension to mean that open type fonts are supported? If so, TrueType style only, or do PS-style opentype fonts work too?

And thanks to all the previous posters for their answers to my question!

Xenophon
Reply 

#6  llasram 01-14-2009, 02:42 PM
Quote Xenophon
Should I take your use of the '.otf' extension to mean that open type fonts are supported? If so, TrueType style only, or do PS-style opentype fonts work too?
You know, I'm not sure. If you figured it out and reported back I know that I would be grateful .
Reply 

#7  Xenophon 01-16-2009, 12:35 PM
I spent several hours last night experimenting with this feature. I was unable to get it to work. I tried every combination I could of the following:
I also attempted using Opentype fonts, both truetype and PS style. I was not able to construct a working example, no matter the combination.

At this point, I'd really appreciate it if someone who's gotten this to work on their 700 (or 505!) would be willing to send me both a zip of the actual font file they used AND the css they used to invoke it.

Xenophon
Reply 

#8  Xenophon 01-20-2009, 02:23 PM
Bump...
Reply 

#9  llasram 01-30-2009, 11:13 PM
I meant to answer this in more detail earlier...

You need three basic ingredients to do this:
I'm guessing that you were missing the last one, but I'll go into detail on all of them, just to be safe.

You can put the font-files anywhere on the Reader's internal memory partition, but let's keep it simple and put them all in a folder named 'fonts' at the root of the partition. So when you open the Reader's internal memory you should see all the normal stuff plus the 'fonts' folder you created. Just put all the font files you want to use in there.

The CSS needs to have '@font-face' rules describing the font-family and pointing at the font files, including all combination of variant font properties. Here's an example using the open source font "TeX Gyre Cursor":

Code
@font-face { font-family: "TeX Gyre Cursor"; font-weight: normal; font-style: normal; src: url(res:///Data/fonts/texgyrecursor-regular.otf);
}
@font-face { font-family: "TeX Gyre Cursor"; font-weight: bold; font-style: normal; src: url(res:///Data/fonts/texgyrecursor-bold.otf);
}
@font-face { font-family: "TeX Gyre Cursor"; font-weight: normal; font-style: italic; src: url(res:///Data/fonts/texgyrecursor-italic.otf);
}
@font-face { font-family: "TeX Gyre Cursor"; font-weight: bold; font-style: italic; src: url(res:///Data/fonts/texgyrecursor-bolditalic.otf);
}
The value of the 'font-family' property can be anything, but needs to be the same for every font-file in the same family you are referencing, and for simplicity should be the actual name of the typeface included in the font-files. The 'src' properties should point to the individual font-font files: prefix the files with 'res:///Data/', then the path to the font file, using forward slashes ('/') to separate directories. Case matters, so make sure you are using the same case as for the files themselves. Linux (which is what the Reader is running) has options which change how it handles ALLCAPS filenames on FAT-32 filesystems, so I would suggest avoiding them.

Next you need some CSS which actually tells AdobeDE to use the typeface you've configured. The simplest way to do that is with a rule like:

Code
body { font-family: "TeX Gyre Cursor", serif;
}
Which tells it to use "TeX Gyre Cursor" for everything within a <body/> tag (i.e., all the book text) which doesn't explicitly specify a different font-family, and fall back to the built-in 'serif' typeface for any characters missing from "TeX Gyre Cursor."

If you're using the Calibre GUI, you can just put all the text in the textbox for override CSS. If you're using the command-line tools, you can create a file with all the CSS in it and pass the filename as the argument to the '--override-css' option.

For an example, I created the attached book from the attached sources with the attached fonts using the attached CSS file[1] (whew!) using the command:

Code
any2epub --override-css fonts.css.txt TBsrc/content.opf -o TestBook.epub
I hope that gets you sorted out!

[1] The file is named "fonts.css.txt" instead of just "fonts.css" due only to the MR uploaded filename rules.
[epub] TestBook.epub (9.1 KB, 2535 views)
[zip] TestBook.zip (2.2 KB, 2185 views)
[zip] fonts.zip (280.5 KB, 2690 views)
[txt] fonts.css.txt (653 Bytes, 2412 views)
Reply 

#10  Xenophon 01-31-2009, 03:29 PM
Thanks!! I'll try it out this weekend. When you wrote:
Quote
You need three basic ingredients to do this:I'm guessing that you were missing the last one, but I'll go into detail on all of them, just to be safe.
I'll bet that the last one is exactly what I was missing.

Xenophon
Reply 

  Next »  Last »  (1/30)
Today's Posts | Search this Thread | Login | Register