10-24-2017, 12:40 PM | #1 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Darkening and subsetting fonts
Hi
Here are the results of some trials. To begin, you'll find four (there are more of them) otf fonts of the Linux Libertine O family. Please note that these fonts are published under the GPL license, and that the further modified and renamed fonts below share of course the same license. They are in the folder: "A original fonts". These fonts have been darkened using the nice script of Sherman Perry, ReadifyFont. Quote:
These darkened fonts have been subsetted with pyftsubset (a part of the fonttools project) against the list of characters named characters330 which contains the 110 unicode characters of the joint EPUB (the list is produced by the reports tool of the Calibre Editor). The subsets are in the folder: "C subsets." I also joined the test EPUB with its subsetted -and darkened- fonts. It passes the epubcheck validation test. About size This way one can embed subsets of any font, including a customized one. Here the regular subset size used for the EPUB is about 44k, and the italic one, 37k (from a common 110 characters list). As we make it work currently with a single list of characters, pyftsubset can provide a clear size saving advantage if the book use only both regular and italic fonts. This advantage could be greatly reduced, even nullified, if we had to include bold and bolditalics fonts. Last edited by roger64; 10-31-2017 at 03:26 AM. Reason: size saving |
|
10-25-2017, 12:42 AM | #2 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
This is how I did it even if there can be other ways. I used these scripts with Archlinux, but they can work on many other operating systems as long as you have a recent version of Fontforge and Python (and python-pip for Arch).
About pyftsubset I failed to see who are its five authors and its maintainer. Anyway many thanks to them. Here is some more information about its use. If I understand correctly, by default, it says that it preserves ligatures. As you can read in the attachment, it's quite an advanced tool. First, if you do not have it yet, Code:
sudo pip install fonttools - the ttf font (exported from the EPUB or downloaded from elsewhere), for example STSong.ttf - a UTF-8 txt file named for example china.txt containing the characters (here Chinese) 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 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. About ReadifyFont Many thanks to Sherman Perry. Note that the GUI has been made clearer. You will find it here: I used the GUI provided with the script. I could darken and generate ttf for a family of four fonts. The GUI was started with this command. Code:
fontforge -script ReadifyFontGUI.py Quote:
Last edited by roger64; 10-29-2017 at 03:55 PM. |
|
10-28-2017, 06:33 AM | #3 |
Guru
Posts: 856
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
I must admit that I haven't exactly kept my little GUI up to date
The "latest" version can be found here: https://github.com/shermp/ReadifyFon...ceImprovements Goodness knows how well it works. The FontForge folks seem to change/add to the python api as it suits them, and don't exactly keep the documentation up to date (at least it seems that way). They also can't seem to decide whether they want to use Python 2 or 3, which is even more annoying. Fonttools would be great to use, but as roger64 noted, it is a very advanced tool, however documentation on how to use the thing is.... sparse. Note with my tool, that it seems to have real trouble with the internal font naming for a lot of fonts, and I don't know why. |
10-29-2017, 04:41 AM | #4 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
@sherman
Thanks for the link to the new revamped interface. Using Arch I still face the following glitch: even if the four squares (for normal, italic, etc.) are displayed, I can load only one font on the top line. If I try to load a second one, it only erases the first one and takes its place. If I judge from other calibre-debug comments, these troubles may be related to some missing gtk library (?). Code:
[roger@anterg ReadifyFont-InterfaceImprovements]$ calibre-debug ReadifyFontGUI.py QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries. QCommonStyle::drawComplexControl: Control 1 not handled QCommonStyle::drawComplexControl: Control 1 not handled QCommonStyle::drawComplexControl: Control 1 not handled QCommonStyle::drawComplexControl: Control 1 not handled |
10-29-2017, 05:54 AM | #5 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Why are you subsetting in a rather difficult way? Calibre makes subsetting trivial. Also, Linux Libertine is not a nice font.
|
10-29-2017, 06:27 AM | #6 |
Unicycle Daredevil
Posts: 13,923
Karma: 185041098
Join Date: Jan 2011
Location: Planet of the Pudding Brains
Device: Aura HD (R.I.P. After six years the USB socket died.) tolino shine 3
|
|
10-29-2017, 07:09 AM | #7 | |
Guru
Posts: 856
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
Also note that to add multiple font files, you have to add them at the same time (the file chooser dialog allows multiple selection). The current system is designed that if you click the load button again, it assumes you want to load a a new font family. Last edited by sherman; 10-29-2017 at 07:14 AM. |
|
10-29-2017, 07:34 AM | #8 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I would like to know why is anyone recommending using scripts and complicated ways to subset fonts when Calibre does it so easily?
|
10-29-2017, 01:29 PM | #9 |
A Hairy Wizard
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Perhaps they don't wish to use Calibre and are developing their own method??? That is a common practice among software developers.
|
10-29-2017, 01:31 PM | #10 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
10-29-2017, 01:37 PM | #11 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
|
10-29-2017, 02:24 PM | #12 |
Grand Sorcerer
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
It's not a square wheel if the only method involves much more software than you are interested in (install calibre only for subsettings fonts is like using a sledgehammer to crack a nut).
|
10-29-2017, 02:49 PM | #13 | ||
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
Quote:
So yes, it does seem to be inventing a square wheel. |
||
10-29-2017, 03:49 PM | #14 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
I edited the first two posts to include your comments about your new GUI and about selecting a family of four fonts. Last edited by roger64; 10-29-2017 at 04:01 PM. Reason: comments |
|
10-29-2017, 05:10 PM | #15 |
null operator (he/him)
Posts: 20,568
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with font subsetting | grumbles | Editor | 17 | 06-20-2014 02:35 PM |
Font subsetting problem | yktan | Calibre | 5 | 09-19-2013 11:00 PM |
Bug in font subsetting | JSWolf | Calibre | 9 | 01-17-2013 09:46 AM |
ePub Font Subsetting | Cygfrydd | ePub | 2 | 08-17-2010 08:53 AM |
Screen darkening over minutes | Gogolo | iRex | 14 | 11-27-2007 04:37 PM |