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

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-22-2008, 01:12 PM   #1
Acey
Member
Acey began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2008
Device: Sony PRS-505
Question Embedding fonts in EPUB?

I'm creating some EPUB files using html2epub. Is it possible to embed a font to be used? If so, how? Thanks in advance...
Acey is offline   Reply With Quote
Old 10-22-2008, 01:57 PM   #2
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: 25,243
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Not yet...
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 10-22-2008, 03:00 PM   #3
wallcraft
reader
wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.wallcraft ought to be getting tired of karma fortunes by now.
 
wallcraft's Avatar
 
Posts: 6,979
Karma: 5183568
Join Date: Mar 2006
Location: Mississippi, USA
Device: Kindle 3 and Fire
If you are targeting your own PRS-505, an alternative might be ePub with external font. Referencing an external font is less practical for wide distribution, although an embedded font is replicated in every ePub that uses it (a huge waste of resources).
wallcraft is offline   Reply With Quote
Old 10-22-2008, 03:20 PM   #4
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: 25,243
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
embedding an external font is pretty simple with the --override-css option.
kovidgoyal is offline   Reply With Quote
Old 10-23-2008, 03:24 PM   #5
radius
Lector minore
radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.
 
radius's Avatar
 
Posts: 335
Karma: 128734
Join Date: Jan 2008
Device: Sony PRS-T3, Amazon Kindle PaperWhite 2, Sony PRS-505
Quote:
Originally Posted by kovidgoyal View Post
embedding an external font is pretty simple with the --override-css option.
Do you have an example line? Or even better, a screenshot?
radius is offline   Reply With Quote
Old 10-23-2008, 03:42 PM   #6
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: 25,243
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
--override-css "@font-face {font-family: "f1";src:url(res:///Data/FONT/tt0003m_.ttf);}\n\nbody {font-family: f1}"
This assumes that a font file /Data/FONT/tt0003m_.ttf exists on the device.
kovidgoyal is offline   Reply With Quote
Old 10-29-2008, 04:09 PM   #7
radius
Lector minore
radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.
 
radius's Avatar
 
Posts: 335
Karma: 128734
Join Date: Jan 2008
Device: Sony PRS-T3, Amazon Kindle PaperWhite 2, Sony PRS-505
Excellent; thank you!
radius is offline   Reply With Quote
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: 329
Karma: 1400001
Join Date: Jan 2009
Device: nook STR/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
Old 02-03-2009, 04:15 PM   #9
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: 329
Karma: 1400001
Join Date: Jan 2009
Device: nook STR/iPad Air
Quote:
Originally Posted by Vintage Season View Post
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...

... all of which is technically violating the .epub spec, but appears to work.

- M.
Responding to my own suggestion from a few days ago, I finally realized I could simply copy an .epub file to and SD card and test for myself in-store. Much to my disappointment I learned that, although the PRS-505 I tested did successfully recognize and read the .epub, it did not recognize the fonts (probably because they were not extracted from the archive), nor did it honor the full justification I'd specified. Drop-caps worked fine, but that's a small consolation.

- M.
Vintage Season is offline   Reply With Quote
Old 02-26-2009, 11:07 PM   #10
Cygfrydd
Jackass Crazyfish
Cygfrydd began at the beginning.
 
Cygfrydd's Avatar
 
Posts: 7
Karma: 10
Join Date: Jan 2007
Location: St. Petersburg, Florida, US
Device: Sony Reader PRS-505
Quote:
Originally Posted by Vintage Season View Post
Responding to my own suggestion from a few days ago, I finally realized I could simply copy an .epub file to and SD card and test for myself in-store. Much to my disappointment I learned that, although the PRS-505 I tested did successfully recognize and read the .epub, it did not recognize the fonts (probably because they were not extracted from the archive), nor did it honor the full justification I'd specified. Drop-caps worked fine, but that's a small consolation.

- M.
Sadly, full justification doesn't work at all in ePubs on the Sony (yet?), though it's working as of the latest version of desktop ADE. Ragged-right vs. full-justification seems to be a bit of a hot topic, to boot.

— @yg

-=<>=-=<>=-=<>=-=<>=-=<>=-=<>=-=<>=-
Cygfrydd Llewellyn | cygfrydd@gmail.com
-=<>=-=<>=-=<>=-=<>=-=<>=-=<>=-=<>=-

“Worlds only harmonica-playing dog. Tuppence.”
— Gaspode the wonder dog
(Terry Pratchett, Moving Pictures)
Cygfrydd is offline   Reply With Quote
Old 04-20-2010, 02:26 AM   #11
vietchovui
Connoisseur
vietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enough
 
Posts: 86
Karma: 556
Join Date: Nov 2009
Location: SaiGon VietNam
Device: PRS T1
Quote:
Originally Posted by kovidgoyal View Post
Code:
--override-css "@font-face {font-family: "f1";src:url(res:///Data/FONT/tt0003m_.ttf);}\n\nbody {font-family: f1}"
This assumes that a font file /Data/FONT/tt0003m_.ttf exists on the device.
where to put this code? more details please!
vietchovui is offline   Reply With Quote
Old 07-24-2010, 09:23 PM   #12
mikij
Connoisseur
mikij doesn't littermikij doesn't litter
 
Posts: 98
Karma: 161
Join Date: May 2010
Location: Quebec, Canada
Device: PRS-600
Exclamation

Quote:
Originally Posted by vietchovui View Post
where to put this code? more details please!
I am also quite new to Calibre. Is there kind of command line or what in the application where I could execute this code?
mikij is offline   Reply With Quote
Old 07-24-2010, 10:50 PM   #13
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: 25,243
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Put it in the extra css box in conversion settings under look & Feel
kovidgoyal is offline   Reply With Quote
Old 07-25-2010, 11:11 AM   #14
mikij
Connoisseur
mikij doesn't littermikij doesn't litter
 
Posts: 98
Karma: 161
Join Date: May 2010
Location: Quebec, Canada
Device: PRS-600
Quote:
Originally Posted by kovidgoyal View Post
Put it in the extra css box in conversion settings under look & Feel
mikij is offline   Reply With Quote
Old 11-02-2011, 11:12 PM   #15
vietchovui
Connoisseur
vietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enoughvietchovui will become famous soon enough
 
Posts: 86
Karma: 556
Join Date: Nov 2009
Location: SaiGon VietNam
Device: PRS T1
I have problem with my new PRS T1. I do convert in the same way that I used to do with my PRS 650:
- Add extrac css as below:
@font-face {
font-family: "Gentium Book";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/GenBkBasR.ttf);
}

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

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

@font-face {
font-family: "Gentium Book";
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/GenBkBasBI.ttf);
}

body {
font-family: "Gentium Book", serif;
}

- Copy all gentium font files to fonts folder in root directory of the reader.
But PRS T1 still cannot display correctly Vietnamese characters. (PRS 650 display well)
vietchovui is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedding fonts JaneFancher Calibre 14 04-10-2010 09:28 PM
Embedding fonts AprilHare ePub 6 01-02-2010 11:42 AM
Embedding fonts into PDFs lordsilent PDF 2 03-20-2009 05:51 AM
Embedding Fonts with Indesign...... brewt ePub 6 01-01-2009 10:07 PM
Embedding fonts jash Calibre 2 09-09-2008 05:05 PM


All times are GMT -4. The time now is 08:23 PM.


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