Add option to disable font size rescaling

This commit is contained in:
Kovid Goyal 2009-05-07 14:18:18 -07:00
parent b9e07c7e7b
commit 2ac2aed136
5 changed files with 114 additions and 64 deletions

View File

@ -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',

View File

@ -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 '

View File

@ -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

View File

@ -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()

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0" >
<class>Form</class>
<widget class="QWidget" name="Form" >
@ -16,7 +15,7 @@
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QGridLayout" name="gridLayout_6" >
<item row="0" column="0" colspan="2">
<item row="1" column="0" colspan="2" >
<widget class="QLabel" name="label_18" >
<property name="text" >
<string>Base &amp;font size:</string>
@ -26,7 +25,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="2" >
<widget class="QDoubleSpinBox" name="opt_base_font_size" >
<property name="suffix" >
<string> pt</string>
@ -48,7 +47,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Line &amp;height:</string>
@ -58,7 +57,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2" >
<widget class="QDoubleSpinBox" name="opt_line_height" >
<property name="suffix" >
<string> pt</string>
@ -68,35 +67,35 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2" >
<widget class="QCheckBox" name="opt_remove_paragraph_spacing" >
<property name="text" >
<string>Remove &amp;spacing between paragraphs</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2" >
<widget class="QCheckBox" name="opt_dont_justify" >
<property name="text" >
<string>No text &amp;justification</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="opt_linearize_tables" >
<property name="text" >
<string>&amp;Linearize tables</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2" >
<widget class="QCheckBox" name="opt_remove_first_image" >
<property name="text" >
<string>Remove &amp;first image from source file</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Font size &amp;key:</string>
@ -106,17 +105,17 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="opt_font_size_mapping" />
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2" >
<widget class="QCheckBox" name="opt_insert_metadata" >
<property name="text" >
<string>Insert &amp;metadata at start of book</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Input character &amp;encoding</string>
@ -126,9 +125,16 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2" >
<widget class="QLineEdit" name="opt_input_encoding" />
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="opt_disable_font_rescaling" >
<property name="text" >
<string>&amp;Disable font size rescaling</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -146,8 +152,41 @@
</layout>
</widget>
<resources>
<include location="../../../work/calibre-pluginize/src/calibre/gui2/images.qrc"/>
<include location="../images.qrc" />
<include location="../images.qrc" />
</resources>
<connections/>
<connections>
<connection>
<sender>opt_disable_font_rescaling</sender>
<signal>toggled(bool)</signal>
<receiver>opt_base_font_size</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>154</x>
<y>16</y>
</hint>
<hint type="destinationlabel" >
<x>385</x>
<y>40</y>
</hint>
</hints>
</connection>
<connection>
<sender>opt_disable_font_rescaling</sender>
<signal>toggled(bool)</signal>
<receiver>opt_font_size_mapping</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>80</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>285</x>
<y>72</y>
</hint>
</hints>
</connection>
</connections>
</ui>