mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
KF8 Output: Fix calibre produced KF8 files not showing the 'Use publisher font' option on the Kindle Touch when they have embedded fonts
This commit is contained in:
parent
56fb300163
commit
f45341702f
@ -297,10 +297,13 @@ class MobiWriter(object):
|
||||
|
||||
# 0x70 - 0x73 : EXTH flags
|
||||
# Bit 6 (0b1000000) being set indicates the presence of an EXTH header
|
||||
# Bit 12 being set indicates the presence of embedded fonts
|
||||
# The purpose of the other bits is unknown
|
||||
exth_flags = 0b1010000
|
||||
if self.is_periodical:
|
||||
exth_flags |= 0b1000
|
||||
if self.resources.has_fonts:
|
||||
exth_flags |= 0b1000000000000
|
||||
record0.write(pack(b'>I', exth_flags))
|
||||
|
||||
# 0x74 - 0x93 : Unknown
|
||||
@ -406,7 +409,10 @@ class MobiWriter(object):
|
||||
# Now change the header fields that need to be different in the MOBI 6
|
||||
# header
|
||||
header_fields['first_resource_record'] = first_image_record
|
||||
header_fields['exth_flags'] = 0b100001010000 # Kinglegen uses this
|
||||
ef = 0b100001010000 # Kinglegen uses this
|
||||
if self.resources.has_fonts:
|
||||
ef |= 0b1000000000000
|
||||
header_fields['exth_flags'] = ef
|
||||
header_fields['fdst_record'] = pack(b'>HH', 1, last_content_record)
|
||||
header_fields['fdst_count'] = 1 # Why not 0? Kindlegen uses 1
|
||||
header_fields['flis_record'] = flis_number
|
||||
|
@ -32,6 +32,7 @@ class Resources(object):
|
||||
self.used_image_indices = set()
|
||||
self.image_indices = set()
|
||||
self.cover_offset = self.thumbnail_offset = None
|
||||
self.has_fonts = False
|
||||
|
||||
self.add_resources(add_fonts)
|
||||
|
||||
@ -109,6 +110,7 @@ class Resources(object):
|
||||
'ttf', 'otf'} and isinstance(item.data, bytes):
|
||||
self.records.append(write_font_record(item.data))
|
||||
self.item_map[item.href] = len(self.records)
|
||||
self.has_fonts = True
|
||||
|
||||
def add_extra_images(self):
|
||||
'''
|
||||
|
@ -140,7 +140,7 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
|
||||
nrecs += 1
|
||||
|
||||
if be_kindlegen2:
|
||||
vals = {204:201, 205:2, 206:2, 207:35621}
|
||||
vals = {204:201, 205:2, 206:5, 207:0}
|
||||
elif is_periodical:
|
||||
# Pretend to be amazon's super secret periodical generator
|
||||
vals = {204:201, 205:2, 206:0, 207:101}
|
||||
|
@ -277,6 +277,8 @@ class KF8Book(object):
|
||||
self.exth_flags = 0b1010000
|
||||
if writer.opts.mobi_periodical:
|
||||
self.exth_flags |= 0b1000
|
||||
if resources.has_fonts:
|
||||
self.exth_flags |= 0b1000000000000
|
||||
|
||||
self.opts = writer.opts
|
||||
self.start_offset = writer.start_offset
|
||||
|
Loading…
x
Reference in New Issue
Block a user