View Single Post
Old 10-21-2017, 06:33 AM   #1
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
To create a subset

Hi

One of the drawbacks of the embedded fonts are their size. Sometimes, for example when you are dealing with a large Chinese font (15 MB), and when you can't even create a proper subset. This is why I am evaluating this technique, following the advice of a friend.

Let me describe how to do it:

First, if you do not have it yet,
Code:
sudo pip install fonttools
Then, prepare a work folder. We'll find here
- the ttf font exported from the EPUB, say STSong.ttf
- a UTF-8 txt file named china.txt containing the Chinese characters you wish to include in the subset. These characters can easily be copied for example from the last line of the Characters tab of the Calibre Editor reports tool.

To create the subset, just use this command

Code:
pyftsubset STSong.ttf --text-file="china.txt"
It will create a subsetted font "STSong.subset.ttf" (12.9 k) with which you can replace the original one.

This way of creating a subset seems quite useful, for example if you have a book containing some words or expressions in some exotic language.

You can also use it for standard books. I subsetted this way the regular font of Linux Libertine (800k) embedded in an EPUB with 120 different characters in a 58k subset.

I could have followed creating subsets for the italic and bold fonts using the same 120 characters txt file. I just wonder how to reduce this figure to the real number of italic or bold characters used in the book. Somebody has an idea?

Last edited by roger64; 10-21-2017 at 06:39 AM.
roger64 is offline   Reply With Quote