mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Conversion: When inserting metadata as a jacket page, alter the font sizes in the jacket so that the sizes match the sizes used in the rest of the book. Also pretty print the generated jacket HTML.
This commit is contained in:
parent
fe0ea435d2
commit
b48997e9bf
@ -38,7 +38,7 @@
|
||||
** Title
|
||||
*/
|
||||
table.cbj_header td.cbj_title {
|
||||
font-size: x-large;
|
||||
font-size: 1.5em;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
@ -47,7 +47,6 @@ table.cbj_header td.cbj_title {
|
||||
** Series
|
||||
*/
|
||||
table.cbj_header td.cbj_series {
|
||||
font-size: medium;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -55,7 +54,6 @@ table.cbj_header td.cbj_series {
|
||||
** Author
|
||||
*/
|
||||
table.cbj_header td.cbj_author {
|
||||
font-size: medium;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -141,14 +139,11 @@ hr {
|
||||
|
||||
.cbj_footer {
|
||||
font-family: sans-serif;
|
||||
font-size: small;
|
||||
font-size: 0.8em;
|
||||
margin-top: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
.cbj_smallcaps {
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
.cbj_comments {
|
||||
font-family: sans-serif;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Jacket(object):
|
||||
|
||||
root = render_jacket(mi, self.opts.output_profile,
|
||||
alt_title=title, alt_tags=tags,
|
||||
alt_comments=comments)
|
||||
alt_comments=comments, rescale_fonts=True)
|
||||
id, href = self.oeb.manifest.generate('calibre_jacket', 'jacket.xhtml')
|
||||
|
||||
jacket = self.oeb.manifest.add(id, href, guess_type(href)[0], data=root)
|
||||
@ -144,7 +144,7 @@ def get_rating(rating, rchar, e_rchar):
|
||||
|
||||
def render_jacket(mi, output_profile,
|
||||
alt_title=_('Unknown'), alt_tags=[], alt_comments='',
|
||||
alt_publisher=('')):
|
||||
alt_publisher=(''), rescale_fonts=False):
|
||||
css = P('jacket/stylesheet.css', data=True).decode('utf-8')
|
||||
|
||||
try:
|
||||
@ -268,6 +268,24 @@ def render_jacket(mi, output_profile,
|
||||
except:
|
||||
root = etree.fromstring(generate_html(''),
|
||||
parser=RECOVER_PARSER)
|
||||
if rescale_fonts:
|
||||
# We ensure that the conversion pipeline will set the font sizes for
|
||||
# text in the jacket to the same size as the font sizes for the rest of
|
||||
# the text in the book. That means that as long as the jacket uses
|
||||
# relative font sizes (em or %), the post conversion font size will be
|
||||
# the same as for text in the main book. So text with size x em will
|
||||
# be rescaled to the same value in both the jacket and the main content.
|
||||
#
|
||||
# We cannot use calibre_rescale_100 on the body tag as that will just
|
||||
# give the body tag a font size of 1em, which is useless.
|
||||
for body in root.xpath('//*[local-name()="body"]'):
|
||||
fw = body.makeelement(XHTML('div'))
|
||||
fw.set('class', 'calibre_rescale_100')
|
||||
for child in body:
|
||||
fw.append(child)
|
||||
body.append(fw)
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_html_tree
|
||||
pretty_html_tree(None, root)
|
||||
return root
|
||||
|
||||
# }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user