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))
|
||||
else:
|
||||
replacement = '"%s"'%('../'+ href)
|
||||
if href.endswith('.dat'):
|
||||
replacement = 'unable-to-extract.ttf'
|
||||
if href.endswith('.failed'):
|
||||
replacement = '"%s"'%('failed-'+href)
|
||||
tag = font_index_pattern.sub(replacement, tag, 1)
|
||||
|
||||
# process links to other css pieces
|
||||
|
@ -353,14 +353,18 @@ class Mobi8Reader(object):
|
||||
fields = None
|
||||
#self.log.debug('Font record fields: %s'%(fields,))
|
||||
cdata = data[26:-4]
|
||||
ext = 'dat'
|
||||
try:
|
||||
uncompressed_data = zlib.decompress(cdata, -15)
|
||||
except:
|
||||
self.log.warn('Failed to uncompress embedded font %d: '
|
||||
'Fields: %s' % (fname_idx, fields,))
|
||||
uncompressed_data = data[4:]
|
||||
ext = 'failed'
|
||||
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':
|
||||
ext = 'ttf'
|
||||
href = "fonts/%05d.%s" % (fname_idx, ext)
|
||||
|
Loading…
x
Reference in New Issue
Block a user