mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Embed fonts: Create <head> when missing. Fixes #1960180 [Error embedding fonts](https://bugs.launchpad.net/calibre/+bug/1960180)
This commit is contained in:
parent
2adc821a67
commit
e52c124224
@ -247,7 +247,13 @@ def embed_all_fonts(container, stats, report):
|
||||
# Add link to CSS in all files that need it
|
||||
for spine_name in modified:
|
||||
root = container.parsed(spine_name)
|
||||
head = root.xpath('//*[local-name()="head"][1]')[0]
|
||||
try:
|
||||
head = root.xpath('//*[local-name()="head"][1]')[0]
|
||||
except IndexError:
|
||||
head = root.makeelement(XHTML('head'))
|
||||
root.insert(0, head)
|
||||
head.tail = '\n'
|
||||
head.text = '\n '
|
||||
href = container.name_to_href(name, spine_name)
|
||||
etree.SubElement(head, XHTML('link'), rel='stylesheet', type='text/css', href=href).tail = '\n'
|
||||
container.dirty(spine_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user