View Single Post
Old 11-04-2011, 12:52 PM   #11
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by vietchovui View Post
Besides, I don't know exactly what you mean by "fully embedded". I'll do some google search to find it out. Thanks again.
This post tries to explain 3 different methods of customising epub fonts.

Fully embedded fonts are described in Method 1 in the post. This is is only way (so far) which works on the PRST1. I have attached a fully embedded version of your test epub below. It reads fine on my PRST1.

What you have in your test epub is an example of Method 3 in the post. All 3 methods work in older Sony models PRS505, PRS300/600 and PRSx50.

Calibre does not currently have a simple way of automatically fully embedding epub fonts. You can use the Calibre Tweak Epub feature to do it manually. How easy you will find it depends on how comfortable you are manually tweaking epubs. The following is not the 'One True Way' but it works. These are the steps:
  1. Use Tweak Epub to explode the epub.
  2. Find the directory containing the .css file and create a new subdir called fonts copy the 4 GentiumBook .ttf font files into this new subdir.
  3. Open the .css file in your favourite text editor and add 4 @font-face statements. These will be similar, but not the same, as the ones you used to put in Calibre's ExtraCSS box.
    Old:
    Code:
    @font-face {
        font-family: "Gentium Book";
        font-weight: normal;
        font-style: normal;
        src: url(res:///Data/fonts/GenBkBasR.ttf)
        }
    New:
    Code:
    @font-face {
        font-family: serif;
        font-weight: normal;
        font-style: normal;
        src: url(fonts/GenBkBasR.ttf)
        }
    Do the same for the other 3 @font-face statements.
    Anywhere in the .css file where you have
    Code:
    font-family: "Gentium Book", serif;
    can either be replaced with
    Code:
    font-family: serif;
    or removed altogether if you prefer, because serif is the default font used by your reader.
  4. Edit the .opf file in the exploded epub and manually add the 4 font files to the <manifest> section. In theory, this step is necessary if you want to make sure you have a compliant epub. In practice, I think not doing it makes no difference to whether the epub will read correctly on your PRST1. Make your own mind up This is an example of the 4 lines I added in your test epub:
    Code:
    <manifest>
        ... lots of file paths ...
        <item href="fonts/GenBkBasR.ttf" id="serifr" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasI.ttf" id="serifi" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasB.ttf" id="serifb" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasBI.ttf" id="serifbi" media-type="application/x-truetype-font"/>
    </manifest>
    If you do add them, the href attribute needs to be the path of the .ttf file relative to the .opf file inside the epub. If this sounds like technical gobbledegook... well I'm not sure how else to explain it
  5. Save and close all edited files and Rebuild the epub using the Rebuild button.

Caveats:
  • It is not a good idea to do a Calibre conversion on an epub after you have fully embedded fonts. Sometimes the fonts no longer work afterwards.
  • If you try to fully embed fonts in an epub where you have previously added @font-face statements during a Calibre conversion using the ExtraCSS box then the fonts may not work on the reader. The conversion process will have placed all the @font-faces in each and every (x)html file inside the epub rather than in the .css file. These may well override the ones you just manually added to the .css file. If you have this problem, manually removing the @font-faces from the html files should correct the problem.
  • I don't use it myself, but it's possible that Sigil makes it easier to do all of the above.
Attached Files
File Type: epub Luat dat dai 2003 - embedded - Song Khanh.epub (459.4 KB, 734 views)
jackie_w is offline   Reply With Quote