10-10-2012, 08:22 AM | #16 |
The Grand Mouse 高貴的老鼠
Posts: 71,428
Karma: 305784726
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
I've found a Perl-based TTF font subsetter here: https://bitbucket.org/philip/font-optimizer/overview (MIT license)
there seems to be some C++ source here: http://podofo.sourceforge.net/doc/ht...TTFSubset.html (LGPL) Another Perl one here: http://search.cpan.org/~mhosken/Font-TTF-Scripts/ (Perl Artistic license 2.0) A php one here: http://www.4real.gr/technical-documents-ttf-subset.html Aha! A python one under active development as part of a PDF generation project: http://code.google.com/p/pyfpdf/ (LGPL) I do not know if any of the projects also work on otf fonts. matplotlib is another python project that seems to include font subsetting: https://github.com/matplotlib/matplotlib (an attribution licence) |
10-10-2012, 08:24 AM | #17 |
The Grand Mouse 高貴的老鼠
Posts: 71,428
Karma: 305784726
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
10-10-2012, 08:35 AM | #18 |
frumious Bandersnatch
Posts: 7,514
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
I wonder how those subsetters work with ligatures and glyph variants...
|
10-10-2012, 08:42 AM | #19 |
The Grand Mouse 高貴的老鼠
Posts: 71,428
Karma: 305784726
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
10-10-2012, 01:21 PM | #20 |
Resident Curmudgeon
Posts: 73,677
Karma: 128176798
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Not a good solution as Fontforge is Linux and to get it to run on Windows, Cygwin has to be installed and Python has to be installed under Cygwin. That's a very poor solution for Windows users. We need a more universal solution.
|
10-10-2012, 02:17 PM | #21 | |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
You may want to do your own research every now and then. |
|
10-10-2012, 02:39 PM | #22 |
The Grand Mouse 高貴的老鼠
Posts: 71,428
Karma: 305784726
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Working on way to subset fonts for ePub/KF3
In a couple of other threads, the idea has come up that it would be very useful to have a tool that could subset the fonts embedded in ePub and/or KF8 books, as that would both reduce the file sizes and make more fonts available, as some font licences require subsetting to permit embedding.
I have moved the posts from the main other thread over here. |
10-10-2012, 02:49 PM | #23 |
The Grand Mouse 高貴的老鼠
Posts: 71,428
Karma: 305784726
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Someone raised the question of ligatures and alternate characters. As I said, these are very good questions, as the creator of the ePub has no control over the glyph choice of the display software.
In PDFs, the subsetting task is a lot simpler, as all the glyphs used (not just characters) are fixed in the PDF. For ePubs and KF8, I think we must take this into account in any solution. But this doesn't need to be part of the font subsetting code, which should work from a passed list of glyphs that should be included. (And should return an error if any are missing from the font.) For ligatures we might need to generate not only a list of all characters in a file, but also of all character pairs. But, of course, there are also three character ligatures (ffi in English, for examples) and I suppose some languages might have more. Hmmm... Perhaps we just need to include all ligatures for which the source file includes all the characters in the ligature. Or perhaps we also need a script to get information on ligatures present in a font, so that that information can be used when parsing the XHTML. Or should we start off with a very basic solution, and elaborate once that's working? |
10-11-2012, 04:19 AM | #24 |
frumious Bandersnatch
Posts: 7,514
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
10-11-2012, 05:11 AM | #25 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
The C++ class can also work with otf files according to the site. Unfortunately I cannot program in C++...
|
10-11-2012, 12:13 PM | #26 | |
Resident Curmudgeon
Posts: 73,677
Karma: 128176798
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
10-11-2012, 02:55 PM | #27 |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Unfortunately, the MinGW based FontForge Windows binary installer doesn't seem to install the fontforge Python module, but theoretically it should be possible to use Python scripts to control FontForge.
|
10-11-2012, 02:57 PM | #28 |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
The windows binary of FontForge has more drawbacks. It crashes often.
|
10-14-2012, 03:29 PM | #29 |
Grand Sorcerer
Posts: 27,478
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Because I have much more time than sense, I've done some more work on the script that counts/collects the characters used in files.
Building on the core that Man Eating Duck posted, this script will work for a single ePub, (x)html, or text file. In addition to filtering all of the html code/attributes from the results, it will also convert entities (named or otherwise) to their rendered equivalents. It also has the ability to limit the results to a single specified CSS class (handy for determining the font-subset required for headings or drop-caps). Python will almost always have issues printing certain unicode characters to the console on Windows OSs, so Windows users should consider just writing the results to a file and then viewing that file with an editor that supports the required character encoding. Should work with Python 2.5 - 2.7 (maybe even earlier). A test xhtml file is included for testing/benchmarking purposes. Spoiler:
Last edited by DiapDealer; 10-14-2012 at 03:31 PM. |
10-14-2012, 05:44 PM | #30 |
Resident Curmudgeon
Posts: 73,677
Karma: 128176798
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
But is there a way of taking a TTF or OTF font file and subsetting it that works on Windows, OS X, & Linux without the need for Cygwin?
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
group an ARBITRARY subset of records | RotAnal | Library Management | 6 | 10-09-2012 11:53 AM |
Working with Fonts and Calibre | kiwidude | Development | 8 | 03-04-2011 07:49 PM |
Fonts not working in a converted book | snape | Sony Reader | 9 | 11-08-2010 11:46 PM |
Changing fonts not working? | tselling | Astak EZReader | 11 | 09-21-2009 03:03 PM |
Why are some fonts not working?? | daviddem | HanLin eBook | 4 | 01-22-2009 09:14 AM |