View Single Post
Old 02-01-2009, 03:28 PM   #8
Vintage Season
Pulps and dime novels...
Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.Vintage Season ought to be getting tired of karma fortunes by now.
 
Vintage Season's Avatar
 
Posts: 343
Karma: 1952003
Join Date: Jan 2009
Device: Kobo Aura/Kobo Aura One LE/iPad Air
Just found this thread. I posted the following in the "EPUB output" sticky yesterday, but thought it might be worth cross-posting here in case anyone is able to test whether the following approach will actually work on the Sony PRS-505 or PRS-700 (basically the external font approach, but using TrueType fonts stored within the .epub itself):

Quote:
Originally Posted by Xenophon View Post
Does the current ePub conversion capability support embedded fonts? If not, could it be added easily? Alternatively, could someone with a Mac and a PRS700 figure out how to get the change-of-font-via-css-file trick to work properly? I've struck-out on my efforts in that direction.

Xenophon
Quote:
Originally Posted by kovidgoyal View Post
it doesn't and no its not easy, which is why it hasn't been done yet. It is on my TODO list though, so it will get done eventually
Xenophon (or kovidgoyal, or anyone else who already owns a Sony PRS-505 or PRS-700), would you be willing to try an experiment for me? Here are the steps I took to get TrueType fonts accessibly embedded into .epub files using Calibre, and I have verified that they work using the Calibre reader on several different computers and operating systems that have never had these particular fonts installed, but I do not yet own any electronic-ink devices on which to test compatibility.

If anyone wants to donate a PRS-505 or PRS-700 to me, I'd be happy to test further on this end!

In the book I authored this morning, I used three separate TrueType fonts: David Rakowski's "UpperWestSide" for titles, chapter headings and drop-caps, Monotype Typography, Ltd's "Garamond" and the italicized version of same.

When I originally tried a direct conversion, Calibre would only add the first noted font. In order to convince Calibre to import all the three .ttf files into the .epub, I placed each within its own style element in the XHTML - and I also gave "UpperWestSide" an oblique style, since there were certain places I had artificially italicized the font within the text, although I linked it to the same font file - as follows:

Code:
<style type="text/css">
                @font-face { font-family: UpperWestSide; font-style: oblique; font-weight: normal; src: url(UpperWestSide.ttf); }
</style>

<style type="text/css">
                @font-face { font-family: UpperWestSide; font-style: normal; font-weight: normal; src: url(UpperWestSide.ttf); }
</style>

<style type="text/css">
                @font-face { font-family: Garamond; font-style: normal; font-weight: normal; src: url(gara.ttf); }
</style>

<style type="text/css">
                @font-face { font-family: Garamond; font-style: oblique; font-weight: normal; src: url(garait.ttf); }
</style>
I then placed UpperWestSide.ttf, gara.ttf and garait.ttf in the same directory as the XHTML file, and loaded it into Calibre and converted to .epub.

Next I opened the .epub file as if it were a .zip (no need to rename, just open it in whatever utility you would use to view the contents of any other .zip). Browsing the directory structure I saw that all three .ttf fonts were located in "content\resources," but when I checked the relative path structure in (name)_0.css I discovered that the font links were erroneously pointing to a recursive "resources" directory, as follows:

Code:
@font-face {
    font-family: UpperWestSide;
    font-style: oblique;
    font-weight: normal;
    src: url(resources/UpperWestSide_0_0.ttf)
    }
@font-face {
    font-family: UpperWestSide;
    font-style: normal;
    font-weight: normal;
    src: url(resources/UpperWestSide_0_0.ttf)
    }
@font-face {
    font-family: Garamond;
    font-style: normal;
    font-weight: normal;
    src: url(resources/gara_1_1.ttf)
    }
@font-face {
    font-family: Garamond;
    font-style: oblique;
    font-weight: normal;
    src: url(resources/garait_2_2.ttf)
    }
So I stripped out the "resources/" notation and saved it back into the .epub, such that the .css content now appeared like this:

Code:
@font-face {
    font-family: UpperWestSide;
    font-style: oblique;
    font-weight: normal;
    src: url(UpperWestSide_0_0.ttf)
    }
@font-face {
    font-family: UpperWestSide;
    font-style: normal;
    font-weight: normal;
    src: url(UpperWestSide_0_0.ttf)
    }
@font-face {
    font-family: Garamond;
    font-style: normal;
    font-weight: normal;
    src: url(gara_1_1.ttf)
    }
@font-face {
    font-family: Garamond;
    font-style: oblique;
    font-weight: normal;
    src: url(garait_2_2.ttf)
    }
... all of which is technically violating the .epub spec, but appears to work.

- M.
Vintage Season is offline   Reply With Quote