View Single Post
Old 01-30-2009, 10:13 PM   #9
llasram
Reticulator of Tharn
llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.llasram ought to be getting tired of karma fortunes by now.
 
llasram's Avatar
 
Posts: 618
Karma: 400000
Join Date: Jan 2007
Location: EST
Device: Sony PRS-505
I meant to answer this in more detail earlier...

You need three basic ingredients to do this:
  • Your font files somewhere on your Reader's internal memory partition.
  • Some CSS telling AdobeDE where those font files are.
  • Some CSS telling AdobeDE to actually use those fonts.
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.
Attached Files
File Type: epub TestBook.epub (9.1 KB, 3576 views)
File Type: zip TestBook.zip (2.2 KB, 3144 views)
File Type: zip fonts.zip (280.5 KB, 3693 views)
File Type: txt fonts.css.txt (653 Bytes, 3568 views)
llasram is offline   Reply With Quote