View Single Post
Old 02-11-2018, 12:26 PM   #9
st_albert
Guru
st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'
 
Posts: 698
Karma: 150000
Join Date: Feb 2010
Device: none
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:
Code:
Status: failed

Using external Python interpreter.

fontTools version: 3.21.2 

Characters used in this epub:

 !"#$%'()*,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXY[]abcdefghijklmnopqrstuvwxyz —

Processing font:  DejaVuSans.ttf...
Original file size:  756072
Traceback (most recent call last):
  File "/usr/local/share/sigil/plugin_launchers/python/launcher.py", line 135, in launch
    self.exitcode = target_script.run(container)
  File "/home/u838190/.local/share/sigil-ebook/sigil/plugins/SubsetFonts/plugin.py", line 89, in run
    subset_font_size = os.path.getsize(subset_font_path)
  File "/usr/lib/python3.5/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/Sigil-2PHn8A/OEBPS/Fonts/DejaVuSans.subset.ttf'
Error: [Errno 2] No such file or directory: '/tmp/Sigil-2PHn8A/OEBPS/Fonts/DejaVuSans.subset.ttf'


but checking the temporary files,
Code:
$ ls -la /tmp/Sigil-2PHn8A/OEBPS/Fonts
total 772
drwxrwxr-x 2 u838190 u838190   4096 Feb 11 11:41 .
drwxrwxr-x 9 u838190 u838190   4096 Feb 11 11:37 ..
-rw-rw-rw- 1 u838190 u838190 756072 Feb 11 11:38 DejaVuSans.ttf
-rw-rw-r-- 1 u838190 u838190  21652 Feb 11 11:41 DejaVuSans.ttf.subset
so evidently pyftsubset was able to write the subsetted font to the disk, using its default naming.

so at line 88 in plugin.py I changed:
Code:
subset_font_path = original_font_path.replace(ext, '.subset' + ext)
to:
Code:
subset_font_path = original_font_path.replace(ext, ext + '.subset')]
and lo and behold,
Code:
Status: success

Using external Python interpreter.

fontTools version: 3.21.2 

Characters used in this epub:

 !"#$%'()*,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXY[]abcdefghijklmnopqrstuvwxyz —

Processing font:  DejaVuSans.ttf...
Original file size:  756072
Subset file size:  21652 (2.86%)
Original font replaced with subset font.

Click OK to close.
The epub size was reduced from ~408 kB before subsetting to ~52.4 kB afterwards.
For 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

Last edited by st_albert; 02-11-2018 at 12:29 PM.
st_albert is offline   Reply With Quote