12-28-2019, 04:41 AM | #1 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
bk.font_iter() is listing no fonts
Hi,
what am i doing wrong? Code:
def run(bk): print('xxx-|Start|-xxx') for (id, href, mime) in bk.font_iter(): print('xxx-|',id , '|-xxx') print('xxx-|',href , '|-xxx') print('xxx-|',mime , '|-xxx') print('xxx-|End|-xxx') return 0 mac os mojave, sigil 1.0.0 The fonts i have in the book are valid as they do show up in preview, in ADE and on my devices. Regardless of what fonts i'm adding the list is always empty |
12-28-2019, 07:10 AM | #2 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
bk.font_iter() might fail, if the fonts don't have the proper mime type.
Please post the font manifest section of your test epub. For example, Code:
<item id="LinLibertineG30-Regular.ttf" href="LinLibertineG30-Regular.ttf" media-type="application/vnd.ms-opentype"/> Code:
def run(bk): print('xxx-|Start|-xxx') for id, href, mime in bk.manifest_iter(): if href.endswith('tf'): print('xxx-|',id , '|-xxx') print('xxx-|',href , '|-xxx') print('xxx-|',mime , '|-xxx') print('xxx-|End|-xxx') |
12-28-2019, 07:42 AM | #3 |
Banned
Posts: 168
Karma: 10010
Join Date: Oct 2018
Device: Tolino/PRS 650/Tablet
|
Hi,
i added the file with sigil and the original item looks like this Code:
<item id="SourceCodePro-Regular.otf" href="Fonts/SourceCodePro-Regular.otf" media-type="font/otf"/> Code:
<item id="SourceCodePro-Regular.otf" href="Fonts/SourceCodePro-Regular.otf" media-type="application/vnd.ms-opentype"/> So is this a bug in sigil not choosing the right mimetype? As i said, i added the fontfile with sigil. |
12-28-2019, 09:27 AM | #4 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
According to the IANA, the following font mime types can be used:
otf font/otf sfnt font/sfnt ttf font/ttf woff font/woff woff2 font/woff2 According to the epub3 specs, the following mime types are also acceptable: ttf application/font-sfnt otf application/vnd.ms-opentype woff application/font-woff I.e., font/otf is definitely a valid mime type. Maybe bk.font_iter() needs to be updated. |
12-28-2019, 09:47 AM | #5 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Yes, this is a bug as I updated the media-types based on the latest iana spec which icludes the new font/* style recommended media types:
Here is the updated list of recognized font media types: Code:
'font/woff2' : 'Fonts', 'font/woff' : 'Fonts', 'font/ttf' : 'Fonts', 'font/otf' : 'Fonts', 'font/sfnt' : 'Fonts', 'font/collection' : 'Fonts', 'application/vnd.ms-opentype' : 'Fonts', 'application/font-sfnt' : 'Fonts', # deprecated 'application/font-ttf' : 'Fonts', # deprecated 'application/font-otf' : 'Fonts', # deprecated 'application/font-woff' : 'Fonts', # deprecated 'application/font-woff2' : 'Fonts', # deprecated 'application/x-font-ttf' : 'Fonts', # deprecated 'application/x-truetype-font' : 'Fonts', # deprecated 'application/x-opentype-font' : 'Fonts', # deprecated 'application/x-font-ttf' : 'Fonts', # deprecated 'application/x-font-otf' : 'Fonts', # deprecated 'application/x-font-opentype' : 'Fonts', # deprecated 'application/x-font-truetype' : 'Fonts', # deprecated 'application/x-font-truetype-collection' : 'Fonts', # deprecated Code:
def font_iter(self): # yields manifest id, href, and mimetype for id in sorted(self._w.id_to_mime): mime = self._w.id_to_mime[id] if mime.find('font-') > -1 or mime.endswith('-ttf') or mime.endswith('truetype') or mime.endswith('opentype'): href = self._w.id_to_href[id] yield id, href, mime Kevin I will push a fix for this to master today. Kevin |
12-28-2019, 03:42 PM | #6 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
This should now be fixed in master.
Thanks for your bug report. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Listing? | historybuff3737 | Library Management | 2 | 12-24-2017 04:30 AM |
Touch Double listing.... | kevenv | Kobo Reader | 2 | 01-26-2013 06:15 AM |
How to add alternate fonts without replacing system fonts.(this time this is a guide) | techiemonkey | Kindle Developer's Corner | 17 | 09-12-2012 04:55 PM |
Author listing ? | carpetmojo | Sony Reader | 1 | 02-20-2011 07:00 PM |
Need help with library listing | geko | Calibre | 2 | 06-29-2010 03:10 PM |