mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Fix Check book spuriously reporting incorrect mime type warnings for fonts after upgrading a book from EPUB 2 to EPUB 3. Fixes #1882436 [Upgrade book internals from 2 to 3 causes font MIME type warningserr](https://bugs.launchpad.net/calibre/+bug/1882436)
This commit is contained in:
parent
8258b394fb
commit
e4997a02e1
@ -23,11 +23,14 @@ def add_properties(item, *props):
|
||||
|
||||
|
||||
def fix_font_mime_types(container):
|
||||
changed = False
|
||||
for item in container.opf_xpath('//opf:manifest/opf:item[@href and @media-type]'):
|
||||
mt = item.get('media-type') or ''
|
||||
if mt.lower() in OEB_FONTS:
|
||||
name = container.href_to_name(item.get('href'), container.opf_name)
|
||||
item.set('media-type', container.guess_type(name))
|
||||
changed = True
|
||||
return changed
|
||||
|
||||
|
||||
def collect_properties(container):
|
||||
@ -125,7 +128,8 @@ def epub_2_to_3(container, report, previous_nav=None):
|
||||
guide.getparent().remove(guide)
|
||||
create_nav(container, toc, landmarks, previous_nav)
|
||||
container.opf.set('version', '3.0')
|
||||
fix_font_mime_types(container)
|
||||
if fix_font_mime_types(container):
|
||||
container.refresh_mime_map()
|
||||
container.dirty(container.opf_name)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user