From 2ac2aed13623a1a358327ae23f41cf9ca133edf1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 7 May 2009 14:18:18 -0700 Subject: [PATCH] Add option to disable font size rescaling --- src/calibre/ebooks/conversion/cli.py | 2 +- src/calibre/ebooks/conversion/plumber.py | 7 + src/calibre/ebooks/oeb/transforms/flatcss.py | 3 +- src/calibre/gui2/convert/look_and_feel.py | 3 + src/calibre/gui2/convert/look_and_feel.ui | 163 ++++++++++++------- 5 files changed, 114 insertions(+), 64 deletions(-) diff --git a/src/calibre/ebooks/conversion/cli.py b/src/calibre/ebooks/conversion/cli.py index 6c190759f7..4529f060ad 100644 --- a/src/calibre/ebooks/conversion/cli.py +++ b/src/calibre/ebooks/conversion/cli.py @@ -107,7 +107,7 @@ def add_pipeline_options(parser, plumber): 'LOOK AND FEEL' : ( _('Options to control the look and feel of the output'), [ - 'base_font_size', + 'base_font_size', 'disable_font_rescaling', 'font_size_mapping', 'line_height', 'linearize_tables', diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index b409198aac..ee26c3001c 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -117,6 +117,13 @@ OptionRecommendation(name='font_size_mapping', ) ), +OptionRecommendation(name='disable_font_rescaling', + recommended_value=False, level=OptionRecommendation.LOW, + help=_('Disable all rescaling of font sizes.' + ) + ), + + OptionRecommendation(name='line_height', recommended_value=0, level=OptionRecommendation.LOW, help=_('The line height in pts. Controls spacing between consecutive ' diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 216697ae53..b2831bf448 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -202,7 +202,8 @@ class CSSFlattener(object): if 'bgcolor' in node.attrib: cssdict['background-color'] = node.attrib['bgcolor'] del node.attrib['bgcolor'] - if 'font-size' in cssdict or tag == 'body': + if not self.context.disable_font_rescaling and \ + 'font-size' in cssdict or tag == 'body': fsize = self.fmap[style['font-size']] cssdict['font-size'] = "%0.5fem" % (fsize / psize) psize = fsize diff --git a/src/calibre/gui2/convert/look_and_feel.py b/src/calibre/gui2/convert/look_and_feel.py index e2015dc380..a6fe4efce9 100644 --- a/src/calibre/gui2/convert/look_and_feel.py +++ b/src/calibre/gui2/convert/look_and_feel.py @@ -21,8 +21,11 @@ class LookAndFeelWidget(Widget, Ui_Form): ['dont_justify', 'extra_css', 'base_font_size', 'font_size_mapping', 'insert_metadata', 'line_height', 'linearize_tables', 'remove_first_image', + 'disable_font_rescaling', 'remove_paragraph_spacing', 'input_encoding'] ) self.db, self.book_id = db, book_id self.initialize_options(get_option, get_help, db, book_id) + self.opt_disable_font_rescaling.toggle() + self.opt_disable_font_rescaling.toggle() diff --git a/src/calibre/gui2/convert/look_and_feel.ui b/src/calibre/gui2/convert/look_and_feel.ui index c6a1a715a6..e3be914ffa 100644 --- a/src/calibre/gui2/convert/look_and_feel.ui +++ b/src/calibre/gui2/convert/look_and_feel.ui @@ -1,8 +1,7 @@ - - + Form - - + + 0 0 @@ -10,135 +9,142 @@ 500 - + Form - + - - - - + + + + Base &font size: - + opt_base_font_size - - - + + + pt - + 1 - + 0.000000000000000 - + 30.000000000000000 - + 1.000000000000000 - + 15.000000000000000 - - - + + + Line &height: - + opt_line_height - - - + + + pt - + 1 - - - + + + Remove &spacing between paragraphs - - - + + + No text &justification - - - + + + &Linearize tables - - - + + + Remove &first image from source file - - - + + + Font size &key: - + opt_font_size_mapping - - + + - - - + + + Insert &metadata at start of book - - - + + + Input character &encoding - + opt_input_encoding - - + + + + + + + &Disable font size rescaling + + - - + + Extra &CSS - - - + + + @@ -146,8 +152,41 @@ - - + + - + + + opt_disable_font_rescaling + toggled(bool) + opt_base_font_size + setDisabled(bool) + + + 154 + 16 + + + 385 + 40 + + + + + opt_disable_font_rescaling + toggled(bool) + opt_font_size_mapping + setDisabled(bool) + + + 80 + 20 + + + 285 + 72 + + + +