![]() |
[Plugin] SubsetFonts - Simple font subsetter
1 Attachment(s)
Last update: January 5, 2021
Current Version: "0.2.4" This plugin is a simple fontTools wrapper, which'll subset all fonts in an epub. Please note that the plugin will delete the original fonts and replace them with the subset fonts. Make sure to create a backup copy before running this plugin! Credits: The plugin uses Alberto Pettarin's glyphIgo library to calculate the number of uninque characters in the book and the fontTools library to do the actual subsetting. The plugin icon (for Sigil 0.9.9.1 and higher) was created by BeckyEbook. System requirements: This plugin requires Sigil 0.9.5 or higher. If you're using an external Python interpreter, you'll also need to install the fontTools Python library. Installation: 1. Select Manage Plugins from the Plugins menu and select Use Bundled Python, if it isn't already selected. 2. Click Add Plugin and select SubsetFonts_v0.2.4.zip. This will install the SubsetFonts plugin, which you can select via Plugins > Edit > SubsetFonts. Troubleshooting: By default, the plugin will check the fontTools PyPi website for updates and automatically update the fontTools package bundled with the plugin. If the update check causes problems on your machine or if you'd rather update the embedded fontTools library yourself, change the following setting in SubsetFonts.json: Code:
"update_check": false,(Linux users may need to manually update the installed fontTool package with pip.) License: GNU General Public License v3 (GPL-3) |
:thumbsup:
Thanks for making these two efficient tools so easily available!! I allowed myself to add some commentaries on the "Workshop" forum to signal that research is still on its way. |
Very nice. Works better at subsetting than anything I had used before. Thank you.
|
I got curious about font subsetting, which I usually don't do, because I usually don't embed fonts in the first place.
I got the following error(s): Spoiler:
I'm running linux, Kubuntu 16.04.3, Sigil 0.9.9 compiled from source, Qt 5.6.1. I believe I have all the needed python modules installed. Running pyftsubset from the command line, using the above character string supplied in a file, runs successfully. I must be missing something. Probably something obvious. Albert |
Quote:
Can you please zip up your version of DejaVuSans and attach it to your post? (My DejaVuSans version has a different file size.) |
1 Attachment(s)
Quote:
|
Quote:
Spoiler:
Try the following: change line #51 in plugin.py from: Code:
text += BeautifulSoup(html).textCode:
text += BeautifulSoup(html,'html.parser').textIIRC, you also have a Windows machine. Please try to subset the same file on your Windows machine. This will use a Python library instead of the pyftsubset command line tool and you'll hopefully get a meaningful error message. I'll look into this in more detail either tomorrow or on Monday. |
Thanks. Will do, probably tomorrow.
Albert |
After making the suggested change in plugin.py and changing permissions on DejaVuSans.ttf to 666 (was 664) I still get the file not found error...
Spoiler:
but checking the temporary files, Code:
$ ls -la /tmp/Sigil-2PHn8A/OEBPS/Fontsso at line 88 in plugin.py I changed: Code:
subset_font_path = original_font_path.replace(ext, '.subset' + ext)Code:
subset_font_path = original_font_path.replace(ext, ext + '.subset')]Code:
Status: successFor comparison, subsetting with Calibre's epub editor gave ~111.5 kB and with no fonts embedded, it was 38.6 kB Thanks for the pointers, without which I probably wouldn't have known where to begin. Albert |
Quote:
I'll have to run some more tests tomorrow to figure out why the original code didn't work for you but worked fine on my Arch Linux and Elementary OS machines. Maybe your pyftsubset version was compiled differently or, more likely, on my Linux machines the embedded Python library was used instead of the command line tool. Either way I'll post a new version on Monday. |
FYI:
$ apt-cache policy fonttools fonttools: Installed: 3.0-1 Candidate: 3.0-1 Version table: *** 3.0-1 500 500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages 500 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages 100 /var/lib/dpkg/status Should have mentioned this earlier. |
@st_albert: Apparently the fontTools developers changed the default subset font file naming scheme in fontTools version 3.21.2, which I used for testing.
The fontTools 3.0.1 Debian package provided by Ubuntu uses DejaVuSans.ttf.subset, however, the latest fontTools 3.21.2 version (installed via pip3) uses DejaVuSans.subset.ttf. I've updated the plugin code to also look for subset font files with the older naming scheme. BTW, since the Ubuntu fontTools package is totally outdated, you might want to consider uninstalling it and installing the latest fontTools version via pip/pip3. |
Quote:
Thanks again! Albert. |
I've attached a new version with the latest fontTools version (3.25.0) to the first post. The new version will also check the fontTools GitHub website for updates and automatically update the bundled fontTools library.
|
The plugin does not work. From 7 days there is a new version of fonttools 3.32.0 but there is no * whl file
Doitsu, can you help it? Thanks you for the plugin, it is very useful for me. bravosx |
| All times are GMT -4. The time now is 06:50 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.