mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
341f0d73c7
commit
3970da407c
@ -154,8 +154,8 @@ def update_flow_links(mobi8_reader, resource_map, log):
|
|||||||
'valid font in %s' % (num, tag))
|
'valid font in %s' % (num, tag))
|
||||||
else:
|
else:
|
||||||
replacement = '"%s"'%('../'+ href)
|
replacement = '"%s"'%('../'+ href)
|
||||||
if href.endswith('.dat'):
|
if href.endswith('.failed'):
|
||||||
replacement = 'unable-to-extract.ttf'
|
replacement = '"%s"'%('failed-'+href)
|
||||||
tag = font_index_pattern.sub(replacement, tag, 1)
|
tag = font_index_pattern.sub(replacement, tag, 1)
|
||||||
|
|
||||||
# process links to other css pieces
|
# process links to other css pieces
|
||||||
|
@ -353,14 +353,18 @@ class Mobi8Reader(object):
|
|||||||
fields = None
|
fields = None
|
||||||
#self.log.debug('Font record fields: %s'%(fields,))
|
#self.log.debug('Font record fields: %s'%(fields,))
|
||||||
cdata = data[26:-4]
|
cdata = data[26:-4]
|
||||||
|
ext = 'dat'
|
||||||
try:
|
try:
|
||||||
uncompressed_data = zlib.decompress(cdata, -15)
|
uncompressed_data = zlib.decompress(cdata, -15)
|
||||||
except:
|
except:
|
||||||
self.log.warn('Failed to uncompress embedded font %d: '
|
self.log.warn('Failed to uncompress embedded font %d: '
|
||||||
'Fields: %s' % (fname_idx, fields,))
|
'Fields: %s' % (fname_idx, fields,))
|
||||||
uncompressed_data = data[4:]
|
uncompressed_data = data[4:]
|
||||||
|
ext = 'failed'
|
||||||
hdr = uncompressed_data[0:4]
|
hdr = uncompressed_data[0:4]
|
||||||
ext = 'dat'
|
if len(uncompressed_data) < 200:
|
||||||
|
self.log.warn('Corrupted font record: %d'%fname_idx)
|
||||||
|
ext = 'failed'
|
||||||
if hdr == b'\0\1\0\0' or hdr == b'true' or hdr == b'ttcf':
|
if hdr == b'\0\1\0\0' or hdr == b'true' or hdr == b'ttcf':
|
||||||
ext = 'ttf'
|
ext = 'ttf'
|
||||||
href = "fonts/%05d.%s" % (fname_idx, ext)
|
href = "fonts/%05d.%s" % (fname_idx, ext)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user