05-13-2015, 01:01 PM | #16 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Sigil is doing that correct. But there are a lot of converters or other programs doing it not correct.
Doitso: thx but this is only working for octet-stream, there are some other media-types out there. @Diap: yes, thats what i'm looking for. But to achieve this i need to know how Sigil is doinf that to do it the same way. Now i need to have a look in the Sigil-Python-API to find out what is available to achieve this. Getting the fonts is easy, i've done that creating the Stylesheet. But now i need the way back Edit: just read the API documentation and as far as i can see there is no method to write something to the manifest. Last edited by rubeus; 05-13-2015 at 01:23 PM. |
05-13-2015, 02:06 PM | #17 | |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
Quote:
In a plugin, you can walk all of the fonts (or even all of the files in the manifest) using the api and then add new files for any with the wrong media-type and then remove the incorrect ones. So, yes this is easily doable via a plugin. If you want more information about how to understand the plugin api, just ask in the Sigil plugin developers thread so that any answers can be kept in one place to help future plugin developers. KevinH |
|
Advert | |
|
05-14-2015, 03:46 AM | #18 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Code:
#!/usr/bin/env python # -*- coding: utf-8 -*- import os def run(bk): # read manifest items for id in sorted(bk._w.id_to_mime): mime = bk._w.id_to_mime[id] href = bk._w.id_to_href[id] # check for invalid MIME types if href.endswith('tf') and mime not in ('application/x-font-ttf', 'application/vnd.ms-opentype') : data = bk.readfile(id) bk.deletefile(id) if href.endswith('ttf'): bk.addfile(id, os.path.basename(href), data, 'application/x-font-ttf') else: bk.addfile(id, os.path.basename(href), data, 'application/vnd.ms-opentype') print 'MIME type updated: ' + os.path.basename(href) def main(): print 'I reached main when I should not have\n' return -1 if __name__ == "__main__": sys.exit(main()) |
|
05-14-2015, 05:14 AM | #19 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Hi doitso
thats exactly what i'm currently testing, i'm only using the font iterator. Is there a way to get the sigil version in a plugin? But maybe we should really move this to plugin develop forum. |
05-14-2015, 05:34 AM | #20 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
For all intents and purposes my code pretty much mimics what Sigil does when fonts are added. I agree. Can a moderator please move this thread to the Plugin section? |
|
Advert | |
|
05-14-2015, 09:31 AM | #21 | |
Grand Sorcerer
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Code:
for id, href, mime in bk.manifest_iter() Last edited by DiapDealer; 05-14-2015 at 09:58 AM. |
|
05-14-2015, 09:54 AM | #22 |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
Yes, DiapDealer is correct. Calling the wrapper routines directly in your plugin is NOT supported. The wrapper routines are subject to change at any time. You should be using the iterators in the bookcontainer class. The bookcontainer class is the public API for the edit plugins. Given the design uses the content.opf to derive the interface itself and tries to protect the content.opf from being incorrectly changed, directly changing the media-types will not be supported. It should not be needed if font files are added in Sigil as Sigil will assign the correct media-type. Hope this explains things. KevinH |
05-14-2015, 10:09 AM | #23 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
There are books created outside Sigil and often they do have an incorrect media type. Sigil itself does not offer any help here, it only flags the error and i need to manipulate the content.opf manually. I guess i was telling this more than three times, why is there always the hint that Sigil is inserting fonts correctly? I never said that Sigil is inserting fonts incorrectly. But others do. At least one person out of 8 billion would like to have something helpful here. thats why i created this plugin.
|
05-14-2015, 10:39 AM | #24 | |
Sigil Developer
Posts: 7,644
Karma: 5433388
Join Date: Nov 2009
Device: many
|
No, you are incorrect ...
If you load an epub into Sigil that has bad media types it may end up storing the file in the incorrect location for an epub in Sigil. Or it may place it in the correct place but with an incorrect media- type. If either of these happen, the user can do one of two things depending on their skill level. 1) Delete the font files in Sigil and re-add them and Sigil will automatically put them in the right place (as I repeatedly have pointed out). OR 2) Use CodeView to directly edit the content.opf and change just the media-types. If you want to accomplish something similar in the plugin, simply use the correct bookcontainer API calls as directed earler. No one is saying the problem does not exist. We are simply pointing out that if you add fonts using Sigil, they will be assigned the correct media-types which in turn leads directly to approach 1) above and the API approach we pointed out in the plugin. Hope this makes things clearer. KevinH Quote:
|
|
05-14-2015, 12:16 PM | #25 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
*sigh* nuff said
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Q: media-type for TrueType fonts? | phossler | Editor | 19 | 09-08-2023 11:06 PM |
Problem with detection/correction of media-type error | jackie_w | Editor | 2 | 01-04-2014 08:06 AM |
Buy vs licence in another media type | murraypaul | General Discussions | 15 | 06-11-2013 11:11 PM |
media-type | me too | ePub | 5 | 08-07-2012 05:32 PM |
Permissable Spine Media Type Error | mimosawind | ePub | 5 | 10-07-2011 03:55 AM |